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 |
wilken |
1.13.6.1 |
VHbbCandidate getHZtaumuCandidate(const VHbbCandidate & in, bool & ok , std::vector<unsigned int>& muPos, std::vector<unsigned int>& tauPos){
|
38 |
|
|
if (verbose_) std::cout <<" getHZtaumuCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<< " tau " << in.V.taus.size() << std::endl;
|
39 |
|
|
ok = false;
|
40 |
|
|
VHbbCandidate temp=in;
|
41 |
|
|
// Require exactly one tau and muon, and no electrons
|
42 |
|
|
std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
|
43 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
|
44 |
|
|
std::vector<VHbbEvent::TauInfo> taus_ = temp.V.taus;
|
45 |
|
|
|
46 |
|
|
int Nelectrons = 0;
|
47 |
|
|
for(unsigned int j = 0; j<temp.V.electrons.size();j++){
|
48 |
|
|
if (electrons_[j].p4.Pt()>20) Nelectrons++;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
if (temp.V.muons.size() < 1) return in;
|
52 |
|
|
if (temp.V.taus.size() < 1) return in;
|
53 |
|
|
|
54 |
|
|
// only count muons with pT > 15.
|
55 |
|
|
std::vector<VHbbEvent::MuonInfo> muons2_;
|
56 |
|
|
for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons_.begin(); it!= muons_.end(); ++it){
|
57 |
|
|
if (it->p4.Pt()>15) muons2_.push_back(*it);
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
// only consider taus that have opposite charge to the leading muon
|
61 |
|
|
std::vector<VHbbEvent::TauInfo> taus2_;
|
62 |
|
|
for (std::vector<VHbbEvent::TauInfo>::const_iterator it = taus_.begin(); it!= taus_.end(); ++it){
|
63 |
|
|
if ( (*it).charge * muons_[0].charge < 0) taus2_.push_back(*it);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
temp.V.muons = muons2_;
|
67 |
|
|
temp.V.taus = taus2_;
|
68 |
|
|
////////
|
69 |
|
|
////////
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
// Require exactly one tau and muon, and no electrons
|
73 |
|
|
////if (temp.V.taus.size()<1) return in;
|
74 |
|
|
if (temp.V.taus.size()!=1) return in;
|
75 |
|
|
if (temp.V.muons.size()!=1) return in ;
|
76 |
|
|
if (Nelectrons!=0) return in ;
|
77 |
|
|
|
78 |
|
|
temp.V.p4 = temp.V.taus[0].p4 + temp.V.muons[0].p4;
|
79 |
|
|
temp.V.firstLepton = muPos[0];
|
80 |
|
|
temp.V.secondLepton = tauPos[0];
|
81 |
|
|
|
82 |
|
|
ok = true;
|
83 |
|
|
return temp;
|
84 |
|
|
|
85 |
|
|
}
|
86 |
|
|
VHbbCandidate getHZtaueCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& elePos, std::vector<unsigned int>& tauPos){
|
87 |
|
|
if (verbose_) std::cout <<" getHZtaueCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<< " tau " << in.V.taus.size() << std::endl;
|
88 |
|
|
ok = false;
|
89 |
|
|
VHbbCandidate temp=in;
|
90 |
|
|
// Require exactly one tau and muon, and no electrons
|
91 |
|
|
std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
|
92 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
|
93 |
|
|
std::vector<VHbbEvent::TauInfo> taus_ = temp.V.taus;
|
94 |
|
|
|
95 |
|
|
int Nmuons = 0;
|
96 |
|
|
for(unsigned int j = 0; j<temp.V.muons.size();j++){
|
97 |
|
|
if (muons_[j].p4.Pt()>20) Nmuons++;
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
if (temp.V.electrons.size() < 1) return in;
|
101 |
|
|
if (temp.V.taus.size() < 1) return in;
|
102 |
|
|
|
103 |
|
|
// only count muons with pT > 15.
|
104 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons2_;
|
105 |
|
|
for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons_.begin(); it!= electrons_.end(); ++it){
|
106 |
|
|
if (it->p4.Pt()>15) electrons2_.push_back(*it);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
// only consider taus that have opposite charge to the leading electron
|
110 |
|
|
std::vector<VHbbEvent::TauInfo> taus2_;
|
111 |
|
|
for (std::vector<VHbbEvent::TauInfo>::const_iterator it = taus_.begin(); it!= taus_.end(); ++it){
|
112 |
|
|
if ( (*it).charge * electrons_[0].charge < 0) taus2_.push_back(*it);
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
temp.V.electrons = electrons2_;
|
116 |
|
|
temp.V.taus = taus2_;
|
117 |
|
|
////////
|
118 |
|
|
////////
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
// Require exactly one tau and muon, and no electrons
|
122 |
|
|
if (temp.V.taus.size()<1) return in;
|
123 |
|
|
//if (temp.V.taus.size()!=1) return in;
|
124 |
|
|
if (temp.V.electrons.size()!=1) return in ;
|
125 |
|
|
if (Nmuons!=0) return in ;
|
126 |
|
|
|
127 |
|
|
temp.V.p4 = temp.V.taus[0].p4 + temp.V.electrons[0].p4;
|
128 |
|
|
temp.V.firstLepton = elePos[0];
|
129 |
|
|
temp.V.secondLepton = tauPos[0];
|
130 |
|
|
|
131 |
|
|
ok = true;
|
132 |
|
|
return temp;
|
133 |
|
|
|
134 |
|
|
}
|
135 |
|
|
VHbbCandidate getHZtautauCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& pos){
|
136 |
|
|
if (verbose_) std::cout <<" getHZtautauCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<< " tau " << in.V.taus.size() << std::endl;
|
137 |
|
|
ok = false;
|
138 |
|
|
VHbbCandidate temp=in;
|
139 |
|
|
// Require exactly one tau and muon, and no electrons
|
140 |
|
|
std::vector<VHbbEvent::MuonInfo> Nmuons_ = temp.V.muons;
|
141 |
|
|
std::vector<VHbbEvent::ElectronInfo> Nelectrons_ = temp.V.electrons;
|
142 |
|
|
int Nmuons = 0;
|
143 |
|
|
int Nelectrons = 0;
|
144 |
|
|
for(unsigned int i = 0; i<temp.V.muons.size();i++){
|
145 |
|
|
if (Nmuons_[i].p4.Pt()>20) Nmuons++;
|
146 |
|
|
}
|
147 |
|
|
for(unsigned int j = 0; j<temp.V.electrons.size();j++){
|
148 |
|
|
if (Nelectrons_[j].p4.Pt()>20) Nelectrons++;
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
if (temp.V.taus.size()<2) return in;
|
152 |
|
|
if (Nmuons!=0) return in ;
|
153 |
|
|
if (Nelectrons!=0) return in ;
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
std::vector<VHbbEvent::TauInfo> taus_ = temp.V.taus;
|
157 |
|
|
if (taus_[0].p4.Pt() < 20 || taus_[1].p4.Pt()<20) return in;
|
158 |
|
|
if (taus_.size()==2){
|
159 |
|
|
temp.V.p4 = temp.V.taus[0].p4 + temp.V.taus[1].p4;
|
160 |
|
|
temp.V.firstLepton = pos[0];
|
161 |
|
|
temp.V.secondLepton = pos[1];
|
162 |
|
|
|
163 |
|
|
ok = true;
|
164 |
|
|
return temp;
|
165 |
|
|
}
|
166 |
|
|
int selectTau2=1;
|
167 |
|
|
for (unsigned int it=2; it< taus_.size(); ++it){
|
168 |
|
|
if (taus_[0].charge*taus_[it].charge < 0){
|
169 |
|
|
selectTau2 = it;
|
170 |
|
|
break;
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
|
|
std::vector<VHbbEvent::TauInfo> taus2_;
|
174 |
|
|
for (std::vector<VHbbEvent::TauInfo>::const_iterator it = taus_.begin(); it!= taus_.end(); ++it){
|
175 |
|
|
if (it->p4.Pt()>20) taus2_.push_back(*it);
|
176 |
|
|
}
|
177 |
|
|
temp.V.taus = taus2_;
|
178 |
|
|
|
179 |
|
|
temp.V.p4 = temp.V.taus[0].p4 + temp.V.taus[selectTau2].p4;
|
180 |
|
|
temp.V.firstLepton = pos[0];
|
181 |
|
|
temp.V.secondLepton = pos[selectTau2];
|
182 |
|
|
|
183 |
|
|
ok = true;
|
184 |
|
|
return temp;
|
185 |
|
|
|
186 |
|
|
}
|
187 |
|
|
VHbbCandidate getHWtaunCandidate(const VHbbCandidate & in, bool & ok , std::vector<unsigned int>& pos){
|
188 |
sethzenz |
1.13 |
|
189 |
|
|
if (verbose_){
|
190 |
|
|
std::cout <<" getHWtaunCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<< " tau " << in.V.taus.size() << std::endl;
|
191 |
|
|
std::cout << " pos.size()=" << pos.size() << std::endl;
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
ok = false;
|
195 |
|
|
VHbbCandidate temp=in;
|
196 |
|
|
// require a tau and no electrons or muons
|
197 |
wilken |
1.13.6.1 |
std::vector<VHbbEvent::MuonInfo> Nmuons_ = temp.V.muons;
|
198 |
|
|
std::vector<VHbbEvent::ElectronInfo> Nelectrons_ = temp.V.electrons;
|
199 |
|
|
int Nmuons = 0;
|
200 |
|
|
int Nelectrons = 0;
|
201 |
|
|
for(unsigned int i = 0; i<temp.V.muons.size();i++){
|
202 |
|
|
if (Nmuons_[i].p4.Pt()>20) Nmuons++;
|
203 |
|
|
}
|
204 |
|
|
for(unsigned int j = 0; j<temp.V.electrons.size();j++){
|
205 |
|
|
if (Nelectrons_[j].p4.Pt()>20) Nelectrons++;
|
206 |
|
|
}
|
207 |
|
|
|
208 |
sethzenz |
1.13 |
if (temp.V.taus.size()!=1) return in;
|
209 |
wilken |
1.13.6.1 |
if (Nmuons!=0) return in ;
|
210 |
|
|
if (Nelectrons!=0) return in ;
|
211 |
sethzenz |
1.13 |
if (temp.V.mets.size()<1) return in ;
|
212 |
|
|
temp.V.p4 = temp.V.taus[0].p4+temp.V.mets[0].p4;
|
213 |
|
|
temp.V.firstLepton=pos[0];
|
214 |
|
|
|
215 |
|
|
if (verbose_){
|
216 |
|
|
std::cout << "Done with getHWtaunCandidate" << std::endl;
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
ok=true;
|
220 |
|
|
return temp;
|
221 |
|
|
}
|
222 |
|
|
|
223 |
wilken |
1.13.6.1 |
VHbbCandidate getHZemuCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& elePos, std::vector<unsigned int>& muPos){
|
224 |
|
|
if (verbose_){
|
225 |
|
|
std::cout <<" getHZemuCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<<std::endl;
|
226 |
|
|
}
|
227 |
|
|
ok = false;
|
228 |
|
|
VHbbCandidate temp=in;
|
229 |
|
|
|
230 |
|
|
//
|
231 |
|
|
// change: allow for additional leptons; by definition
|
232 |
|
|
//
|
233 |
|
|
if (temp.V.muons.size()<1) return in ;
|
234 |
|
|
if (temp.V.electrons.size()<1) return in ;
|
235 |
|
|
if (temp.V.mets.size()<1) return in;
|
236 |
|
|
|
237 |
|
|
// if (temp.V.electrons.size()!=0) return in ;
|
238 |
|
|
std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
|
239 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
|
240 |
|
|
|
241 |
|
|
//orthogonality with Zmumu and Zee
|
242 |
|
|
if (temp.V.muons.size()>1){
|
243 |
|
|
if (muons_[0].p4.Pt()>20 && muons_[1].p4.Pt()>20 && (muons_[0].charge*muons_[1].charge)< 0)return in;
|
244 |
|
|
}
|
245 |
|
|
if (temp.V.electrons.size()>1){
|
246 |
|
|
if (electrons_[0].p4.Pt()>20 && electrons_[1].p4.Pt()>20&&(electrons_[0].charge*electrons_[1].charge)< 0)return in;
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
// beware: assumes already sorted!!!!
|
251 |
|
|
|
252 |
|
|
// CompareJetPtMuons ptComparator;
|
253 |
|
|
// std::sort(muons_.begin(), muons_.end(), ptComparator);
|
254 |
|
|
if (muons_[0].p4.Pt()<10 || electrons_[0].p4.Pt()<10 ) return in;
|
255 |
|
|
|
256 |
|
|
//
|
257 |
|
|
// now I need to ask also for the charge
|
258 |
|
|
//
|
259 |
|
|
int tauEle=-99, tauMu =-99;
|
260 |
|
|
float Tau_pT = -99.99;
|
261 |
|
|
int tmpEle =0, tmpMu =0;
|
262 |
|
|
int N_pairs = 0;
|
263 |
|
|
//
|
264 |
|
|
// i need to find a proper pair
|
265 |
|
|
//
|
266 |
|
|
|
267 |
|
|
for (unsigned int ele_it=0; ele_it< electrons_.size(); ++ele_it){
|
268 |
|
|
for (unsigned int mu_it=0; mu_it< muons_.size(); ++mu_it){
|
269 |
|
|
if (muons_[mu_it].p4.Pt()>10 && electrons_[ele_it].p4.Pt()>10 ){
|
270 |
|
|
if ( electrons_[ele_it].charge * muons_[mu_it].charge < 0) {
|
271 |
|
|
tmpEle = ele_it;
|
272 |
|
|
tmpMu = mu_it;
|
273 |
|
|
if (N_pairs ==0){
|
274 |
|
|
tauEle = ele_it;
|
275 |
|
|
tauMu = mu_it;
|
276 |
|
|
}
|
277 |
|
|
N_pairs++;
|
278 |
|
|
temp.V.p4 = muons_[mu_it].p4+electrons_[ele_it].p4;
|
279 |
|
|
if (temp.V.p4.Pt() > Tau_pT) {
|
280 |
|
|
tauEle = ele_it;
|
281 |
|
|
tauMu = mu_it;
|
282 |
|
|
Tau_pT = temp.V.p4.Pt();
|
283 |
|
|
}
|
284 |
|
|
} // if opposite charge
|
285 |
|
|
}//leption pt requirement
|
286 |
|
|
} // muon for loop
|
287 |
|
|
} //electron for loop
|
288 |
|
|
if (tauEle==-99) return in;
|
289 |
|
|
if (N_pairs>1) std::cout <<" Number emu pairs: "<<N_pairs<<std::endl;
|
290 |
|
|
|
291 |
|
|
|
292 |
|
|
temp.V.p4 = muons_[tauMu].p4+electrons_[tauEle].p4;
|
293 |
|
|
std::vector<VHbbEvent::MuonInfo> muons2_;
|
294 |
|
|
for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons_.begin(); it!= muons_.end(); ++it){
|
295 |
|
|
if (it->p4.Pt()>10) muons2_.push_back(*it);
|
296 |
|
|
}
|
297 |
|
|
temp.V.muons = muons2_;
|
298 |
|
|
|
299 |
|
|
// beware; assumes already sorted
|
300 |
|
|
|
301 |
|
|
// CompareJetPtElectrons ptComparator2;
|
302 |
|
|
// std::sort(electrons_.begin(), electrons_.end(), ptComparator2);
|
303 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons2_;
|
304 |
|
|
for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons_.begin(); it!= electrons_.end(); ++it){
|
305 |
|
|
if (it->p4.Pt()>10) electrons2_.push_back(*it);
|
306 |
|
|
}
|
307 |
|
|
temp.V.electrons = electrons2_;
|
308 |
|
|
|
309 |
|
|
//
|
310 |
|
|
// consider all
|
311 |
|
|
//
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
// if (temp.V.Pt()<150 ) return in;
|
315 |
|
|
// if (temp.H.Pt()<150) return in;
|
316 |
|
|
// if (temp.H.firstJet().csv< 0.9) return in;
|
317 |
|
|
// if (temp.H.secondJet().csv<0.5) return in;
|
318 |
|
|
// if (deltaPhi(temp.V.Phi(),temp.H.Phi())<2.7) return in;
|
319 |
|
|
// if (temp.V.FourMomentum.Mass()<75 || temp.V.FourMomentum.Mass()>105) return in;
|
320 |
|
|
// if (temp.additionalJets.size()>0) return in;
|
321 |
|
|
// if (std::Abs(deltaTheta) ????
|
322 |
|
|
|
323 |
|
|
temp.V.firstLepton = elePos[tauEle];
|
324 |
|
|
temp.V.secondLepton = muPos[tauMu];
|
325 |
|
|
ok = true;
|
326 |
|
|
|
327 |
|
|
return temp;
|
328 |
|
|
}
|
329 |
|
|
|
330 |
sethzenz |
1.13 |
|
331 |
tboccali |
1.9 |
|
332 |
|
|
VHbbCandidate getHZmumuCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& pos){
|
333 |
tboccali |
1.1 |
if (verbose_){
|
334 |
|
|
std::cout <<" getHZmumuCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<<std::endl;
|
335 |
|
|
}
|
336 |
|
|
ok = false;
|
337 |
|
|
VHbbCandidate temp=in;
|
338 |
tboccali |
1.9 |
|
339 |
tboccali |
1.7 |
//
|
340 |
|
|
// change: allow for additional leptons; by definition
|
341 |
|
|
//
|
342 |
wilken |
1.13.6.1 |
std::vector<VHbbEvent::MuonInfo> Nmuons_ = temp.V.muons;
|
343 |
|
|
std::vector<VHbbEvent::ElectronInfo> Nelectrons_ = temp.V.electrons;
|
344 |
|
|
int Nmuons = 0;
|
345 |
|
|
int Nelectrons = 0;
|
346 |
|
|
for(unsigned int i = 0; i<temp.V.muons.size();i++){
|
347 |
|
|
if (Nmuons_[i].p4.Pt()>20) Nmuons++;
|
348 |
|
|
}
|
349 |
|
|
for(unsigned int j = 0; j<temp.V.electrons.size();j++){
|
350 |
|
|
if (Nelectrons_[j].p4.Pt()>20) Nelectrons++;
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
if (Nmuons<2) return in ;
|
354 |
tboccali |
1.7 |
// if (temp.V.electrons.size()!=0) return in ;
|
355 |
|
|
std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
|
356 |
tboccali |
1.9 |
|
357 |
|
|
// beware: assumes already sorted!!!!
|
358 |
|
|
|
359 |
|
|
// CompareJetPtMuons ptComparator;
|
360 |
|
|
// std::sort(muons_.begin(), muons_.end(), ptComparator);
|
361 |
tboccali |
1.7 |
if (muons_[0].p4.Pt()<20 || muons_[1].p4.Pt()<20 ) return in;
|
362 |
tboccali |
1.9 |
|
363 |
|
|
//
|
364 |
|
|
// now I need to ask also for the charge
|
365 |
|
|
//
|
366 |
|
|
int selectMu2=1;
|
367 |
|
|
|
368 |
|
|
if (muons_[0].charge* muons_[selectMu2].charge > 0){
|
369 |
|
|
if (muons_.size() ==2) return in;
|
370 |
|
|
//
|
371 |
|
|
// i need to find a proper pair
|
372 |
|
|
//
|
373 |
|
|
|
374 |
|
|
for (unsigned int it=2; it< muons_.size(); ++it){
|
375 |
|
|
if ( muons_[it].charge * muons_[0].charge < 0) {
|
376 |
wilken |
1.13.6.1 |
if (muons_[it].p4.Pt()>20) selectMu2 = it;
|
377 |
tboccali |
1.9 |
break;
|
378 |
|
|
}
|
379 |
|
|
if (selectMu2 == 1) return in;
|
380 |
|
|
}
|
381 |
|
|
}
|
382 |
|
|
temp.V.p4 = muons_[0].p4+muons_[selectMu2].p4;
|
383 |
tboccali |
1.7 |
std::vector<VHbbEvent::MuonInfo> muons2_;
|
384 |
|
|
for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons_.begin(); it!= muons_.end(); ++it){
|
385 |
|
|
if (it->p4.Pt()>20) muons2_.push_back(*it);
|
386 |
|
|
}
|
387 |
|
|
temp.V.muons = muons2_;
|
388 |
tboccali |
1.9 |
|
389 |
tboccali |
1.7 |
// the same for electrons
|
390 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
|
391 |
tboccali |
1.9 |
|
392 |
|
|
// beware; assumes already sorted
|
393 |
|
|
|
394 |
|
|
// CompareJetPtElectrons ptComparator2;
|
395 |
|
|
// std::sort(electrons_.begin(), electrons_.end(), ptComparator2);
|
396 |
tboccali |
1.7 |
std::vector<VHbbEvent::ElectronInfo> electrons2_;
|
397 |
|
|
for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons_.begin(); it!= electrons_.end(); ++it){
|
398 |
|
|
if (it->p4.Pt()>20) electrons2_.push_back(*it);
|
399 |
|
|
}
|
400 |
|
|
temp.V.electrons = electrons2_;
|
401 |
|
|
|
402 |
tboccali |
1.9 |
//
|
403 |
tboccali |
1.7 |
// consider all
|
404 |
|
|
//
|
405 |
|
|
|
406 |
tboccali |
1.1 |
|
407 |
|
|
// if (temp.V.Pt()<150 ) return in;
|
408 |
|
|
// if (temp.H.Pt()<150) return in;
|
409 |
|
|
// if (temp.H.firstJet().csv< 0.9) return in;
|
410 |
|
|
// if (temp.H.secondJet().csv<0.5) return in;
|
411 |
|
|
// if (deltaPhi(temp.V.Phi(),temp.H.Phi())<2.7) return in;
|
412 |
|
|
// if (temp.V.FourMomentum.Mass()<75 || temp.V.FourMomentum.Mass()>105) return in;
|
413 |
|
|
// if (temp.additionalJets.size()>0) return in;
|
414 |
|
|
// if (std::Abs(deltaTheta) ????
|
415 |
tboccali |
1.9 |
|
416 |
|
|
temp.V.firstLepton = pos[0];
|
417 |
|
|
temp.V.secondLepton = pos[selectMu2];
|
418 |
|
|
ok = true;
|
419 |
tboccali |
1.1 |
return temp;
|
420 |
|
|
}
|
421 |
tboccali |
1.9 |
VHbbCandidate getHZeeCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& pos){
|
422 |
tboccali |
1.1 |
if (verbose_){
|
423 |
wilken |
1.13.6.1 |
std::cout <<" getHZeeCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<<std::endl;
|
424 |
tboccali |
1.1 |
}
|
425 |
|
|
ok = false;
|
426 |
|
|
VHbbCandidate temp=in;
|
427 |
tboccali |
1.9 |
|
428 |
tboccali |
1.1 |
//
|
429 |
tboccali |
1.7 |
// change: allow for additional leptons; by definition
|
430 |
tboccali |
1.1 |
//
|
431 |
wilken |
1.13.6.1 |
std::vector<VHbbEvent::MuonInfo> Nmuons_ = temp.V.muons;
|
432 |
|
|
std::vector<VHbbEvent::ElectronInfo> Nelectrons_ = temp.V.electrons;
|
433 |
|
|
int Nmuons = 0;
|
434 |
|
|
int Nelectrons = 0;
|
435 |
|
|
for(unsigned int i = 0; i<temp.V.muons.size();i++){
|
436 |
|
|
if (Nmuons_[i].p4.Pt()>20) Nmuons++;
|
437 |
|
|
}
|
438 |
|
|
for(unsigned int j = 0; j<temp.V.electrons.size();j++){
|
439 |
|
|
if (Nelectrons_[j].p4.Pt()>20) Nelectrons++;
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
if (Nelectrons<2) return in ;
|
443 |
tboccali |
1.7 |
// if (temp.V.electrons.size()!=0) return in ;
|
444 |
|
|
std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
|
445 |
tboccali |
1.9 |
|
446 |
|
|
// beware assumes already sorted
|
447 |
|
|
|
448 |
|
|
// CompareJetPtElectrons ptComparator;
|
449 |
|
|
// std::sort(electrons_.begin(), electrons_.end(), ptComparator);
|
450 |
tboccali |
1.7 |
if (electrons_[0].p4.Pt()<20 || electrons_[1].p4.Pt()<20 ) return in;
|
451 |
tboccali |
1.9 |
//
|
452 |
|
|
// now I need to ask also for the charge
|
453 |
|
|
//
|
454 |
|
|
int selectE2=1;
|
455 |
|
|
|
456 |
|
|
if (electrons_[0].charge* electrons_[selectE2].charge > 0){
|
457 |
|
|
if (electrons_.size() ==2) return in;
|
458 |
|
|
//
|
459 |
|
|
// i need to find a proper pair
|
460 |
|
|
//
|
461 |
|
|
|
462 |
|
|
for (unsigned int it=2; it< electrons_.size(); ++it){
|
463 |
|
|
if ( electrons_[it].charge * electrons_[0].charge < 0) {
|
464 |
wilken |
1.13.6.1 |
if (electrons_[it].p4.Pt()>20) selectE2 = it;
|
465 |
tboccali |
1.9 |
break;
|
466 |
|
|
}
|
467 |
|
|
if (selectE2 == 1) return in;
|
468 |
|
|
}
|
469 |
|
|
}
|
470 |
|
|
temp.V.p4 = electrons_[0].p4+electrons_[selectE2].p4;
|
471 |
tboccali |
1.7 |
std::vector<VHbbEvent::ElectronInfo> electrons2_;
|
472 |
|
|
for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons_.begin(); it!= electrons_.end(); ++it){
|
473 |
|
|
if (it->p4.Pt()>20) electrons2_.push_back(*it);
|
474 |
|
|
}
|
475 |
|
|
temp.V.electrons = electrons2_;
|
476 |
|
|
|
477 |
|
|
// the same for muonss
|
478 |
|
|
std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
|
479 |
tboccali |
1.9 |
|
480 |
|
|
// beware assumes already sorted
|
481 |
|
|
|
482 |
|
|
// CompareJetPtMuons ptComparator2;
|
483 |
|
|
// std::sort(muons_.begin(), muons_.end(), ptComparator2);
|
484 |
tboccali |
1.7 |
std::vector<VHbbEvent::MuonInfo> muons2_;
|
485 |
|
|
for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons_.begin(); it!= muons_.end(); ++it){
|
486 |
|
|
if (it->p4.Pt()>20) muons2_.push_back(*it);
|
487 |
|
|
}
|
488 |
|
|
temp.V.muons = muons2_;
|
489 |
tboccali |
1.9 |
|
490 |
|
|
temp.V.firstLepton = pos[0];
|
491 |
|
|
temp.V.secondLepton = pos[selectE2];
|
492 |
|
|
|
493 |
tboccali |
1.7 |
|
494 |
|
|
ok = true;
|
495 |
tboccali |
1.1 |
return temp;
|
496 |
|
|
}
|
497 |
|
|
VHbbCandidate getHZnnCandidate(const VHbbCandidate & in, bool & ok){
|
498 |
|
|
if (verbose_){
|
499 |
|
|
std::cout <<" getHZnnCandidate input mu "<<in.V.muons.size()<<" e "<<in.V.electrons.size()<<" met "<<in.V.mets.size()<<std::endl;
|
500 |
|
|
}
|
501 |
|
|
|
502 |
|
|
ok = false;
|
503 |
|
|
VHbbCandidate temp=in;
|
504 |
|
|
if (temp.V.mets.size()!=1) return in;
|
505 |
arizzi |
1.10 |
//always build a NuNu candidate, exclusion come from if/else series on the caller side
|
506 |
|
|
// this allow to still build candidates for mu+e and same sign dilept
|
507 |
|
|
// if (temp.V.muons.size()!=0) return in ;
|
508 |
|
|
// if (temp.V.electrons.size()!=0) return in ;
|
509 |
tboccali |
1.1 |
|
510 |
tboccali |
1.6 |
temp.V.p4 = temp.V.mets[0].p4;
|
511 |
tboccali |
1.1 |
if (verbose_) {
|
512 |
|
|
std::cout <<" debug met "<< temp.V.mets[0].metSig << " " << temp.V.mets[0].sumEt<< std::endl;
|
513 |
|
|
}
|
514 |
arizzi |
1.12 |
// if (temp.V.mets[0].metSig<5) return in;
|
515 |
tboccali |
1.11 |
if (temp.V.mets[0].p4.Pt()<80) return in;
|
516 |
tboccali |
1.6 |
// if (temp.H.p4.Pt()<150)return in;
|
517 |
tboccali |
1.1 |
// if (temp.H.firstJet().csv< 0.9) return in;
|
518 |
|
|
// if (temp.H.secondJet().csv<0.5) return in;
|
519 |
tboccali |
1.6 |
// if (deltaPhi(temp.V.p4.Phi(),temp.H.p4.Phi())<2.95) return in;
|
520 |
tboccali |
1.1 |
// if (temp.V.electrons.size()>0 || temp.V.muons.size()>0 ) return in;
|
521 |
|
|
// if (temp.additionalJets.size()>0) return in;
|
522 |
|
|
// if (std::Abs(deltaTheta) ????
|
523 |
|
|
|
524 |
|
|
ok = true;
|
525 |
|
|
return temp;
|
526 |
|
|
}
|
527 |
|
|
|
528 |
tboccali |
1.9 |
VHbbCandidate getHWmunCandidate(const VHbbCandidate & in, bool & ok , std::vector<unsigned int>& pos){
|
529 |
tboccali |
1.1 |
ok = false;
|
530 |
|
|
VHbbCandidate temp=in;
|
531 |
tboccali |
1.2 |
// require a muon and no electrons
|
532 |
wilken |
1.13.6.1 |
std::vector<VHbbEvent::MuonInfo> Nmuons_ = temp.V.muons;
|
533 |
|
|
std::vector<VHbbEvent::ElectronInfo> Nelectrons_ = temp.V.electrons;
|
534 |
|
|
int Nmuons = 0;
|
535 |
|
|
int Nelectrons = 0;
|
536 |
|
|
int position = 0;
|
537 |
|
|
for(unsigned int i = 0; i<temp.V.muons.size();i++){
|
538 |
|
|
if (Nmuons_[i].p4.Pt()>20) {
|
539 |
|
|
Nmuons++;
|
540 |
|
|
position = i;
|
541 |
|
|
} }
|
542 |
|
|
for(unsigned int j = 0; j<temp.V.electrons.size();j++){
|
543 |
|
|
if (Nelectrons_[j].p4.Pt()>20) Nelectrons++;
|
544 |
|
|
}
|
545 |
|
|
|
546 |
|
|
if (Nmuons!=1) return in ;
|
547 |
|
|
if (Nelectrons!=0) return in ;
|
548 |
tboccali |
1.3 |
if (temp.V.mets.size()<1) return in ;
|
549 |
wilken |
1.13.6.1 |
std::vector<VHbbEvent::MuonInfo> muons_ = temp.V.muons;
|
550 |
|
|
if (muons_[position].p4.Pt()<20) return in;
|
551 |
tboccali |
1.1 |
//
|
552 |
tboccali |
1.2 |
/*pT(W) > 150 GeV (pt(W) computed using lepton px,y and PF MET x and y components)
|
553 |
|
|
pT(H) > 150 GeV
|
554 |
|
|
best btag, CSV > 0.90
|
555 |
|
|
second-best btag, CSV > 0.50
|
556 |
|
|
Dphi(W,H) > 2.95
|
557 |
|
|
no additional isolated leptons (pT > 15 GeV)
|
558 |
|
|
|
559 |
|
|
same lepton definition as in the physics objects section
|
560 |
|
|
|
561 |
|
|
No additional ak5PFjets (pT > 30 GeV; |eta| < 2.4)
|
562 |
|
|
MET>35. for the electron BDT analysis
|
563 |
|
|
|cos(theta * )| (TBO)
|
564 |
|
|
color flow pull angle (TBO)
|
565 |
|
|
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.)
|
566 |
|
|
*/
|
567 |
|
|
|
568 |
wilken |
1.13.6.1 |
temp.V.p4 = temp.V.muons[position].p4+temp.V.mets[0].p4;
|
569 |
tboccali |
1.9 |
temp.V.firstLepton=pos[0];
|
570 |
tboccali |
1.2 |
|
571 |
|
|
ok=true;
|
572 |
tboccali |
1.3 |
return temp;
|
573 |
tboccali |
1.1 |
}
|
574 |
|
|
|
575 |
tboccali |
1.9 |
VHbbCandidate getHWenCandidate(const VHbbCandidate & in, bool & ok, std::vector<unsigned int>& pos){
|
576 |
tboccali |
1.1 |
ok = false;
|
577 |
|
|
VHbbCandidate temp=in;
|
578 |
wilken |
1.13.6.1 |
std::vector<VHbbEvent::MuonInfo> Nmuons_ = temp.V.muons;
|
579 |
|
|
std::vector<VHbbEvent::ElectronInfo> Nelectrons_ = temp.V.electrons;
|
580 |
|
|
int Nmuons = 0;
|
581 |
|
|
int Nelectrons = 0;
|
582 |
|
|
int position = 0;
|
583 |
|
|
for(unsigned int i = 0; i<temp.V.muons.size();i++){
|
584 |
|
|
if (Nmuons_[i].p4.Pt()>20) Nmuons++;
|
585 |
|
|
}
|
586 |
|
|
for(unsigned int j = 0; j<temp.V.electrons.size();j++){
|
587 |
|
|
if (Nelectrons_[j].p4.Pt()>20) {
|
588 |
|
|
Nelectrons++;
|
589 |
|
|
position = j;
|
590 |
|
|
} }
|
591 |
|
|
|
592 |
|
|
if (Nelectrons!=1) return in ;
|
593 |
|
|
if (Nmuons!=0) return in ;
|
594 |
tboccali |
1.3 |
if (temp.V.mets.size()<1) return in ;
|
595 |
wilken |
1.13.6.1 |
std::vector<VHbbEvent::ElectronInfo> electrons_ = temp.V.electrons;
|
596 |
|
|
if (electrons_[position].p4.Pt()<20) return in;
|
597 |
tboccali |
1.1 |
//
|
598 |
tboccali |
1.2 |
/*pT(W) > 150 GeV (pt(W) computed using lepton px,y and PF MET x and y components)
|
599 |
|
|
pT(H) > 150 GeV
|
600 |
|
|
best btag, CSV > 0.90
|
601 |
|
|
second-best btag, CSV > 0.50
|
602 |
|
|
Dphi(W,H) > 2.95
|
603 |
|
|
no additional isolated leptons (pT > 15 GeV)
|
604 |
|
|
|
605 |
|
|
same lepton definition as in the physics objects section
|
606 |
|
|
|
607 |
|
|
No additional ak5PFjets (pT > 30 GeV; |eta| < 2.4)
|
608 |
|
|
MET>35. for the electron BDT analysis
|
609 |
|
|
|cos(theta * )| (TBO)
|
610 |
|
|
color flow pull angle (TBO)
|
611 |
|
|
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.)
|
612 |
|
|
*/
|
613 |
|
|
|
614 |
|
|
ok=true;
|
615 |
tboccali |
1.9 |
temp.V.firstLepton=pos[0];
|
616 |
tboccali |
1.6 |
temp.V.p4 = temp.V.electrons[0].p4+temp.V.mets[0].p4;
|
617 |
tboccali |
1.3 |
return temp;
|
618 |
tboccali |
1.1 |
}
|
619 |
|
|
|
620 |
|
|
public:
|
621 |
|
|
bool verbose_;
|
622 |
tboccali |
1.2 |
|
623 |
|
|
public:
|
624 |
tboccali |
1.9 |
static float getDeltaTheta( const VHbbEvent::SimpleJet & j1, const VHbbEvent::SimpleJet & j2 ) {
|
625 |
tboccali |
1.5 |
double deltaTheta = 1e10;
|
626 |
|
|
TLorentzVector pi(0,0,0,0);
|
627 |
|
|
TLorentzVector v_j1 = j1.chargedTracksFourMomentum;
|
628 |
|
|
TLorentzVector v_j2 = j2.chargedTracksFourMomentum;
|
629 |
|
|
|
630 |
|
|
if( v_j2.Mag() == 0
|
631 |
|
|
|| v_j1.Mag() == 0 )
|
632 |
|
|
return deltaTheta = 1e10;
|
633 |
|
|
|
634 |
|
|
//use j1 to calculate the pull vector
|
635 |
|
|
TVector2 t = j1.tVector;
|
636 |
|
|
|
637 |
|
|
if( t.Mod() == 0 )
|
638 |
|
|
return deltaTheta = 1e10;
|
639 |
|
|
|
640 |
|
|
Double_t dphi = v_j2.Phi()- v_j1.Phi();
|
641 |
|
|
if ( dphi > M_PI ) {
|
642 |
|
|
dphi -= 2.0*M_PI;
|
643 |
|
|
} else if ( dphi <= -M_PI ) {
|
644 |
|
|
dphi += 2.0*M_PI;
|
645 |
|
|
}
|
646 |
|
|
Double_t deltaeta = v_j2.Rapidity() - v_j1.Rapidity();
|
647 |
|
|
TVector2 BBdir( deltaeta, dphi );
|
648 |
|
|
|
649 |
|
|
deltaTheta = t.DeltaPhi(BBdir);
|
650 |
|
|
|
651 |
|
|
return deltaTheta;
|
652 |
|
|
|
653 |
|
|
}
|
654 |
|
|
|
655 |
tboccali |
1.4 |
float getHelicity(const VHbbEvent::SimpleJet& j, TVector3 boost) const {
|
656 |
|
|
double hel = 1e10;
|
657 |
tboccali |
1.6 |
TLorentzVector jet = j.p4;
|
658 |
tboccali |
1.4 |
jet.Boost( -boost );
|
659 |
|
|
hel = TMath::Cos( jet.Vect().Angle( boost ) );
|
660 |
|
|
return hel;
|
661 |
|
|
}
|
662 |
|
|
|
663 |
tboccali |
1.1 |
|
664 |
|
|
};
|
665 |
|
|
|
666 |
|
|
|
667 |
|
|
|
668 |
|
|
#endif
|
669 |
|
|
|
670 |
|
|
|
671 |
|
|
|
672 |
|
|
|
673 |
|
|
|
674 |
|
|
|