ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/interface/VHbbCandidateTools.h
Revision: 1.8
Committed: Tue Aug 9 09:35:47 2011 UTC (13 years, 8 months ago) by arizzi
Content type: text/plain
Branch: MAIN
CVS Tags: AR_Sep8_LightNtuple, VHBB_EDMNtupleV3, AndreaAug10th
Changes since 1.7: +3 -0 lines
Log Message:
add methods for transverse mass computation

File Contents

# User Rev Content
1 tboccali 1.1 #ifndef VHBBCANDIDATETOOLS_H
2     #define VHBBCANDIDATETOOLS_H
3    
4     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbCandidate.h"
5    
6     #include <iostream>
7    
8 tboccali 1.7 struct CompareJetPtMuons {
9     bool operator()( const VHbbEvent::MuonInfo& j1, const VHbbEvent::MuonInfo& j2 ) const {
10     return j1.p4.Pt() > j2.p4.Pt();
11     }
12     };
13     struct CompareJetPtElectrons {
14     bool operator()( const VHbbEvent::ElectronInfo& j1, const VHbbEvent::ElectronInfo& j2 ) const {
15     return j1.p4.Pt() > j2.p4.Pt();
16     }
17     };
18    
19    
20    
21 tboccali 1.1 class VHbbCandidateTools {
22     public:
23    
24     VHbbCandidateTools(bool verbose = false): verbose_(verbose){}
25    
26     float deltaPhi(float in2, float in1){
27     float dphi = in2-in1;
28     if ( dphi > M_PI ) {
29     dphi -= 2.0*M_PI;
30     } else if ( dphi <= -M_PI ) {
31     dphi += 2.0*M_PI;
32     }
33     return dphi;
34     }
35    
36 arizzi 1.8
37    
38    
39 tboccali 1.1 VHbbCandidate getHZmumuCandidate(const VHbbCandidate & in, bool & ok){
40     if (verbose_){
41     std::cout <<" getHZmumuCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<<std::endl;
42     }
43     ok = false;
44     VHbbCandidate temp=in;
45 tboccali 1.7
46     //
47     // change: allow for additional leptons; by definition
48     //
49     if (temp.V.muons.size()<2) return in ;
50     // if (temp.V.electrons.size()!=0) return in ;
51     std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
52     CompareJetPtMuons ptComparator;
53     std::sort(muons_.begin(), muons_.end(), ptComparator);
54     if (muons_[0].p4.Pt()<20 || muons_[1].p4.Pt()<20 ) return in;
55     temp.V.p4 = muons_[0].p4+muons_[1].p4;
56     std::vector<VHbbEvent::MuonInfo> muons2_;
57     for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons_.begin(); it!= muons_.end(); ++it){
58     if (it->p4.Pt()>20) muons2_.push_back(*it);
59     }
60     temp.V.muons = muons2_;
61    
62     // the same for electrons
63     std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
64     CompareJetPtElectrons ptComparator2;
65     std::sort(electrons_.begin(), electrons_.end(), ptComparator2);
66     std::vector<VHbbEvent::ElectronInfo> electrons2_;
67     for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons_.begin(); it!= electrons_.end(); ++it){
68     if (it->p4.Pt()>20) electrons2_.push_back(*it);
69     }
70     temp.V.electrons = electrons2_;
71    
72     //
73     // consider all
74     //
75    
76 tboccali 1.1
77     // if (temp.V.Pt()<150 ) return in;
78     // if (temp.H.Pt()<150) return in;
79     // if (temp.H.firstJet().csv< 0.9) return in;
80     // if (temp.H.secondJet().csv<0.5) return in;
81     // if (deltaPhi(temp.V.Phi(),temp.H.Phi())<2.7) return in;
82     // if (temp.V.FourMomentum.Mass()<75 || temp.V.FourMomentum.Mass()>105) return in;
83     // if (temp.additionalJets.size()>0) return in;
84     // if (std::Abs(deltaTheta) ????
85     ok = true;
86     return temp;
87     }
88     VHbbCandidate getHZeeCandidate(const VHbbCandidate & in, bool & ok){
89     if (verbose_){
90 tboccali 1.7 std::cout <<" getHZeeCandidate input mu "<<in.V.electrons.size()<<" e "<<in.V.muons.size()<<std::endl;
91 tboccali 1.1 }
92     ok = false;
93     VHbbCandidate temp=in;
94    
95     //
96 tboccali 1.7 // change: allow for additional leptons; by definition
97 tboccali 1.1 //
98 tboccali 1.7 if (temp.V.electrons.size()<2) return in ;
99     // if (temp.V.electrons.size()!=0) return in ;
100     std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
101     CompareJetPtElectrons ptComparator;
102     std::sort(electrons_.begin(), electrons_.end(), ptComparator);
103     if (electrons_[0].p4.Pt()<20 || electrons_[1].p4.Pt()<20 ) return in;
104     temp.V.p4 = electrons_[0].p4+electrons_[1].p4;
105     std::vector<VHbbEvent::ElectronInfo> electrons2_;
106     for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons_.begin(); it!= electrons_.end(); ++it){
107     if (it->p4.Pt()>20) electrons2_.push_back(*it);
108     }
109     temp.V.electrons = electrons2_;
110    
111     // the same for muonss
112     std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
113     CompareJetPtMuons ptComparator2;
114     std::sort(muons_.begin(), muons_.end(), ptComparator2);
115     std::vector<VHbbEvent::MuonInfo> muons2_;
116     for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons_.begin(); it!= muons_.end(); ++it){
117     if (it->p4.Pt()>20) muons2_.push_back(*it);
118     }
119     temp.V.muons = muons2_;
120    
121     ok = true;
122 tboccali 1.1 return temp;
123     }
124     VHbbCandidate getHZnnCandidate(const VHbbCandidate & in, bool & ok){
125     if (verbose_){
126     std::cout <<" getHZnnCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<<" met "<<in.V.mets.size()<<std::endl;
127     }
128    
129     ok = false;
130     VHbbCandidate temp=in;
131     if (temp.V.mets.size()!=1) return in;
132     if (temp.V.muons.size()!=0) return in ;
133     if (temp.V.electrons.size()!=0) return in ;
134    
135 tboccali 1.6 temp.V.p4 = temp.V.mets[0].p4;
136 tboccali 1.1 if (verbose_) {
137     std::cout <<" debug met "<< temp.V.mets[0].metSig << " " << temp.V.mets[0].sumEt<< std::endl;
138     }
139     if (temp.V.mets[0].metSig<5) return in;
140     if (temp.V.mets[0].sumEt<50) return in;
141 tboccali 1.6 // if (temp.H.p4.Pt()<150)return in;
142 tboccali 1.1 // if (temp.H.firstJet().csv< 0.9) return in;
143     // if (temp.H.secondJet().csv<0.5) return in;
144 tboccali 1.6 // if (deltaPhi(temp.V.p4.Phi(),temp.H.p4.Phi())<2.95) return in;
145 tboccali 1.1 // if (temp.V.electrons.size()>0 || temp.V.muons.size()>0 ) return in;
146     // if (temp.additionalJets.size()>0) return in;
147     // if (std::Abs(deltaTheta) ????
148    
149     ok = true;
150     return temp;
151     }
152    
153     VHbbCandidate getHWmunCandidate(const VHbbCandidate & in, bool & ok){
154     ok = false;
155     VHbbCandidate temp=in;
156 tboccali 1.2 // require a muon and no electrons
157 tboccali 1.1 if (temp.V.muons.size()!=1) return in ;
158     if (temp.V.electrons.size()!=0) return in ;
159 tboccali 1.3 if (temp.V.mets.size()<1) return in ;
160 tboccali 1.1 //
161 tboccali 1.2 /*pT(W) > 150 GeV (pt(W) computed using lepton px,y and PF MET x and y components)
162     pT(H) > 150 GeV
163     best btag, CSV > 0.90
164     second-best btag, CSV > 0.50
165     Dphi(W,H) > 2.95
166     no additional isolated leptons (pT > 15 GeV)
167    
168     same lepton definition as in the physics objects section
169    
170     No additional ak5PFjets (pT > 30 GeV; |eta| < 2.4)
171     MET>35. for the electron BDT analysis
172     |cos(theta * )| (TBO)
173     color flow pull angle (TBO)
174     We don't cut on the transverse mass (for boosted objects cutting on the transverse mass introduces an inefficiency due to the angle between the MET and the lepton being close to 0.)
175     */
176    
177 tboccali 1.6 temp.V.p4 = temp.V.muons[0].p4+temp.V.mets[0].p4;
178 tboccali 1.2
179     ok=true;
180 tboccali 1.3 return temp;
181 tboccali 1.1 }
182    
183     VHbbCandidate getHWenCandidate(const VHbbCandidate & in, bool & ok){
184     ok = false;
185     VHbbCandidate temp=in;
186     if (temp.V.electrons.size()!=1) return in ;
187     if (temp.V.muons.size()!=0) return in ;
188 tboccali 1.3 if (temp.V.mets.size()<1) return in ;
189 tboccali 1.1 //
190 tboccali 1.2 /*pT(W) > 150 GeV (pt(W) computed using lepton px,y and PF MET x and y components)
191     pT(H) > 150 GeV
192     best btag, CSV > 0.90
193     second-best btag, CSV > 0.50
194     Dphi(W,H) > 2.95
195     no additional isolated leptons (pT > 15 GeV)
196    
197     same lepton definition as in the physics objects section
198    
199     No additional ak5PFjets (pT > 30 GeV; |eta| < 2.4)
200     MET>35. for the electron BDT analysis
201     |cos(theta * )| (TBO)
202     color flow pull angle (TBO)
203     We don't cut on the transverse mass (for boosted objects cutting on the transverse mass introduces an inefficiency due to the angle between the MET and the lepton being close to 0.)
204     */
205    
206     ok=true;
207    
208 tboccali 1.6 temp.V.p4 = temp.V.electrons[0].p4+temp.V.mets[0].p4;
209 tboccali 1.3 return temp;
210 tboccali 1.1 }
211    
212     public:
213     bool verbose_;
214 tboccali 1.2
215     public:
216     float getDeltaTheta( const VHbbEvent::SimpleJet & j1, const VHbbEvent::SimpleJet & j2 ) const {
217 tboccali 1.5 double deltaTheta = 1e10;
218     TLorentzVector pi(0,0,0,0);
219     TLorentzVector v_j1 = j1.chargedTracksFourMomentum;
220     TLorentzVector v_j2 = j2.chargedTracksFourMomentum;
221    
222     if( v_j2.Mag() == 0
223     || v_j1.Mag() == 0 )
224     return deltaTheta = 1e10;
225    
226     //use j1 to calculate the pull vector
227     TVector2 t = j1.tVector;
228    
229     if( t.Mod() == 0 )
230     return deltaTheta = 1e10;
231    
232     Double_t dphi = v_j2.Phi()- v_j1.Phi();
233     if ( dphi > M_PI ) {
234     dphi -= 2.0*M_PI;
235     } else if ( dphi <= -M_PI ) {
236     dphi += 2.0*M_PI;
237     }
238     Double_t deltaeta = v_j2.Rapidity() - v_j1.Rapidity();
239     TVector2 BBdir( deltaeta, dphi );
240    
241     deltaTheta = t.DeltaPhi(BBdir);
242    
243     return deltaTheta;
244    
245     }
246    
247 tboccali 1.4 float getHelicity(const VHbbEvent::SimpleJet& j, TVector3 boost) const {
248     double hel = 1e10;
249 tboccali 1.6 TLorentzVector jet = j.p4;
250 tboccali 1.4 jet.Boost( -boost );
251     hel = TMath::Cos( jet.Vect().Angle( boost ) );
252     return hel;
253     }
254    
255 tboccali 1.1
256     };
257    
258    
259    
260     #endif
261    
262    
263    
264    
265    
266