ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/ElectronTools.cc
Revision: 1.15
Committed: Sat Oct 9 20:15:33 2010 UTC (14 years, 6 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.14: +3 -3 lines
Log Message:
Extra electron id options to synchronize with vbtf selection

File Contents

# User Rev Content
1 bendavid 1.15 // $Id: ElectronTools.cc,v 1.14 2010/10/09 18:41:50 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.14 {0.15, 0.15, 0.15, 0.15, 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 ceballos 1.13
127     if(ele->SCluster() == 0)
128     return kFALSE;
129 sixie 1.1 Double_t eSeedOverPin = ele->ESeedClusterOverPIn();
130     Double_t hOverE = ele->HadronicOverEm();
131     Double_t sigmaee = ele->CoviEtaiEta();
132     Double_t deltaPhiIn = TMath::Abs(ele->DeltaPhiSuperClusterTrackAtVtx());
133     Double_t deltaEtaIn = TMath::Abs(ele->DeltaEtaSuperClusterTrackAtVtx());
134    
135     Int_t eb = 1;
136     if (ele->IsEB())
137     eb = 0;
138    
139     if (hOverE>fCuts[0][cat+4*eb])
140     return kFALSE;
141    
142     if (sigmaee>fCuts[1][cat+4*eb])
143     return kFALSE;
144    
145     if (deltaPhiIn>fCuts[2][cat+4*eb])
146     return kFALSE;
147    
148     if(deltaEtaIn>fCuts[3][cat+4*eb])
149     return kFALSE;
150    
151     if(eSeedOverPin<fCuts[4][cat+4*eb])
152     return kFALSE;
153    
154     return kTRUE;
155     }
156    
157     //--------------------------------------------------------------------------------------------------
158 ceballos 1.5 Bool_t ElectronTools::PassCustomIso(const Electron *ele, EElIsoType isoType,
159     Bool_t useCombineIso)
160 sixie 1.1 {
161     Bool_t pass = kTRUE;
162     Double_t fIsoCuts[4][2]; //!custom isolation cuts
163     Double_t VBTFWorkingPoint95[4][2] = {
164 ceballos 1.5 {0.15 , 0.08 }, //TrkIso
165     {2.00 , 0.06 }, //ECALIso
166     {0.12 , 0.05 }, //HCALIso
167     {0.15, 0.10 } //Combined
168 sixie 1.1 };
169    
170     Double_t VBTFWorkingPoint90[4][2] = {
171 ceballos 1.5 {0.12 , 0.05 }, //TrkIso
172     {0.09 , 0.06 }, //ECALIso
173     {0.10 , 0.03 }, //HCALIso
174     {0.10, 0.07 } //Combined
175     };
176    
177     Double_t VBTFWorkingPoint85[4][2] = {
178     {0.09 , 0.05 }, //TrkIso
179     {0.08 , 0.05 }, //ECALIso
180     {0.10 , 0.025 }, //HCALIso
181     {0.09, 0.06 } //Combined
182 sixie 1.1 };
183    
184     Double_t VBTFWorkingPoint80[4][2] = {
185 ceballos 1.5 {0.09 , 0.04 }, //TrkIso
186     {0.07 , 0.05 }, //ECALIso
187     {0.10 , 0.025 }, //HCALIso
188     {0.07, 0.06 } //Combined
189 sixie 1.1 };
190    
191     Double_t VBTFWorkingPoint70[4][2] = {
192 ceballos 1.11 {0.05 , 0.025 }, //TrkIso
193     {0.06 , 0.025 }, //ECALIso
194     {0.03 , 0.020 }, //HCALIso
195     {0.04, 0.030 } //Combined
196 sixie 1.1 };
197    
198     switch (isoType) {
199     case kVBTFWorkingPoint95Iso:
200     memcpy(fIsoCuts,VBTFWorkingPoint95,sizeof(fIsoCuts));
201     break;
202     case kVBTFWorkingPoint90Iso:
203     memcpy(fIsoCuts,VBTFWorkingPoint90,sizeof(fIsoCuts));
204     break;
205 ceballos 1.5 case kVBTFWorkingPoint85Iso:
206     memcpy(fIsoCuts,VBTFWorkingPoint85,sizeof(fIsoCuts));
207     break;
208 sixie 1.1 case kVBTFWorkingPoint80Iso:
209     memcpy(fIsoCuts,VBTFWorkingPoint80,sizeof(fIsoCuts));
210     break;
211     case kVBTFWorkingPoint70Iso:
212     memcpy(fIsoCuts,VBTFWorkingPoint70,sizeof(fIsoCuts));
213     break;
214     default:
215     memset(fIsoCuts,0,sizeof(fIsoCuts));
216     break;
217     }
218    
219 ceballos 1.10 Double_t trkIso = ele->TrackIsolationDr03() / ele->Pt();
220     Double_t ecalIso = ele->EcalRecHitIsoDr03() / ele->Pt();
221     Double_t hcalIso = ele->HcalTowerSumEtDr03() / ele->Pt();
222     Double_t combinedIso = ele->TrackIsolationDr03() + ele->EcalRecHitIsoDr03() + ele->HcalTowerSumEtDr03();
223     if(ele->IsEB()) combinedIso = ele->TrackIsolationDr03() + TMath::Max(ele->EcalRecHitIsoDr03() - 1.0, 0.0) + ele->HcalTowerSumEtDr03();
224 ceballos 1.11 combinedIso = combinedIso / ele->Pt();
225 sixie 1.1
226     Int_t eb = 1;
227     if (ele->IsEB())
228     eb = 0;
229    
230 ceballos 1.5 if(useCombineIso == kFALSE){
231     if (trkIso>fIsoCuts[0][eb])
232     pass = kFALSE;
233     if (ecalIso>fIsoCuts[1][eb])
234     pass = kFALSE;
235     if (hcalIso>fIsoCuts[2][eb])
236     pass = kFALSE;
237     }
238     else {
239     if (combinedIso>fIsoCuts[3][eb])
240     pass = kFALSE;
241     }
242 sixie 1.1
243     return pass;
244     }
245    
246    
247     //--------------------------------------------------------------------------------------------------
248     Bool_t ElectronTools::PassConversionFilter(const Electron *ele,
249     const DecayParticleCol *conversions,
250     Bool_t WrongHitsRequirement)
251     {
252     Bool_t isGoodConversion = kFALSE;
253    
254     for (UInt_t ifc=0; ifc<conversions->GetEntries(); ifc++) {
255     Bool_t ConversionMatchFound = kFALSE;
256     for (UInt_t d=0; d<conversions->At(ifc)->NDaughters(); d++) {
257     const Track *trk = dynamic_cast<const ChargedParticle*>
258     (conversions->At(ifc)->Daughter(d))->Trk();
259     if (ele->GsfTrk() == trk) {
260     ConversionMatchFound = kTRUE;
261     break;
262     }
263     }
264    
265     // if match between the e-track and one of the conversion legs
266     if (ConversionMatchFound == kTRUE){
267     isGoodConversion = (conversions->At(ifc)->Prob() > 1e-6) &&
268     (conversions->At(ifc)->Lxy() > 0) &&
269 bendavid 1.3 (conversions->At(ifc)->Lz() > 0) &&
270 sixie 1.1 (conversions->At(ifc)->Position().Rho() > 2.0);
271    
272     if (isGoodConversion == kTRUE) {
273     for (UInt_t d=0; d<conversions->At(ifc)->NDaughters(); d++) {
274     const Track *trk = dynamic_cast<const ChargedParticle*>
275     (conversions->At(ifc)->Daughter(d))->Trk();
276     if (trk) {
277     // These requirements are not used for the GSF track
278     if (!(trk->NHits() >= 3 && trk->Prob() > 1e-6) && trk!=ele->GsfTrk())
279     isGoodConversion = kFALSE;
280     const StableData *sd = dynamic_cast<const StableData*>
281     (conversions->At(ifc)->DaughterDat(d));
282     if (WrongHitsRequirement && sd->NWrongHits() != 0)
283     isGoodConversion = kFALSE;
284     } else {
285     isGoodConversion = kFALSE;
286     }
287     }
288     }
289     }
290 ceballos 1.13
291 sixie 1.1 if (isGoodConversion == kTRUE) break;
292    
293     } // loop over all conversions
294    
295     return !isGoodConversion;
296     }
297    
298     //--------------------------------------------------------------------------------------------------
299     Bool_t ElectronTools::PassD0Cut(const Electron *ele, const VertexCol *vertices, Double_t fD0Cut,
300     Bool_t fReverseD0Cut)
301     {
302     Bool_t d0cut = kFALSE;
303     // d0 cut
304     Double_t d0_real = 99999;
305     for(UInt_t i0 = 0; i0 < vertices->GetEntries(); i0++) {
306 ceballos 1.12 if(vertices->At(i0)->NTracks() > 0){
307     Double_t pD0 = ele->GsfTrk()->D0Corrected(*vertices->At(i0));
308     d0_real = TMath::Abs(pD0);
309     break;
310     }
311 sixie 1.1 }
312     if(d0_real < fD0Cut) d0cut = kTRUE;
313    
314     if (fReverseD0Cut == kTRUE &&
315     d0cut == kFALSE && d0_real < 0.05)
316     d0cut = kTRUE;
317     else if(fReverseD0Cut == kTRUE)
318     d0cut = kFALSE;
319    
320     return d0cut;
321     }
322    
323     //--------------------------------------------------------------------------------------------------
324 sixie 1.2 Bool_t ElectronTools::PassD0Cut(const Electron *ele, const BeamSpotCol *beamspots, Double_t fD0Cut,
325     Bool_t fReverseD0Cut)
326     {
327     Bool_t d0cut = kFALSE;
328     // d0 cut
329     Double_t d0_real = 99999;
330     for(UInt_t i0 = 0; i0 < beamspots->GetEntries(); i0++) {
331     Double_t pD0 = ele->GsfTrk()->D0Corrected(*beamspots->At(i0));
332     if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
333     }
334     if(d0_real < fD0Cut) d0cut = kTRUE;
335    
336     if (fReverseD0Cut == kTRUE &&
337     d0cut == kFALSE && d0_real < 0.05)
338     d0cut = kTRUE;
339     else if(fReverseD0Cut == kTRUE)
340     d0cut = kFALSE;
341    
342     return d0cut;
343     }
344    
345     //--------------------------------------------------------------------------------------------------
346 sixie 1.1 Bool_t ElectronTools::PassChargeFilter(const Electron *ele)
347     {
348     Bool_t passChargeFilter = kTRUE;
349     if(ele->TrackerTrk() &&
350     ele->TrackerTrk()->Charge() != ele->Charge()) passChargeFilter = kFALSE;
351    
352     return passChargeFilter;
353     }
354    
355     //--------------------------------------------------------------------------------------------------
356     Bool_t ElectronTools::PassSpikeRemovalFilter(const Electron *ele)
357     {
358     Bool_t passSpikeRemovalFilter = kTRUE;
359 ceballos 1.13 if(ele->SCluster() &&
360     ele->SCluster()->Seed()->Energy() > 5.0 &&
361 sixie 1.1 ele->SCluster()->Seed()->EMax() / ele->SCluster()->Seed()->E3x3() > 0.95
362     ) {
363     passSpikeRemovalFilter = kFALSE;
364     }
365    
366     // For Now Only use the EMax/E3x3 prescription.
367     // if(ele->SCluster()->Seed()->Energy() > 5.0 &&
368     // (1 - (ele->SCluster()->Seed()->E1x3() + ele->SCluster()->Seed()->E3x1() - 2*ele->SCluster()->Seed()->EMax())) > 0.95
369     // ) {
370     // passSpikeRemovalFilter = kFALSE;
371     // }
372    
373     return passSpikeRemovalFilter;
374     }
375 ceballos 1.4
376 bendavid 1.9 Bool_t ElectronTools::PassTriggerMatching(const Electron *ele, const TriggerObjectCol *trigobjs)
377     {
378    
379     for (UInt_t i=0; i<trigobjs->GetEntries(); ++i) {
380     const TriggerObject *trigobj = trigobjs->At(i);
381 bendavid 1.15 if (trigobj->TriggerType()==TriggerObject::TriggerCluster || trigobj->TriggerType()==TriggerObject::TriggerElectron || trigobj->TriggerType()==TriggerObject::TriggerPhoton) {
382     if (MathUtils::DeltaR(ele->SCluster(),trigobj)<0.3) {
383 bendavid 1.9 return kTRUE;
384     }
385     }
386     }
387    
388     return kFALSE;
389    
390    
391     }
392    
393 ceballos 1.4 //--------------------------------------------------------------------------------------------------
394     Int_t ElectronTools::Classify(const Electron *ele) {
395    
396 ceballos 1.5 double eta = ele->AbsEta();
397 ceballos 1.4 double eOverP = ele->ESuperClusterOverP();
398     double fBrem = ele->FBrem();
399    
400     int cat = -1;
401     if (ele->IsEB()) {
402 ceballos 1.5 if ((fBrem >= 0.12) and (eOverP > 0.9) and (eOverP < 1.2))
403 ceballos 1.4 cat = 0;
404 ceballos 1.5 else if (((eta > .445 and eta < .45 ) or
405     (eta > .79 and eta < .81 ) or
406     (eta > 1.137 and eta < 1.157 ) or
407     (eta > 1.47285 and eta < 1.4744)))
408     cat = 6;
409     else if (ele->IsTrackerDriven() and !ele->IsEcalDriven())
410 ceballos 1.4 cat = 8;
411     else if (fBrem < 0.12)
412     cat = 1;
413     else
414     cat = 2;
415     } else {
416 ceballos 1.5 if ((fBrem >= 0.2) and (eOverP > 0.82) and (eOverP < 1.22))
417 ceballos 1.4 cat = 3;
418 ceballos 1.5 else if (eta > 1.5 and eta < 1.58)
419     cat = 7;
420     else if (ele->IsTrackerDriven() and !ele->IsEcalDriven())
421 ceballos 1.4 cat = 8;
422     else if (fBrem < 0.2)
423     cat = 4;
424     else
425     cat = 5;
426     }
427    
428     return cat;
429     }
430    
431     //--------------------------------------------------------------------------------------------------
432     Int_t ElectronTools::PassTightId(const Electron *ele, const VertexCol *vertices,
433     const DecayParticleCol *conversions, const Int_t typeCuts){
434    
435     Double_t scEt = ele->SCluster()->Et();
436     Double_t eOverP = ele->ESuperClusterOverP();
437    
438     Double_t fBrem = ele->FBrem();
439     Double_t hOverE = ele->HadronicOverEm();
440     Double_t sigmaee = ele->CoviEtaiEta();
441     Double_t deltaPhiIn = TMath::Abs(ele->DeltaPhiSuperClusterTrackAtVtx());
442     Double_t deltaEtaIn = TMath::Abs(ele->DeltaEtaSuperClusterTrackAtVtx());
443     Double_t eSeedOverPin = ele->ESeedClusterOverPIn();
444    
445     Int_t mishits = ele->BestTrk()->NExpectedHitsInner();
446     Double_t tkIso = ele->TrackIsolationDr03();
447     Double_t ecalIso = ele->EcalRecHitIsoDr04();
448     Double_t ecalIsoPed = (ele->IsEB())?std::max(0.,ecalIso-1.):ecalIso;
449     Double_t hcalIso = ele->HcalTowerSumEtDr04();
450     Double_t hcalIso1 = ele->HcalDepth1TowerSumEtDr04();
451     Double_t hcalIso2 = ele->HcalDepth2TowerSumEtDr04();
452     Double_t e25Max = ele->E25Max();
453     Double_t e15 = ele->E15();
454     Double_t e55 = ele->E55();
455     Double_t e25Maxoe55 = e25Max/e55;
456     Double_t e15oe55 = e15/e55;
457    
458     int cat = Classify(ele);
459     int eb;
460    
461     if (ele->IsEB())
462     eb = 0;
463     else
464     eb = 1;
465    
466     Int_t result = 0.;
467    
468     Int_t bin = 0;
469 ceballos 1.5
470     Double_t WantBin = kFALSE;
471     if(WantBin) {
472     if (scEt < 20.)
473     bin = 2;
474     else if (scEt > 30.)
475     bin = 0;
476     else
477     bin = 1;
478     }
479 ceballos 1.4
480     if (fBrem > 0)
481     eSeedOverPin = eSeedOverPin + fBrem;
482    
483     if(typeCuts == 3 || typeCuts == 4){
484     // Loose robust cuts
485     Double_t robustlooseEleIDCuts[52] = {
486     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,
487     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
488     };
489     // Tight robust cuts
490     Double_t robusttightEleIDCuts[52] = {
491     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,
492     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
493     };
494     Double_t cut[52];
495     if (typeCuts == 3) {
496     memcpy(cut ,robustlooseEleIDCuts ,sizeof(cut));
497     }
498     else {
499     memcpy(cut ,robusttightEleIDCuts ,sizeof(cut));
500     }
501    
502     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]) ||
503     (tkIso/ele->Pt() > cut[26*eb+11]) || (ecalIso/ele->Pt() > cut[26*eb+12]) || (hcalIso/ele->Pt() > cut[26*eb+13]) ||
504     ((tkIso+ecalIso+hcalIso)>cut[26*eb+14]) || (((tkIso+ecalIso+hcalIso)/ ele->Pt()) > cut[26*eb+15]) ||
505     ((tkIso+ecalIsoPed+hcalIso)>cut[26*eb+16]) || (((tkIso+ecalIsoPed+hcalIso)/ ele->Pt()) > cut[26*eb+17]) )
506     result = 0.;
507     else
508     result = 2.;
509    
510     if (hOverE > cut[26*eb+0])
511     return result;
512    
513     if (sigmaee > cut[26*eb+1])
514     return result;
515    
516     if (fabs(deltaPhiIn) > cut[26*eb+2])
517     return result;
518    
519     if (fabs(deltaEtaIn) > cut[26*eb+3])
520     return result;
521    
522     if (e25Maxoe55 < cut[26*eb+4] && e15oe55 < cut[26*eb+5])
523     return result;
524     // some extra electron id cuts
525     if (sigmaee < cut[26*eb+18]) // inverted sigmaee cut - spike removal related
526     return result;
527    
528     if ( eOverP < cut[26*eb+19] || eOverP > cut[26*eb+20]) // lower and upper cut in E/P
529     return result;
530    
531     result = result + 1;
532    
533 ceballos 1.12 Bool_t passD0cut = PassD0Cut(ele, vertices, cut[26*eb+21], kFALSE);
534     if (!passD0cut)
535 ceballos 1.4 return result;
536    
537     if (mishits > cut[26*eb+22]) // expected missing hits
538     return result;
539    
540     Bool_t passConvVeto = PassConversionFilter(ele, conversions, kTRUE);
541     if (passConvVeto == kFALSE)
542     return result;
543    
544     result += 4;
545     }
546     else if(typeCuts == 0 || typeCuts == 1 || typeCuts == 2){
547     // Loose cuts
548 ceballos 1.5 Double_t cutdcotdistLoose[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
549     };
550     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
551     };
552     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
553     };
554     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
555     };
556     Double_t cutetLoose[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.
557     };
558     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
559     };
560     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
561     };
562     Double_t cutip_gsfLoose[9] = {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02
563     };
564     Double_t cutiso_sumLoose[9] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
565     };
566     Double_t cutiso_sumoetLoose[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
567     };
568     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
569 ceballos 1.4 };
570    
571     // Medium cuts
572 ceballos 1.5 Double_t cutdcotdistMedium[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
573     };
574     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
575     };
576     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
577     };
578     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
579     };
580     Double_t cutetMedium[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.
581     };
582     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
583     };
584     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
585     };
586     Double_t cutip_gsfMedium[9] = {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02
587     };
588     Double_t cutiso_sumMedium[9] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
589     };
590     Double_t cutiso_sumoetMedium[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
591     };
592     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
593 ceballos 1.4 };
594    
595     // Tight cuts
596 ceballos 1.5 Double_t cutdcotdistTight[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
597     };
598     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
599     };
600     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
601     };
602     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
603     };
604     Double_t cutetTight[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.
605     };
606     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
607     };
608     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
609     };
610     Double_t cutip_gsfTight[9] = {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02
611     };
612     Double_t cutiso_sumTight[9] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
613     };
614     Double_t cutiso_sumoetTight[9] = {9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999., 9999.
615     };
616     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
617     };
618    
619     Double_t cutdcotdist[9];
620     Double_t cutdetain[9];
621     Double_t cutdphiin[9];
622     Double_t cuteseedopcor[9];
623     Double_t cutet[9];
624     Double_t cutfmishits[9];
625     Double_t cuthoe[9];
626     Double_t cutip_gsf[9];
627     Double_t cutiso_sum[9];
628     Double_t cutiso_sumoet[9];
629     Double_t cutsee[9];
630 ceballos 1.4 if (typeCuts == 0) {
631     memcpy(cutdcotdist ,cutdcotdistLoose ,sizeof(cutdcotdistLoose));
632     memcpy(cutdetain ,cutdetainLoose ,sizeof(cutdetainLoose));
633     memcpy(cutdphiin ,cutdphiinLoose ,sizeof(cutdphiinLoose));
634     memcpy(cuteseedopcor,cuteseedopcorLoose,sizeof(cuteseedopcorLoose));
635     memcpy(cutet ,cutetLoose ,sizeof(cutetLoose));
636     memcpy(cutfmishits ,cutfmishitsLoose ,sizeof(cutfmishitsLoose));
637     memcpy(cuthoe ,cuthoeLoose ,sizeof(cuthoeLoose));
638     memcpy(cutip_gsf ,cutip_gsfLoose ,sizeof(cutip_gsfLoose));
639     memcpy(cutiso_sum ,cutiso_sumLoose ,sizeof(cutiso_sumLoose));
640     memcpy(cutiso_sumoet,cutiso_sumoetLoose,sizeof(cutiso_sumoetLoose));
641     memcpy(cutsee ,cutseeLoose ,sizeof(cutseeLoose));
642     }
643     else if(typeCuts == 1) {
644     memcpy(cutdcotdist ,cutdcotdistMedium ,sizeof(cutdcotdistMedium));
645     memcpy(cutdetain ,cutdetainMedium ,sizeof(cutdetainMedium));
646     memcpy(cutdphiin ,cutdphiinMedium ,sizeof(cutdphiinMedium));
647     memcpy(cuteseedopcor,cuteseedopcorMedium,sizeof(cuteseedopcorMedium));
648     memcpy(cutet ,cutetMedium ,sizeof(cutetMedium));
649     memcpy(cutfmishits ,cutfmishitsMedium ,sizeof(cutfmishitsMedium));
650     memcpy(cuthoe ,cuthoeMedium ,sizeof(cuthoeMedium));
651     memcpy(cutip_gsf ,cutip_gsfMedium ,sizeof(cutip_gsfMedium));
652     memcpy(cutiso_sum ,cutiso_sumMedium ,sizeof(cutiso_sumMedium));
653     memcpy(cutiso_sumoet,cutiso_sumoetMedium,sizeof(cutiso_sumoetMedium));
654     memcpy(cutsee ,cutseeMedium ,sizeof(cutseeMedium));
655     }
656     else {
657     memcpy(cutdcotdist ,cutdcotdistTight ,sizeof(cutdcotdistTight));
658     memcpy(cutdetain ,cutdetainTight ,sizeof(cutdetainTight));
659     memcpy(cutdphiin ,cutdphiinTight ,sizeof(cutdphiinTight));
660     memcpy(cuteseedopcor,cuteseedopcorTight,sizeof(cuteseedopcorTight));
661     memcpy(cutet ,cutetTight ,sizeof(cutetTight));
662     memcpy(cutfmishits ,cutfmishitsTight ,sizeof(cutfmishitsTight));
663     memcpy(cuthoe ,cuthoeTight ,sizeof(cuthoeTight));
664     memcpy(cutip_gsf ,cutip_gsfTight ,sizeof(cutip_gsfTight));
665     memcpy(cutiso_sum ,cutiso_sumTight ,sizeof(cutiso_sumTight));
666     memcpy(cutiso_sumoet,cutiso_sumoetTight,sizeof(cutiso_sumoetTight));
667     memcpy(cutsee ,cutseeTight ,sizeof(cutseeTight));
668     }
669    
670 ceballos 1.6 // CAREFUL, I HAVE COMMENTED OUT WHAT SANI IS DOING
671 ceballos 1.5 //Double_t iso_sum = tkIso + ecalIso + hcalIso;
672 ceballos 1.7 Double_t iso_sum = (ele->TrackIsolationDr03() + TMath::Max(ele->EcalRecHitIsoDr03() - 1.0, 0.0) +
673     ele->HcalTowerSumEtDr03()) / ele->Pt();
674 ceballos 1.4 Double_t iso_sum_corrected = iso_sum*pow(40./scEt, 2);
675     if ((iso_sum < cutiso_sum[cat+bin*9]) &&
676     (iso_sum_corrected < cutiso_sumoet[cat+bin*9]))
677     result += 2;
678    
679     if (fBrem > -2) {
680     if ((hOverE < cuthoe[cat+bin*9]) and
681     (sigmaee < cutsee[cat+bin*9]) and
682     (fabs(deltaPhiIn) < cutdphiin[cat+bin*9]) and
683     (fabs(deltaEtaIn) < cutdetain[cat+bin*9]) and
684     (eSeedOverPin > cuteseedopcor[cat+bin*9]) and
685     (scEt > cutet[cat+bin*9]))
686     result += 1.;
687     }
688    
689 ceballos 1.12 Bool_t passD0cut = PassD0Cut(ele, vertices, cutip_gsf[cat+bin*9], kFALSE);
690     if (passD0cut)
691 ceballos 1.4 result += 4;
692    
693     Bool_t passConvVeto = PassConversionFilter(ele, conversions, kTRUE);
694     if (mishits < cutfmishits[cat+bin*9] &&
695     passConvVeto)
696     result += 8;
697     } // classbased
698    
699     return result;
700     }