Ticket #74: MYANALYSIS.2.cc
File MYANALYSIS.2.cc, 3.9 KB (added by , 14 years ago) |
---|
Line | |
---|---|
1 | #include "Rivet/Analysis.hh" |
2 | #include "Rivet/Projections/FinalState.hh" |
3 | #include "Rivet/Projections/IdentifiedFinalState.hh" |
4 | #include "Rivet/Projections/UnstableFinalState.hh" |
5 | #include "Rivet/AnalysisLoader.hh" |
6 | |
7 | namespace Rivet { |
8 | |
9 | |
10 | class MYANALYSIS : public Analysis { |
11 | public: |
12 | |
13 | MYANALYSIS() : Analysis("MYANALYSIS") {} |
14 | |
15 | void init() { |
16 | _sigma1 = 0; |
17 | _sigma2 = 0; |
18 | _sigma3 = 0; |
19 | _sigma4 = 0; |
20 | } |
21 | |
22 | void analyze(const Event& event) { |
23 | |
24 | GenEvent::particle_const_iterator p; |
25 | vector<vector <GenParticle> > tau_parts; |
26 | vector<GenParticle> tmp_parts; |
27 | //loop over all particles |
28 | for (p = event.genEvent().particles_begin(); |
29 | p != event.genEvent().particles_end(); ++p) { |
30 | //loop over particles at decay vertex of status = 2 taus |
31 | if (fabs((*p)->pdg_id())==15 && (*p)->status()==2){ |
32 | const GenVertex* dv = (*p)->end_vertex(); |
33 | |
34 | bool found = 0; |
35 | int count=0; |
36 | tmp_parts.clear(); |
37 | for (GenVertex::particles_out_const_iterator pp = dv->particles_out_const_begin() ; |
38 | pp != dv->particles_out_const_end(); ++pp) { |
39 | if (fabs((*pp)->pdg_id())==16) found=1; |
40 | tmp_parts.push_back(**pp); |
41 | count++; |
42 | } |
43 | //are there exactly two particles at this tau decay vertex, one of which is a tau (anti) neutrino |
44 | if (count !=2) found =0; |
45 | if (found){ |
46 | //then push back these two particles as a vector |
47 | tau_parts.push_back(tmp_parts); |
48 | } |
49 | } |
50 | } |
51 | //are there exactly two vectors of two particles, with a tau (anti)neutrino in each? |
52 | if (tau_parts.size()!=2) vetoEvent; |
53 | |
54 | |
55 | GenParticle *piplus, *piminus; |
56 | |
57 | float re, rpx, rpy, rpz; |
58 | re = rpx = rpy = rpz = 0; |
59 | bool find_tauplus,find_tauminus; |
60 | find_tauplus = find_tauminus = 0; |
61 | |
62 | //cout <<"ntau = "<<tau_parts.size()<<": children are\t"; |
63 | for (unsigned int i=0;i<tau_parts.size();i++){ |
64 | for (unsigned int j=0;j<tau_parts.at(i).size();j++){ |
65 | //cout <<"\t\t"<<tau_parts.at(i).at(j).pdg_id(); |
66 | if (tau_parts.at(i).at(j).pdg_id()==211){ piplus= &GenParticle(tau_parts.at(i).at(j));find_tauplus=1;} |
67 | if (tau_parts.at(i).at(j).pdg_id()==-211){ piminus= &GenParticle(tau_parts.at(i).at(j));find_tauminus=1;} |
68 | re += tau_parts.at(i).at(j).momentum().e(); |
69 | rpx += tau_parts.at(i).at(j).momentum().px(); |
70 | rpy += tau_parts.at(i).at(j).momentum().py(); |
71 | rpz += tau_parts.at(i).at(j).momentum().pz(); |
72 | } |
73 | //cout <<"\n"; |
74 | } |
75 | //cout <<"\n"; |
76 | |
77 | //failed to find pi+-, somehow |
78 | if (!find_tauplus || !find_tauminus) vetoEvent; |
79 | |
80 | //make calculation |
81 | FourMomentum restframe(re,rpx,rpy,rpz); |
82 | LorentzTransform cms_boost(-restframe.boostVector()); |
83 | FourMomentum piplus_b(cms_boost.transform(piplus->momentum())); |
84 | FourMomentum piminus_b(cms_boost.transform(piminus->momentum())); |
85 | |
86 | double zplus = 2.0*piplus_b.E()/120.0; |
87 | double zminus = 2.0*piminus_b.E()/120.0; |
88 | if (zplus>0.5 && zminus>0.5) { |
89 | _sigma1+=event.weight(); |
90 | } |
91 | else if (zplus<0.5 && zminus<0.5) { |
92 | _sigma2+=event.weight(); |
93 | } |
94 | else if (zplus>0.5 && zminus<0.5) { |
95 | _sigma3+=event.weight(); |
96 | } |
97 | else if (zplus<0.5 && zminus>0.5) { |
98 | _sigma4+=event.weight(); |
99 | } |
100 | |
101 | if (zplus <0 || zminus <0 || zplus>1. || zplus>1.){ |
102 | std::cout <<"zplus = "<<zplus<<"\t zminus = "<<zminus<<std::endl; |
103 | } |
104 | } |
105 | |
106 | void finalize() { |
107 | // No histos, so nothing to do! |
108 | std::cout<<"_sigma1="<<_sigma1*crossSectionPerEvent()<<std::endl; |
109 | std::cout<<"_sigma2="<<_sigma2*crossSectionPerEvent()<<std::endl; |
110 | std::cout<<"_sigma3="<<_sigma3*crossSectionPerEvent()<<std::endl; |
111 | std::cout<<"_sigma4="<<_sigma4*crossSectionPerEvent()<<std::endl; |
112 | |
113 | std::cout<<"A_fastslow="<<(_sigma1+_sigma2-_sigma3-_sigma4)/(_sigma1+_sigma2+_sigma3+_sigma4)<<std::endl; |
114 | |
115 | std::cout<<"_sigma1="<<_sigma1<<std::endl; |
116 | std::cout<<"_sigma2="<<_sigma2<<std::endl; |
117 | std::cout<<"_sigma3="<<_sigma3<<std::endl; |
118 | std::cout<<"_sigma4="<<_sigma4<<std::endl; |
119 | |
120 | } |
121 | |
122 | private: |
123 | |
124 | double _sigma1, _sigma2, _sigma3, _sigma4; |
125 | }; |
126 | |
127 | |
128 | |
129 | // This global object acts as a hook for the plugin system |
130 | AnalysisBuilder<MYANALYSIS> plugin_MYANALYSIS; |
131 | |
132 | |
133 | } |