ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/interface/VHbbCandidateTools.h
Revision: 1.7
Committed: Mon Jul 25 15:55:56 2011 UTC (13 years, 9 months ago) by tboccali
Content type: text/plain
Branch: MAIN
CVS Tags: HBB_EDMNtupleV1_ProcV2, Jul28th2011, Jul26th2011
Changes since 1.6: +70 -24 lines
Log Message:
allow for more leptons when having the Z

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