ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Selection/src/Selection.cc
Revision: 1.7
Committed: Fri Oct 14 11:20:25 2011 UTC (13 years, 7 months ago) by khahn
Content type: text/plain
Branch: MAIN
Changes since 1.6: +14 -2 lines
Log Message:
passing ctrl all the way through to bdt selection

File Contents

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