ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronIDMod.cc
Revision: 1.99
Committed: Fri Jul 22 14:36:29 2011 UTC (13 years, 9 months ago) by sixie
Content type: text/plain
Branch: MAIN
Changes since 1.98: +11 -3 lines
Log Message:
update VBTF80 and re-organizeisolation code

File Contents

# User Rev Content
1 sixie 1.99 // $Id: ElectronIDMod.cc,v 1.98 2011/06/21 06:15:57 ceballos 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 ceballos 1.80 if(fElIsoType == ElectronTools::kTrackJuraSliding) {
314     LoadEventObject(fPileupEnergyDensityName, fPileupEnergyDensity);
315     }
316 ceballos 1.76 fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
317 loizides 1.1
318 bendavid 1.62 //get trigger object collection if trigger matching is enabled
319     const TriggerObjectCol *trigObjs = 0;
320     if (fApplyTriggerMatching) {
321     trigObjs = GetHLTObjects(fTrigObjectsName);
322     }
323    
324 loizides 1.6 ElectronOArr *GoodElectrons = new ElectronOArr;
325     GoodElectrons->SetName(fGoodElectronsName);
326 loizides 1.1
327 ceballos 1.18 for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
328 loizides 1.5 const Electron *e = fElectrons->At(i);
329 loizides 1.1
330 ceballos 1.66 if (e->SCluster() == 0)
331     continue;
332    
333 ceballos 1.65 if (e->Pt() < fElectronPtMin)
334 loizides 1.5 continue;
335 loizides 1.1
336 dkralph 1.73 if (e->SCluster()->Et() < fElectronEtMin)
337 bendavid 1.67 continue;
338    
339 ceballos 1.65 if (e->AbsEta() > fElectronEtaMax)
340 ceballos 1.64 continue;
341    
342 bendavid 1.67 if (fApplyEcalFiducial && ( (e->SCluster()->AbsEta()>1.4442 && e->SCluster()->AbsEta()<1.5666) || e->SCluster()->AbsEta()>2.5 )) {
343     continue;
344     }
345    
346     if (fApplyEcalSeeded && !e->IsEcalDriven()) {
347     continue;
348     }
349    
350 bendavid 1.62 //apply trigger matching
351     Bool_t matchTrigger = fApplyTriggerMatching && ElectronTools::PassTriggerMatching(e,trigObjs);
352     if (fApplyTriggerMatching && !matchTrigger)
353     continue;
354    
355 sixie 1.55 //apply ECAL spike removal
356 sixie 1.56 Bool_t spikecut = ElectronTools::PassSpikeRemovalFilter(e);
357 sixie 1.57 if (fApplySpikeRemoval && !spikecut)
358 sixie 1.55 continue;
359    
360 sixie 1.42 //apply id cut
361     Bool_t idcut = PassIDCut(e, fElIdType);
362 loizides 1.5 if (!idcut)
363     continue;
364    
365 sixie 1.42 //apply Isolation Cut
366 ceballos 1.80 Double_t Rho = 0.0;
367     if(fElIsoType == ElectronTools::kTrackJuraSliding) {
368     Rho = fPileupEnergyDensity->At(0)->Rho();
369     }
370     Bool_t isocut = PassIsolationCut(e, fElIsoType, fTracks, fVertices->At(0), Rho);
371 sixie 1.42 if (!isocut)
372 loizides 1.5 continue;
373    
374 ceballos 1.60 // apply conversion filters
375     Bool_t passConvVetoType1 = kFALSE;
376     if (fApplyConvFilterType1) {
377 sixie 1.42 LoadEventObject(fConversionBranchName, fConversions);
378 ceballos 1.60 passConvVetoType1 = ElectronTools::PassConversionFilter(e, fConversions,
379 bendavid 1.82 fBeamSpot->At(0), 0, 1e-6, 2.0, kTRUE, kFALSE);
380 ceballos 1.12 }
381 ceballos 1.60 else {
382     passConvVetoType1 = kTRUE;
383     }
384    
385     if (passConvVetoType1 == kFALSE) continue;
386    
387     Bool_t passConvVetoType2 = kFALSE;
388     if (fApplyConvFilterType2) {
389     passConvVetoType2 = TMath::Abs(e->ConvPartnerDCotTheta()) >= 0.02 ||
390     TMath::Abs(e->ConvPartnerDist()) >= 0.02;
391     }
392     else {
393     passConvVetoType2 = kTRUE;
394     }
395 sixie 1.42
396 ceballos 1.60 if (passConvVetoType2 == kFALSE) continue;
397 ceballos 1.72
398 ceballos 1.60 // apply NExpectedHitsInner Cut
399 ceballos 1.98 if(fInvertNExpectedHitsInnerCut == kFALSE && fNExpectedHitsInnerCut < 999 &&
400 ceballos 1.69 e->CorrectedNExpectedHitsInner() > fNExpectedHitsInnerCut) continue;
401 ceballos 1.60
402 ceballos 1.98 // apply NExpectedHitsInner inverted Cut
403     if(fInvertNExpectedHitsInnerCut == kTRUE && fNExpectedHitsInnerCut < 999 &&
404     e->CorrectedNExpectedHitsInner() <= fNExpectedHitsInnerCut) continue;
405    
406 sixie 1.42 // apply d0 cut
407 ceballos 1.15 if (fApplyD0Cut) {
408 ceballos 1.81 Bool_t passD0cut = kTRUE;
409     if(fWhichVertex >= -1) passD0cut = ElectronTools::PassD0Cut(e, fVertices, fD0Cut, fWhichVertex);
410     else passD0cut = ElectronTools::PassD0Cut(e, fBeamSpot, fD0Cut);
411 sixie 1.42 if (!passD0cut)
412 ceballos 1.24 continue;
413 ceballos 1.12 }
414    
415 ceballos 1.81 // apply dz cut
416     if (fApplyDZCut) {
417 ceballos 1.83 Bool_t passDZcut = ElectronTools::PassDZCut(e, fVertices, fDZCut, fWhichVertex);
418 ceballos 1.81 if (!passDZcut)
419     continue;
420     }
421    
422 ceballos 1.59 // apply charge filter
423 sixie 1.42 if(fChargeFilter == kTRUE) {
424 sixie 1.56 Bool_t passChargeFilter = ElectronTools::PassChargeFilter(e);
425 sixie 1.42 if (!passChargeFilter) continue;
426 ceballos 1.45 }
427    
428 ceballos 1.63 // apply full combined id, using Tight cuts
429 ceballos 1.59 if(fCombinedIdCut == kTRUE) {
430 ceballos 1.68 fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
431 ceballos 1.59 LoadEventObject(fConversionBranchName, fConversions);
432 ceballos 1.63 Int_t result = ElectronTools::PassTightId(e, *&fVertices, fConversions, 2);
433 ceballos 1.59 if(result != 15) continue;
434     }
435    
436 loizides 1.5 // add good electron
437 ceballos 1.12 GoodElectrons->Add(e);
438 loizides 1.5 }
439 loizides 1.1
440 loizides 1.9 // sort according to pt
441     GoodElectrons->Sort();
442    
443 loizides 1.5 // add to event for other modules to use
444 loizides 1.6 AddObjThisEvt(GoodElectrons);
445 loizides 1.1 }
446    
447     //--------------------------------------------------------------------------------------------------
448     void ElectronIDMod::SlaveBegin()
449     {
450     // Run startup code on the computer (slave) doing the actual analysis. Here,
451 loizides 1.5 // we just request the electron collection branch.
452 loizides 1.1
453 ceballos 1.76 // In this case we cannot have a branch
454     if (fElectronIsoType.CompareTo("PFIsoNoL") != 0 ) {
455     ReqEventObject(fElectronBranchName, fElectrons,fElectronsFromBranch);
456     }
457     ReqEventObject(fBeamSpotName, fBeamSpot, kTRUE);
458     ReqEventObject(fTrackName, fTracks, kTRUE);
459     ReqEventObject(fPFCandidatesName, fPFCandidates, kTRUE);
460 ceballos 1.80 if (fElectronIsoType.CompareTo("TrackJuraSliding") == 0 ) {
461     ReqEventObject(fPileupEnergyDensityName, fPileupEnergyDensity, kTRUE);
462     }
463 loizides 1.17
464 ceballos 1.59 if(fCombinedIdCut == kTRUE) {
465 ceballos 1.60 fElectronIDType = "NoId";
466     fElectronIsoType = "NoIso";
467     fApplyConvFilterType1 = kFALSE;
468     fApplyConvFilterType2 = kFALSE;
469     fApplyD0Cut = kFALSE;
470 ceballos 1.81 fApplyDZCut = kFALSE;
471 ceballos 1.59 }
472    
473 ceballos 1.60 if (fApplyConvFilterType1 || fCombinedIdCut == kTRUE)
474 loizides 1.23 ReqEventObject(fConversionBranchName, fConversions, kTRUE);
475 loizides 1.17
476 sixie 1.42 Setup();
477     }
478    
479     //--------------------------------------------------------------------------------------------------
480     void ElectronIDMod::Setup()
481     {
482     // Set all options properly before execution.
483    
484 loizides 1.5 if (fElectronIDType.CompareTo("Tight") == 0)
485 sixie 1.56 fElIdType = ElectronTools::kTight;
486 loizides 1.5 else if (fElectronIDType.CompareTo("Loose") == 0)
487 sixie 1.56 fElIdType = ElectronTools::kLoose;
488 sixie 1.93 else if (fElectronIDType.CompareTo("Likelihood") == 0) {
489     if (!fLH) { cout << "Error: Likelihood not initialized.\n"; assert(0); }
490 sixie 1.56 fElIdType = ElectronTools::kLikelihood;
491 sixie 1.93 } else if (fElectronIDType.CompareTo("NoId") == 0)
492 sixie 1.56 fElIdType = ElectronTools::kNoId;
493 sixie 1.42 else if (fElectronIDType.CompareTo("ZeeId") == 0)
494 sixie 1.56 fElIdType = ElectronTools::kZeeId;
495 sixie 1.51 else if (fElectronIDType.CompareTo("CustomLoose") == 0)
496 sixie 1.56 fElIdType = ElectronTools::kCustomIdLoose;
497 sixie 1.51 else if (fElectronIDType.CompareTo("CustomTight") == 0)
498 sixie 1.56 fElIdType = ElectronTools::kCustomIdTight;
499 ceballos 1.86 else if (fElectronIDType.CompareTo("VBTFWorkingPointFakeableId") == 0)
500     fElIdType = ElectronTools::kVBTFWorkingPointFakeableId;
501 sixie 1.55 else if (fElectronIDType.CompareTo("VBTFWorkingPoint95Id") == 0)
502 sixie 1.56 fElIdType = ElectronTools::kVBTFWorkingPoint95Id;
503 sixie 1.51 else if (fElectronIDType.CompareTo("VBTFWorkingPoint90Id") == 0)
504 sixie 1.56 fElIdType = ElectronTools::kVBTFWorkingPoint90Id;
505 sixie 1.51 else if (fElectronIDType.CompareTo("VBTFWorkingPoint80Id") == 0)
506 sixie 1.56 fElIdType = ElectronTools::kVBTFWorkingPoint80Id;
507 ceballos 1.83 else if (fElectronIDType.CompareTo("VBTFWorkingPointLowPtId") == 0)
508     fElIdType = ElectronTools::kVBTFWorkingPointLowPtId;
509 ceballos 1.60 else if (fElectronIDType.CompareTo("VBTFWorkingPoint85Id") == 0)
510     fElIdType = ElectronTools::kVBTFWorkingPoint85Id;
511 sixie 1.51 else if (fElectronIDType.CompareTo("VBTFWorkingPoint70Id") == 0)
512 sixie 1.56 fElIdType = ElectronTools::kVBTFWorkingPoint70Id;
513 sixie 1.51
514 peveraer 1.29 else {
515 loizides 1.5 SendError(kAbortAnalysis, "SlaveBegin",
516     "The specified electron identification %s is not defined.",
517     fElectronIDType.Data());
518     return;
519     }
520 sixie 1.51
521 loizides 1.5 if (fElectronIsoType.CompareTo("TrackCalo") == 0 )
522 sixie 1.56 fElIsoType = ElectronTools::kTrackCalo;
523 loizides 1.5 else if (fElectronIsoType.CompareTo("TrackJura") == 0)
524 sixie 1.56 fElIsoType = ElectronTools::kTrackJura;
525 ceballos 1.49 else if(fElectronIsoType.CompareTo("TrackJuraCombined") == 0)
526 sixie 1.56 fElIsoType = ElectronTools::kTrackJuraCombined;
527 loizides 1.5 else if(fElectronIsoType.CompareTo("TrackJuraSliding") == 0)
528 sixie 1.56 fElIsoType = ElectronTools::kTrackJuraSliding;
529 ceballos 1.80 else if(fElectronIsoType.CompareTo("TrackJuraSlidingNoCorrection") == 0)
530     fElIsoType = ElectronTools::kTrackJuraSlidingNoCorrection;
531 sixie 1.99 else if(fElectronIsoType.CompareTo("CombinedRelativeConeAreaCorrected") == 0)
532     fElIsoType = ElectronTools::kCombinedRelativeConeAreaCorrected;
533 ceballos 1.76 else if (fElectronIsoType.CompareTo("PFIso") == 0 )
534     fElIsoType = ElectronTools::kPFIso;
535     else if (fElectronIsoType.CompareTo("PFIsoNoL") == 0 )
536     fElIsoType = ElectronTools::kPFIsoNoL;
537 loizides 1.5 else if (fElectronIsoType.CompareTo("NoIso") == 0 )
538 sixie 1.56 fElIsoType = ElectronTools::kNoIso;
539 sixie 1.42 else if (fElectronIsoType.CompareTo("ZeeIso") == 0 )
540 sixie 1.56 fElIsoType = ElectronTools::kZeeIso;
541 sixie 1.55 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint95Iso") == 0 )
542 sixie 1.56 fElIsoType = ElectronTools::kVBTFWorkingPoint95Iso;
543 sixie 1.51 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint90Iso") == 0 )
544 sixie 1.56 fElIsoType = ElectronTools::kVBTFWorkingPoint90Iso;
545 ceballos 1.60 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint85Iso") == 0 )
546     fElIsoType = ElectronTools::kVBTFWorkingPoint85Iso;
547 sixie 1.51 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint80Iso") == 0 )
548 sixie 1.56 fElIsoType = ElectronTools::kVBTFWorkingPoint80Iso;
549 sixie 1.51 else if (fElectronIsoType.CompareTo("VBTFWorkingPoint70Iso") == 0 )
550 sixie 1.56 fElIsoType = ElectronTools::kVBTFWorkingPoint70Iso;
551 loizides 1.5 else if (fElectronIsoType.CompareTo("Custom") == 0 ) {
552 sixie 1.56 fElIsoType = ElectronTools::kCustomIso;
553 loizides 1.5 SendError(kWarning, "SlaveBegin",
554     "Custom electron isolation is not yet implemented.");
555     } else {
556     SendError(kAbortAnalysis, "SlaveBegin",
557     "The specified electron isolation %s is not defined.",
558     fElectronIsoType.Data());
559     return;
560     }
561 sixie 1.42
562 loizides 1.30
563     }
564 ceballos 1.77
565     //--------------------------------------------------------------------------------------------------
566     void ElectronIDMod::Terminate()
567     {
568     // Run finishing code on the computer (slave) that did the analysis
569     }