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 |
tboccali |
1.9 |
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
VHbbCandidate getHZmumuCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& pos){
|
40 |
tboccali |
1.1 |
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.9 |
|
46 |
tboccali |
1.7 |
//
|
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 |
tboccali |
1.9 |
|
53 |
|
|
// beware: assumes already sorted!!!!
|
54 |
|
|
|
55 |
|
|
// CompareJetPtMuons ptComparator;
|
56 |
|
|
// std::sort(muons_.begin(), muons_.end(), ptComparator);
|
57 |
tboccali |
1.7 |
if (muons_[0].p4.Pt()<20 || muons_[1].p4.Pt()<20 ) return in;
|
58 |
tboccali |
1.9 |
|
59 |
|
|
//
|
60 |
|
|
// now I need to ask also for the charge
|
61 |
|
|
//
|
62 |
|
|
int selectMu2=1;
|
63 |
|
|
|
64 |
|
|
if (muons_[0].charge* muons_[selectMu2].charge > 0){
|
65 |
|
|
if (muons_.size() ==2) return in;
|
66 |
|
|
//
|
67 |
|
|
// i need to find a proper pair
|
68 |
|
|
//
|
69 |
|
|
|
70 |
|
|
for (unsigned int it=2; it< muons_.size(); ++it){
|
71 |
|
|
if ( muons_[it].charge * muons_[0].charge < 0) {
|
72 |
|
|
selectMu2 = it;
|
73 |
|
|
break;
|
74 |
|
|
}
|
75 |
|
|
if (selectMu2 == 1) return in;
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
|
|
temp.V.p4 = muons_[0].p4+muons_[selectMu2].p4;
|
79 |
tboccali |
1.7 |
std::vector<VHbbEvent::MuonInfo> muons2_;
|
80 |
|
|
for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons_.begin(); it!= muons_.end(); ++it){
|
81 |
|
|
if (it->p4.Pt()>20) muons2_.push_back(*it);
|
82 |
|
|
}
|
83 |
|
|
temp.V.muons = muons2_;
|
84 |
tboccali |
1.9 |
|
85 |
tboccali |
1.7 |
// the same for electrons
|
86 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
|
87 |
tboccali |
1.9 |
|
88 |
|
|
// beware; assumes already sorted
|
89 |
|
|
|
90 |
|
|
// CompareJetPtElectrons ptComparator2;
|
91 |
|
|
// std::sort(electrons_.begin(), electrons_.end(), ptComparator2);
|
92 |
tboccali |
1.7 |
std::vector<VHbbEvent::ElectronInfo> electrons2_;
|
93 |
|
|
for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons_.begin(); it!= electrons_.end(); ++it){
|
94 |
|
|
if (it->p4.Pt()>20) electrons2_.push_back(*it);
|
95 |
|
|
}
|
96 |
|
|
temp.V.electrons = electrons2_;
|
97 |
|
|
|
98 |
tboccali |
1.9 |
//
|
99 |
tboccali |
1.7 |
// consider all
|
100 |
|
|
//
|
101 |
|
|
|
102 |
tboccali |
1.1 |
|
103 |
|
|
// if (temp.V.Pt()<150 ) return in;
|
104 |
|
|
// if (temp.H.Pt()<150) return in;
|
105 |
|
|
// if (temp.H.firstJet().csv< 0.9) return in;
|
106 |
|
|
// if (temp.H.secondJet().csv<0.5) return in;
|
107 |
|
|
// if (deltaPhi(temp.V.Phi(),temp.H.Phi())<2.7) return in;
|
108 |
|
|
// if (temp.V.FourMomentum.Mass()<75 || temp.V.FourMomentum.Mass()>105) return in;
|
109 |
|
|
// if (temp.additionalJets.size()>0) return in;
|
110 |
|
|
// if (std::Abs(deltaTheta) ????
|
111 |
tboccali |
1.9 |
|
112 |
|
|
temp.V.firstLepton = pos[0];
|
113 |
|
|
temp.V.secondLepton = pos[selectMu2];
|
114 |
|
|
ok = true;
|
115 |
tboccali |
1.1 |
return temp;
|
116 |
|
|
}
|
117 |
tboccali |
1.9 |
VHbbCandidate getHZeeCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& pos){
|
118 |
tboccali |
1.1 |
if (verbose_){
|
119 |
tboccali |
1.7 |
std::cout <<" getHZeeCandidate input mu "<<in.V.electrons.size()<<" e "<<in.V.muons.size()<<std::endl;
|
120 |
tboccali |
1.1 |
}
|
121 |
|
|
ok = false;
|
122 |
|
|
VHbbCandidate temp=in;
|
123 |
tboccali |
1.9 |
|
124 |
tboccali |
1.1 |
//
|
125 |
tboccali |
1.7 |
// change: allow for additional leptons; by definition
|
126 |
tboccali |
1.1 |
//
|
127 |
tboccali |
1.7 |
if (temp.V.electrons.size()<2) return in ;
|
128 |
|
|
// if (temp.V.electrons.size()!=0) return in ;
|
129 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
|
130 |
tboccali |
1.9 |
|
131 |
|
|
// beware assumes already sorted
|
132 |
|
|
|
133 |
|
|
// CompareJetPtElectrons ptComparator;
|
134 |
|
|
// std::sort(electrons_.begin(), electrons_.end(), ptComparator);
|
135 |
tboccali |
1.7 |
if (electrons_[0].p4.Pt()<20 || electrons_[1].p4.Pt()<20 ) return in;
|
136 |
tboccali |
1.9 |
//
|
137 |
|
|
// now I need to ask also for the charge
|
138 |
|
|
//
|
139 |
|
|
int selectE2=1;
|
140 |
|
|
|
141 |
|
|
if (electrons_[0].charge* electrons_[selectE2].charge > 0){
|
142 |
|
|
if (electrons_.size() ==2) return in;
|
143 |
|
|
//
|
144 |
|
|
// i need to find a proper pair
|
145 |
|
|
//
|
146 |
|
|
|
147 |
|
|
for (unsigned int it=2; it< electrons_.size(); ++it){
|
148 |
|
|
if ( electrons_[it].charge * electrons_[0].charge < 0) {
|
149 |
|
|
selectE2 = it;
|
150 |
|
|
break;
|
151 |
|
|
}
|
152 |
|
|
if (selectE2 == 1) return in;
|
153 |
|
|
}
|
154 |
|
|
}
|
155 |
|
|
temp.V.p4 = electrons_[0].p4+electrons_[selectE2].p4;
|
156 |
tboccali |
1.7 |
std::vector<VHbbEvent::ElectronInfo> electrons2_;
|
157 |
|
|
for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons_.begin(); it!= electrons_.end(); ++it){
|
158 |
|
|
if (it->p4.Pt()>20) electrons2_.push_back(*it);
|
159 |
|
|
}
|
160 |
|
|
temp.V.electrons = electrons2_;
|
161 |
|
|
|
162 |
|
|
// the same for muonss
|
163 |
|
|
std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
|
164 |
tboccali |
1.9 |
|
165 |
|
|
// beware assumes already sorted
|
166 |
|
|
|
167 |
|
|
// CompareJetPtMuons ptComparator2;
|
168 |
|
|
// std::sort(muons_.begin(), muons_.end(), ptComparator2);
|
169 |
tboccali |
1.7 |
std::vector<VHbbEvent::MuonInfo> muons2_;
|
170 |
|
|
for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons_.begin(); it!= muons_.end(); ++it){
|
171 |
|
|
if (it->p4.Pt()>20) muons2_.push_back(*it);
|
172 |
|
|
}
|
173 |
|
|
temp.V.muons = muons2_;
|
174 |
tboccali |
1.9 |
|
175 |
|
|
temp.V.firstLepton = pos[0];
|
176 |
|
|
temp.V.secondLepton = pos[selectE2];
|
177 |
|
|
|
178 |
tboccali |
1.7 |
|
179 |
|
|
ok = true;
|
180 |
tboccali |
1.1 |
return temp;
|
181 |
|
|
}
|
182 |
|
|
VHbbCandidate getHZnnCandidate(const VHbbCandidate & in, bool & ok){
|
183 |
|
|
if (verbose_){
|
184 |
|
|
std::cout <<" getHZnnCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<<" met "<<in.V.mets.size()<<std::endl;
|
185 |
|
|
}
|
186 |
|
|
|
187 |
|
|
ok = false;
|
188 |
|
|
VHbbCandidate temp=in;
|
189 |
|
|
if (temp.V.mets.size()!=1) return in;
|
190 |
arizzi |
1.10 |
//always build a NuNu candidate, exclusion come from if/else series on the caller side
|
191 |
|
|
// this allow to still build candidates for mu+e and same sign dilept
|
192 |
|
|
// if (temp.V.muons.size()!=0) return in ;
|
193 |
|
|
// if (temp.V.electrons.size()!=0) return in ;
|
194 |
tboccali |
1.1 |
|
195 |
tboccali |
1.6 |
temp.V.p4 = temp.V.mets[0].p4;
|
196 |
tboccali |
1.1 |
if (verbose_) {
|
197 |
|
|
std::cout <<" debug met "<< temp.V.mets[0].metSig << " " << temp.V.mets[0].sumEt<< std::endl;
|
198 |
|
|
}
|
199 |
|
|
if (temp.V.mets[0].metSig<5) return in;
|
200 |
tboccali |
1.11 |
if (temp.V.mets[0].p4.Pt()<80) return in;
|
201 |
tboccali |
1.6 |
// if (temp.H.p4.Pt()<150)return in;
|
202 |
tboccali |
1.1 |
// if (temp.H.firstJet().csv< 0.9) return in;
|
203 |
|
|
// if (temp.H.secondJet().csv<0.5) return in;
|
204 |
tboccali |
1.6 |
// if (deltaPhi(temp.V.p4.Phi(),temp.H.p4.Phi())<2.95) return in;
|
205 |
tboccali |
1.1 |
// if (temp.V.electrons.size()>0 || temp.V.muons.size()>0 ) return in;
|
206 |
|
|
// if (temp.additionalJets.size()>0) return in;
|
207 |
|
|
// if (std::Abs(deltaTheta) ????
|
208 |
|
|
|
209 |
|
|
ok = true;
|
210 |
|
|
return temp;
|
211 |
|
|
}
|
212 |
|
|
|
213 |
tboccali |
1.9 |
VHbbCandidate getHWmunCandidate(const VHbbCandidate & in, bool & ok , std::vector<unsigned int>& pos){
|
214 |
tboccali |
1.1 |
ok = false;
|
215 |
|
|
VHbbCandidate temp=in;
|
216 |
tboccali |
1.2 |
// require a muon and no electrons
|
217 |
tboccali |
1.1 |
if (temp.V.muons.size()!=1) return in ;
|
218 |
|
|
if (temp.V.electrons.size()!=0) return in ;
|
219 |
tboccali |
1.3 |
if (temp.V.mets.size()<1) return in ;
|
220 |
tboccali |
1.1 |
//
|
221 |
tboccali |
1.2 |
/*pT(W) > 150 GeV (pt(W) computed using lepton px,y and PF MET x and y components)
|
222 |
|
|
pT(H) > 150 GeV
|
223 |
|
|
best btag, CSV > 0.90
|
224 |
|
|
second-best btag, CSV > 0.50
|
225 |
|
|
Dphi(W,H) > 2.95
|
226 |
|
|
no additional isolated leptons (pT > 15 GeV)
|
227 |
|
|
|
228 |
|
|
same lepton definition as in the physics objects section
|
229 |
|
|
|
230 |
|
|
No additional ak5PFjets (pT > 30 GeV; |eta| < 2.4)
|
231 |
|
|
MET>35. for the electron BDT analysis
|
232 |
|
|
|cos(theta * )| (TBO)
|
233 |
|
|
color flow pull angle (TBO)
|
234 |
|
|
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.)
|
235 |
|
|
*/
|
236 |
|
|
|
237 |
tboccali |
1.6 |
temp.V.p4 = temp.V.muons[0].p4+temp.V.mets[0].p4;
|
238 |
tboccali |
1.9 |
temp.V.firstLepton=pos[0];
|
239 |
tboccali |
1.2 |
|
240 |
|
|
ok=true;
|
241 |
tboccali |
1.3 |
return temp;
|
242 |
tboccali |
1.1 |
}
|
243 |
|
|
|
244 |
tboccali |
1.9 |
VHbbCandidate getHWenCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& pos){
|
245 |
tboccali |
1.1 |
ok = false;
|
246 |
|
|
VHbbCandidate temp=in;
|
247 |
|
|
if (temp.V.electrons.size()!=1) return in ;
|
248 |
|
|
if (temp.V.muons.size()!=0) return in ;
|
249 |
tboccali |
1.3 |
if (temp.V.mets.size()<1) return in ;
|
250 |
tboccali |
1.1 |
//
|
251 |
tboccali |
1.2 |
/*pT(W) > 150 GeV (pt(W) computed using lepton px,y and PF MET x and y components)
|
252 |
|
|
pT(H) > 150 GeV
|
253 |
|
|
best btag, CSV > 0.90
|
254 |
|
|
second-best btag, CSV > 0.50
|
255 |
|
|
Dphi(W,H) > 2.95
|
256 |
|
|
no additional isolated leptons (pT > 15 GeV)
|
257 |
|
|
|
258 |
|
|
same lepton definition as in the physics objects section
|
259 |
|
|
|
260 |
|
|
No additional ak5PFjets (pT > 30 GeV; |eta| < 2.4)
|
261 |
|
|
MET>35. for the electron BDT analysis
|
262 |
|
|
|cos(theta * )| (TBO)
|
263 |
|
|
color flow pull angle (TBO)
|
264 |
|
|
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.)
|
265 |
|
|
*/
|
266 |
|
|
|
267 |
|
|
ok=true;
|
268 |
tboccali |
1.9 |
temp.V.firstLepton=pos[0];
|
269 |
tboccali |
1.6 |
temp.V.p4 = temp.V.electrons[0].p4+temp.V.mets[0].p4;
|
270 |
tboccali |
1.3 |
return temp;
|
271 |
tboccali |
1.1 |
}
|
272 |
|
|
|
273 |
|
|
public:
|
274 |
|
|
bool verbose_;
|
275 |
tboccali |
1.2 |
|
276 |
|
|
public:
|
277 |
tboccali |
1.9 |
static float getDeltaTheta( const VHbbEvent::SimpleJet & j1, const VHbbEvent::SimpleJet & j2 ) {
|
278 |
tboccali |
1.5 |
double deltaTheta = 1e10;
|
279 |
|
|
TLorentzVector pi(0,0,0,0);
|
280 |
|
|
TLorentzVector v_j1 = j1.chargedTracksFourMomentum;
|
281 |
|
|
TLorentzVector v_j2 = j2.chargedTracksFourMomentum;
|
282 |
|
|
|
283 |
|
|
if( v_j2.Mag() == 0
|
284 |
|
|
|| v_j1.Mag() == 0 )
|
285 |
|
|
return deltaTheta = 1e10;
|
286 |
|
|
|
287 |
|
|
//use j1 to calculate the pull vector
|
288 |
|
|
TVector2 t = j1.tVector;
|
289 |
|
|
|
290 |
|
|
if( t.Mod() == 0 )
|
291 |
|
|
return deltaTheta = 1e10;
|
292 |
|
|
|
293 |
|
|
Double_t dphi = v_j2.Phi()- v_j1.Phi();
|
294 |
|
|
if ( dphi > M_PI ) {
|
295 |
|
|
dphi -= 2.0*M_PI;
|
296 |
|
|
} else if ( dphi <= -M_PI ) {
|
297 |
|
|
dphi += 2.0*M_PI;
|
298 |
|
|
}
|
299 |
|
|
Double_t deltaeta = v_j2.Rapidity() - v_j1.Rapidity();
|
300 |
|
|
TVector2 BBdir( deltaeta, dphi );
|
301 |
|
|
|
302 |
|
|
deltaTheta = t.DeltaPhi(BBdir);
|
303 |
|
|
|
304 |
|
|
return deltaTheta;
|
305 |
|
|
|
306 |
|
|
}
|
307 |
|
|
|
308 |
tboccali |
1.4 |
float getHelicity(const VHbbEvent::SimpleJet& j, TVector3 boost) const {
|
309 |
|
|
double hel = 1e10;
|
310 |
tboccali |
1.6 |
TLorentzVector jet = j.p4;
|
311 |
tboccali |
1.4 |
jet.Boost( -boost );
|
312 |
|
|
hel = TMath::Cos( jet.Vect().Angle( boost ) );
|
313 |
|
|
return hel;
|
314 |
|
|
}
|
315 |
|
|
|
316 |
tboccali |
1.1 |
|
317 |
|
|
};
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
#endif
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|