ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronIDMod.cc
Revision: 1.100
Committed: Fri Jul 22 15:45:37 2011 UTC (13 years, 9 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_024b, Mit_025pre1, Mit_024a, Mit_024
Changes since 1.99: +8 -5 lines
Log Message:
fix bug

File Contents

# User Rev Content
1 sixie 1.100 // $Id: ElectronIDMod.cc,v 1.99 2011/07/22 14:36:29 sixie Exp $
2 loizides 1.1
3     #include "MitPhysics/Mods/interface/ElectronIDMod.h"
4 loizides 1.26 #include "MitAna/DataTree/interface/StableData.h"
5 ceballos 1.76 #include "MitAna/DataTree/interface/ElectronFwd.h"
6     #include "MitAna/DataTree/interface/MuonFwd.h"
7 loizides 1.26 #include "MitAna/DataTree/interface/VertexCol.h"
8 bendavid 1.62 #include "MitAna/DataTree/interface/TriggerObjectCol.h"
9 loizides 1.26 #include "MitAna/DataTree/interface/DecayParticleCol.h"
10 loizides 1.5 #include "MitPhysics/Init/interface/ModNames.h"
11 loizides 1.1
12     using namespace mithep;
13    
14     ClassImp(mithep::ElectronIDMod)
15    
16     //--------------------------------------------------------------------------------------------------
17 loizides 1.5 ElectronIDMod::ElectronIDMod(const char *name, const char *title) :
18 loizides 1.1 BaseMod(name,title),
19 loizides 1.5 fElectronBranchName(Names::gkElectronBrn),
20 ceballos 1.12 fConversionBranchName(Names::gkMvfConversionBrn),
21 loizides 1.5 fGoodElectronsName(ModNames::gkGoodElectronsName),
22 ceballos 1.78 fNonIsolatedMuonsName("random"),
23     fNonIsolatedElectronsName("random"),
24 ceballos 1.68 fVertexName(ModNames::gkGoodVertexesName),
25 bendavid 1.75 fBeamSpotName(Names::gkBeamSpotBrn),
26 ceballos 1.76 fTrackName(Names::gkTrackBrn),
27     fPFCandidatesName(Names::gkPFCandidatesBrn),
28 ceballos 1.31 fElectronIDType("CustomTight"),
29 sixie 1.87 fElectronIsoType("PFIso"),
30 bendavid 1.62 fTrigObjectsName("HLTModTrigObjs"),
31 loizides 1.1 fElectronPtMin(10),
32 bendavid 1.67 fElectronEtMin(0.0),
33 ceballos 1.64 fElectronEtaMax(2.5),
34 ceballos 1.95 fIDLikelihoodCut(-999.0),
35 loizides 1.1 fTrackIsolationCut(5.0),
36     fCaloIsolationCut(5.0),
37 loizides 1.5 fEcalJuraIsoCut(5.0),
38     fHcalIsolationCut(5.0),
39 fabstoec 1.97 fCombIsolationCut(0.1),
40 sixie 1.99 fCombRelativeIsolationCut(0.10),
41 fabstoec 1.97 fPFIsolationCut(-1.0),
42 ceballos 1.60 fApplyConvFilterType1(kTRUE),
43     fApplyConvFilterType2(kFALSE),
44 bendavid 1.82 fNWrongHitsMax(0),
45 ceballos 1.60 fNExpectedHitsInnerCut(999),
46 ceballos 1.98 fInvertNExpectedHitsInnerCut(kFALSE),
47 ceballos 1.59 fCombinedIdCut(kFALSE),
48 sixie 1.58 fApplySpikeRemoval(kTRUE),
49 ceballos 1.18 fApplyD0Cut(kTRUE),
50 ceballos 1.81 fApplyDZCut(kTRUE),
51 ceballos 1.45 fChargeFilter(kTRUE),
52 ceballos 1.60 fD0Cut(0.020),
53 ceballos 1.89 fDZCut(0.10),
54 ceballos 1.81 fWhichVertex(-1),
55 bendavid 1.62 fApplyTriggerMatching(kFALSE),
56 bendavid 1.67 fApplyEcalSeeded(kFALSE),
57     fApplyCombinedIso(kTRUE),
58     fApplyEcalFiducial(kFALSE),
59 ceballos 1.76 fElectronsFromBranch(kTRUE),
60 sixie 1.56 fElIdType(ElectronTools::kIdUndef),
61     fElIsoType(ElectronTools::kIsoUndef),
62 loizides 1.14 fElectrons(0),
63     fConversions(0),
64 bendavid 1.75 fVertices(0),
65 ceballos 1.76 fBeamSpot(0),
66     fTracks(0),
67     fPFCandidates(0),
68 ceballos 1.78 fNonIsolatedMuons(0),
69     fNonIsolatedElectrons(0),
70 ceballos 1.80 fLH(0),
71     fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn),
72     fPileupEnergyDensity(0)
73 loizides 1.1 {
74     // Constructor.
75     }
76    
77     //--------------------------------------------------------------------------------------------------
78 ceballos 1.77 Bool_t ElectronIDMod::Likelihood(const Electron *ele) const
79     {
80     LikelihoodMeasurements measurements;
81     measurements.pt = ele->Pt();
82 ceballos 1.95 if (ele->IsEB() && ele->AbsEta()<1.0) measurements.subdet = 0;
83     else if (ele->IsEB()) measurements.subdet = 1;
84     else measurements.subdet = 2;
85 ceballos 1.77 measurements.deltaPhi = TMath::Abs(ele->DeltaPhiSuperClusterTrackAtVtx());
86     measurements.deltaEta = TMath::Abs(ele->DeltaEtaSuperClusterTrackAtVtx());
87     measurements.eSeedClusterOverPout = ele->ESeedClusterOverPout();
88     measurements.eSuperClusterOverP = ele->ESuperClusterOverP();
89     measurements.hadronicOverEm = ele->HadronicOverEm();
90     measurements.sigmaIEtaIEta = ele->CoviEtaiEta();
91     measurements.sigmaIPhiIPhi = TMath::Sqrt(ele->SCluster()->Seed()->CoviPhiiPhi());
92     measurements.fBrem = ele->FBrem();
93     measurements.nBremClusters = ele->NumberOfClusters() - 1;
94 ceballos 1.96 //measurements.OneOverEMinusOneOverP = (1.0 / ele->SCluster()->Energy()) - (1.0 / ele->BestTrk()->P());
95     measurements.OneOverEMinusOneOverP = (1.0 / ele->ESuperClusterOverP() / ele->BestTrk()->P()) - (1.0 / ele->BestTrk()->P());
96 ceballos 1.77 double likelihood = fLH->result(measurements);
97    
98 ceballos 1.95 double newLik = 0.0;
99     if (likelihood<=0) newLik = -20.0;
100     else if(likelihood>=1) newLik = 20.0;
101     else newLik = log(likelihood/(1.0-likelihood));
102    
103 ceballos 1.96 Bool_t isDebug = kFALSE;
104     if(isDebug == kTRUE){
105     printf("LIKELIHOOD: %f %d %f %f %f %f %f %f %f %f %d %f %f %f - %f %f\n",measurements.pt,measurements.subdet,
106     measurements.deltaPhi ,measurements.deltaEta ,measurements.eSeedClusterOverPout,
107     measurements.eSuperClusterOverP,measurements.hadronicOverEm,measurements.sigmaIEtaIEta,
108     measurements.sigmaIPhiIPhi ,measurements.fBrem ,measurements.nBremClusters,
109     measurements.OneOverEMinusOneOverP,ele->SCluster()->Energy(),ele->BestTrk()->P(),
110     likelihood,newLik);
111     }
112    
113 ceballos 1.95 double likCut = fIDLikelihoodCut;
114     if(likCut > -900){
115     if(ele->Pt() > 20){
116     if(ele->SCluster()->AbsEta() < 1.479){
117     if(ele->NumberOfClusters() - 1 == 0) likCut = -1.497;
118     else likCut = -1.521;
119     }
120     else {
121     if(ele->NumberOfClusters() - 1 == 0) likCut = -2.571;
122     else likCut = -0.657;
123     }
124     }
125     else {
126     if(ele->SCluster()->AbsEta() < 1.479){
127     if(ele->NumberOfClusters() - 1 == 0) likCut = 1.193;
128     else likCut = 1.345;
129     }
130     else {
131     if(ele->NumberOfClusters() - 1 == 0) likCut = 0.810;
132     else likCut = 3.021;
133     }
134     }
135     }
136     if (newLik > likCut) return kTRUE;
137 ceballos 1.77 return kFALSE;
138     }
139    
140     //--------------------------------------------------------------------------------------------------
141 sixie 1.56 Bool_t ElectronIDMod::PassIDCut(const Electron *ele, ElectronTools::EElIdType idType) const
142 sixie 1.42 {
143    
144     Bool_t idcut = kFALSE;
145     switch (idType) {
146 sixie 1.56 case ElectronTools::kTight:
147 sixie 1.42 idcut = ele->PassTightID();
148     break;
149 sixie 1.56 case ElectronTools::kLoose:
150 sixie 1.42 idcut = ele->PassLooseID();
151     break;
152 sixie 1.56 case ElectronTools::kLikelihood:
153 ceballos 1.77 idcut = Likelihood(ele);
154 sixie 1.42 break;
155 sixie 1.56 case ElectronTools::kNoId:
156 sixie 1.42 idcut = kTRUE;
157     break;
158 sixie 1.56 case ElectronTools::kCustomIdLoose:
159     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kCustomIdLoose);
160 sixie 1.42 break;
161 sixie 1.56 case ElectronTools::kCustomIdTight:
162     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kCustomIdTight);
163 sixie 1.42 break;
164 ceballos 1.86 case ElectronTools::kVBTFWorkingPointFakeableId:
165     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kVBTFWorkingPointFakeableId);
166     break;
167 sixie 1.56 case ElectronTools::kVBTFWorkingPoint95Id:
168     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kVBTFWorkingPoint95Id);
169 ceballos 1.54 break;
170 sixie 1.56 case ElectronTools::kVBTFWorkingPoint90Id:
171     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kVBTFWorkingPoint90Id);
172 ceballos 1.54 break;
173 ceballos 1.60 case ElectronTools::kVBTFWorkingPoint85Id:
174     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kVBTFWorkingPoint85Id);
175     break;
176 sixie 1.56 case ElectronTools::kVBTFWorkingPoint80Id:
177     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kVBTFWorkingPoint80Id);
178     break;
179 ceballos 1.83 case ElectronTools::kVBTFWorkingPointLowPtId:
180     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kVBTFWorkingPointLowPtId);
181 ceballos 1.81 break;
182 sixie 1.56 case ElectronTools::kVBTFWorkingPoint70Id:
183     idcut = ElectronTools::PassCustomID(ele, ElectronTools::kVBTFWorkingPoint70Id);
184 ceballos 1.54 break;
185 sixie 1.42 default:
186     break;
187     }
188    
189     return idcut;
190     }
191    
192     //--------------------------------------------------------------------------------------------------
193 ceballos 1.76 Bool_t ElectronIDMod::PassIsolationCut(const Electron *ele, ElectronTools::EElIsoType isoType,
194 ceballos 1.80 const TrackCol *tracks, const Vertex *vertex,
195     const Double_t rho) const
196 sixie 1.42 {
197    
198     Bool_t isocut = kFALSE;
199     switch (isoType) {
200 sixie 1.56 case ElectronTools::kTrackCalo:
201 sixie 1.42 isocut = (ele->TrackIsolationDr03() < fTrackIsolationCut) &&
202     (ele->CaloIsolation() < fCaloIsolationCut);
203     break;
204 sixie 1.56 case ElectronTools::kTrackJura:
205 ceballos 1.85 isocut = (ele->TrackIsolationDr03() < ele->Pt()*fTrackIsolationCut) &&
206     (ele->EcalRecHitIsoDr03() < ele->Pt()*fEcalJuraIsoCut) &&
207     (ele->HcalTowerSumEtDr03() < ele->Pt()*fHcalIsolationCut);
208 sixie 1.42 break;
209 sixie 1.56 case ElectronTools::kTrackJuraCombined:
210 ceballos 1.60 isocut = (ele->TrackIsolationDr03() + ele->EcalRecHitIsoDr03()
211 ceballos 1.49 - 1.5 < fCombIsolationCut);
212     break;
213 sixie 1.56 case ElectronTools::kTrackJuraSliding:
214 sixie 1.42 {
215 ceballos 1.80 Double_t totalIso = ele->TrackIsolationDr03() + TMath::Max(ele->EcalRecHitIsoDr03() + ele->HcalTowerSumEtDr03() - rho * TMath::Pi() * 0.3 * 0.3, 0.0);
216     if(ele->SCluster()->AbsEta() < 1.479) totalIso = ele->TrackIsolationDr03() + TMath::Max(TMath::Max(ele->EcalRecHitIsoDr03() - 1.0, 0.0) + ele->HcalTowerSumEtDr03() - rho * TMath::Pi() * 0.3 * 0.3, 0.0);
217 ceballos 1.79 if (totalIso < (ele->Pt()*fCombIsolationCut) )
218     isocut = kTRUE;
219     }
220     break;
221 ceballos 1.80 case ElectronTools::kTrackJuraSlidingNoCorrection:
222 ceballos 1.79 {
223 ceballos 1.80 Double_t totalIso = ele->TrackIsolationDr03() + (ele->EcalRecHitIsoDr03() + ele->HcalTowerSumEtDr03());
224     if(ele->SCluster()->AbsEta() < 1.479) totalIso = ele->TrackIsolationDr03() + (TMath::Max(ele->EcalRecHitIsoDr03() - 1.0, 0.0) + ele->HcalTowerSumEtDr03());
225 ceballos 1.76 if (totalIso < (ele->Pt()*fCombIsolationCut) )
226     isocut = kTRUE;
227     }
228     break;
229 sixie 1.99 case ElectronTools::kCombinedRelativeConeAreaCorrected:
230     {
231     Double_t totalIso = ele->TrackIsolationDr03() + ele->EcalRecHitIsoDr03() + ele->HcalTowerSumEtDr03() - rho * TMath::Pi() * 0.3 * 0.3;
232     if (totalIso < (ele->Pt()*fCombRelativeIsolationCut) )
233     isocut = kTRUE;
234     }
235     break;
236 ceballos 1.76 case ElectronTools::kPFIso:
237     {
238 sixie 1.87 Double_t pfIsoCutValue = 9999;
239 fabstoec 1.97 if(fPFIsolationCut > 0){
240     pfIsoCutValue = fPFIsolationCut;
241 ceballos 1.88 } else {
242 ceballos 1.91 if (ele->SCluster()->AbsEta() < 1.479) {
243 ceballos 1.88 if (ele->Pt() > 20) {
244 ceballos 1.92 pfIsoCutValue = 0.13;
245 ceballos 1.88 } else {
246 ceballos 1.92 pfIsoCutValue = 0.13;
247 ceballos 1.88 }
248 sixie 1.87 } else {
249 ceballos 1.91 if (ele->Pt() > 20) {
250     pfIsoCutValue = 0.09;
251     } else {
252     pfIsoCutValue = 0.09;
253     }
254     }
255 sixie 1.87 }
256 ceballos 1.89 Double_t totalIso = IsolationTools::PFElectronIsolation(ele, fPFCandidates, vertex, 0.1, 1.0, 0.4, 0.0);
257 sixie 1.87 if (totalIso < (ele->Pt()*pfIsoCutValue) )
258 ceballos 1.89 isocut = kTRUE;
259 ceballos 1.76 }
260     break;
261     case ElectronTools::kPFIsoNoL:
262     {
263     Double_t beta = IsolationTools::BetaE(tracks, ele, vertex, 0.0, 0.2, 0.3, 0.02);
264 ceballos 1.79 if(beta == 0) beta = 1.0;
265 sixie 1.87 Double_t totalIso = IsolationTools::PFElectronIsolation(ele, fPFCandidates, vertex, fNonIsolatedMuons, fNonIsolatedElectrons, 0.1, 1.0, 0.4, 0.0, 3, beta);
266 fabstoec 1.97 if (totalIso < (ele->Pt()*fPFIsolationCut) )
267 sixie 1.42 isocut = kTRUE;
268     }
269     break;
270 sixie 1.56 case ElectronTools::kVBTFWorkingPoint95Iso:
271 bendavid 1.67 isocut = ElectronTools::PassCustomIso(ele, ElectronTools::kVBTFWorkingPoint95Iso, fApplyCombinedIso);
272 sixie 1.56 break;
273     case ElectronTools::kVBTFWorkingPoint90Iso:
274 bendavid 1.67 isocut = ElectronTools::PassCustomIso(ele, ElectronTools::kVBTFWorkingPoint90Iso, fApplyCombinedIso);
275 sixie 1.51 break;
276 ceballos 1.60 case ElectronTools::kVBTFWorkingPoint85Iso:
277 bendavid 1.67 isocut = ElectronTools::PassCustomIso(ele, ElectronTools::kVBTFWorkingPoint85Iso, fApplyCombinedIso);
278 ceballos 1.60 break;
279 sixie 1.56 case ElectronTools::kVBTFWorkingPoint80Iso:
280 bendavid 1.67 isocut = ElectronTools::PassCustomIso(ele, ElectronTools::kVBTFWorkingPoint80Iso, fApplyCombinedIso);
281 sixie 1.51 break;
282 sixie 1.56 case ElectronTools::kVBTFWorkingPoint70Iso:
283 bendavid 1.67 isocut = ElectronTools::PassCustomIso(ele, ElectronTools::kVBTFWorkingPoint70Iso, fApplyCombinedIso);
284 sixie 1.51 break;
285 sixie 1.56 case ElectronTools::kNoIso:
286 sixie 1.42 isocut = kTRUE;
287     break;
288 sixie 1.56 case ElectronTools::kCustomIso:
289 sixie 1.42 default:
290     break;
291     }
292    
293     return isocut;
294     }
295    
296    
297     //--------------------------------------------------------------------------------------------------
298 loizides 1.1 void ElectronIDMod::Process()
299     {
300     // Process entries of the tree.
301    
302 ceballos 1.76 if(fElIsoType != ElectronTools::kPFIsoNoL) {
303     LoadEventObject(fElectronBranchName, fElectrons);
304     }
305     else {
306     fElectrons = GetObjThisEvt<ElectronOArr>(fElectronBranchName);
307 ceballos 1.78 fNonIsolatedMuons = GetObjThisEvt<MuonCol>(fNonIsolatedMuonsName);
308     fNonIsolatedElectrons = GetObjThisEvt<ElectronCol>(fNonIsolatedElectronsName);
309 ceballos 1.76 }
310 bendavid 1.75 LoadEventObject(fBeamSpotName, fBeamSpot);
311 ceballos 1.76 LoadEventObject(fTrackName, fTracks);
312     LoadEventObject(fPFCandidatesName, fPFCandidates);
313 sixie 1.100 if(fElIsoType == ElectronTools::kTrackJuraSliding ||
314     fElIsoType == ElectronTools::kCombinedRelativeConeAreaCorrected) {
315 ceballos 1.80 LoadEventObject(fPileupEnergyDensityName, fPileupEnergyDensity);
316     }
317 ceballos 1.76 fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
318 loizides 1.1
319 bendavid 1.62 //get trigger object collection if trigger matching is enabled
320     const TriggerObjectCol *trigObjs = 0;
321     if (fApplyTriggerMatching) {
322     trigObjs = GetHLTObjects(fTrigObjectsName);
323     }
324    
325 loizides 1.6 ElectronOArr *GoodElectrons = new ElectronOArr;
326     GoodElectrons->SetName(fGoodElectronsName);
327 loizides 1.1
328 ceballos 1.18 for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
329 loizides 1.5 const Electron *e = fElectrons->At(i);
330 loizides 1.1
331 ceballos 1.66 if (e->SCluster() == 0)
332     continue;
333    
334 ceballos 1.65 if (e->Pt() < fElectronPtMin)
335 loizides 1.5 continue;
336 loizides 1.1
337 dkralph 1.73 if (e->SCluster()->Et() < fElectronEtMin)
338 bendavid 1.67 continue;
339    
340 ceballos 1.65 if (e->AbsEta() > fElectronEtaMax)
341 ceballos 1.64 continue;
342    
343 bendavid 1.67 if (fApplyEcalFiducial && ( (e->SCluster()->AbsEta()>1.4442 && e->SCluster()->AbsEta()<1.5666) || e->SCluster()->AbsEta()>2.5 )) {
344     continue;
345     }
346    
347     if (fApplyEcalSeeded && !e->IsEcalDriven()) {
348     continue;
349     }
350    
351 bendavid 1.62 //apply trigger matching
352     Bool_t matchTrigger = fApplyTriggerMatching && ElectronTools::PassTriggerMatching(e,trigObjs);
353     if (fApplyTriggerMatching && !matchTrigger)
354     continue;
355    
356 sixie 1.55 //apply ECAL spike removal
357 sixie 1.56 Bool_t spikecut = ElectronTools::PassSpikeRemovalFilter(e);
358 sixie 1.57 if (fApplySpikeRemoval && !spikecut)
359 sixie 1.55 continue;
360    
361 sixie 1.42 //apply id cut
362     Bool_t idcut = PassIDCut(e, fElIdType);
363 loizides 1.5 if (!idcut)
364     continue;
365    
366 sixie 1.42 //apply Isolation Cut
367 ceballos 1.80 Double_t Rho = 0.0;
368 sixie 1.100 if( fElIsoType == ElectronTools::kTrackJuraSliding
369     || fElIsoType == ElectronTools::kCombinedRelativeConeAreaCorrected ) {
370     Rho = fPileupEnergyDensity->At(0)->Rho();
371 ceballos 1.80 }
372     Bool_t isocut = PassIsolationCut(e, fElIsoType, fTracks, fVertices->At(0), Rho);
373 sixie 1.42 if (!isocut)
374 loizides 1.5 continue;
375    
376 ceballos 1.60 // apply conversion filters
377     Bool_t passConvVetoType1 = kFALSE;
378     if (fApplyConvFilterType1) {
379 sixie 1.42 LoadEventObject(fConversionBranchName, fConversions);
380 ceballos 1.60 passConvVetoType1 = ElectronTools::PassConversionFilter(e, fConversions,
381 bendavid 1.82 fBeamSpot->At(0), 0, 1e-6, 2.0, kTRUE, kFALSE);
382 ceballos 1.12 }
383 ceballos 1.60 else {
384     passConvVetoType1 = kTRUE;
385     }
386    
387     if (passConvVetoType1 == kFALSE) continue;
388    
389     Bool_t passConvVetoType2 = kFALSE;
390     if (fApplyConvFilterType2) {
391     passConvVetoType2 = TMath::Abs(e->ConvPartnerDCotTheta()) >= 0.02 ||
392     TMath::Abs(e->ConvPartnerDist()) >= 0.02;
393     }
394     else {
395     passConvVetoType2 = kTRUE;
396     }
397 sixie 1.42
398 ceballos 1.60 if (passConvVetoType2 == kFALSE) continue;
399 ceballos 1.72
400 ceballos 1.60 // apply NExpectedHitsInner Cut
401 ceballos 1.98 if(fInvertNExpectedHitsInnerCut == kFALSE && fNExpectedHitsInnerCut < 999 &&
402 ceballos 1.69 e->CorrectedNExpectedHitsInner() > fNExpectedHitsInnerCut) continue;
403 ceballos 1.60
404 ceballos 1.98 // apply NExpectedHitsInner inverted Cut
405     if(fInvertNExpectedHitsInnerCut == kTRUE && fNExpectedHitsInnerCut < 999 &&
406     e->CorrectedNExpectedHitsInner() <= fNExpectedHitsInnerCut) continue;
407    
408 sixie 1.42 // apply d0 cut
409 ceballos 1.15 if (fApplyD0Cut) {
410 ceballos 1.81 Bool_t passD0cut = kTRUE;
411     if(fWhichVertex >= -1) passD0cut = ElectronTools::PassD0Cut(e, fVertices, fD0Cut, fWhichVertex);
412     else passD0cut = ElectronTools::PassD0Cut(e, fBeamSpot, fD0Cut);
413 sixie 1.42 if (!passD0cut)
414 ceballos 1.24 continue;
415 ceballos 1.12 }
416    
417 ceballos 1.81 // apply dz cut
418     if (fApplyDZCut) {
419 ceballos 1.83 Bool_t passDZcut = ElectronTools::PassDZCut(e, fVertices, fDZCut, fWhichVertex);
420 ceballos 1.81 if (!passDZcut)
421     continue;
422     }
423    
424 ceballos 1.59 // apply charge filter
425 sixie 1.42 if(fChargeFilter == kTRUE) {
426 sixie 1.56 Bool_t passChargeFilter = ElectronTools::PassChargeFilter(e);
427 sixie 1.42 if (!passChargeFilter) continue;
428 ceballos 1.45 }
429    
430 ceballos 1.63 // apply full combined id, using Tight cuts
431 ceballos 1.59 if(fCombinedIdCut == kTRUE) {
432 ceballos 1.68 fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
433 ceballos 1.59 LoadEventObject(fConversionBranchName, fConversions);
434 ceballos 1.63 Int_t result = ElectronTools::PassTightId(e, *&fVertices, fConversions, 2);
435 ceballos 1.59 if(result != 15) continue;
436     }
437    
438 loizides 1.5 // add good electron
439 ceballos 1.12 GoodElectrons->Add(e);
440 loizides 1.5 }
441 loizides 1.1
442 loizides 1.9 // sort according to pt
443     GoodElectrons->Sort();
444    
445 loizides 1.5 // add to event for other modules to use
446 loizides 1.6 AddObjThisEvt(GoodElectrons);
447 loizides 1.1 }
448    
449     //--------------------------------------------------------------------------------------------------
450     void ElectronIDMod::SlaveBegin()
451     {
452     // Run startup code on the computer (slave) doing the actual analysis. Here,
453 loizides 1.5 // we just request the electron collection branch.
454 loizides 1.1
455 ceballos 1.76 // In this case we cannot have a branch
456     if (fElectronIsoType.CompareTo("PFIsoNoL") != 0 ) {
457     ReqEventObject(fElectronBranchName, fElectrons,fElectronsFromBranch);
458     }
459     ReqEventObject(fBeamSpotName, fBeamSpot, kTRUE);
460     ReqEventObject(fTrackName, fTracks, kTRUE);
461     ReqEventObject(fPFCandidatesName, fPFCandidates, kTRUE);
462 sixie 1.100 if (fElectronIsoType.CompareTo("TrackJuraSliding") == 0
463     || fElectronIsoType.CompareTo("CombinedRelativeConeAreaCorrected") == 0 ) {
464 ceballos 1.80 ReqEventObject(fPileupEnergyDensityName, fPileupEnergyDensity, kTRUE);
465     }
466 loizides 1.17
467 ceballos 1.59 if(fCombinedIdCut == kTRUE) {
468 ceballos 1.60 fElectronIDType = "NoId";
469     fElectronIsoType = "NoIso";
470     fApplyConvFilterType1 = kFALSE;
471     fApplyConvFilterType2 = kFALSE;
472     fApplyD0Cut = kFALSE;
473 ceballos 1.81 fApplyDZCut = kFALSE;
474 ceballos 1.59 }
475    
476 ceballos 1.60 if (fApplyConvFilterType1 || fCombinedIdCut == kTRUE)
477 loizides 1.23 ReqEventObject(fConversionBranchName, fConversions, kTRUE);
478 loizides 1.17
479 sixie 1.42 Setup();
480     }
481    
482     //--------------------------------------------------------------------------------------------------
483     void ElectronIDMod::Setup()
484     {
485     // Set all options properly before execution.
486    
487 loizides 1.5 if (fElectronIDType.CompareTo("Tight") == 0)
488 sixie 1.56 fElIdType = ElectronTools::kTight;
489 loizides 1.5 else if (fElectronIDType.CompareTo("Loose") == 0)
490 sixie 1.56 fElIdType = ElectronTools::kLoose;
491 sixie 1.93 else if (fElectronIDType.CompareTo("Likelihood") == 0) {
492     if (!fLH) { cout << "Error: Likelihood not initialized.\n"; assert(0); }
493 sixie 1.56 fElIdType = ElectronTools::kLikelihood;
494 sixie 1.93 } else if (fElectronIDType.CompareTo("NoId") == 0)
495 sixie 1.56 fElIdType = ElectronTools::kNoId;
496 sixie 1.42 else if (fElectronIDType.CompareTo("ZeeId") == 0)
497 sixie 1.56 fElIdType = ElectronTools::kZeeId;
498 sixie 1.51 else if (fElectronIDType.CompareTo("CustomLoose") == 0)
499 sixie 1.56 fElIdType = ElectronTools::kCustomIdLoose;
500 sixie 1.51 else if (fElectronIDType.CompareTo("CustomTight") == 0)
501 sixie 1.56 fElIdType = ElectronTools::kCustomIdTight;
502 ceballos 1.86 else if (fElectronIDType.CompareTo("VBTFWorkingPointFakeableId") == 0)
503     fElIdType = ElectronTools::kVBTFWorkingPointFakeableId;
504 sixie 1.55 else if (fElectronIDType.CompareTo("VBTFWorkingPoint95Id") == 0)
505 sixie 1.56 fElIdType = ElectronTools::kVBTFWorkingPoint95Id;
506 sixie 1.51 else if (fElectronIDType.CompareTo("VBTFWorkingPoint90Id") == 0)
507 sixie 1.56 fElIdType = ElectronTools::kVBTFWorkingPoint90Id;
508 sixie 1.51 else if (fElectronIDType.CompareTo("VBTFWorkingPoint80Id") == 0)
509 sixie 1.56 fElIdType = ElectronTools::kVBTFWorkingPoint80Id;
510 ceballos 1.83 else if (fElectronIDType.CompareTo("VBTFWorkingPointLowPtId") == 0)
511     fElIdType = ElectronTools::kVBTFWorkingPointLowPtId;
512 ceballos 1.60 else if (fElectronIDType.CompareTo("VBTFWorkingPoint85Id") == 0)
513     fElIdType = ElectronTools::kVBTFWorkingPoint85Id;
514 sixie 1.51 else if (fElectronIDType.CompareTo("VBTFWorkingPoint70Id") == 0)
515 sixie 1.56 fElIdType = ElectronTools::kVBTFWorkingPoint70Id;
516 sixie 1.51
517 peveraer 1.29 else {
518 loizides 1.5 SendError(kAbortAnalysis, "SlaveBegin",
519     "The specified electron identification %s is not defined.",
520     fElectronIDType.Data());
521     return;
522     }
523 sixie 1.51
524 loizides 1.5 if (fElectronIsoType.CompareTo("TrackCalo") == 0 )
525 sixie 1.56 fElIsoType = ElectronTools::kTrackCalo;
526 loizides 1.5 else if (fElectronIsoType.CompareTo("TrackJura") == 0)
527 sixie 1.56 fElIsoType = ElectronTools::kTrackJura;
528 ceballos 1.49 else if(fElectronIsoType.CompareTo("TrackJuraCombined") == 0)
529 sixie 1.56 fElIsoType = ElectronTools::kTrackJuraCombined;
530 loizides 1.5 else if(fElectronIsoType.CompareTo("TrackJuraSliding") == 0)
531 sixie 1.56 fElIsoType = ElectronTools::kTrackJuraSliding;
532 ceballos 1.80 else if(fElectronIsoType.CompareTo("TrackJuraSlidingNoCorrection") == 0)
533     fElIsoType = ElectronTools::kTrackJuraSlidingNoCorrection;
534 sixie 1.99 else if(fElectronIsoType.CompareTo("CombinedRelativeConeAreaCorrected") == 0)
535     fElIsoType = ElectronTools::kCombinedRelativeConeAreaCorrected;
536 ceballos 1.76 else if (fElectronIsoType.CompareTo("PFIso") == 0 )
537     fElIsoType = ElectronTools::kPFIso;
538     else if (fElectronIsoType.CompareTo("PFIsoNoL") == 0 )
539     fElIsoType = ElectronTools::kPFIsoNoL;
540 loizides 1.5 else if (fElectronIsoType.CompareTo("NoIso") == 0 )
541 sixie 1.56 fElIsoType = ElectronTools::kNoIso;
542 sixie 1.42 else if (fElectronIsoType.CompareTo("ZeeIso") == 0 )
543 sixie 1.56 fElIsoType = ElectronTools::kZeeIso;
544 sixie 1.55 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint95Iso") == 0 )
545 sixie 1.56 fElIsoType = ElectronTools::kVBTFWorkingPoint95Iso;
546 sixie 1.51 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint90Iso") == 0 )
547 sixie 1.56 fElIsoType = ElectronTools::kVBTFWorkingPoint90Iso;
548 ceballos 1.60 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint85Iso") == 0 )
549     fElIsoType = ElectronTools::kVBTFWorkingPoint85Iso;
550 sixie 1.51 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint80Iso") == 0 )
551 sixie 1.56 fElIsoType = ElectronTools::kVBTFWorkingPoint80Iso;
552 sixie 1.51 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint70Iso") == 0 )
553 sixie 1.56 fElIsoType = ElectronTools::kVBTFWorkingPoint70Iso;
554 loizides 1.5 else if (fElectronIsoType.CompareTo("Custom") == 0 ) {
555 sixie 1.56 fElIsoType = ElectronTools::kCustomIso;
556 loizides 1.5 SendError(kWarning, "SlaveBegin",
557     "Custom electron isolation is not yet implemented.");
558     } else {
559     SendError(kAbortAnalysis, "SlaveBegin",
560     "The specified electron isolation %s is not defined.",
561     fElectronIsoType.Data());
562     return;
563     }
564 sixie 1.42
565 loizides 1.30
566     }
567 ceballos 1.77
568     //--------------------------------------------------------------------------------------------------
569     void ElectronIDMod::Terminate()
570     {
571     // Run finishing code on the computer (slave) that did the analysis
572     }