ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronIDMod.cc
Revision: 1.101
Committed: Fri Sep 16 14:09:17 2011 UTC (13 years, 7 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.100: +13 -11 lines
Log Message:
fixing iso

File Contents

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