ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronIDMod.cc
Revision: 1.97
Committed: Tue Jun 14 11:08:36 2011 UTC (13 years, 10 months ago) by fabstoec
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_023, Mit_022a, Mit_022
Changes since 1.96: +8 -5 lines
Log Message:
fixed CombIso default value

File Contents

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