ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Selection/src/Selection.cc
Revision: 1.10
Committed: Fri Oct 14 12:07:20 2011 UTC (13 years, 7 months ago) by khahn
Content type: text/plain
Branch: MAIN
Changes since 1.9: +3 -2 lines
Log Message:
iso switch fixes

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 // cout << "calling cic with debug set to : " << ctrl.debug << endl;
159 failsCIC = failsCicSelection(ctrl, ele, ciccuts, ctrl.kinematics);
160 FAIL = failsCIC;
161 }
162 LikStruct likcuts;
163 unsigned failsLike=0;
164 if(ctrl.eleSele=="lik") {
165 likcuts = getLikCuts(ctrl.eleSeleScheme);
166 failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
167 FAIL = failsLike;
168 }
169 unsigned failsBDT=0;
170 if(ctrl.eleSele=="bdt") {
171 failsBDT = failsBDTSelection(ctrl,ele);
172 FAIL = failsBDT;
173 }
174 unsigned failsSi=0;
175 if(ctrl.eleSele=="si") {
176 failsSi = failsSiMVAElectronSelection(ctrl, ele, 0.95, ctrl.kinematics);
177 FAIL = failsSi;
178 }
179
180
181
182
183 if( ctrl.debug ){
184 cout << "CIC category: " << cicCategory(ele)
185 << "\tlikelihood: " << ele->likelihood
186 << "\tFAIL: 0x" << hex << FAIL << dec
187 << "\tfailsCIC: 0x" << hex << failsCIC << dec
188 << "\tfailsLike: 0x" << hex << failsLike << dec
189 << "\tfailsBDT: 0x" << hex << failsBDT << dec
190 << "\tscEt: " << ele->scEt
191 << "\tscEta: " << ele->scEta
192 << "\tncluster: " << ele->ncluster
193 << endl;
194 }
195 if ( !FAIL && !isMuonOverlap ) {
196 SimpleLepton tmplep;
197 tmplep.vec.SetPtEtaPhiM( ele->pt,
198 ele->eta,
199 ele->phi,
200 0.51099892e-3 );
201 tmplep.type = 11;
202 tmplep.index = i;
203 tmplep.charge = ele->q;
204 tmplep.isoTrk = ele->trkIso03;
205 tmplep.isoEcal = ele->emIso03;
206 tmplep.isoHcal = ele->hadIso03;
207 tmplep.isoPF04 = ele->pfIso04;
208 tmplep.ip3dSig = ele->ip3dSig;
209 tmplep.is4l = false;
210 tmplep.isEB = ele->isEB;
211 lepvec.push_back(tmplep);
212 if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
213 }
214 }
215
216 sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
217
218 int nmu=0, nele=0;
219 for( int i=0; i<lepvec.size(); i++ ) {
220 if( abs(lepvec[i].type) == 11 ) nele++;
221 else nmu++;
222 }
223 if( ctrl.debug ) {
224 cout << "postsel nlep: " << lepvec.size()
225 << "\tnmuon: " << nmu
226 << "\tnelectron: " << nele
227 << endl;
228 }
229
230 //******************************************************************************
231 //Z1 Selection
232 //******************************************************************************
233 int Z1LeptonPlusIndex = -1;
234 int Z1LeptonMinusIndex = -1;
235 double BestZ1Mass = -999;
236 if( ctrl.debug ) { cout << "looking for a Z1 ..." << endl; }
237 for(int i = 0; i < lepvec.size(); ++i) {
238 for(int j = i+1; j < lepvec.size(); ++j) {
239 if( ctrl.debug ) { cout << "\tconsidering leptons " << i << " & " << j << endl; }
240 if (!(lepvec[i].vec.Pt() > 20.0 || lepvec[j].vec.Pt() > 20.0)) continue;
241 if( ctrl.debug ) { cout << "\tat least one is > 20 GeV" << endl; }
242 if (!(lepvec[i].vec.Pt() > 10.0 && lepvec[j].vec.Pt() > 10.0)) continue;
243 if( ctrl.debug ) { cout << "\tthe other is > 10 GeV" << endl; }
244 if (lepvec[i].charge == lepvec[j].charge) continue;
245 if( ctrl.debug ) { cout << "\tthey're opposite charge" << endl; }
246 if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) continue;
247 if( ctrl.debug ) { cout << "\tthey're same flavor" << endl; }
248
249 //Make Z1 hypothesis
250 TLorentzVector leptonPlus, leptonMinus;
251 if ( lepvec[i].charge > 0 ) {
252 leptonPlus = lepvec[i].vec;
253 leptonMinus = lepvec[j].vec;
254 } else {
255 leptonPlus = lepvec[j].vec;
256 leptonMinus = lepvec[i].vec;
257 }
258
259 float tmpZ1Mass = (leptonPlus+leptonMinus).M();
260 if( ctrl.debug ) cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl;
261 if( tmpZ1Mass > 60 ) {
262 if (fabs(tmpZ1Mass - 91.1876) < fabs(BestZ1Mass - 91.1876)) {
263 BestZ1Mass = tmpZ1Mass;
264 if( ctrl.debug ) cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass
265 << "\tdM: " << fabs(BestZ1Mass - 91.1876)
266 << endl;
267 if (lepvec[i].charge > 0) {
268 Z1LeptonPlusIndex = i;
269 Z1LeptonMinusIndex = j;
270 } else {
271 Z1LeptonPlusIndex = j;
272 Z1LeptonMinusIndex = i;
273 }
274 }
275 }
276 }
277 }
278 // stop if no Z1 candidate is found
279 if( BestZ1Mass < 0 ) {
280 evtfail |= (1<<EVTFAIL_Z1);
281 return evtfail;
282 }
283 if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum << endl;
284 if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
285 TLorentzVector Z1LeptonPlus = lepvec[Z1LeptonPlusIndex].vec;
286 TLorentzVector Z1LeptonMinus = lepvec[Z1LeptonMinusIndex].vec;
287 TLorentzVector Z1Candidate = Z1LeptonPlus + Z1LeptonMinus;
288 if( l != NULL ) {
289 l->vecz1 = Z1Candidate;
290 l->vecl1p = Z1LeptonPlus;
291 l->vecl1m = Z1LeptonMinus;
292 }
293
294 //******************************************************************************
295 // Z1 + l
296 //******************************************************************************
297 if( lepvec.size() < 3 ) {
298 evtfail |= (1<<EVTFAIL_Z1_PLUSL);
299 return evtfail;
300 }
301
302 //******************************************************************************
303 // 4l/Z2 Selection
304 //******************************************************************************
305 Int_t Z2LeptonPlusIndex = -1;
306 Int_t Z2LeptonMinusIndex = -1;
307 Double_t BestZ2Mass = -1;
308 if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
309 for(int i = 0; i < lepvec.size(); ++i) {
310 for(int j = i+1; j < lepvec.size(); ++j) {
311 // cout << "i: " << i << "\tj: " << j << endl;
312 if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) {
313 // cout << "\ti matches a Z1 index, skipping ..." << endl;
314 continue; //skip Z1 leptons
315 }
316 if (j == Z1LeptonPlusIndex || j == Z1LeptonMinusIndex) {
317 // cout << "\tj matches a Z1 index, skipping ..." << endl;
318 continue; //skip Z1 leptons
319 }
320 if (lepvec[i].charge == lepvec[j].charge) {
321 // cout << "\ti and j are same sign, skipping ..." << endl;
322 continue; //require opp sign
323 }
324 if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) {
325 // cout << "\ti and j are not same flavor, skipping ..." << endl;
326 continue; //require same flavor
327 }
328
329
330 //Make Z2 hypothesis
331 TLorentzVector leptonPlus, leptonMinus;
332
333 if (lepvec[i].charge > 0 ) {
334 leptonPlus = lepvec[i].vec;
335 leptonMinus = lepvec[j].vec;
336 } else {
337 leptonPlus = lepvec[j].vec;
338 leptonMinus = lepvec[i].vec;
339 }
340
341 TLorentzVector dilepton = leptonPlus+leptonMinus;
342 TLorentzVector fourLepton = Z1Candidate + dilepton;
343
344 if( ctrl.debug ) cout << "dilepton.M() : " << dilepton.M() << endl;
345 if( ctrl.debug ) cout << "fourLepton.M() : " << fourLepton.M() << endl;
346
347 if (!(dilepton.M() > 12.0)) continue;
348 if (!(fourLepton.M() > 100.0)) continue;
349
350
351 //for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12
352 if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
353 TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
354 TLorentzVector pair2 = Z1LeptonMinus+leptonPlus;
355 if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
356 if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
357 }
358
359 //Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin
360 if (Z2LeptonPlusIndex < 0) {
361 if (lepvec[i].charge > 0) {
362 Z2LeptonPlusIndex = i;
363 Z2LeptonMinusIndex = j;
364 } else {
365 Z2LeptonPlusIndex = j;
366 Z2LeptonMinusIndex = i;
367 }
368 } else {
369 Double_t BestPairPtMax = lepvec[Z2LeptonPlusIndex].vec.Pt();
370 Double_t BestPairPtMin = lepvec[Z2LeptonMinusIndex].vec.Pt();
371 if (lepvec[Z2LeptonMinusIndex].vec.Pt() > BestPairPtMax) {
372 BestPairPtMax = lepvec[Z2LeptonMinusIndex].vec.Pt();
373 BestPairPtMin = lepvec[Z2LeptonPlusIndex].vec.Pt();
374 }
375
376 Double_t CurrentPairPtMax = lepvec[i].vec.Pt();
377 Double_t CurrentPairPtMin = lepvec[j].vec.Pt();
378 if (lepvec[j].vec.Pt() > CurrentPairPtMax) {
379 CurrentPairPtMax = lepvec[j].vec.Pt();
380 CurrentPairPtMin = lepvec[i].vec.Pt();
381 }
382
383 if (CurrentPairPtMax > BestPairPtMax) {
384 if (lepvec[i].charge > 0) {
385 Z2LeptonPlusIndex = i;
386 Z2LeptonMinusIndex = j;
387 } else {
388 Z2LeptonPlusIndex = j;
389 Z2LeptonMinusIndex = i;
390 }
391 } else if (CurrentPairPtMax == BestPairPtMax) {
392 if (CurrentPairPtMin > BestPairPtMin) {
393 if (lepvec[i].charge > 0) {
394 Z2LeptonPlusIndex = i;
395 Z2LeptonMinusIndex = j;
396 } else {
397 Z2LeptonPlusIndex = j;
398 Z2LeptonMinusIndex = i;
399 }
400 }
401 }
402 }
403 }
404 }
405
406 // stop if no Z2 candidate is found
407 if (Z2LeptonPlusIndex == -1) {
408 evtfail |= ( 1<<EVTFAIL_4L );
409 return evtfail;
410 // h_evtfail->Fill( evtfail );
411 // cout << "evtfail: " << hex << evtfail << dec << endl;
412 // continue;
413 }
414 if( ctrl.debug ) cout << "\tgot a Z2 ..." << endl;
415 if( ctrl.debug ) cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex
416 << "\tminusindex: " << Z2LeptonMinusIndex << endl;
417 TLorentzVector Z2LeptonPlus = lepvec[Z2LeptonPlusIndex].vec;
418 TLorentzVector Z2LeptonMinus = lepvec[Z2LeptonMinusIndex].vec;
419 TLorentzVector Z2Candidate = Z2LeptonPlus+Z2LeptonMinus;
420 TLorentzVector ZZSystem = Z1Candidate + Z2Candidate;
421 if( l != NULL ) {
422 l->vecz2 = Z2Candidate;
423 l->vecl2p = Z2LeptonPlus;
424 l->vecl2m = Z2LeptonMinus;
425 l->vec4l = ZZSystem;
426 }
427 lepvec[Z1LeptonPlusIndex].is4l = true;
428 lepvec[Z1LeptonMinusIndex].is4l = true;
429 lepvec[Z2LeptonPlusIndex].is4l = true;
430 lepvec[Z2LeptonMinusIndex].is4l = true;
431
432 //***************************************************************
433 // Isolation
434 //***************************************************************
435 bool failiso=false;
436
437 if( ctrl.isoScheme == "pf" ) {
438
439 for( int i=0; i<lepvec.size(); i++ ) {
440 if( !(lepvec[i].is4l) ) continue;
441 if( abs(lepvec[i].type) == 11 ) {
442 if( (lepvec[i].isEB && lepvec[i].isoPF04 >0.13) ||
443 (!(lepvec[i].isEB) && lepvec[i].isoPF04 >0.09) ) {
444 failiso = true;
445 break;
446 }
447 }
448 if( abs(lepvec[i].type) == 13 ) {
449 if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && lepvec[i].isoPF04 > 0.13 ) {
450 failiso = true;
451 break;
452 }
453 if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && lepvec[i].isoPF04 > 0.06 ) {
454 failiso = true;
455 break;
456 }
457 if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && lepvec[i].isoPF04 > 0.09 ) {
458 failiso = true;
459 break;
460 }
461 if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && lepvec[i].isoPF04 > 0.05 ) {
462 failiso = true;
463 break;
464 }
465 }
466 }
467 } else if ( ctrl.isoScheme == "pairwise" ) {
468 float rho = info->rho;
469 for( int i=0; i<lepvec.size(); i++ ) {
470 if( !(lepvec[i].is4l) ) continue;
471 float effArea_ecal_i, effArea_hcal_i;
472 if( lepvec[i].isEB ) {
473 if( lepvec[i].type == 11 ) {
474 effArea_ecal_i = 0.101;
475 effArea_hcal_i = 0.021;
476 } else {
477 effArea_ecal_i = 0.074;
478 effArea_hcal_i = 0.022;
479 }
480 } else {
481 if( lepvec[i].type == 11 ) {
482 effArea_ecal_i = 0.046;
483 effArea_hcal_i = 0.040;
484 } else {
485 effArea_ecal_i = 0.045;
486 effArea_hcal_i = 0.030;
487 }
488 }
489 float isoEcal_corr_i = lepvec[i].isoEcal - (effArea_ecal_i*rho);
490 float isoHcal_corr_i = lepvec[i].isoHcal - (effArea_hcal_i*rho);
491 for( int j=i+1; j<lepvec.size(); j++ ) {
492 if( !(lepvec[j].is4l) ) continue;
493 float effArea_ecal_j, effArea_hcal_j;
494 if( lepvec[j].isEB ) {
495 if( lepvec[j].type == 11 ) {
496 effArea_ecal_j = 0.101;
497 effArea_hcal_j = 0.021;
498 } else {
499 effArea_ecal_j = 0.074;
500 effArea_hcal_j = 0.022;
501 }
502 } else {
503 if( lepvec[j].type == 11 ) {
504 effArea_ecal_j = 0.046;
505 effArea_hcal_j = 0.040;
506 } else {
507 effArea_ecal_j = 0.045;
508 effArea_hcal_j = 0.030;
509 }
510 }
511 float isoEcal_corr_j = lepvec[j].isoEcal - (effArea_ecal_j*rho);
512 float isoHcal_corr_j = lepvec[j].isoHcal - (effArea_hcal_j*rho);
513 float RIso_i = (lepvec[i].isoTrk+isoEcal_corr_i+isoHcal_corr_i)/lepvec[i].vec.Pt();
514 float RIso_j = (lepvec[j].isoTrk+isoEcal_corr_j+isoHcal_corr_j)/lepvec[j].vec.Pt();
515 float comboIso = RIso_i + RIso_j;
516 if( info->evtNum == 1038911933 ) {
517 float tmpdR = lepvec[i].vec.DrEtaPhi(lepvec[j].vec);
518 cout << "i: " << i
519 << "\tdR: " << tmpdR
520 << "\trho: " << rho
521 << "\tRIso_i: " << RIso_i
522 << "\ttkrel: " << lepvec[i].isoTrk/lepvec[i].vec.Pt()
523 << "\tecalrel: " << lepvec[i].isoEcal/lepvec[i].vec.Pt()
524 << "\tecalrelcor: " << isoEcal_corr_i/lepvec[i].vec.Pt()
525 << "\thcalrel: " << lepvec[i].isoHcal/lepvec[i].vec.Pt()
526 << "\thcalrelcor: " << isoHcal_corr_i/lepvec[i].vec.Pt()
527 << "\tpt_i: " << lepvec[i].vec.Pt()
528 << "\tj: " << j
529 << "\tRIso_j: " << RIso_j
530 << "\ttkrel: " << lepvec[j].isoTrk/lepvec[j].vec.Pt()
531 << "\tecalrel: " << lepvec[j].isoEcal/lepvec[j].vec.Pt()
532 << "\tecalrelcor: " << isoEcal_corr_j/lepvec[j].vec.Pt()
533 << "\thcalrel: " << lepvec[j].isoHcal/lepvec[j].vec.Pt()
534 << "\thcalrelcor: " << isoHcal_corr_j/lepvec[j].vec.Pt()
535 << "\tpt_j: " << lepvec[j].vec.Pt()
536 << "\tcombo: " << comboIso
537 << endl;
538 cout.flush();
539 }
540 if( comboIso > 0.35 ) {
541 if( ctrl.debug ) cout << "combo failing for indices: " << i << "," << j << endl;
542 failiso = true;
543 // break;
544 }
545 }
546 }
547 }
548
549
550 if( failiso ) {
551 evtfail |= ( 1<<EVTFAIL_ISOLATION );
552 return evtfail;
553 //h_evtfail->Fill( evtfail, eventweight );
554 // h_evtfail->Fill( evtfail );
555 // cout << "evtfail: " << hex << evtfail << dec << endl;
556 // continue;
557 }
558
559 //***************************************************************
560 // IP significance
561 //***************************************************************
562 bool failip = false;
563 for( int i=0; i<lepvec.size(); i++ ) {
564 if( !(lepvec[i].is4l) ) continue;
565 if( lepvec[i].ip3dSig > 4 ) {
566 failip=true;
567 break;
568 }
569 }
570 if( failip ) {
571 evtfail |= (1<<EVTFAIL_IP );
572 return evtfail;
573 //h_evtfail->Fill( evtfail, eventweight );
574 // h_evtfail->Fill( evtfail );
575 // cout << "evtfail: " << hex << evtfail << dec << endl;
576 // continue;
577 }
578
579 //***************************************************************
580 // remaining kinematic cuts
581 //***************************************************************
582 double Z2massCut=0;
583 if ( ctrl.kinematics == "loose" ) Z2massCut = 12;
584 else if ( ctrl.kinematics == "tight" ) Z2massCut = 20;
585 else { cout << "error! kinematic tightness not defined!" << endl; assert(0); }
586
587 if ( Z1Candidate.M() > 120 ||
588 Z2Candidate.M() < Z2massCut ||
589 Z2Candidate.M() > 120 ||
590 !(lepvec[Z1LeptonPlusIndex].vec.Pt() > 20.0 || lepvec[Z1LeptonMinusIndex].vec.Pt() > 20.0) ||
591 !(lepvec[Z1LeptonPlusIndex].vec.Pt() > 10.0 && lepvec[Z1LeptonMinusIndex].vec.Pt() > 10.0)
592 ) {
593 evtfail |= (1<<EVTFAIL_KINEMATICS );
594 return evtfail;
595 //h_evtfail->Fill( evtfail, eventweight );
596 // h_evtfail->Fill( evtfail );
597 // cout << "evtfail: " << hex << evtfail << dec << endl;
598 // continue;
599 }
600
601 int channel;
602 if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0;
603 if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1;
604 if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) ||
605 (lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
606
607
608
609 if( passtuple != NULL ) {
610 unsigned run = info->runNum;
611 unsigned evt = info->evtNum;
612 unsigned lumi = info->lumiSec;
613 unsigned chan = channel;
614 double w = eventweight;
615 float mZ1 = Z1Candidate.M() ;
616 float mZ2 = Z2Candidate.M() ;
617 float m4l = ZZSystem.M() ;
618 float pt4l = ZZSystem.Pt() ;
619 passtuple->SetBranchAddress("run", &run);
620 passtuple->SetBranchAddress("evt", &evt);
621 passtuple->SetBranchAddress("lumi", &lumi);
622 passtuple->SetBranchAddress("mZ1", &mZ1);
623 passtuple->SetBranchAddress("mZ2", &mZ2);
624 passtuple->SetBranchAddress("m4l", &m4l);
625 passtuple->SetBranchAddress("pt4l", &pt4l);
626 passtuple->SetBranchAddress("w", &w);
627 passtuple->Fill( );
628 }
629
630 if( ctrl.debug ) cout << "run: " << info->runNum
631 << "\tevt: " << info->evtNum
632 << "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type
633 << "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type
634 << "\tmZ1: " << Z1Candidate.M()
635 << "\tmZ2: " << Z2Candidate.M()
636 << "\tm4l: " << ZZSystem.M()
637 << "\tevtfail: " << hex << evtfail << dec
638 << "\ttrigbits: " << hex << info->triggerBits << dec
639 // << "\ttree: " << inputFiles[q][f]
640 << endl;
641
642 return evtfail;
643
644 }
645
646
647
648
649