ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/ElectronTools.cc
Revision: 1.11
Committed: Sun Jun 6 17:27:21 2010 UTC (14 years, 10 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.10: +7 -6 lines
Log Message:
update following recommended cuts

File Contents

# User Rev Content
1 ceballos 1.11 // $Id: ElectronTools.cc,v 1.10 2010/06/04 20:07:29 ceballos Exp $
2 sixie 1.1
3     #include "MitPhysics/Utils/interface/ElectronTools.h"
4     #include "MitAna/DataTree/interface/StableData.h"
5     #include <TFile.h>
6    
7     ClassImp(mithep::ElectronTools)
8    
9     using namespace mithep;
10    
11     //--------------------------------------------------------------------------------------------------
12     ElectronTools::ElectronTools()
13     {
14     // Constructor.
15     }
16    
17     //--------------------------------------------------------------------------------------------------
18     Bool_t ElectronTools::PassCustomID(const Electron *ele, EElIdType idType) {
19    
20     Double_t fCuts[6][8]; //!custom id cuts
21    
22     Double_t tightcuts[6][8]={
23     {0.086, 0.1, 0.052, 0.0, 0.050, 0.059, 0.061, 0.0}, //hovere
24     {0.011, 0.011, 0.011, 0.0, 0.033, 0.029, 0.030, 0.0}, //sigmaetaeta
25     {0.038, 0.024, 0.045, 0.0, 0.034, 0.017, 0.026, 0.0}, //deltaphiin
26     {0.0081, 0.0029, 0.0051, 0.0, 0.0070, 0.0062, 0.0088, 0.0}, //deltaetain
27     {0.0, 0.9, 0.0, 0.0, 0.0, 0.78, 0.0, 0.0}, //eoverp
28     {0.8,0.2,0.9,0,0,0,0,0}}; //extra cuts fbrem and E_Over_P
29    
30     Double_t loosecuts[6][8]={
31     {0.076, 0.033, 0.07, 0.0, 0.083,0.148, 0.033, 0.0}, //hovere
32     {0.0101, 0.0095, 0.0097, 0.0, 0.03, 0.03, 0.03, 0.0}, //sigmaetaeta
33     {0.053, 0.0189, 0.059, 0.099, 0.0278,0.0157, 0.042, 0.080}, //deltaphiin
34     {0.0078, 0.00259, 0.0062, 0.0, 0.0078,0.0061, 0.0061, 0.0}, //deltaetain
35     {0.3, 0.92, 0.211, 0.0, 0.42, 0.88, 0.68, 0.0}, //eoverp
36     {0.8,0.2,0,0,0,0,0,0}}; //extra cuts fbrem and E_Over_P
37    
38     Double_t VBTFWorkingPoint95[6][8] = {
39 ceballos 1.5 {0.5, 0.5, 0.5, 0.5, 0.07, 0.07, 0.07, 0.07 }, //hovere
40 sixie 1.1 {0.01, 0.01, 0.01, 0.01, 0.03, 0.03, 0.03, 0.03 }, //sigmaetaeta
41     {0.8, 0.8, 0.8, 0.8, 0.7, 0.7, 0.7, 0.7 }, //deltaphiin
42 ceballos 1.5 {0.007, 0.007, 0.007, 0.007, 0.010, 0.010, 0.010, 0.010 }, //deltaetain
43 sixie 1.1 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, //eoverp
44     {0.0, 0.0, 0, 0, 0, 0, 0, 0 } //extra cuts fbrem and E_Over_P
45     };
46    
47 ceballos 1.5 Double_t VBTFWorkingPoint90[6][8] = {
48     {0.12, 0.12, 0.12, 0.12, 0.05, 0.05, 0.05, 0.05 }, //hovere
49     {0.01, 0.01, 0.01, 0.01, 0.03, 0.03, 0.03, 0.03 }, //sigmaetaeta
50     {0.8, 0.8, 0.8, 0.8, 0.7, 0.7, 0.7, 0.7 }, //deltaphiin
51     {0.007, 0.007, 0.007, 0.007, 0.009, 0.009, 0.009, 0.009 }, //deltaetain
52     {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, //eoverp
53     {0.0, 0.0, 0, 0, 0, 0, 0, 0 } //extra cuts fbrem and E_Over_P
54     };
55 sixie 1.1
56 ceballos 1.5 Double_t VBTFWorkingPoint85[6][8] = {
57     {0.04, 0.04, 0.04, 0.04, 0.025, 0.025, 0.025, 0.025 }, //hovere
58 sixie 1.1 {0.01, 0.01, 0.01, 0.01, 0.03, 0.03, 0.03, 0.03 }, //sigmaetaeta
59 ceballos 1.5 {0.06, 0.06, 0.06, 0.06, 0.04, 0.04, 0.04, 0.04 }, //deltaphiin
60     {0.006, 0.006, 0.006, 0.006, 0.007, 0.007, 0.007, 0.007 }, //deltaetain
61 sixie 1.1 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, //eoverp
62     {0.0, 0.0, 0, 0, 0, 0, 0, 0 } //extra cuts fbrem and E_Over_P
63     };
64    
65     Double_t VBTFWorkingPoint80[6][8] = {
66 ceballos 1.5 {0.04, 0.04, 0.04, 0.04, 0.025, 0.025, 0.025, 0.025}, //hovere
67 sixie 1.1 {0.01, 0.01, 0.01, 0.01, 0.03, 0.03, 0.03, 0.03 }, //sigmaetaeta
68 ceballos 1.5 {0.06, 0.06, 0.06, 0.06, 0.03, 0.03, 0.03, 0.03 }, //deltaphiin
69     {0.004, 0.004, 0.004, 0.004, 0.007, 0.007, 0.007, 0.007}, //deltaetain
70 sixie 1.1 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, //eoverp
71     {0.0, 0.0, 0, 0, 0, 0, 0, 0 } //extra cuts fbrem and E_Over_P
72     };
73    
74     Double_t VBTFWorkingPoint70[6][8] = {
75 ceballos 1.5 {0.025, 0.025, 0.025, 0.025, 0.012, 0.012, 0.012, 0.012}, //hovere
76 sixie 1.1 {0.01, 0.01, 0.01, 0.01, 0.03, 0.03, 0.03, 0.03 }, //sigmaetaeta
77 ceballos 1.5 {0.03, 0.03, 0.03, 0.03, 0.02, 0.02, 0.02, 0.02 }, //deltaphiin
78 ceballos 1.11 {0.004, 0.004, 0.004, 0.004, 0.005, 0.005, 0.005, 0.005}, //deltaetain
79 sixie 1.1 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, //eoverp
80     {0.0, 0.0, 0, 0, 0, 0, 0, 0 } //extra cuts fbrem and E_Over_P
81     };
82    
83     switch (idType) {
84     case kCustomIdTight:
85     memcpy(fCuts,tightcuts,sizeof(fCuts));
86     break;
87     case kCustomIdLoose:
88     memcpy(fCuts,loosecuts,sizeof(fCuts));
89     break;
90     case kVBTFWorkingPoint95Id:
91     memcpy(fCuts,VBTFWorkingPoint95,sizeof(fCuts));
92     break;
93     case kVBTFWorkingPoint90Id:
94     memcpy(fCuts,VBTFWorkingPoint90,sizeof(fCuts));
95     break;
96 ceballos 1.5 case kVBTFWorkingPoint85Id:
97     memcpy(fCuts,VBTFWorkingPoint85,sizeof(fCuts));
98     break;
99 sixie 1.1 case kVBTFWorkingPoint80Id:
100     memcpy(fCuts,VBTFWorkingPoint80,sizeof(fCuts));
101     break;
102     case kVBTFWorkingPoint70Id:
103     memcpy(fCuts,VBTFWorkingPoint70,sizeof(fCuts));
104     break;
105     default:
106     memset(fCuts,0,sizeof(fCuts));
107     break;
108     }
109    
110    
111     // Based on RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc.
112     Double_t eOverP = ele->ESuperClusterOverP();
113     Double_t fBrem = ele->FBrem();
114    
115     if ((eOverP < fCuts[5][0]) && (fBrem < fCuts[5][1]))
116     return kFALSE;
117    
118     if (eOverP < fCuts[5][2]*(1-fBrem))
119     return kFALSE;
120    
121     Int_t cat = 2;
122     if ((ele->IsEB() && fBrem<0.06) || (ele->IsEE() && fBrem<0.1))
123     cat=1;
124     else if (eOverP < 1.2 && eOverP > 0.8)
125     cat=0;
126    
127     Double_t eSeedOverPin = ele->ESeedClusterOverPIn();
128     Double_t hOverE = ele->HadronicOverEm();
129     Double_t sigmaee = ele->CoviEtaiEta();
130     Double_t deltaPhiIn = TMath::Abs(ele->DeltaPhiSuperClusterTrackAtVtx());
131     Double_t deltaEtaIn = TMath::Abs(ele->DeltaEtaSuperClusterTrackAtVtx());
132    
133     Int_t eb = 1;
134     if (ele->IsEB())
135     eb = 0;
136    
137     if (hOverE>fCuts[0][cat+4*eb])
138     return kFALSE;
139    
140     if (sigmaee>fCuts[1][cat+4*eb])
141     return kFALSE;
142    
143     if (deltaPhiIn>fCuts[2][cat+4*eb])
144     return kFALSE;
145    
146     if(deltaEtaIn>fCuts[3][cat+4*eb])
147     return kFALSE;
148    
149     if(eSeedOverPin<fCuts[4][cat+4*eb])
150     return kFALSE;
151    
152     return kTRUE;
153     }
154    
155     //--------------------------------------------------------------------------------------------------
156 ceballos 1.5 Bool_t ElectronTools::PassCustomIso(const Electron *ele, EElIsoType isoType,
157     Bool_t useCombineIso)
158 sixie 1.1 {
159     Bool_t pass = kTRUE;
160     Double_t fIsoCuts[4][2]; //!custom isolation cuts
161     Double_t VBTFWorkingPoint95[4][2] = {
162 ceballos 1.5 {0.15 , 0.08 }, //TrkIso
163     {2.00 , 0.06 }, //ECALIso
164     {0.12 , 0.05 }, //HCALIso
165     {0.15, 0.10 } //Combined
166 sixie 1.1 };
167    
168     Double_t VBTFWorkingPoint90[4][2] = {
169 ceballos 1.5 {0.12 , 0.05 }, //TrkIso
170     {0.09 , 0.06 }, //ECALIso
171     {0.10 , 0.03 }, //HCALIso
172     {0.10, 0.07 } //Combined
173     };
174    
175     Double_t VBTFWorkingPoint85[4][2] = {
176     {0.09 , 0.05 }, //TrkIso
177     {0.08 , 0.05 }, //ECALIso
178     {0.10 , 0.025 }, //HCALIso
179     {0.09, 0.06 } //Combined
180 sixie 1.1 };
181    
182     Double_t VBTFWorkingPoint80[4][2] = {
183 ceballos 1.5 {0.09 , 0.04 }, //TrkIso
184     {0.07 , 0.05 }, //ECALIso
185     {0.10 , 0.025 }, //HCALIso
186     {0.07, 0.06 } //Combined
187 sixie 1.1 };
188    
189     Double_t VBTFWorkingPoint70[4][2] = {
190 ceballos 1.11 {0.05 , 0.025 }, //TrkIso
191     {0.06 , 0.025 }, //ECALIso
192     {0.03 , 0.020 }, //HCALIso
193     {0.04, 0.030 } //Combined
194 sixie 1.1 };
195    
196     switch (isoType) {
197     case kVBTFWorkingPoint95Iso:
198     memcpy(fIsoCuts,VBTFWorkingPoint95,sizeof(fIsoCuts));
199     break;
200     case kVBTFWorkingPoint90Iso:
201     memcpy(fIsoCuts,VBTFWorkingPoint90,sizeof(fIsoCuts));
202     break;
203 ceballos 1.5 case kVBTFWorkingPoint85Iso:
204     memcpy(fIsoCuts,VBTFWorkingPoint85,sizeof(fIsoCuts));
205     break;
206 sixie 1.1 case kVBTFWorkingPoint80Iso:
207     memcpy(fIsoCuts,VBTFWorkingPoint80,sizeof(fIsoCuts));
208     break;
209     case kVBTFWorkingPoint70Iso:
210     memcpy(fIsoCuts,VBTFWorkingPoint70,sizeof(fIsoCuts));
211     break;
212     default:
213     memset(fIsoCuts,0,sizeof(fIsoCuts));
214     break;
215     }
216    
217 ceballos 1.10 Double_t trkIso = ele->TrackIsolationDr03() / ele->Pt();
218     Double_t ecalIso = ele->EcalRecHitIsoDr03() / ele->Pt();
219     Double_t hcalIso = ele->HcalTowerSumEtDr03() / ele->Pt();
220     Double_t combinedIso = ele->TrackIsolationDr03() + ele->EcalRecHitIsoDr03() + ele->HcalTowerSumEtDr03();
221     if(ele->IsEB()) combinedIso = ele->TrackIsolationDr03() + TMath::Max(ele->EcalRecHitIsoDr03() - 1.0, 0.0) + ele->HcalTowerSumEtDr03();
222 ceballos 1.11 combinedIso = combinedIso / ele->Pt();
223 sixie 1.1
224     Int_t eb = 1;
225     if (ele->IsEB())
226     eb = 0;
227    
228 ceballos 1.5 if(useCombineIso == kFALSE){
229     if (trkIso>fIsoCuts[0][eb])
230     pass = kFALSE;
231     if (ecalIso>fIsoCuts[1][eb])
232     pass = kFALSE;
233     if (hcalIso>fIsoCuts[2][eb])
234     pass = kFALSE;
235     }
236     else {
237     if (combinedIso>fIsoCuts[3][eb])
238     pass = kFALSE;
239     }
240 sixie 1.1
241     return pass;
242     }
243    
244    
245     //--------------------------------------------------------------------------------------------------
246     Bool_t ElectronTools::PassConversionFilter(const Electron *ele,
247     const DecayParticleCol *conversions,
248     Bool_t WrongHitsRequirement)
249     {
250     Bool_t isGoodConversion = kFALSE;
251    
252     for (UInt_t ifc=0; ifc<conversions->GetEntries(); ifc++) {
253     Bool_t ConversionMatchFound = kFALSE;
254     for (UInt_t d=0; d<conversions->At(ifc)->NDaughters(); d++) {
255     const Track *trk = dynamic_cast<const ChargedParticle*>
256     (conversions->At(ifc)->Daughter(d))->Trk();
257     if (ele->GsfTrk() == trk) {
258     ConversionMatchFound = kTRUE;
259     break;
260     }
261     }
262    
263     // if match between the e-track and one of the conversion legs
264     if (ConversionMatchFound == kTRUE){
265     isGoodConversion = (conversions->At(ifc)->Prob() > 1e-6) &&
266     (conversions->At(ifc)->Lxy() > 0) &&
267 bendavid 1.3 (conversions->At(ifc)->Lz() > 0) &&
268 sixie 1.1 (conversions->At(ifc)->Position().Rho() > 2.0);
269    
270     if (isGoodConversion == kTRUE) {
271     for (UInt_t d=0; d<conversions->At(ifc)->NDaughters(); d++) {
272     const Track *trk = dynamic_cast<const ChargedParticle*>
273     (conversions->At(ifc)->Daughter(d))->Trk();
274     if (trk) {
275     // These requirements are not used for the GSF track
276     if (!(trk->NHits() >= 3 && trk->Prob() > 1e-6) && trk!=ele->GsfTrk())
277     isGoodConversion = kFALSE;
278     const StableData *sd = dynamic_cast<const StableData*>
279     (conversions->At(ifc)->DaughterDat(d));
280     if (WrongHitsRequirement && sd->NWrongHits() != 0)
281     isGoodConversion = kFALSE;
282     } else {
283     isGoodConversion = kFALSE;
284     }
285     }
286     }
287     }
288     if (isGoodConversion == kTRUE) break;
289    
290     } // loop over all conversions
291    
292     return !isGoodConversion;
293     }
294    
295     //--------------------------------------------------------------------------------------------------
296     Bool_t ElectronTools::PassD0Cut(const Electron *ele, const VertexCol *vertices, Double_t fD0Cut,
297     Bool_t fReverseD0Cut)
298     {
299     Bool_t d0cut = kFALSE;
300     // d0 cut
301     Double_t d0_real = 99999;
302     for(UInt_t i0 = 0; i0 < vertices->GetEntries(); i0++) {
303     Double_t pD0 = ele->GsfTrk()->D0Corrected(*vertices->At(i0));
304     if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
305     }
306     if(d0_real < fD0Cut) d0cut = kTRUE;
307    
308     if (fReverseD0Cut == kTRUE &&
309     d0cut == kFALSE && d0_real < 0.05)
310     d0cut = kTRUE;
311     else if(fReverseD0Cut == kTRUE)
312     d0cut = kFALSE;
313    
314     return d0cut;
315     }
316    
317     //--------------------------------------------------------------------------------------------------
318 sixie 1.2 Bool_t ElectronTools::PassD0Cut(const Electron *ele, const BeamSpotCol *beamspots, Double_t fD0Cut,
319     Bool_t fReverseD0Cut)
320     {
321     Bool_t d0cut = kFALSE;
322     // d0 cut
323     Double_t d0_real = 99999;
324     for(UInt_t i0 = 0; i0 < beamspots->GetEntries(); i0++) {
325     Double_t pD0 = ele->GsfTrk()->D0Corrected(*beamspots->At(i0));
326     if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
327     }
328     if(d0_real < fD0Cut) d0cut = kTRUE;
329    
330     if (fReverseD0Cut == kTRUE &&
331     d0cut == kFALSE && d0_real < 0.05)
332     d0cut = kTRUE;
333     else if(fReverseD0Cut == kTRUE)
334     d0cut = kFALSE;
335    
336     return d0cut;
337     }
338    
339     //--------------------------------------------------------------------------------------------------
340 sixie 1.1 Bool_t ElectronTools::PassChargeFilter(const Electron *ele)
341     {
342     Bool_t passChargeFilter = kTRUE;
343     if(ele->TrackerTrk() &&
344     ele->TrackerTrk()->Charge() != ele->Charge()) passChargeFilter = kFALSE;
345    
346     return passChargeFilter;
347     }
348    
349     //--------------------------------------------------------------------------------------------------
350     Bool_t ElectronTools::PassSpikeRemovalFilter(const Electron *ele)
351     {
352     Bool_t passSpikeRemovalFilter = kTRUE;
353     if(ele->SCluster()->Seed()->Energy() > 5.0 &&
354     ele->SCluster()->Seed()->EMax() / ele->SCluster()->Seed()->E3x3() > 0.95
355     ) {
356     passSpikeRemovalFilter = kFALSE;
357     }
358    
359     // For Now Only use the EMax/E3x3 prescription.
360     // if(ele->SCluster()->Seed()->Energy() > 5.0 &&
361     // (1 - (ele->SCluster()->Seed()->E1x3() + ele->SCluster()->Seed()->E3x1() - 2*ele->SCluster()->Seed()->EMax())) > 0.95
362     // ) {
363     // passSpikeRemovalFilter = kFALSE;
364     // }
365    
366     return passSpikeRemovalFilter;
367     }
368 ceballos 1.4
369 bendavid 1.9 Bool_t ElectronTools::PassTriggerMatching(const Electron *ele, const TriggerObjectCol *trigobjs)
370     {
371    
372     for (UInt_t i=0; i<trigobjs->GetEntries(); ++i) {
373     const TriggerObject *trigobj = trigobjs->At(i);
374     if (trigobj->TriggerType()==TriggerObject::TriggerCluster || trigobj->TriggerType()==TriggerObject::TriggerElectron) {
375     if (MathUtils::DeltaR(ele,trigobj)<0.3) {
376     return kTRUE;
377     }
378     }
379     }
380    
381     return kFALSE;
382    
383    
384     }
385    
386 ceballos 1.4 //--------------------------------------------------------------------------------------------------
387     Int_t ElectronTools::Classify(const Electron *ele) {
388    
389 ceballos 1.5 double eta = ele->AbsEta();
390 ceballos 1.4 double eOverP = ele->ESuperClusterOverP();
391     double fBrem = ele->FBrem();
392    
393     int cat = -1;
394     if (ele->IsEB()) {
395 ceballos 1.5 if ((fBrem >= 0.12) and (eOverP > 0.9) and (eOverP < 1.2))
396 ceballos 1.4 cat = 0;
397 ceballos 1.5 else if (((eta > .445 and eta < .45 ) or
398     (eta > .79 and eta < .81 ) or
399     (eta > 1.137 and eta < 1.157 ) or
400     (eta > 1.47285 and eta < 1.4744)))
401     cat = 6;
402     else if (ele->IsTrackerDriven() and !ele->IsEcalDriven())
403 ceballos 1.4 cat = 8;
404     else if (fBrem < 0.12)
405     cat = 1;
406     else
407     cat = 2;
408     } else {
409 ceballos 1.5 if ((fBrem >= 0.2) and (eOverP > 0.82) and (eOverP < 1.22))
410 ceballos 1.4 cat = 3;
411 ceballos 1.5 else if (eta > 1.5 and eta < 1.58)
412     cat = 7;
413     else if (ele->IsTrackerDriven() and !ele->IsEcalDriven())
414 ceballos 1.4 cat = 8;
415     else if (fBrem < 0.2)
416     cat = 4;
417     else
418     cat = 5;
419     }
420    
421     return cat;
422     }
423    
424     //--------------------------------------------------------------------------------------------------
425     Int_t ElectronTools::PassTightId(const Electron *ele, const VertexCol *vertices,
426     const DecayParticleCol *conversions, const Int_t typeCuts){
427    
428     Double_t scEt = ele->SCluster()->Et();
429     Double_t eOverP = ele->ESuperClusterOverP();
430    
431     Double_t fBrem = ele->FBrem();
432     Double_t hOverE = ele->HadronicOverEm();
433     Double_t sigmaee = ele->CoviEtaiEta();
434     Double_t deltaPhiIn = TMath::Abs(ele->DeltaPhiSuperClusterTrackAtVtx());
435     Double_t deltaEtaIn = TMath::Abs(ele->DeltaEtaSuperClusterTrackAtVtx());
436     Double_t eSeedOverPin = ele->ESeedClusterOverPIn();
437    
438     Int_t mishits = ele->BestTrk()->NExpectedHitsInner();
439     Double_t tkIso = ele->TrackIsolationDr03();
440     Double_t ecalIso = ele->EcalRecHitIsoDr04();
441     Double_t ecalIsoPed = (ele->IsEB())?std::max(0.,ecalIso-1.):ecalIso;
442     Double_t hcalIso = ele->HcalTowerSumEtDr04();
443     Double_t hcalIso1 = ele->HcalDepth1TowerSumEtDr04();
444     Double_t hcalIso2 = ele->HcalDepth2TowerSumEtDr04();
445     Double_t e25Max = ele->E25Max();
446     Double_t e15 = ele->E15();
447     Double_t e55 = ele->E55();
448     Double_t e25Maxoe55 = e25Max/e55;
449     Double_t e15oe55 = e15/e55;
450    
451     int cat = Classify(ele);
452     int eb;
453    
454     if (ele->IsEB())
455     eb = 0;
456     else
457     eb = 1;
458    
459     Int_t result = 0.;
460    
461     Int_t bin = 0;
462 ceballos 1.5
463     Double_t WantBin = kFALSE;
464     if(WantBin) {
465     if (scEt < 20.)
466     bin = 2;
467     else if (scEt > 30.)
468     bin = 0;
469     else
470     bin = 1;
471     }
472 ceballos 1.4
473     if (fBrem > 0)
474     eSeedOverPin = eSeedOverPin + fBrem;
475    
476     if(typeCuts == 3 || typeCuts == 4){
477     // Loose robust cuts
478     Double_t robustlooseEleIDCuts[52] = {
479     0.05, 0.0103, 0.8, 0.00688, -1, -1, 7.33, 4.68, 9999., 9999., 9999.,9999., 9999.,9999., 9999., 9999.,9999., 9999., 0.000, -9999., 9999., 9999., 9999, -1, 0, 0,
480     0.0389, 0.0307, 0.7, 0.00944, -1, -1, 7.76, 3.09, 2.23, 9999., 9999.,9999., 9999.,9999., 9999., 9999.,9999., 9999., 0.000, -9999., 9999., 9999., 9999, -1, 0, 0
481     };
482     // Tight robust cuts
483     Double_t robusttightEleIDCuts[52] = {
484     0.0201, 0.0102, 0.0211, 0.00606, -1, -1, 2.34, 3.24, 4.51, 9999., 9999.,9999., 9999.,9999., 9999., 9999.,9999., 9999., 0.000, -9999., 9999., 9999., 9999, -1, 0, 0,
485     0.00253, 0.0291, 0.022, 0.0032, -1, -1, 0.826, 2.7, 0.255, 9999., 9999.,9999., 9999.,9999., 9999., 9999.,9999., 9999., 0.000, -9999., 9999., 9999., 9999, -1, 0, 0
486     };
487     Double_t cut[52];
488     if (typeCuts == 3) {
489     memcpy(cut ,robustlooseEleIDCuts ,sizeof(cut));
490     }
491     else {
492     memcpy(cut ,robusttightEleIDCuts ,sizeof(cut));
493     }
494    
495     if ((tkIso > cut[26*eb+6]) || (ecalIso > cut[26*eb+7]) || (hcalIso > cut[26*eb+8]) || (hcalIso1 > cut[26*eb+9]) || (hcalIso2 > cut[26*eb+10]) ||
496     (tkIso/ele->Pt() > cut[26*eb+11]) || (ecalIso/ele->Pt() > cut[26*eb+12]) || (hcalIso/ele->Pt() > cut[26*eb+13]) ||
497     ((tkIso+ecalIso+hcalIso)>cut[26*eb+14]) || (((tkIso+ecalIso+hcalIso)/ ele->Pt()) > cut[26*eb+15]) ||
498     ((tkIso+ecalIsoPed+hcalIso)>cut[26*eb+16]) || (((tkIso+ecalIsoPed+hcalIso)/ ele->Pt()) > cut[26*eb+17]) )
499     result = 0.;
500     else
501     result = 2.;
502    
503     if (hOverE > cut[26*eb+0])
504     return result;
505    
506     if (sigmaee > cut[26*eb+1])
507     return result;
508    
509     if (fabs(deltaPhiIn) > cut[26*eb+2])
510     return result;
511    
512     if (fabs(deltaEtaIn) > cut[26*eb+3])
513     return result;
514    
515     if (e25Maxoe55 < cut[26*eb+4] && e15oe55 < cut[26*eb+5])
516     return result;
517     // some extra electron id cuts
518     if (sigmaee < cut[26*eb+18]) // inverted sigmaee cut - spike removal related
519     return result;
520    
521     if ( eOverP < cut[26*eb+19] || eOverP > cut[26*eb+20]) // lower and upper cut in E/P
522     return result;
523    
524     result = result + 1;
525    
526     Double_t d0_real = 99999;
527     for(UInt_t i0 = 0; i0 < vertices->GetEntries(); i0++) {
528     Double_t pD0 = ele->GsfTrk()->D0Corrected(*vertices->At(i0));
529     if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
530     }
531     if (d0_real > cut[26*eb+21])
532     return result;
533    
534     if (mishits > cut[26*eb+22]) // expected missing hits
535     return result;
536    
537     Bool_t passConvVeto = PassConversionFilter(ele, conversions, kTRUE);
538     if (passConvVeto == kFALSE)
539     return result;
540    
541     result += 4;
542     }
543     else if(typeCuts == 0 || typeCuts == 1 || typeCuts == 2){
544     // Loose cuts
545 ceballos 1.5 Double_t cutdcotdistLoose[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
546     };
547     Double_t cutdetainLoose[9] = {1.30e-02, 5.95e-03, 3.10e-02, 1.68e-02, 8.44e-03, 1.70e-02, 1.55e-02, 5.13e-02, 1.61e-02
548     };
549     Double_t cutdphiinLoose[9] = {7.51e-02, 3.30e-01, 4.20e-01, 9.86e-02, 2.84e-01, 3.28e-01, 3.77e-01, 4.32e-01, 3.74e-01
550     };
551     Double_t cuteseedopcorLoose[9] = {6.31e-01, 3.02e-01, 3.04e-01, 8.10e-01, 2.23e-01, 5.03e-01, 2.78e-01, 3.10e-01, 4.69e-01
552     };
553     Double_t cutetLoose[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.
554     };
555     Double_t cutfmishitsLoose[9] = {4.50e+00, 1.50e+00, 1.50e+00, 2.50e+00, 2.50e+00, 1.50e+00, 2.50e+00, 4.50e+00, 5.00e-01
556     };
557     Double_t cuthoeLoose[9] = {2.47e-01, 7.78e-02, 1.49e-01, 3.82e-01, 4.70e-02, 1.12e-01, 1.16e+00, 5.04e+00, 1.35e+00
558     };
559     Double_t cutip_gsfLoose[9] = {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02
560     };
561     Double_t cutiso_sumLoose[9] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
562     };
563     Double_t cutiso_sumoetLoose[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
564     };
565     Double_t cutseeLoose[9] = {1.92e-02, 1.31e-02, 2.53e-02, 5.27e-02, 3.29e-02, 4.19e-02, 2.65e-02, 6.58e-02, 1.38e-01
566 ceballos 1.4 };
567    
568     // Medium cuts
569 ceballos 1.5 Double_t cutdcotdistMedium[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
570     };
571     Double_t cutdetainMedium[9] = {1.19e-02, 4.20e-03, 1.07e-02, 1.49e-02, 6.56e-03, 1.19e-02, 1.16e-02, 5.13e-02, 6.37e-03
572     };
573     Double_t cutdphiinMedium[9] = {7.51e-02, 2.93e-01, 3.58e-01, 9.53e-02, 1.62e-01, 2.99e-01, 2.76e-01, 4.32e-01, 2.57e-01
574     };
575     Double_t cuteseedopcorMedium[9] = {6.31e-01, 8.14e-01, 7.60e-01, 8.18e-01, 7.56e-01, 5.35e-01, 6.20e-01, 7.88e-01, 8.85e-01
576     };
577     Double_t cutetMedium[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.
578     };
579     Double_t cutfmishitsMedium[9] = {1.50e+00, 1.50e+00, 1.50e+00, 1.50e+00, 1.50e+00, 1.50e+00, 2.50e+00, 1.50e+00, 5.00e-01
580     };
581     Double_t cuthoeMedium[9] = {2.46e-01, 6.80e-02, 1.35e-01, 3.73e-01, 2.33e-02, 5.58e-02, 8.80e-01, 5.04e+00, 3.78e-02
582     };
583     Double_t cutip_gsfMedium[9] = {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02
584     };
585     Double_t cutiso_sumMedium[9] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
586     };
587     Double_t cutiso_sumoetMedium[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
588     };
589     Double_t cutseeMedium[9] = {1.92e-02, 1.13e-02, 1.47e-02, 3.84e-02, 3.05e-02, 3.36e-02, 1.35e-02, 5.05e-02, 2.79e-02
590 ceballos 1.4 };
591    
592     // Tight cuts
593 ceballos 1.5 Double_t cutdcotdistTight[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
594     };
595     Double_t cutdetainTight[9] = {9.28e-03, 3.56e-03, 7.16e-03, 1.31e-02, 5.81e-03, 9.79e-03, 1.15e-02, 1.66e-02, 3.19e-03
596     };
597     Double_t cutdphiinTight[9] = {4.66e-02, 7.80e-02, 2.64e-01, 4.42e-02, 3.20e-02, 2.37e-01, 8.25e-02, 2.07e-01, 5.39e-02
598     };
599     Double_t cuteseedopcorTight[9] = {6.48e-01, 8.97e-01, 8.91e-01, 8.39e-01, 8.35e-01, 6.49e-01, 6.76e-01, 8.70e-01, 9.91e-01
600     };
601     Double_t cutetTight[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.
602     };
603     Double_t cutfmishitsTight[9] = {1.50e+00, 1.50e+00, 1.50e+00, 1.50e+00, 1.50e+00, 5.00e-01, 2.50e+00, 5.00e-01, 5.00e-01
604     };
605     Double_t cuthoeTight[9] = {9.94e-02, 5.61e-02, 1.05e-01, 9.73e-02, 1.81e-02, 3.06e-02, 5.57e-01, 5.04e+00, 1.06e-03
606     };
607     Double_t cutip_gsfTight[9] = {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02
608     };
609     Double_t cutiso_sumTight[9] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
610     };
611     Double_t cutiso_sumoetTight[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
612     };
613     Double_t cutseeTight[9] = {1.56e-02, 1.07e-02, 1.23e-02, 3.35e-02, 2.98e-02, 3.06e-02, 1.07e-02, 3.79e-02, 1.01e-02
614     };
615    
616     Double_t cutdcotdist[9];
617     Double_t cutdetain[9];
618     Double_t cutdphiin[9];
619     Double_t cuteseedopcor[9];
620     Double_t cutet[9];
621     Double_t cutfmishits[9];
622     Double_t cuthoe[9];
623     Double_t cutip_gsf[9];
624     Double_t cutiso_sum[9];
625     Double_t cutiso_sumoet[9];
626     Double_t cutsee[9];
627 ceballos 1.4 if (typeCuts == 0) {
628     memcpy(cutdcotdist ,cutdcotdistLoose ,sizeof(cutdcotdistLoose));
629     memcpy(cutdetain ,cutdetainLoose ,sizeof(cutdetainLoose));
630     memcpy(cutdphiin ,cutdphiinLoose ,sizeof(cutdphiinLoose));
631     memcpy(cuteseedopcor,cuteseedopcorLoose,sizeof(cuteseedopcorLoose));
632     memcpy(cutet ,cutetLoose ,sizeof(cutetLoose));
633     memcpy(cutfmishits ,cutfmishitsLoose ,sizeof(cutfmishitsLoose));
634     memcpy(cuthoe ,cuthoeLoose ,sizeof(cuthoeLoose));
635     memcpy(cutip_gsf ,cutip_gsfLoose ,sizeof(cutip_gsfLoose));
636     memcpy(cutiso_sum ,cutiso_sumLoose ,sizeof(cutiso_sumLoose));
637     memcpy(cutiso_sumoet,cutiso_sumoetLoose,sizeof(cutiso_sumoetLoose));
638     memcpy(cutsee ,cutseeLoose ,sizeof(cutseeLoose));
639     }
640     else if(typeCuts == 1) {
641     memcpy(cutdcotdist ,cutdcotdistMedium ,sizeof(cutdcotdistMedium));
642     memcpy(cutdetain ,cutdetainMedium ,sizeof(cutdetainMedium));
643     memcpy(cutdphiin ,cutdphiinMedium ,sizeof(cutdphiinMedium));
644     memcpy(cuteseedopcor,cuteseedopcorMedium,sizeof(cuteseedopcorMedium));
645     memcpy(cutet ,cutetMedium ,sizeof(cutetMedium));
646     memcpy(cutfmishits ,cutfmishitsMedium ,sizeof(cutfmishitsMedium));
647     memcpy(cuthoe ,cuthoeMedium ,sizeof(cuthoeMedium));
648     memcpy(cutip_gsf ,cutip_gsfMedium ,sizeof(cutip_gsfMedium));
649     memcpy(cutiso_sum ,cutiso_sumMedium ,sizeof(cutiso_sumMedium));
650     memcpy(cutiso_sumoet,cutiso_sumoetMedium,sizeof(cutiso_sumoetMedium));
651     memcpy(cutsee ,cutseeMedium ,sizeof(cutseeMedium));
652     }
653     else {
654     memcpy(cutdcotdist ,cutdcotdistTight ,sizeof(cutdcotdistTight));
655     memcpy(cutdetain ,cutdetainTight ,sizeof(cutdetainTight));
656     memcpy(cutdphiin ,cutdphiinTight ,sizeof(cutdphiinTight));
657     memcpy(cuteseedopcor,cuteseedopcorTight,sizeof(cuteseedopcorTight));
658     memcpy(cutet ,cutetTight ,sizeof(cutetTight));
659     memcpy(cutfmishits ,cutfmishitsTight ,sizeof(cutfmishitsTight));
660     memcpy(cuthoe ,cuthoeTight ,sizeof(cuthoeTight));
661     memcpy(cutip_gsf ,cutip_gsfTight ,sizeof(cutip_gsfTight));
662     memcpy(cutiso_sum ,cutiso_sumTight ,sizeof(cutiso_sumTight));
663     memcpy(cutiso_sumoet,cutiso_sumoetTight,sizeof(cutiso_sumoetTight));
664     memcpy(cutsee ,cutseeTight ,sizeof(cutseeTight));
665     }
666    
667 ceballos 1.6 // CAREFUL, I HAVE COMMENTED OUT WHAT SANI IS DOING
668 ceballos 1.5 //Double_t iso_sum = tkIso + ecalIso + hcalIso;
669 ceballos 1.7 Double_t iso_sum = (ele->TrackIsolationDr03() + TMath::Max(ele->EcalRecHitIsoDr03() - 1.0, 0.0) +
670     ele->HcalTowerSumEtDr03()) / ele->Pt();
671 ceballos 1.4 Double_t iso_sum_corrected = iso_sum*pow(40./scEt, 2);
672     if ((iso_sum < cutiso_sum[cat+bin*9]) &&
673     (iso_sum_corrected < cutiso_sumoet[cat+bin*9]))
674     result += 2;
675    
676     if (fBrem > -2) {
677     if ((hOverE < cuthoe[cat+bin*9]) and
678     (sigmaee < cutsee[cat+bin*9]) and
679     (fabs(deltaPhiIn) < cutdphiin[cat+bin*9]) and
680     (fabs(deltaEtaIn) < cutdetain[cat+bin*9]) and
681     (eSeedOverPin > cuteseedopcor[cat+bin*9]) and
682     (scEt > cutet[cat+bin*9]))
683     result += 1.;
684     }
685    
686     Double_t d0_real = 99999;
687     for(UInt_t i0 = 0; i0 < vertices->GetEntries(); i0++) {
688     Double_t pD0 = ele->GsfTrk()->D0Corrected(*vertices->At(i0));
689     if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
690     }
691     if (d0_real < cutip_gsf[cat+bin*9])
692     result += 4;
693    
694     Bool_t passConvVeto = PassConversionFilter(ele, conversions, kTRUE);
695     if (mishits < cutfmishits[cat+bin*9] &&
696     passConvVeto)
697     result += 8;
698     } // classbased
699    
700     return result;
701     }