ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Selection/src/Selection.cc
Revision: 1.6
Committed: Thu Oct 13 14:20:55 2011 UTC (13 years, 7 months ago) by khahn
Content type: text/plain
Branch: MAIN
Changes since 1.5: +0 -5 lines
Log Message:
remove accidental debug

File Contents

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