ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/ElectronTools.cc
Revision: 1.19
Committed: Thu Feb 17 13:44:55 2011 UTC (14 years, 2 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.18: +7 -10 lines
Log Message:
Updated conversion cuts for vertexing-based removal

File Contents

# User Rev Content
1 bendavid 1.19 // $Id: ElectronTools.cc,v 1.18 2011/01/21 11:25: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.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 bendavid 1.16 if ( (fCuts[5][0]>0.0) && (eOverP < fCuts[5][0]) && (fCuts[5][1]>0.0) && (fBrem < fCuts[5][1]))
116 sixie 1.1 return kFALSE;
117    
118 bendavid 1.16 if ( (fCuts[5][2]>0.0) && (eOverP < fCuts[5][2]*(1-fBrem)))
119 sixie 1.1 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 bendavid 1.19 const DecayParticleCol *conversions,
250     const BaseVertex *vtx,
251     UInt_t nWrongHitsMax)
252 sixie 1.1 {
253     Bool_t isGoodConversion = kFALSE;
254    
255     for (UInt_t ifc=0; ifc<conversions->GetEntries(); ifc++) {
256     Bool_t ConversionMatchFound = kFALSE;
257     for (UInt_t d=0; d<conversions->At(ifc)->NDaughters(); d++) {
258     const Track *trk = dynamic_cast<const ChargedParticle*>
259     (conversions->At(ifc)->Daughter(d))->Trk();
260     if (ele->GsfTrk() == trk) {
261     ConversionMatchFound = kTRUE;
262     break;
263     }
264     }
265    
266     // if match between the e-track and one of the conversion legs
267     if (ConversionMatchFound == kTRUE){
268     isGoodConversion = (conversions->At(ifc)->Prob() > 1e-6) &&
269 bendavid 1.19 (conversions->At(ifc)->Quality().Quality(ConversionQuality::arbitratedMerged)) &&
270     (conversions->At(ifc)->LxyCorrected(vtx) > 2.0);
271 sixie 1.1
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     const StableData *sd = dynamic_cast<const StableData*>
278     (conversions->At(ifc)->DaughterDat(d));
279 bendavid 1.19 if (sd->NWrongHits() > nWrongHitsMax)
280 sixie 1.1 isGoodConversion = kFALSE;
281     } else {
282     isGoodConversion = kFALSE;
283     }
284     }
285     }
286     }
287 ceballos 1.13
288 sixie 1.1 if (isGoodConversion == kTRUE) break;
289    
290     } // loop over all conversions
291    
292     return !isGoodConversion;
293     }
294    
295     //--------------------------------------------------------------------------------------------------
296 ceballos 1.18 Bool_t ElectronTools::PassD0Cut(const Electron *ele, const VertexCol *vertices, Double_t fD0Cut)
297 sixie 1.1 {
298     Bool_t d0cut = kFALSE;
299     // d0 cut
300     Double_t d0_real = 99999;
301     for(UInt_t i0 = 0; i0 < vertices->GetEntries(); i0++) {
302 ceballos 1.12 if(vertices->At(i0)->NTracks() > 0){
303     Double_t pD0 = ele->GsfTrk()->D0Corrected(*vertices->At(i0));
304     d0_real = TMath::Abs(pD0);
305     break;
306     }
307 sixie 1.1 }
308     if(d0_real < fD0Cut) d0cut = kTRUE;
309    
310     return d0cut;
311     }
312    
313     //--------------------------------------------------------------------------------------------------
314 ceballos 1.18 Bool_t ElectronTools::PassD0Cut(const Electron *ele, const BeamSpotCol *beamspots, Double_t fD0Cut)
315 sixie 1.2 {
316     Bool_t d0cut = kFALSE;
317     // d0 cut
318     Double_t d0_real = 99999;
319     for(UInt_t i0 = 0; i0 < beamspots->GetEntries(); i0++) {
320     Double_t pD0 = ele->GsfTrk()->D0Corrected(*beamspots->At(i0));
321     if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
322     }
323     if(d0_real < fD0Cut) d0cut = kTRUE;
324    
325     return d0cut;
326     }
327    
328     //--------------------------------------------------------------------------------------------------
329 sixie 1.1 Bool_t ElectronTools::PassChargeFilter(const Electron *ele)
330     {
331     Bool_t passChargeFilter = kTRUE;
332     if(ele->TrackerTrk() &&
333     ele->TrackerTrk()->Charge() != ele->Charge()) passChargeFilter = kFALSE;
334    
335     return passChargeFilter;
336     }
337    
338     //--------------------------------------------------------------------------------------------------
339     Bool_t ElectronTools::PassSpikeRemovalFilter(const Electron *ele)
340     {
341     Bool_t passSpikeRemovalFilter = kTRUE;
342 ceballos 1.13 if(ele->SCluster() &&
343     ele->SCluster()->Seed()->Energy() > 5.0 &&
344 sixie 1.1 ele->SCluster()->Seed()->EMax() / ele->SCluster()->Seed()->E3x3() > 0.95
345     ) {
346     passSpikeRemovalFilter = kFALSE;
347     }
348    
349     // For Now Only use the EMax/E3x3 prescription.
350     // if(ele->SCluster()->Seed()->Energy() > 5.0 &&
351     // (1 - (ele->SCluster()->Seed()->E1x3() + ele->SCluster()->Seed()->E3x1() - 2*ele->SCluster()->Seed()->EMax())) > 0.95
352     // ) {
353     // passSpikeRemovalFilter = kFALSE;
354     // }
355    
356     return passSpikeRemovalFilter;
357     }
358 ceballos 1.4
359 bendavid 1.9 Bool_t ElectronTools::PassTriggerMatching(const Electron *ele, const TriggerObjectCol *trigobjs)
360     {
361    
362     for (UInt_t i=0; i<trigobjs->GetEntries(); ++i) {
363     const TriggerObject *trigobj = trigobjs->At(i);
364 bendavid 1.15 if (trigobj->TriggerType()==TriggerObject::TriggerCluster || trigobj->TriggerType()==TriggerObject::TriggerElectron || trigobj->TriggerType()==TriggerObject::TriggerPhoton) {
365     if (MathUtils::DeltaR(ele->SCluster(),trigobj)<0.3) {
366 bendavid 1.9 return kTRUE;
367     }
368     }
369     }
370    
371     return kFALSE;
372    
373    
374     }
375    
376 ceballos 1.4 //--------------------------------------------------------------------------------------------------
377     Int_t ElectronTools::Classify(const Electron *ele) {
378    
379 ceballos 1.5 double eta = ele->AbsEta();
380 ceballos 1.4 double eOverP = ele->ESuperClusterOverP();
381     double fBrem = ele->FBrem();
382    
383     int cat = -1;
384     if (ele->IsEB()) {
385 ceballos 1.5 if ((fBrem >= 0.12) and (eOverP > 0.9) and (eOverP < 1.2))
386 ceballos 1.4 cat = 0;
387 ceballos 1.5 else if (((eta > .445 and eta < .45 ) or
388     (eta > .79 and eta < .81 ) or
389     (eta > 1.137 and eta < 1.157 ) or
390     (eta > 1.47285 and eta < 1.4744)))
391     cat = 6;
392     else if (ele->IsTrackerDriven() and !ele->IsEcalDriven())
393 ceballos 1.4 cat = 8;
394     else if (fBrem < 0.12)
395     cat = 1;
396     else
397     cat = 2;
398     } else {
399 ceballos 1.5 if ((fBrem >= 0.2) and (eOverP > 0.82) and (eOverP < 1.22))
400 ceballos 1.4 cat = 3;
401 ceballos 1.5 else if (eta > 1.5 and eta < 1.58)
402     cat = 7;
403     else if (ele->IsTrackerDriven() and !ele->IsEcalDriven())
404 ceballos 1.4 cat = 8;
405     else if (fBrem < 0.2)
406     cat = 4;
407     else
408     cat = 5;
409     }
410    
411     return cat;
412     }
413    
414     //--------------------------------------------------------------------------------------------------
415     Int_t ElectronTools::PassTightId(const Electron *ele, const VertexCol *vertices,
416     const DecayParticleCol *conversions, const Int_t typeCuts){
417    
418 ceballos 1.17 // original code on
419     // http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc
420    
421     Double_t scEt = ele->SCluster()->Et();
422     Double_t scEta = ele->SCluster()->Eta();
423 ceballos 1.4
424     Double_t fBrem = ele->FBrem();
425     Double_t hOverE = ele->HadronicOverEm();
426     Double_t sigmaee = ele->CoviEtaiEta();
427     Double_t deltaPhiIn = TMath::Abs(ele->DeltaPhiSuperClusterTrackAtVtx());
428     Double_t deltaEtaIn = TMath::Abs(ele->DeltaEtaSuperClusterTrackAtVtx());
429     Double_t eSeedOverPin = ele->ESeedClusterOverPIn();
430    
431     Int_t mishits = ele->BestTrk()->NExpectedHitsInner();
432     Double_t tkIso = ele->TrackIsolationDr03();
433     Double_t ecalIso = ele->EcalRecHitIsoDr04();
434     Double_t hcalIso = ele->HcalTowerSumEtDr04();
435    
436     int cat = Classify(ele);
437     int eb;
438    
439     if (ele->IsEB())
440     eb = 0;
441     else
442     eb = 1;
443    
444 ceballos 1.17 // Medium cuts
445     Double_t cutdcotdistMedium[9] = {
446     3.32e-02, 2.92e-02, 2.49e-02, 3.92e-02, 3.41e-02, 3.96e-02, 2.91e-02, 3.95e-02, 7.71e-03};
447     Double_t cutdetainMedium[9] = {
448     1.33e-02, 4.48e-03, 9.22e-03, 1.54e-02, 7.26e-03, 1.24e-02, 1.29e-02, 3.84e-02, 1.88e-02};
449     Double_t cutdetainlMedium[9] = {
450     1.21e-02, 4.22e-03, 9.18e-03, 1.61e-02, 6.45e-03, 1.16e-02, 1.23e-02, 6.20e-02, 2.43e-02};
451     Double_t cutdphiinMedium[9] = {
452     7.09e-02, 2.43e-01, 2.96e-01, 7.98e-02, 2.35e-01, 2.76e-01, 3.42e-01, 4.04e-01, 2.99e-01};
453     Double_t cutdphiinlMedium[9] = {
454     7.42e-02, 2.43e-01, 2.97e-01, 9.12e-02, 2.26e-01, 2.76e-01, 3.34e-01, 5.58e-01, 2.91e-01};
455     Double_t cuteseedopcorMedium[9] = {
456     6.42e-01, 9.44e-01, 4.53e-01, 7.62e-01, 3.67e-01, 5.57e-01, 1.98e-01, 9.15e-01, 6.28e-02};
457     Double_t cutfmishitsMedium[9] = {
458     4.50e+00, 1.50e+00, 1.50e+00, 1.50e+00, 1.50e+00, 5.00e-01, 1.50e+00, 5.00e-01, 5.00e-01};
459     Double_t cuthoeMedium[9] = {
460     1.96e-01, 6.30e-02, 1.48e-01, 3.66e-01, 5.66e-02, 1.45e-01, 4.29e-01, 4.28e-01, 3.99e-01};
461     Double_t cuthoelMedium[9] = {
462     2.19e-01, 6.19e-02, 1.47e-01, 3.58e-01, 4.61e-02, 1.46e-01, 3.26e-01, 3.81e-01, 3.89e-01};
463     Double_t cutip_gsfMedium[9] = {
464     2.45e-02, 9.74e-02, 1.48e-01, 5.49e-02, 5.65e-01, 3.33e-01, 2.04e-01, 5.41e-01, 1.21e-01};
465     Double_t cutip_gsflMedium[9] = {
466     1.92e-02, 9.81e-02, 1.33e-01, 4.34e-02, 5.65e-01, 3.24e-01, 2.33e-01, 4.30e-01, 6.44e-02};
467     Double_t cutiso_sumMedium[9] = {
468     1.44e+01, 1.12e+01, 1.09e+01, 1.08e+01, 6.35e+00, 9.78e+00, 1.30e+01, 1.62e+01, 1.96e+00};
469     Double_t cutiso_sumoetMedium[9] = {
470     1.01e+01, 6.41e+00, 6.00e+00, 8.14e+00, 3.90e+00, 4.76e+00, 6.86e+00, 6.48e+00, 1.74e+01};
471     Double_t cutiso_sumoetlMedium[9] = {
472     9.44e+00, 7.67e+00, 7.15e+00, 7.34e+00, 3.35e+00, 4.70e+00, 8.32e+00, 7.55e+00, 6.25e+00};
473     Double_t cutseeMedium[9] = {
474     1.30e-02, 1.09e-02, 1.18e-02, 3.94e-02, 3.04e-02, 3.28e-02, 1.00e-02, 3.73e-02, 6.69e-02};
475     Double_t cutseelMedium[9] = {
476     1.42e-02, 1.11e-02, 1.29e-02, 4.32e-02, 2.96e-02, 3.82e-02, 1.01e-02, 4.45e-02, 1.19e-01};
477    
478     // Tight cuts
479     Double_t cutdcotdistTight[9] = {
480     2.68e-02, 2.36e-02, 2.21e-02, 3.72e-02, 3.17e-02, 3.61e-02, 2.55e-02, 3.75e-02, 2.16e-04};
481     Double_t cutdetainTight[9] = {
482     8.92e-03, 3.96e-03, 8.50e-03, 1.34e-02, 6.27e-03, 1.05e-02, 1.12e-02, 3.09e-02, 1.88e-02};
483     Double_t cutdetainlTight[9] = {
484     9.23e-03, 3.77e-03, 8.70e-03, 1.39e-02, 5.60e-03, 9.40e-03, 1.07e-02, 6.20e-02, 4.10e-03};
485     Double_t cutdphiinTight[9] = {
486     6.37e-02, 1.53e-01, 2.90e-01, 7.69e-02, 1.81e-01, 2.34e-01, 3.42e-01, 3.93e-01, 2.84e-01};
487     Double_t cutdphiinlTight[9] = {
488     6.92e-02, 2.33e-01, 2.96e-01, 8.65e-02, 1.85e-01, 2.76e-01, 3.34e-01, 3.53e-01, 2.90e-01};
489     Double_t cuteseedopcorTight[9] = {
490     6.52e-01, 9.69e-01, 9.12e-01, 7.79e-01, 3.67e-01, 6.99e-01, 3.28e-01, 9.67e-01, 5.89e-01};
491     Double_t cutfmishitsTight[9] = {
492     4.50e+00, 1.50e+00, 5.00e-01, 1.50e+00, 1.50e+00, 5.00e-01, 5.00e-01, 5.00e-01, 5.00e-01};
493     Double_t cuthoeTight[9] = {
494     1.74e-01, 4.88e-02, 1.46e-01, 3.64e-01, 4.93e-02, 1.45e-01, 4.29e-01, 4.20e-01, 3.99e-01};
495     Double_t cuthoelTight[9] = {
496     2.19e-01, 5.25e-02, 1.47e-01, 3.57e-01, 4.25e-02, 1.45e-01, 3.26e-01, 3.80e-01, 1.32e-01};
497     Double_t cutip_gsfTight[9] = {
498     1.58e-02, 8.25e-02, 1.15e-01, 4.05e-02, 5.40e-01, 1.51e-01, 7.74e-02, 4.17e-01, 7.80e-02};
499     Double_t cutip_gsflTight[9] = {
500     1.27e-02, 6.26e-02, 9.68e-02, 3.02e-02, 5.65e-01, 1.46e-01, 7.90e-02, 4.10e-01, 4.79e-02};
501     Double_t cutiso_sumTight[9] = {
502     1.23e+01, 9.77e+00, 1.01e+01, 9.77e+00, 6.13e+00, 7.55e+00, 1.30e+01, 1.62e+01, 1.78e+00};
503     Double_t cutiso_sumoetTight[9] = {
504     7.75e+00, 5.45e+00, 5.67e+00, 5.97e+00, 3.17e+00, 3.86e+00, 6.06e+00, 5.31e+00, 1.05e+01};
505     Double_t cutiso_sumoetlTight[9] = {
506     7.56e+00, 5.08e+00, 5.77e+00, 5.74e+00, 2.37e+00, 3.32e+00, 4.97e+00, 5.46e+00, 3.82e+00};
507     Double_t cutseeTight[9] = {
508     1.16e-02, 1.07e-02, 1.08e-02, 3.49e-02, 2.89e-02, 3.08e-02, 9.87e-03, 3.37e-02, 4.40e-02};
509     Double_t cutseelTight[9] = {
510     1.27e-02, 1.08e-02, 1.13e-02, 4.19e-02, 2.81e-02, 3.02e-02, 9.76e-03, 4.28e-02, 2.98e-02};
511    
512     Double_t cutdcotdistSuperTight[9] = {
513     2.11e-02, 1.86e-02, 1.55e-02, 3.40e-02, 2.85e-02, 3.32e-02, 1.64e-02, 3.75e-02, 1.30e-04};
514     Double_t cutdetainSuperTight[9] = {
515     7.84e-03, 3.67e-03, 7.00e-03, 1.28e-02, 5.65e-03, 9.53e-03, 1.08e-02, 2.97e-02, 7.24e-03};
516     Double_t cutdetainlSuperTight[9] = {
517     7.61e-03, 3.28e-03, 6.57e-03, 1.03e-02, 5.05e-03, 8.55e-03, 1.07e-02, 2.94e-02, 4.10e-03};
518     Double_t cutdphiinSuperTight[9] = {
519     4.83e-02, 7.39e-02, 2.38e-01, 5.74e-02, 1.29e-01, 2.13e-01, 3.31e-01, 3.93e-01, 2.84e-01};
520     Double_t cutdphiinlSuperTight[9] = {
521     5.79e-02, 7.21e-02, 2.18e-01, 7.70e-02, 1.41e-01, 2.11e-01, 2.43e-01, 3.53e-01, 2.89e-01};
522     Double_t cuteseedopcorSuperTight[9] = {
523     7.32e-01, 9.77e-01, 9.83e-01, 8.55e-01, 4.31e-01, 7.35e-01, 4.18e-01, 9.99e-01, 5.89e-01};
524     Double_t cutfmishitsSuperTight[9] = {
525     3.50e+00, 1.50e+00, 5.00e-01, 5.00e-01, 5.00e-01, 5.00e-01, 5.00e-01, 5.00e-01, 5.00e-01};
526     Double_t cuthoeSuperTight[9] = {
527     9.19e-02, 4.11e-02, 1.42e-01, 3.35e-01, 3.82e-02, 1.41e-01, 4.29e-01, 4.01e-01, 3.99e-01};
528     Double_t cuthoelSuperTight[9] = {
529     7.51e-02, 3.81e-02, 1.41e-01, 3.32e-01, 3.10e-02, 1.43e-01, 2.35e-01, 3.80e-01, 1.32e-01};
530     Double_t cutip_gsfSuperTight[9] = {
531     1.42e-02, 2.66e-02, 1.06e-01, 3.38e-02, 3.23e-01, 1.07e-01, 7.74e-02, 2.32e-01, 7.80e-02};
532     Double_t cutip_gsflSuperTight[9] = {
533     1.15e-02, 2.72e-02, 8.41e-02, 2.49e-02, 4.17e-01, 1.02e-01, 7.90e-02, 1.69e-01, 4.79e-02};
534     Double_t cutiso_sumSuperTight[9] = {
535     8.95e+00, 8.18e+00, 8.75e+00, 7.47e+00, 5.43e+00, 5.87e+00, 8.16e+00, 1.02e+01, 1.78e+00};
536     Double_t cutiso_sumoetSuperTight[9] = {
537     6.45e+00, 5.14e+00, 4.99e+00, 5.21e+00, 2.65e+00, 3.12e+00, 4.52e+00, 4.72e+00, 3.68e+00};
538     Double_t cutiso_sumoetlSuperTight[9] = {
539     6.02e+00, 3.96e+00, 4.23e+00, 4.73e+00, 1.99e+00, 2.64e+00, 3.72e+00, 3.81e+00, 1.44e+00};
540     Double_t cutseeSuperTight[9] = {
541     1.09e-02, 1.05e-02, 1.05e-02, 3.24e-02, 2.81e-02, 2.95e-02, 9.77e-03, 2.75e-02, 2.95e-02};
542     Double_t cutseelSuperTight[9] = {
543     1.12e-02, 1.05e-02, 1.07e-02, 3.51e-02, 2.75e-02, 2.87e-02, 9.59e-03, 2.67e-02, 2.98e-02};
544    
545     Double_t cutdcotdist[9];
546     Double_t cutdetain[9];
547     Double_t cutdetainl[9];
548     Double_t cutdphiin[9];
549     Double_t cutdphiinl[9];
550     Double_t cuteseedopcor[9];
551     Double_t cutfmishits[9];
552     Double_t cuthoe[9];
553     Double_t cuthoel[9];
554     Double_t cutip_gsf[9];
555     Double_t cutip_gsfl[9];
556     Double_t cutiso_sum[9];
557     Double_t cutiso_sumoet[9];
558     Double_t cutiso_sumoetl[9];
559     Double_t cutsee[9];
560     Double_t cutseel[9];
561     if (typeCuts == 0) {
562     memcpy(cutdcotdist ,cutdcotdistMedium ,sizeof(cutdcotdistMedium));
563     memcpy(cutdetain ,cutdetainMedium ,sizeof(cutdetainMedium));
564     memcpy(cutdetainl ,cutdetainlMedium ,sizeof(cutdetainlMedium));
565     memcpy(cutdphiin ,cutdphiinMedium ,sizeof(cutdphiinMedium));
566     memcpy(cutdphiinl ,cutdphiinlMedium ,sizeof(cutdphiinlMedium));
567     memcpy(cuteseedopcor ,cuteseedopcorMedium ,sizeof(cuteseedopcorMedium));
568     memcpy(cutfmishits ,cutfmishitsMedium ,sizeof(cutfmishitsMedium));
569     memcpy(cuthoe ,cuthoeMedium ,sizeof(cuthoeMedium));
570     memcpy(cuthoel ,cuthoelMedium ,sizeof(cuthoelMedium));
571     memcpy(cutip_gsf ,cutip_gsfMedium ,sizeof(cutip_gsfMedium));
572     memcpy(cutip_gsfl ,cutip_gsflMedium ,sizeof(cutip_gsflMedium));
573     memcpy(cutiso_sum ,cutiso_sumMedium ,sizeof(cutiso_sumMedium));
574     memcpy(cutiso_sumoet ,cutiso_sumoetMedium ,sizeof(cutiso_sumoetMedium));
575     memcpy(cutiso_sumoetl,cutiso_sumoetlMedium,sizeof(cutiso_sumoetlMedium));
576     memcpy(cutsee ,cutseeMedium ,sizeof(cutseeMedium));
577     memcpy(cutseel ,cutseelMedium ,sizeof(cutseelMedium));
578     }
579     else if(typeCuts == 1) {
580     memcpy(cutdcotdist ,cutdcotdistTight ,sizeof(cutdcotdistTight));
581     memcpy(cutdetain ,cutdetainTight ,sizeof(cutdetainTight));
582     memcpy(cutdetainl ,cutdetainlTight ,sizeof(cutdetainlTight));
583     memcpy(cutdphiin ,cutdphiinTight ,sizeof(cutdphiinTight));
584     memcpy(cutdphiinl ,cutdphiinlTight ,sizeof(cutdphiinlTight));
585     memcpy(cuteseedopcor ,cuteseedopcorTight ,sizeof(cuteseedopcorTight));
586     memcpy(cutfmishits ,cutfmishitsTight ,sizeof(cutfmishitsTight));
587     memcpy(cuthoe ,cuthoeTight ,sizeof(cuthoeTight));
588     memcpy(cuthoel ,cuthoelTight ,sizeof(cuthoelTight));
589     memcpy(cutip_gsf ,cutip_gsfTight ,sizeof(cutip_gsfTight));
590     memcpy(cutip_gsfl ,cutip_gsflTight ,sizeof(cutip_gsflTight));
591     memcpy(cutiso_sum ,cutiso_sumTight ,sizeof(cutiso_sumTight));
592     memcpy(cutiso_sumoet ,cutiso_sumoetTight ,sizeof(cutiso_sumoetTight));
593     memcpy(cutiso_sumoetl,cutiso_sumoetlTight,sizeof(cutiso_sumoetlTight));
594     memcpy(cutsee ,cutseeTight ,sizeof(cutseeTight));
595     memcpy(cutseel ,cutseelTight ,sizeof(cutseelTight));
596 ceballos 1.5 }
597 ceballos 1.17 else {
598     memcpy(cutdcotdist ,cutdcotdistSuperTight ,sizeof(cutdcotdistSuperTight));
599     memcpy(cutdetain ,cutdetainSuperTight ,sizeof(cutdetainSuperTight));
600     memcpy(cutdetainl ,cutdetainlSuperTight ,sizeof(cutdetainlSuperTight));
601     memcpy(cutdphiin ,cutdphiinSuperTight ,sizeof(cutdphiinSuperTight));
602     memcpy(cutdphiinl ,cutdphiinlSuperTight ,sizeof(cutdphiinlSuperTight));
603     memcpy(cuteseedopcor ,cuteseedopcorSuperTight ,sizeof(cuteseedopcorSuperTight));
604     memcpy(cutfmishits ,cutfmishitsSuperTight ,sizeof(cutfmishitsSuperTight));
605     memcpy(cuthoe ,cuthoeSuperTight ,sizeof(cuthoeSuperTight));
606     memcpy(cuthoel ,cuthoelSuperTight ,sizeof(cuthoelSuperTight));
607     memcpy(cutip_gsf ,cutip_gsfSuperTight ,sizeof(cutip_gsfSuperTight));
608     memcpy(cutip_gsfl ,cutip_gsflSuperTight ,sizeof(cutip_gsflSuperTight));
609     memcpy(cutiso_sum ,cutiso_sumSuperTight ,sizeof(cutiso_sumSuperTight));
610     memcpy(cutiso_sumoet ,cutiso_sumoetSuperTight ,sizeof(cutiso_sumoetSuperTight));
611     memcpy(cutiso_sumoetl,cutiso_sumoetlSuperTight,sizeof(cutiso_sumoetlSuperTight));
612     memcpy(cutsee ,cutseeSuperTight ,sizeof(cutseeSuperTight));
613     memcpy(cutseel ,cutseelSuperTight ,sizeof(cutseelSuperTight));
614     }
615    
616     int result = 0;
617    
618     const int ncuts = 10;
619     std::vector<bool> cut_results(ncuts, false);
620    
621     float iso_sum = tkIso + ecalIso + hcalIso;
622     if(fabs(scEta)>1.5)
623     iso_sum += (fabs(scEta)-1.5)*1.09;
624    
625     float iso_sumoet = iso_sum*(40./scEt);
626    
627     float eseedopincor = eSeedOverPin + fBrem;
628     if(fBrem < 0)
629     eseedopincor = eSeedOverPin;
630 ceballos 1.4
631 ceballos 1.17 float dist = (TMath::Abs(ele->ConvPartnerDist()) == -9999.? 9999:TMath::Abs(ele->ConvPartnerDist()));
632     float dcot = (TMath::Abs(ele->ConvPartnerDCotTheta()) == -9999.? 9999:TMath::Abs(ele->ConvPartnerDCotTheta()));
633 ceballos 1.4
634 ceballos 1.17 float dcotdistcomb = ((0.04 - std::max(dist, dcot)) > 0?(0.04 - std::max(dist, dcot)):0);
635    
636     Double_t ip = 99999;
637     for(UInt_t i0 = 0; i0 < vertices->GetEntries(); i0++) {
638     if(vertices->At(i0)->NTracks() > 0){
639     Double_t pD0 = ele->GsfTrk()->D0Corrected(*vertices->At(i0));
640     ip = TMath::Abs(pD0);
641     break;
642 ceballos 1.4 }
643 ceballos 1.17 }
644    
645     for (int cut=0; cut<ncuts; cut++) {
646     switch (cut) {
647     case 0:
648     cut_results[cut] = compute_cut(fabs(deltaEtaIn), scEt, cutdetainl[cat], cutdetain[cat]);
649     break;
650     case 1:
651     cut_results[cut] = compute_cut(fabs(deltaPhiIn), scEt, cutdphiinl[cat], cutdphiin[cat]);
652     break;
653     case 2:
654     cut_results[cut] = (eseedopincor > cuteseedopcor[cat]);
655     break;
656     case 3:
657     cut_results[cut] = compute_cut(hOverE, scEt, cuthoel[cat], cuthoe[cat]);
658     break;
659     case 4:
660     cut_results[cut] = compute_cut(sigmaee, scEt, cutseel[cat], cutsee[cat]);
661     break;
662     case 5:
663     cut_results[cut] = compute_cut(iso_sumoet, scEt, cutiso_sumoetl[cat], cutiso_sumoet[cat]);
664     break;
665     case 6:
666     cut_results[cut] = (iso_sum < cutiso_sum[cat]);
667     break;
668     case 7:
669     cut_results[cut] = compute_cut(fabs(ip), scEt, cutip_gsfl[cat], cutip_gsf[cat]);
670     break;
671     case 8:
672     cut_results[cut] = (mishits < cutfmishits[cat]);
673     break;
674     case 9:
675     cut_results[cut] = (dcotdistcomb < cutdcotdist[cat]);
676     break;
677 ceballos 1.4 }
678 ceballos 1.17 }
679    
680     // ID part
681     if (cut_results[0] & cut_results[1] & cut_results[2] & cut_results[3] & cut_results[4])
682     result = result + 1;
683    
684     // ISO part
685     if (cut_results[5] & cut_results[6])
686     result = result + 2;
687    
688     // IP part
689     if (cut_results[7])
690     result = result + 8;
691    
692     // Conversion part
693     if (cut_results[8] and cut_results[9])
694     result = result + 4;
695    
696     return result;
697     }
698 ceballos 1.4
699 ceballos 1.17 //--------------------------------------------------------------------------------------------------
700     bool ElectronTools::compute_cut(double x, double et, double cut_min, double cut_max, bool gtn) {
701 ceballos 1.4
702 ceballos 1.17 float et_min = 10;
703     float et_max = 40;
704 ceballos 1.4
705 ceballos 1.17 bool accept = false;
706     float cut = cut_max; // the cut at et=40 GeV
707 ceballos 1.4
708 ceballos 1.17 if(et < et_max) {
709     cut = cut_min + (1/et_min - 1/et)*(cut_max - cut_min)/(1/et_min - 1/et_max);
710     }
711    
712     if(et < et_min) {
713     cut = cut_min;
714     }
715 ceballos 1.4
716 ceballos 1.17 if(gtn) { // useful for e/p cut which is gt
717     accept = (x >= cut);
718     }
719     else {
720     accept = (x <= cut);
721     }
722 ceballos 1.4
723 ceballos 1.17 return accept;
724 ceballos 1.4 }