ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Selection/src/Selection.cc
Revision: 1.5
Committed: Thu Oct 13 14:18:55 2011 UTC (13 years, 7 months ago) by khahn
Content type: text/plain
Branch: MAIN
Changes since 1.4: +35 -18 lines
Log Message:
ntuple->tree to fix unsigned issues

File Contents

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