ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronIDMod.cc
Revision: 1.98
Committed: Tue Jun 21 06:15:57 2011 UTC (13 years, 10 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.97: +7 -2 lines
Log Message:
updated options

File Contents

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