ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/FakeMods/src/GenFakeableObjsMod.cc
Revision: 1.14
Committed: Sun Jan 23 19:00:09 2011 UTC (14 years, 3 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_018
Changes since 1.13: +32 -175 lines
Log Message:
update denominator definitions. delete old obsolete definitions

File Contents

# User Rev Content
1 ceballos 1.13 // $Id: GenFakeableObjsMod.cc,v 1.12 2010/10/26 10:26:28 sixie Exp $
2 loizides 1.1
3     #include "MitPhysics/FakeMods/interface/GenFakeableObjsMod.h"
4 loizides 1.3 #include "MitCommon/MathTools/interface/MathUtils.h"
5 loizides 1.1 #include "MitAna/DataUtil/interface/Debug.h"
6 loizides 1.3 #include "MitAna/DataTree/interface/ElectronCol.h"
7     #include "MitAna/DataTree/interface/MuonCol.h"
8     #include "MitAna/DataTree/interface/SuperClusterCol.h"
9     #include "MitAna/DataTree/interface/TrackCol.h"
10     #include "MitAna/DataTree/interface/JetCol.h"
11     #include "MitAna/DataTree/interface/VertexCol.h"
12     #include "MitAna/DataTree/interface/DecayParticleCol.h"
13     #include "MitAna/DataTree/interface/StableData.h"
14 loizides 1.1 #include "MitPhysics/Init/interface/ModNames.h"
15     #include "MitPhysics/Utils/interface/IsolationTools.h"
16 ceballos 1.6 #include "MitPhysics/Mods/interface/ElectronIDMod.h"
17 loizides 1.1
18     using namespace mithep;
19    
20     ClassImp(mithep::GenFakeableObjsMod)
21    
22     //--------------------------------------------------------------------------------------------------
23     GenFakeableObjsMod::GenFakeableObjsMod(const char *name, const char *title) :
24     BaseMod(name,title),
25 ceballos 1.6
26     fApplyConvFilter(kTRUE),
27     fWrongHitsRequirement(kTRUE),
28     fApplyD0Cut(kTRUE),
29     fChargeFilter(kTRUE),
30 sixie 1.12 fD0Cut(0.02),
31     fCombIsolationCut(0.5),
32 ceballos 1.6 fTrackIsolationCut(-1.0),
33     fEcalIsolationCut(-1.0),
34     fHcalIsolationCut(-1.0),
35     fVetoTriggerJet(kFALSE),
36     fVetoGenLeptons(kTRUE),
37     fVetoCleanLeptons(kFALSE),
38 sixie 1.14 fElectronFOType("Iso"),
39 loizides 1.1 fMuonFOType("IsoTrack"),
40     fTriggerName("NotSpecified"),
41     fTriggerObjectsName("NotSpecified"),
42     fElectronBranchName(Names::gkElectronBrn),
43     fMuonBranchName(Names::gkMuonBrn),
44     fTrackBranchName(Names::gkTrackBrn),
45     fGsfTrackBranchName(Names::gkGsfTrackBrn),
46     fBarrelSuperClusterBranchName(Names::gkBarrelSuperClusterBrn),
47     fEndcapSuperClusterBranchName(Names::gkEndcapSuperClusterBrn),
48 ceballos 1.11 fVertexName(ModNames::gkGoodVertexesName),
49 loizides 1.1 fConversionBranchName(Names::gkMvfConversionBrn),
50     fGoodJetsName(ModNames::gkGoodJetsName),
51     fCleanElectronsName(ModNames::gkCleanElectronsName),
52     fCleanMuonsName(ModNames::gkCleanMuonsName),
53     fMCLeptonsName(ModNames::gkMCLeptonsName),
54     fMCTausName(ModNames::gkMCTausName),
55 phedex 1.2 fElFakeableObjsName(ModNames::gkElFakeableObjsName),
56     fMuFakeableObjsName(ModNames::gkMuFakeableObjsName),
57 loizides 1.1 fElFOType(kElFOUndef),
58     fMuFOType(kMuFOUndef),
59     fBarrelSuperClusters(0),
60     fEndcapSuperClusters(0),
61     fTracks(0),
62     fGsfTracks(0),
63     fVertices(0),
64     fConversions(0)
65     {
66     // Constructor.
67     }
68    
69     //--------------------------------------------------------------------------------------------------
70     void GenFakeableObjsMod::SlaveBegin()
71     {
72     // Run startup code on the computer (slave) doing the actual analysis. Here,
73     // we typically initialize histograms and other analysis objects and request
74     // branches. For this module, we request a branch of the MitTree.
75    
76     //------------------------------------------------------------------------------------------------
77     // Request the branches (no significant time safed by not doing this)
78     //------------------------------------------------------------------------------------------------
79     ReqBranch(fElectronBranchName, fElectrons);
80     ReqBranch(fMuonBranchName, fMuons);
81     ReqBranch(fTrackBranchName, fTracks);
82     ReqBranch(fGsfTrackBranchName, fGsfTracks);
83     ReqBranch(fBarrelSuperClusterBranchName, fBarrelSuperClusters);
84     ReqBranch(fEndcapSuperClusterBranchName, fEndcapSuperClusters);
85     ReqBranch(fConversionBranchName, fConversions);
86    
87 sixie 1.14 if (fElectronFOType.CompareTo("Iso") == 0)
88     fElFOType = kElFOIso;
89     else if (fElectronFOType.CompareTo("LooseIdLooseIso") == 0)
90     fElFOType = kElFOLooseIdLooseIso;
91 loizides 1.1 else {
92     SendError(kAbortAnalysis, "SlaveBegin",
93     "The specified electron fakeable object %s is not defined.",
94     fElectronFOType.Data());
95     return;
96     }
97    
98     if (fMuonFOType.CompareTo("IsoTrack") == 0)
99     fMuFOType = kMuFOIsoTrack;
100     else if (fMuonFOType.CompareTo("Global") == 0)
101     fMuFOType = kMuFOGlobal;
102     else if (fMuonFOType.CompareTo("TrackerMuon") == 0)
103     fMuFOType = kMuFOTrackerMuon;
104     else {
105     SendError(kAbortAnalysis, "SlaveBegin",
106     "The specified muon fakeable object %s is not defined.",
107     fMuonFOType.Data());
108     return;
109     }
110    
111 ceballos 1.9 electronID = new ElectronIDMod();
112 sixie 1.14 electronID->SetApplyConversionFilterType1(kFALSE);
113     electronID->SetApplyConversionFilterType1(fApplyConvFilter);
114 ceballos 1.9 electronID->SetWrongHitsRequirement(fWrongHitsRequirement);
115     electronID->SetApplyD0Cut(fApplyD0Cut);
116     electronID->SetChargeFilter(fChargeFilter);
117     electronID->SetD0Cut(fD0Cut);
118    
119 loizides 1.1 }
120    
121     //--------------------------------------------------------------------------------------------------
122     void GenFakeableObjsMod::Process()
123     {
124     // Process entries of the tree.
125     LoadBranch(fElectronBranchName);
126     LoadBranch(fMuonBranchName);
127     LoadBranch(fTrackBranchName);
128     LoadBranch(fGsfTrackBranchName);
129     LoadBranch(fBarrelSuperClusterBranchName);
130     LoadBranch(fEndcapSuperClusterBranchName);
131     LoadBranch(fConversionBranchName);
132    
133 ceballos 1.11 fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
134    
135 loizides 1.1 //Load Trigger Objects
136     const TriggerObjectCol *triggerObjects = GetHLTObjects(fTriggerObjectsName);
137     if (!triggerObjects && fVetoTriggerJet) {
138     cout << "Error: Could not load Trigger Object Collection with name "
139     << fTriggerObjectsName << endl;
140     }
141    
142     // get input clean object collections
143     mithep::ParticleOArr *CleanLeptons = dynamic_cast<mithep::ParticleOArr*>
144     (FindObjThisEvt(ModNames::gkMergedLeptonsName));
145     const ElectronCol *CleanElectrons = 0;
146     if (!fCleanElectronsName.IsNull())
147     CleanElectrons = GetObjThisEvt<ElectronCol>(fCleanElectronsName);
148     const MuonCol *CleanMuons = 0;
149     if (!fCleanMuonsName.IsNull())
150     CleanMuons = GetObjThisEvt<MuonCol>(fCleanMuonsName);
151     const JetCol *GoodJets = 0;
152     if (!fGoodJetsName.IsNull())
153     GoodJets = GetObjThisEvt<JetCol>(fGoodJetsName);
154    
155     //get input MC collections
156     const MCParticleCol *GenLeptons = 0;
157     if (!fMCLeptonsName.IsNull())
158     GenLeptons = GetObjThisEvt<MCParticleCol>(fMCLeptonsName);
159     const MCParticleCol *GenTaus = 0;
160     if (!fMCTausName.IsNull())
161     GenTaus = GetObjThisEvt<MCParticleCol>(fMCTausName);
162     ObjArray<MCParticle> *GenLeptonsAndTaus = new ObjArray<MCParticle>;
163     for (UInt_t i=0; i<GenLeptons->GetEntries(); i++)
164     GenLeptonsAndTaus->Add(GenLeptons->At(i));
165     for (UInt_t i=0; i<GenTaus->GetEntries(); i++)
166     GenLeptonsAndTaus->Add(GenTaus->At(i));
167    
168     //Combine Barrel and Endcap superclusters into the same ObjArray
169     ObjArray <SuperCluster> *SuperClusters = new ObjArray <SuperCluster>;
170     for (UInt_t i=0; i<fBarrelSuperClusters->GetEntries(); i++) {
171     SuperClusters->Add(fBarrelSuperClusters->At(i));
172     }
173     for (UInt_t i=0; i<fEndcapSuperClusters->GetEntries(); i++) {
174     SuperClusters->Add(fEndcapSuperClusters->At(i));
175     }
176    
177     //collections for duplicate removed electrons
178     ObjArray<Electron> *DuplicateRemovedElectrons = new ObjArray<Electron>;
179     std::vector<const Electron*> tmpDuplicateRemovedElectrons;
180    
181     // create final output collection
182 phedex 1.2 ElectronArr *ElFakeableObjs = new ElectronArr;
183     MuonArr *MuFakeableObjs = new MuonArr;
184 loizides 1.1
185    
186     //***********************************************************************************************
187     //First do duplicate electron removal
188     //***********************************************************************************************
189     for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
190 ceballos 1.6
191 sixie 1.14
192 loizides 1.1 const Electron *e = fElectrons->At(i);
193     Bool_t isElectronOverlap = kFALSE;
194    
195     for (UInt_t j=0; j<tmpDuplicateRemovedElectrons.size(); ++j) {
196 sixie 1.14 Double_t deltaR = MathUtils::DeltaR(tmpDuplicateRemovedElectrons[j]->Mom(), e->Mom());
197 loizides 1.1 if (e->SCluster() == tmpDuplicateRemovedElectrons[j]->SCluster() ||
198 sixie 1.12 e->GsfTrk() == tmpDuplicateRemovedElectrons[j]->GsfTrk()) {
199 loizides 1.1 isElectronOverlap = kTRUE;
200     }
201    
202    
203     if (isElectronOverlap) {
204     if (TMath::Abs(tmpDuplicateRemovedElectrons[j]->ESuperClusterOverP() - 1) >
205     TMath::Abs(e->ESuperClusterOverP() - 1)) {
206     tmpDuplicateRemovedElectrons[j] = e;
207     }
208     break;
209     }
210     }
211    
212     if (!isElectronOverlap) {
213     tmpDuplicateRemovedElectrons.push_back(e);
214     }
215     }
216     for (UInt_t i=0; i<tmpDuplicateRemovedElectrons.size(); ++i) {
217     DuplicateRemovedElectrons->Add(tmpDuplicateRemovedElectrons[i]);
218     }
219    
220     //***********************************************************************************************
221     //Fakeable Objects for Electron Fakes
222 sixie 1.14 //Reco electron with full isolation
223 loizides 1.1 //***********************************************************************************************
224 sixie 1.14 if (fElFOType == kElFOIso) {
225 ceballos 1.6
226 loizides 1.1 for (UInt_t i=0; i<DuplicateRemovedElectrons->GetEntries(); i++) {
227     const Electron *denominator = DuplicateRemovedElectrons->At(i);
228    
229     //Veto denominators matching to real electrons
230     Bool_t IsGenLepton = false;
231     for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
232     if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
233     GenLeptonsAndTaus->At(l)->Phi(),
234     GenLeptonsAndTaus->At(l)->Eta()) < 0.1) {
235     IsGenLepton = true;
236     }
237     }
238    
239     //Veto denominators matching to clean leptons
240     Bool_t IsCleanLepton = false;
241     for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
242     if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
243     CleanLeptons->At(l)->Phi(),
244     CleanLeptons->At(l)->Eta()) < 0.1) {
245     IsCleanLepton = true;
246     }
247     }
248    
249     //Veto on Trigger jet
250     Bool_t IsTriggerJet = false;
251     if (fVetoTriggerJet) {
252     for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
253 loizides 1.5 Double_t deltaR = MathUtils::DeltaR(denominator->Phi(),
254     denominator->Eta(),
255     triggerObjects->At(l)->Phi(),
256     triggerObjects->At(l)->Eta());
257 loizides 1.1 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
258     && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
259     && deltaR < 0.3
260     ) {
261     IsTriggerJet = true;
262     break;
263     }
264     }
265     }
266    
267 ceballos 1.6 const Electron *tmpEle = denominator;
268     //****************************************************************************************
269     // Isolation Cut
270     //****************************************************************************************
271     Double_t combIso =
272 sixie 1.12 denominator->TrackIsolationDr03() + TMath::Max(denominator->EcalRecHitIsoDr03() - 1.0, 0.0) + denominator->HcalTowerSumEtDr03();
273     if (fabs(denominator->Eta()) > 1.5) {
274     combIso = denominator->TrackIsolationDr03() + denominator->EcalRecHitIsoDr03() + denominator->HcalTowerSumEtDr03();
275     }
276 ceballos 1.6
277 sixie 1.14 Bool_t passIsolationCut = (combIso / denominator->Pt() < 0.1) ;
278 ceballos 1.6
279     //****************************************************************************************
280 loizides 1.1 // conversion filter
281 ceballos 1.6 //****************************************************************************************
282 sixie 1.14 Bool_t passConversionFilter = (TMath::Abs(denominator->ConvPartnerDCotTheta()) >= 0.02 ||
283     TMath::Abs(denominator->ConvPartnerDist()) >= 0.02);
284 loizides 1.1
285     //****************************************************************************************
286     // D0 Cut
287 loizides 1.5 //****************************************************************************************
288 ceballos 1.13 Bool_t passD0Cut = ElectronTools::PassD0Cut(tmpEle,fVertices, kTRUE);
289 ceballos 1.6
290 loizides 1.1 //****************************************************************************************
291 ceballos 1.6 // Make denominator object cuts
292 loizides 1.5 //****************************************************************************************
293 ceballos 1.6 if( denominator->Pt() > 10.0
294     && passIsolationCut
295     && (passConversionFilter || !fApplyConvFilter)
296     && (passD0Cut || !fApplyD0Cut)
297     && !(fVetoCleanLeptons && IsCleanLepton)
298 loizides 1.1 && !(fVetoGenLeptons && IsGenLepton)
299     && !(fVetoTriggerJet && IsTriggerJet)
300 ceballos 1.6 ) {
301 phedex 1.2 Electron *tmpElectron = ElFakeableObjs->AddNew();
302 loizides 1.1 tmpElectron->SetPtEtaPhi(denominator->Pt(), denominator->Eta(),denominator->Phi());
303     tmpElectron->SetGsfTrk(denominator->GsfTrk());
304     tmpElectron->SetSuperCluster(denominator->SCluster());
305 sixie 1.7 }
306 loizides 1.1 }
307 sixie 1.14 } else if (fElFOType == kElFOLooseIdLooseIso) {
308 loizides 1.1 for (UInt_t i=0; i<DuplicateRemovedElectrons->GetEntries(); i++) {
309     const Electron *denominator = DuplicateRemovedElectrons->At(i);
310 ceballos 1.6
311 loizides 1.1 //Veto denominators matching to real electrons
312     Bool_t IsGenLepton = false;
313     for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
314     if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
315     GenLeptonsAndTaus->At(l)->Phi(),
316     GenLeptonsAndTaus->At(l)->Eta()) < 0.1) {
317     IsGenLepton = true;
318     }
319     }
320    
321     //Veto denominators matching to clean leptons
322     Bool_t IsCleanLepton = false;
323     for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
324     if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
325     CleanLeptons->At(l)->Phi(),
326     CleanLeptons->At(l)->Eta()) < 0.1) {
327     IsCleanLepton = true;
328     }
329     }
330    
331     //Veto on Trigger jet
332     Bool_t IsTriggerJet = false;
333     if (fVetoTriggerJet) {
334     for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
335 loizides 1.5 Double_t deltaR = MathUtils::DeltaR(denominator->Phi(),
336     denominator->Eta(),
337     triggerObjects->At(l)->Phi(),
338     triggerObjects->At(l)->Eta());
339 loizides 1.1 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
340     && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
341     && deltaR < 0.3
342     ) {
343     IsTriggerJet = true;
344     break;
345     }
346     }
347     }
348    
349 ceballos 1.6 const Electron *tmpEle = denominator;
350     //****************************************************************************************
351 sixie 1.14 // Id Cuts
352     //****************************************************************************************
353     Bool_t passIdCut = ElectronTools::PassCustomID(denominator, ElectronTools::kVBTFWorkingPoint90Id);
354    
355    
356     //****************************************************************************************
357 ceballos 1.6 // Isolation Cut
358     //****************************************************************************************
359     Double_t combIso =
360 sixie 1.14 denominator->TrackIsolationDr03() + TMath::Max(denominator->EcalRecHitIsoDr03() - 1.0, 0.0) + denominator->HcalTowerSumEtDr03();
361     if (fabs(denominator->Eta()) > 1.5) {
362     combIso = denominator->TrackIsolationDr03() + denominator->EcalRecHitIsoDr03() + denominator->HcalTowerSumEtDr03();
363     }
364     Bool_t passIsolationCut = (combIso / denominator->Pt() < 0.3) ;
365    
366 loizides 1.1 //****************************************************************************************
367     // conversion filter
368 sixie 1.14 //****************************************************************************************
369     Bool_t passConversionFilter = (TMath::Abs(denominator->ConvPartnerDCotTheta()) >= 0.02 ||
370     TMath::Abs(denominator->ConvPartnerDist()) >= 0.02);
371    
372 loizides 1.1 //****************************************************************************************
373     // D0 Cut
374 loizides 1.5 //****************************************************************************************
375 ceballos 1.13 Bool_t passD0Cut = ElectronTools::PassD0Cut(tmpEle,fVertices, kTRUE);
376 ceballos 1.6
377     //****************************************************************************************
378     // Make denominator object cuts
379     //****************************************************************************************
380     if( denominator->Pt() > 10.0
381 sixie 1.14 && passIdCut
382 ceballos 1.6 && passIsolationCut
383     && (passConversionFilter || !fApplyConvFilter)
384     && (passD0Cut || !fApplyD0Cut)
385 loizides 1.1 && denominator->PassLooseID()
386 ceballos 1.6 && !(fVetoCleanLeptons && IsCleanLepton)
387 loizides 1.1 && !(fVetoGenLeptons && IsGenLepton)
388     && !(fVetoTriggerJet && IsTriggerJet)
389 ceballos 1.6 ) {
390 phedex 1.2 Electron *tmpElectron = ElFakeableObjs->AddNew();
391 loizides 1.1 tmpElectron->SetPtEtaPhi(denominator->Pt(), denominator->Eta(),denominator->Phi());
392     tmpElectron->SetGsfTrk(denominator->GsfTrk());
393     tmpElectron->SetSuperCluster(denominator->SCluster());
394     }
395     }
396     }
397    
398     //***********************************************************************************************
399     //Fakeable Objects for Muon Fakes
400     //***********************************************************************************************
401     if (fMuFOType == kMuFOIsoTrack) {
402     for (UInt_t i=0; i<fTracks->GetEntries(); i++) {
403     const Track *track = fTracks->At(i);
404     Double_t trackIsolation = IsolationTools::TrackIsolation(track, 0.4, 0.015, 1.0,
405     0.2, fTracks);
406     //Determine if muon fakeable object matches a gen lepton
407     Bool_t IsGenLepton = false;
408     for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
409     if (MathUtils::DeltaR(track->Phi(), track->Eta(),
410     GenLeptonsAndTaus->At(l)->Phi(),
411     GenLeptonsAndTaus->At(l)->Eta()) < 0.3) {
412     IsGenLepton = true;
413     }
414     }
415    
416     //Veto denominators matching to clean leptons
417     Bool_t IsCleanLepton = false;
418     for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
419     if (MathUtils::DeltaR(track->Phi(), track->Eta(),
420     CleanLeptons->At(l)->Phi(),
421     CleanLeptons->At(l)->Eta()) < 0.1) {
422     IsCleanLepton = true;
423     }
424     }
425    
426     //Veto on Trigger jet
427     Bool_t IsTriggerJet = false;
428     if (fVetoTriggerJet) {
429     for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
430     Double_t deltaR = MathUtils::DeltaR(track->Phi(), track->Eta(),
431     triggerObjects->At(l)->Phi(),
432     triggerObjects->At(l)->Eta());
433     if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
434     && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
435     && deltaR < 0.3
436     ) {
437     IsTriggerJet = true;
438     break;
439     }
440     }
441     }
442    
443     //****************************************************************************************
444     // D0 Cut
445     //****************************************************************************************
446     double d0Min = 99999;
447     for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
448     double pD0 = track->D0Corrected(*fVertices->At(i0));
449     if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
450     }
451    
452    
453     //define denominator cuts
454     if (track->Pt() > 10.0 && trackIsolation < 10.0
455     && d0Min < 0.025
456     && !(fVetoGenLeptons && IsGenLepton)
457     && !(fVetoCleanLeptons && IsCleanLepton)
458     && !(fVetoTriggerJet && IsTriggerJet)
459     ) {
460     //add to fakeable objects
461 phedex 1.2 Muon* tmpMuon = MuFakeableObjs->AddNew();
462 loizides 1.1 tmpMuon->SetTrackerTrk(track);
463     }
464     }
465     } else if (fMuFOType == kMuFOGlobal) {
466     for (UInt_t i=0; i<fMuons->GetEntries(); i++) {
467     const Muon *denominator = fMuons->At(i);
468     Double_t totalIsolation = denominator->IsoR03SumPt() + denominator->IsoR03EmEt() +
469     denominator->IsoR03HadEt();
470    
471     //Determine if muon fakeable object matches a gen lepton
472     Bool_t IsGenLepton = false;
473     for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
474     if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
475     GenLeptonsAndTaus->At(l)->Phi(),
476     GenLeptonsAndTaus->At(l)->Eta()) < 0.3) {
477     IsGenLepton = true;
478     }
479     }
480    
481     //Veto denominators matching to clean leptons
482     Bool_t IsCleanLepton = false;
483     for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
484     if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
485     CleanLeptons->At(l)->Phi(),
486     CleanLeptons->At(l)->Eta()) < 0.1) {
487     IsCleanLepton = true;
488     }
489     }
490    
491     //Veto on Trigger jet
492     Bool_t IsTriggerJet = false;
493     if (fVetoTriggerJet) {
494     for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
495 loizides 1.5 Double_t deltaR = MathUtils::DeltaR(denominator->Phi(),
496     denominator->Eta(),
497     triggerObjects->At(l)->Phi(),
498     triggerObjects->At(l)->Eta());
499 loizides 1.1 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
500     && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
501     && deltaR < 0.3
502     ) {
503     IsTriggerJet = true;
504     break;
505     }
506     }
507     }
508    
509     //****************************************************************************************
510     // D0 Cut
511 loizides 1.5 //****************************************************************************************
512 loizides 1.1 double d0Min = 99999;
513     for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
514     double pD0 = denominator->Trk()->D0Corrected(*fVertices->At(i0));
515     if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
516     }
517    
518     if (denominator->Pt() > 10.0 && totalIsolation < 10.0 && denominator->HasGlobalTrk()
519     && d0Min < 0.025
520     && !(fVetoGenLeptons && IsGenLepton)
521     && !(fVetoCleanLeptons && IsCleanLepton)
522     && !(fVetoTriggerJet && IsTriggerJet)
523     ) {
524 phedex 1.2 Muon* tmpMuon = MuFakeableObjs->AddNew();
525 loizides 1.1 tmpMuon->SetGlobalTrk(denominator->GlobalTrk());
526     tmpMuon->SetTrackerTrk(denominator->TrackerTrk());
527     }
528     }
529     } else if (fMuFOType == kMuFOTrackerMuon) {
530     for (UInt_t i=0; i<fMuons->GetEntries(); i++) {
531     const Muon *denominator = fMuons->At(i);
532 loizides 1.5 Double_t totalIsolation =
533     denominator->IsoR03SumPt() +
534     denominator->IsoR03EmEt() +
535     denominator->IsoR03HadEt();
536 loizides 1.1
537     //Determine if muon fakeable object matches a gen lepton
538     Bool_t IsGenLepton = false;
539     for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
540     if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
541     GenLeptonsAndTaus->At(l)->Phi(),
542     GenLeptonsAndTaus->At(l)->Eta()) < 0.3) {
543     IsGenLepton = true;
544     }
545     }
546    
547     //Veto denominators matching to clean leptons
548     Bool_t IsCleanLepton = false;
549     for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
550     if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
551     CleanLeptons->At(l)->Phi(),
552     CleanLeptons->At(l)->Eta()) < 0.1) {
553     IsCleanLepton = true;
554     }
555     }
556    
557     //Veto on Trigger jet
558     Bool_t IsTriggerJet = false;
559     if (fVetoTriggerJet) {
560     for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
561 loizides 1.5 Double_t deltaR = MathUtils::DeltaR(denominator->Phi(),
562     denominator->Eta(),
563     triggerObjects->At(l)->Phi(),
564     triggerObjects->At(l)->Eta());
565 loizides 1.1 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
566     && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
567     && deltaR < 0.3
568     ) {
569     IsTriggerJet = true;
570     break;
571     }
572     }
573     }
574    
575     //****************************************************************************************
576     // D0 Cut
577 loizides 1.5 //****************************************************************************************
578 loizides 1.1 double d0Min = 99999;
579     for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
580     double pD0 = denominator->Trk()->D0Corrected(*fVertices->At(i0));
581     if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
582     }
583    
584     if (denominator->Pt() > 10.0 && totalIsolation < 10.0 && denominator->HasTrackerTrk()
585     && d0Min < 0.025
586     && !(fVetoGenLeptons && IsGenLepton)
587     && !(fVetoCleanLeptons && IsCleanLepton)
588     && !(fVetoTriggerJet && IsTriggerJet)
589     ) {
590 phedex 1.2 Muon* tmpMuon = MuFakeableObjs->AddNew();
591 loizides 1.1 tmpMuon->SetTrackerTrk(denominator->TrackerTrk());
592     }
593     }
594     }
595    
596     //***********************************************************************************************
597     //Export the fakeable object collections for other modules to use
598     //***********************************************************************************************
599 phedex 1.2 ElFakeableObjs->SetName(fElFakeableObjsName);
600     AddObjThisEvt(ElFakeableObjs);
601     MuFakeableObjs->SetName(fMuFakeableObjsName);
602     AddObjThisEvt(MuFakeableObjs);
603 loizides 1.1
604     delete GenLeptonsAndTaus;
605     delete SuperClusters;
606     delete DuplicateRemovedElectrons;
607     }