ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Selection/src/Selection.cc
Revision: 1.9
Committed: Fri Oct 14 11:38:10 2011 UTC (13 years, 7 months ago) by khahn
Content type: text/plain
Branch: MAIN
Changes since 1.8: +6 -5 lines
Log Message:
adding (w/o bugs) switchable pf iso

File Contents

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