1 |
#include "Selection.h"
|
2 |
#include "ControlSelection.h"
|
3 |
#include "PassHLT.h"
|
4 |
#include "HZZCiCElectronSelection.h"
|
5 |
#include "HZZLikelihoodElectronSelection.h"
|
6 |
#include "RunLumiRangeMap.h"
|
7 |
#include "TRandom3.h"
|
8 |
#include <fstream>
|
9 |
#include <sstream>
|
10 |
#include "TMath.h"
|
11 |
|
12 |
int getSFetaBin( float eta, vector<float> &SFeta ) {
|
13 |
for( int i=0; i<SFeta.size()-1; i++ ) {
|
14 |
if ( eta > SFeta[i] && eta <= SFeta[i+1] )
|
15 |
return i;
|
16 |
}
|
17 |
if( eta > SFeta[SFeta.size()-1] && eta <= 2.5 )
|
18 |
return SFeta.size()-1;
|
19 |
return -1;
|
20 |
}
|
21 |
|
22 |
void getSF( char * sfname, vector<float> &SFeta, vector<float> &SFscale, vector<float> &SFres ) {
|
23 |
|
24 |
ifstream sf;
|
25 |
sf.open(sfname);
|
26 |
|
27 |
std::string line;
|
28 |
float eta, scale, scaleerr, res, reserr;
|
29 |
while( getline(sf,line) ) {
|
30 |
stringstream ss(line);
|
31 |
ss >> eta;
|
32 |
ss >> scale;
|
33 |
ss >> scaleerr;
|
34 |
ss >> res;
|
35 |
ss >> reserr;
|
36 |
SFeta.push_back(eta);
|
37 |
SFscale.push_back(scale);
|
38 |
SFres.push_back(res);
|
39 |
}
|
40 |
|
41 |
};
|
42 |
|
43 |
|
44 |
|
45 |
// RunLumiRangeMap rlrm;
|
46 |
|
47 |
// void initRunLumiRangeMap() {
|
48 |
// rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
|
49 |
// rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
|
50 |
// rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));
|
51 |
// rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));
|
52 |
// };
|
53 |
|
54 |
|
55 |
|
56 |
unsigned fails_Control_selection(ControlFlags &ctrl, // input control
|
57 |
mithep::TEventInfo *info, // input event inof
|
58 |
TClonesArray *electronArr, // input electrons
|
59 |
TClonesArray *muonArr, // input muons
|
60 |
TClonesArray *jetArr, // input muons
|
61 |
double eventweight, // weight
|
62 |
TTree * ctrltuple ) {
|
63 |
|
64 |
|
65 |
TRandom3 r;
|
66 |
unsigned evtfail = 0x0;
|
67 |
|
68 |
vector<float> SFeta, SFscale, SFres;
|
69 |
if( ctrl.do_ele_scale_res ) {
|
70 |
getSF( "results.txt", SFeta, SFscale, SFres );
|
71 |
}
|
72 |
|
73 |
// if( !ctrl.mc ) {
|
74 |
// // not accounting for overlap atm
|
75 |
// RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);
|
76 |
// if( !(rlrm.HasRunLumi(rl)) ) {
|
77 |
// evtfail |= (1<<EVTFAIL_JSON);
|
78 |
// return evtfail;
|
79 |
// }
|
80 |
// }
|
81 |
|
82 |
|
83 |
if( ctrl.debug ) {
|
84 |
cout << "Run: " << info->runNum
|
85 |
<< "\tEvt: " << info->evtNum
|
86 |
<< "\tLumi: " << info->lumiSec
|
87 |
<< endl;
|
88 |
}
|
89 |
|
90 |
|
91 |
//********************************************************
|
92 |
// Trigger
|
93 |
//********************************************************
|
94 |
if( !ctrl.mc ) {
|
95 |
// if( !(passHLT(info->triggerBits, info->runNum, channel) ) ) {
|
96 |
if( !(passHLT(info->triggerBits, info->runNum, 999) ) ) {
|
97 |
evtfail |= (1<<EVTFAIL_TRIGGER);
|
98 |
return evtfail;
|
99 |
}
|
100 |
} else {
|
101 |
if( !(passHLTMC(info->triggerBits)) ) {
|
102 |
evtfail |= (1<<EVTFAIL_TRIGGER);
|
103 |
return evtfail;
|
104 |
}
|
105 |
// cout << "MC trigger bits: " << hex << info->triggerBits << dec << endl;
|
106 |
}
|
107 |
if( ctrl.debug ) {
|
108 |
cout << "presel nlep: " << muonArr->GetEntries() + electronArr->GetEntries()
|
109 |
<< "\tnmuon: " << muonArr->GetEntries()
|
110 |
<< "\tnelectron: " << electronArr->GetEntries()
|
111 |
<< endl;
|
112 |
}
|
113 |
|
114 |
//********************************************************
|
115 |
// Lepton Selection
|
116 |
//********************************************************
|
117 |
vector<SimpleLepton> lepvec;
|
118 |
|
119 |
//
|
120 |
if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl;
|
121 |
//----------------------------------------------------
|
122 |
for(Int_t i=0; i<muonArr->GetEntries(); i++) {
|
123 |
const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);
|
124 |
unsigned muonfail = passMuonSelectionZZ(mu);
|
125 |
if( ctrl.debug ) {
|
126 |
cout << "muon:: pt: " << mu->pt
|
127 |
<< "\teta: " << mu->eta
|
128 |
<< "\tmask: 0x" << hex << muonfail << dec
|
129 |
<< endl;
|
130 |
}
|
131 |
if ( isMuonFO(mu) ) {
|
132 |
SimpleLepton tmplep;
|
133 |
tmplep.vec.SetPtEtaPhiM(mu->pt,
|
134 |
mu->eta,
|
135 |
mu->phi,
|
136 |
105.658369e-3);
|
137 |
tmplep.type = 13;
|
138 |
tmplep.index = i;
|
139 |
tmplep.charge = mu->q;
|
140 |
tmplep.isoTrk = mu->trkIso03;
|
141 |
tmplep.isoEcal = mu->emIso03;
|
142 |
tmplep.isoHcal = mu->hadIso03;
|
143 |
tmplep.ip3dSig = mu->ip3dSig;
|
144 |
tmplep.is4l = false;
|
145 |
tmplep.isEB = (fabs(mu->eta) < 1.479 ? 1 : 0 );
|
146 |
tmplep.isTight = ( muonfail == 0 ? 1 : 0) ;
|
147 |
lepvec.push_back(tmplep);
|
148 |
if( ctrl.debug ) { cout << "muon passes ... " << endl;}
|
149 |
}
|
150 |
}
|
151 |
|
152 |
if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; }
|
153 |
|
154 |
//----------------------------------------------------
|
155 |
for(Int_t i=0; i<electronArr->GetEntries(); i++) {
|
156 |
const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]);
|
157 |
|
158 |
Bool_t isMuonOverlap = kFALSE;
|
159 |
for (int k=0; k<lepvec.size(); ++k) {
|
160 |
TVector3 tmplep;
|
161 |
tmplep.SetPtEtaPhi(ele->pt, ele->eta, ele->phi);
|
162 |
if ( lepvec[k].type == 13 && lepvec[k].vec.Vect().DrEtaPhi(tmplep) < 0.1 ) {
|
163 |
if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl;
|
164 |
isMuonOverlap = kTRUE;
|
165 |
break;
|
166 |
}
|
167 |
}
|
168 |
|
169 |
unsigned FAIL;
|
170 |
CICStruct tightcuts = getTightCuts();
|
171 |
unsigned failsCICTight = failsCicSelection(ctrl, ele, tightcuts, ctrl.kinematics);
|
172 |
CICStruct loosecuts = getVeryLooseCuts();
|
173 |
unsigned failsCICLoose = failsCicSelection(ctrl, ele, loosecuts, ctrl.kinematics);
|
174 |
|
175 |
if( ctrl.debug ){
|
176 |
cout << "CIC category: " << cicCategory(ele)
|
177 |
<< "\tfailsCIC: 0x" << hex << failsCICTight << dec
|
178 |
<< "\tscEt: " << ele->scEt
|
179 |
<< "\tscEta: " << ele->scEta
|
180 |
<< "\tncluster: " << ele->ncluster
|
181 |
<< endl;
|
182 |
}
|
183 |
if ( (!failsCICTight || !failsCICLoose) && !isMuonOverlap ) {
|
184 |
SimpleLepton tmplep;
|
185 |
|
186 |
tmplep.vec.SetPtEtaPhiM( ele->pt,
|
187 |
ele->eta,
|
188 |
ele->phi,
|
189 |
0.51099892e-3 );
|
190 |
|
191 |
if( ctrl.do_ele_scale_res) {
|
192 |
int etabin = getSFetaBin( ele->scEta, SFeta );
|
193 |
if ( etabin > 0 ) {
|
194 |
float ptorig = tmplep.vec.Pt();
|
195 |
float Eorig = ele->pt*TMath::CosH(ele->eta);
|
196 |
float Enew = r.Gaus(Eorig*SFscale[etabin], SFres[etabin] );
|
197 |
// float Enew = r.Gaus(Eorig, SFres[etabin] );
|
198 |
tmplep.vec.SetE(Enew);
|
199 |
//tmplep.vec.SetE(Eorig);
|
200 |
//float ptnew = tmplep.vec.Pt();
|
201 |
//cout << "ptorig: " << ptorig << "\tptnew: " << ptnew << endl;
|
202 |
}
|
203 |
}
|
204 |
|
205 |
tmplep.type = 11;
|
206 |
tmplep.index = i;
|
207 |
tmplep.charge = ele->q;
|
208 |
tmplep.isoTrk = ele->trkIso03;
|
209 |
tmplep.isoEcal = ele->emIso03;
|
210 |
tmplep.isoHcal = ele->hadIso03;
|
211 |
tmplep.ip3dSig = ele->ip3dSig;
|
212 |
tmplep.is4l = false;
|
213 |
tmplep.isEB = ele->isEB;
|
214 |
tmplep.isTight = ( failsCICTight == 0 ? 1 : 0);
|
215 |
lepvec.push_back(tmplep);
|
216 |
if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
|
217 |
}
|
218 |
}
|
219 |
|
220 |
sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
|
221 |
|
222 |
|
223 |
|
224 |
int nmu=0, nele=0;
|
225 |
for( int i=0; i<lepvec.size(); i++ ) {
|
226 |
//
|
227 |
// check for a matched btagged jet
|
228 |
//
|
229 |
for(int k=0; k<jetArr->GetEntries(); k++) {
|
230 |
const mithep::TJet *jet = (mithep::TJet*)((*jetArr)[k]);
|
231 |
TVector3 jvec;
|
232 |
jvec.SetPtEtaPhi(jet->pt, jet->eta, jet->phi);
|
233 |
if( jvec.DrEtaPhi( lepvec[i].vec.Vect()) < 0.3 ) {
|
234 |
lepvec[i].bTag = jet->tche;
|
235 |
}
|
236 |
}
|
237 |
|
238 |
if( abs(lepvec[i].type) == 11 ) nele++;
|
239 |
else nmu++;
|
240 |
}
|
241 |
if( ctrl.debug ) {
|
242 |
cout << "postsel nlep: " << lepvec.size()
|
243 |
<< "\tnmuon: " << nmu
|
244 |
<< "\tnelectron: " << nele
|
245 |
<< endl;
|
246 |
}
|
247 |
|
248 |
//******************************************************************************
|
249 |
//Z1 Selection
|
250 |
//******************************************************************************
|
251 |
int Z1LeptonPlusIndex = -1;
|
252 |
int Z1LeptonMinusIndex = -1;
|
253 |
double BestZ1Mass = -999;
|
254 |
if( ctrl.debug ) { cout << "looking for a Z1 ..." << endl; }
|
255 |
for(int i = 0; i < lepvec.size(); i++) {
|
256 |
if (fabs(lepvec[i].type) == 11 && !(lepvec[i].isTight) ) continue;
|
257 |
for(int j = i+1; j < lepvec.size(); j++) {
|
258 |
if (fabs(lepvec[j].type) == 11 && !(lepvec[j].isTight) ) continue;
|
259 |
if( ctrl.debug ) { cout << "\tconsidering leptons " << i << " & " << j << endl; }
|
260 |
if (!(lepvec[i].vec.Pt() > 20.0 || lepvec[j].vec.Pt() > 20.0)) continue;
|
261 |
if( ctrl.debug ) { cout << "\tat least one is > 20 GeV" << endl; }
|
262 |
if (!(lepvec[i].vec.Pt() > 10.0 && lepvec[j].vec.Pt() > 10.0)) continue;
|
263 |
if( ctrl.debug ) { cout << "\tthe other is > 10 GeV" << endl; }
|
264 |
if (lepvec[i].charge == lepvec[j].charge) continue;
|
265 |
if( ctrl.debug ) { cout << "\tthey're opposite charge" << endl; }
|
266 |
if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) continue;
|
267 |
if( ctrl.debug ) { cout << "\tthey're same flavor" << endl; }
|
268 |
|
269 |
|
270 |
//Make Z1 hypothesis
|
271 |
TLorentzVector leptonPlus, leptonMinus;
|
272 |
if ( lepvec[i].charge > 0 ) {
|
273 |
leptonPlus = lepvec[i].vec;
|
274 |
leptonMinus = lepvec[j].vec;
|
275 |
} else {
|
276 |
leptonPlus = lepvec[j].vec;
|
277 |
leptonMinus = lepvec[i].vec;
|
278 |
}
|
279 |
|
280 |
float tmpZ1Mass = (leptonPlus+leptonMinus).M();
|
281 |
if( ctrl.debug ) cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl;
|
282 |
if( tmpZ1Mass > 60 ) {
|
283 |
if (fabs(tmpZ1Mass - 91.1876) < fabs(BestZ1Mass - 91.1876)) {
|
284 |
BestZ1Mass = tmpZ1Mass;
|
285 |
if( ctrl.debug ) cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass
|
286 |
<< "\tdM: " << fabs(BestZ1Mass - 91.1876)
|
287 |
<< endl;
|
288 |
if (lepvec[i].charge > 0) {
|
289 |
Z1LeptonPlusIndex = i;
|
290 |
Z1LeptonMinusIndex = j;
|
291 |
} else {
|
292 |
Z1LeptonPlusIndex = j;
|
293 |
Z1LeptonMinusIndex = i;
|
294 |
}
|
295 |
}
|
296 |
}
|
297 |
}
|
298 |
}
|
299 |
// stop if no Z1 candidate is found
|
300 |
if( BestZ1Mass < 0 ) {
|
301 |
evtfail |= (1<<EVTFAIL_Z1);
|
302 |
return evtfail;
|
303 |
}
|
304 |
if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum << endl;
|
305 |
if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
|
306 |
TLorentzVector Z1LeptonPlus = lepvec[Z1LeptonPlusIndex].vec;
|
307 |
TLorentzVector Z1LeptonMinus = lepvec[Z1LeptonMinusIndex].vec;
|
308 |
TLorentzVector Z1Candidate = Z1LeptonPlus + Z1LeptonMinus;
|
309 |
|
310 |
|
311 |
//******************************************************************************
|
312 |
// Z1 + l
|
313 |
//******************************************************************************
|
314 |
if( lepvec.size() < 3 ) {
|
315 |
evtfail |= (1<<EVTFAIL_Z1_PLUSL);
|
316 |
return evtfail;
|
317 |
}
|
318 |
|
319 |
//******************************************************************************
|
320 |
// 4l/Z2 Selection
|
321 |
//******************************************************************************
|
322 |
Int_t Z2LeptonPlusIndex = -1;
|
323 |
Int_t Z2LeptonMinusIndex = -1;
|
324 |
Double_t BestZ2Mass = -1;
|
325 |
if( ctrl.debug ) cout << "hey ... looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
|
326 |
for(int i = 0; i < lepvec.size(); ++i) {
|
327 |
for(int j = i+1; j < lepvec.size(); ++j) {
|
328 |
if( ctrl.debug ) cout << "i: " << i << "\tj: " << j << endl;
|
329 |
if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) {
|
330 |
if( ctrl.debug ) cout << "\ti matches a Z1 index, skipping ..." << endl;
|
331 |
continue; //skip Z1 leptons
|
332 |
}
|
333 |
if (j == Z1LeptonPlusIndex || j == Z1LeptonMinusIndex) {
|
334 |
if( ctrl.debug ) cout << "\tj matches a Z1 index, skipping ..." << endl;
|
335 |
continue; //skip Z1 leptons
|
336 |
}
|
337 |
|
338 |
//
|
339 |
// no charge or flavor for control
|
340 |
//
|
341 |
/*
|
342 |
if (lepvec[i].charge == lepvec[j].charge) {
|
343 |
// cout << "\ti and j are same sign, skipping ..." << endl;
|
344 |
continue; //require opp sign
|
345 |
}
|
346 |
if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) {
|
347 |
// cout << "\ti and j are not same flavor, skipping ..." << endl;
|
348 |
continue; //require same flavor
|
349 |
}
|
350 |
*/
|
351 |
|
352 |
//Make Z2 hypothesis
|
353 |
TLorentzVector leptonPlus, leptonMinus;
|
354 |
|
355 |
if (lepvec[i].charge > 0 ) {
|
356 |
leptonPlus = lepvec[i].vec;
|
357 |
leptonMinus = lepvec[j].vec;
|
358 |
} else {
|
359 |
leptonPlus = lepvec[j].vec;
|
360 |
leptonMinus = lepvec[i].vec;
|
361 |
}
|
362 |
|
363 |
TLorentzVector dilepton = leptonPlus+leptonMinus;
|
364 |
TLorentzVector fourLepton = Z1Candidate + dilepton;
|
365 |
|
366 |
//
|
367 |
// no Z2 mass for control
|
368 |
//
|
369 |
/*
|
370 |
if( ctrl.debug ) cout << "dilepton.M() : " << dilepton.M() << endl;
|
371 |
if( ctrl.debug ) cout << "fourLepton.M() : " << fourLepton.M() << endl;
|
372 |
if (!(dilepton.M() > 12.0)) continue;
|
373 |
if (!(fourLepton.M() > 100.0)) continue;
|
374 |
|
375 |
//for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12
|
376 |
if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
|
377 |
TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
|
378 |
TLorentzVector pair2 = Z1LeptonMinus+leptonPlus;
|
379 |
if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
|
380 |
if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
|
381 |
}
|
382 |
*/
|
383 |
|
384 |
//Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin
|
385 |
if (Z2LeptonPlusIndex < 0) {
|
386 |
if (lepvec[i].charge > 0) {
|
387 |
Z2LeptonPlusIndex = i;
|
388 |
Z2LeptonMinusIndex = j;
|
389 |
} else {
|
390 |
Z2LeptonPlusIndex = j;
|
391 |
Z2LeptonMinusIndex = i;
|
392 |
}
|
393 |
} else {
|
394 |
Double_t BestPairPtMax = lepvec[Z2LeptonPlusIndex].vec.Pt();
|
395 |
Double_t BestPairPtMin = lepvec[Z2LeptonMinusIndex].vec.Pt();
|
396 |
if (lepvec[Z2LeptonMinusIndex].vec.Pt() > BestPairPtMax) {
|
397 |
BestPairPtMax = lepvec[Z2LeptonMinusIndex].vec.Pt();
|
398 |
BestPairPtMin = lepvec[Z2LeptonPlusIndex].vec.Pt();
|
399 |
}
|
400 |
|
401 |
Double_t CurrentPairPtMax = lepvec[i].vec.Pt();
|
402 |
Double_t CurrentPairPtMin = lepvec[j].vec.Pt();
|
403 |
if (lepvec[j].vec.Pt() > CurrentPairPtMax) {
|
404 |
CurrentPairPtMax = lepvec[j].vec.Pt();
|
405 |
CurrentPairPtMin = lepvec[i].vec.Pt();
|
406 |
}
|
407 |
|
408 |
if (CurrentPairPtMax > BestPairPtMax) {
|
409 |
if (lepvec[i].charge > 0) {
|
410 |
Z2LeptonPlusIndex = i;
|
411 |
Z2LeptonMinusIndex = j;
|
412 |
} else {
|
413 |
Z2LeptonPlusIndex = j;
|
414 |
Z2LeptonMinusIndex = i;
|
415 |
}
|
416 |
} else if (CurrentPairPtMax == BestPairPtMax) {
|
417 |
if (CurrentPairPtMin > BestPairPtMin) {
|
418 |
if (lepvec[i].charge > 0) {
|
419 |
Z2LeptonPlusIndex = i;
|
420 |
Z2LeptonMinusIndex = j;
|
421 |
} else {
|
422 |
Z2LeptonPlusIndex = j;
|
423 |
Z2LeptonMinusIndex = i;
|
424 |
}
|
425 |
}
|
426 |
}
|
427 |
}
|
428 |
}
|
429 |
}
|
430 |
|
431 |
// stop if no Z2 candidate is found
|
432 |
if (Z2LeptonPlusIndex == -1) {
|
433 |
evtfail |= ( 1<<EVTFAIL_4L );
|
434 |
return evtfail;
|
435 |
// h_evtfail->Fill( evtfail );
|
436 |
// cout << "evtfail: " << hex << evtfail << dec << endl;
|
437 |
// continue;
|
438 |
}
|
439 |
if( ctrl.debug ) cout << "\tgot a Z2 ..." << endl;
|
440 |
if( ctrl.debug ) cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex
|
441 |
<< "\tminusindex: " << Z2LeptonMinusIndex << endl;
|
442 |
TLorentzVector Z2LeptonPlus = lepvec[Z2LeptonPlusIndex].vec;
|
443 |
TLorentzVector Z2LeptonMinus = lepvec[Z2LeptonMinusIndex].vec;
|
444 |
|
445 |
// HACKHACKHACKHACKHACKHACKHACKHACK
|
446 |
if( Z2LeptonPlus.Pt() < 20 ) {
|
447 |
Z2LeptonPlus.SetPtEtaPhiM(1.5*Z2LeptonPlus.Pt(),
|
448 |
Z2LeptonPlus.Eta(),
|
449 |
Z2LeptonPlus.Phi(),
|
450 |
Z2LeptonPlus.M());
|
451 |
}
|
452 |
if( Z2LeptonMinus.Pt() < 20 ) {
|
453 |
Z2LeptonMinus.SetPtEtaPhiM(1.5*Z2LeptonMinus.Pt(),
|
454 |
Z2LeptonMinus.Eta(),
|
455 |
Z2LeptonMinus.Phi(),
|
456 |
Z2LeptonMinus.M());
|
457 |
}
|
458 |
// HACKHACKHACKHACKHACKHACKHACKHACK
|
459 |
|
460 |
TLorentzVector Z2Candidate = Z2LeptonPlus+Z2LeptonMinus;
|
461 |
TLorentzVector ZZSystem = Z1Candidate + Z2Candidate;
|
462 |
|
463 |
lepvec[Z1LeptonPlusIndex].is4l = true;
|
464 |
lepvec[Z1LeptonMinusIndex].is4l = true;
|
465 |
lepvec[Z2LeptonPlusIndex].is4l = true;
|
466 |
lepvec[Z2LeptonMinusIndex].is4l = true;
|
467 |
|
468 |
//***************************************************************
|
469 |
// Isolation
|
470 |
//***************************************************************
|
471 |
|
472 |
|
473 |
//
|
474 |
// require tighter individual iso for Z1 leptons
|
475 |
//
|
476 |
bool failiso=false;
|
477 |
float rho = info->rho;
|
478 |
for( int i=0; i<lepvec.size(); i++ ) {
|
479 |
if( !(lepvec[i].is4l) ) continue;
|
480 |
float effArea_ecal_i, effArea_hcal_i;
|
481 |
if( lepvec[i].isEB ) {
|
482 |
if( lepvec[i].type == 11 ) {
|
483 |
effArea_ecal_i = 0.101;
|
484 |
effArea_hcal_i = 0.021;
|
485 |
} else {
|
486 |
effArea_ecal_i = 0.074;
|
487 |
effArea_hcal_i = 0.022;
|
488 |
}
|
489 |
} else {
|
490 |
if( lepvec[i].type == 11 ) {
|
491 |
effArea_ecal_i = 0.046;
|
492 |
effArea_hcal_i = 0.040;
|
493 |
} else {
|
494 |
effArea_ecal_i = 0.045;
|
495 |
effArea_hcal_i = 0.030;
|
496 |
}
|
497 |
}
|
498 |
|
499 |
lepvec[i].isoEcal = lepvec[i].isoEcal - (effArea_ecal_i*rho);
|
500 |
lepvec[i].isoHcal = lepvec[i].isoHcal - (effArea_hcal_i*rho);
|
501 |
float RIso_i = (lepvec[i].isoTrk+lepvec[i].isoEcal+lepvec[i].isoHcal)/lepvec[i].vec.Pt();
|
502 |
lepvec[i].isoCombo = RIso_i;
|
503 |
|
504 |
if( ( i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex ) && RIso_i > 0.15 )
|
505 |
failiso=true;
|
506 |
}
|
507 |
|
508 |
|
509 |
if( failiso ) {
|
510 |
evtfail |= ( 1<<EVTFAIL_ISOLATION );
|
511 |
return evtfail;
|
512 |
//h_evtfail->Fill( evtfail, eventweight );
|
513 |
// h_evtfail->Fill( evtfail );
|
514 |
// cout << "evtfail: " << hex << evtfail << dec << endl;
|
515 |
// continue;
|
516 |
}
|
517 |
|
518 |
//***************************************************************
|
519 |
// IP significance
|
520 |
//***************************************************************
|
521 |
bool failip = false;
|
522 |
for( int i=0; i<lepvec.size(); i++ ) {
|
523 |
if( !(lepvec[i].is4l) ) continue;
|
524 |
if( lepvec[i].ip3dSig > 4 ) {
|
525 |
if( ( i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex ))
|
526 |
failip=true;
|
527 |
}
|
528 |
}
|
529 |
if( failip ) {
|
530 |
evtfail |= (1<<EVTFAIL_IP );
|
531 |
//return evtfail;
|
532 |
//h_evtfail->Fill( evtfail, eventweight );
|
533 |
// h_evtfail->Fill( evtfail );
|
534 |
// cout << "evtfail: " << hex << evtfail << dec << endl;
|
535 |
// continue;
|
536 |
}
|
537 |
|
538 |
//***************************************************************
|
539 |
// remaining kinematic cuts
|
540 |
//***************************************************************
|
541 |
double Z2massCut=0;
|
542 |
if ( ctrl.kinematics == "loose" ) Z2massCut = 0;
|
543 |
else if ( ctrl.kinematics == "tight" ) Z2massCut = 0;
|
544 |
else { cout << "error! kinematic tightness not defined!" << endl; assert(0); }
|
545 |
|
546 |
if ( Z1Candidate.M() > 120 ||
|
547 |
Z2Candidate.M() < Z2massCut ||
|
548 |
Z2Candidate.M() > 120 ||
|
549 |
!(lepvec[Z1LeptonPlusIndex].vec.Pt() > 20.0 || lepvec[Z1LeptonMinusIndex].vec.Pt() > 20.0) ||
|
550 |
!(lepvec[Z1LeptonPlusIndex].vec.Pt() > 10.0 && lepvec[Z1LeptonMinusIndex].vec.Pt() > 10.0)
|
551 |
) {
|
552 |
evtfail |= (1<<EVTFAIL_KINEMATICS );
|
553 |
return evtfail;
|
554 |
//h_evtfail->Fill( evtfail, eventweight );
|
555 |
// h_evtfail->Fill( evtfail );
|
556 |
// cout << "evtfail: " << hex << evtfail << dec << endl;
|
557 |
// continue;
|
558 |
}
|
559 |
|
560 |
int channel;
|
561 |
if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0;
|
562 |
if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1;
|
563 |
if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) ||
|
564 |
(lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
|
565 |
|
566 |
|
567 |
|
568 |
if( ctrltuple != NULL ) {
|
569 |
|
570 |
float w = eventweight;
|
571 |
float ch = channel;
|
572 |
float mZ1=Z1Candidate.M();
|
573 |
float mZ2=Z2Candidate.M();
|
574 |
float m4l=ZZSystem.M();
|
575 |
float l12t = abs(lepvec[Z1LeptonMinusIndex].type);
|
576 |
float l3t = lepvec[Z2LeptonMinusIndex].type;
|
577 |
float l4t = lepvec[Z2LeptonPlusIndex].type;
|
578 |
float l3ipsig = lepvec[Z2LeptonMinusIndex].ip3dSig;
|
579 |
float l4ipsig = lepvec[Z2LeptonPlusIndex].ip3dSig;
|
580 |
float l3iso = lepvec[Z2LeptonMinusIndex].isoCombo;
|
581 |
float l4iso = lepvec[Z2LeptonPlusIndex].isoCombo;
|
582 |
float l3tight = lepvec[Z2LeptonMinusIndex].isTight;
|
583 |
float l4tight = lepvec[Z2LeptonPlusIndex].isTight;
|
584 |
float l3pt = lepvec[Z2LeptonMinusIndex].vec.Pt();
|
585 |
float l3eta = lepvec[Z2LeptonMinusIndex].vec.Eta();
|
586 |
float l3phi = lepvec[Z2LeptonMinusIndex].vec.Phi();
|
587 |
float l4pt = lepvec[Z2LeptonPlusIndex].vec.Pt();
|
588 |
float l4eta = lepvec[Z2LeptonPlusIndex].vec.Eta();
|
589 |
float l4phi = lepvec[Z2LeptonPlusIndex].vec.Phi();
|
590 |
float met = info->pfMET;
|
591 |
|
592 |
ctrltuple->SetBranchAddress("channel", &ch );
|
593 |
ctrltuple->SetBranchAddress("mZ1", &mZ1 );
|
594 |
ctrltuple->SetBranchAddress("mZ2", &mZ2 );
|
595 |
ctrltuple->SetBranchAddress("m4l", &m4l );
|
596 |
ctrltuple->SetBranchAddress("l12type", &l12t );
|
597 |
ctrltuple->SetBranchAddress("l3type", &l3t );
|
598 |
ctrltuple->SetBranchAddress("l4type", &l4t );
|
599 |
ctrltuple->SetBranchAddress("l3ipsig", &l3ipsig );
|
600 |
ctrltuple->SetBranchAddress("l4ipsig", &l4ipsig );
|
601 |
ctrltuple->SetBranchAddress("l3iso", &l3iso );
|
602 |
ctrltuple->SetBranchAddress("l4iso", &l4iso );
|
603 |
ctrltuple->SetBranchAddress("l3tight", &l3tight );
|
604 |
ctrltuple->SetBranchAddress("l4tight", &l4tight );
|
605 |
ctrltuple->SetBranchAddress("l3pt", &l3pt );
|
606 |
ctrltuple->SetBranchAddress("l3eta", &l3eta );
|
607 |
ctrltuple->SetBranchAddress("l3phi", &l3phi );
|
608 |
ctrltuple->SetBranchAddress("l4pt", &l4pt );
|
609 |
ctrltuple->SetBranchAddress("l4eta", &l4eta );
|
610 |
ctrltuple->SetBranchAddress("l4phi", &l4phi );
|
611 |
ctrltuple->SetBranchAddress("met", &met );
|
612 |
ctrltuple->SetBranchAddress("w", &w);
|
613 |
|
614 |
ctrltuple->Fill( );
|
615 |
}
|
616 |
|
617 |
if( ctrl.debug ) cout << "run: " << info->runNum
|
618 |
<< "\tevt: " << info->evtNum
|
619 |
<< "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type
|
620 |
<< "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type
|
621 |
<< "\tmZ1: " << Z1Candidate.M()
|
622 |
<< "\tmZ2: " << Z2Candidate.M()
|
623 |
<< "\tm4l: " << ZZSystem.M()
|
624 |
<< "\tevtfail: " << hex << evtfail << dec
|
625 |
<< "\ttrigbits: " << hex << info->triggerBits << dec
|
626 |
// << "\ttree: " << inputFiles[q][f]
|
627 |
<< endl;
|
628 |
|
629 |
return evtfail;
|
630 |
|
631 |
}
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|