ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronIDMod.cc
Revision: 1.26
Committed: Mon Jun 15 15:00:21 2009 UTC (15 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009c, Mit_009b
Changes since 1.25: +5 -1 lines
Log Message:
Added proper fwd defs plus split up complilation of MitAna/DataTree LinkDefs.

File Contents

# User Rev Content
1 loizides 1.26 // $Id: ElectronIDMod.cc,v 1.25 2009/06/02 05:30:44 loizides Exp $
2 loizides 1.1
3     #include "MitPhysics/Mods/interface/ElectronIDMod.h"
4 loizides 1.26 #include "MitAna/DataTree/interface/StableData.h"
5     #include "MitAna/DataTree/interface/ElectronCol.h"
6     #include "MitAna/DataTree/interface/VertexCol.h"
7     #include "MitAna/DataTree/interface/DecayParticleCol.h"
8 loizides 1.5 #include "MitPhysics/Init/interface/ModNames.h"
9 loizides 1.1
10     using namespace mithep;
11    
12     ClassImp(mithep::ElectronIDMod)
13    
14     //--------------------------------------------------------------------------------------------------
15 loizides 1.5 ElectronIDMod::ElectronIDMod(const char *name, const char *title) :
16 loizides 1.1 BaseMod(name,title),
17 loizides 1.5 fElectronBranchName(Names::gkElectronBrn),
18 ceballos 1.12 fConversionBranchName(Names::gkMvfConversionBrn),
19 loizides 1.5 fGoodElectronsName(ModNames::gkGoodElectronsName),
20 ceballos 1.12 fVertexName(string("PrimaryVertexesBeamSpot").c_str()),
21 loizides 1.1 fElectronIDType("Tight"),
22 ceballos 1.8 fElectronIsoType("TrackJuraSliding"),
23 loizides 1.1 fElectronPtMin(10),
24     fIDLikelihoodCut(0.9),
25     fTrackIsolationCut(5.0),
26     fCaloIsolationCut(5.0),
27 loizides 1.5 fEcalJuraIsoCut(5.0),
28     fHcalIsolationCut(5.0),
29 loizides 1.14 fApplyConvFilter(kTRUE),
30 ceballos 1.18 fApplyD0Cut(kTRUE),
31 loizides 1.14 fD0Cut(0.025),
32 loizides 1.25 fReverseIsoCut(kFALSE),
33     fReverseD0Cut(kFALSE),
34 loizides 1.5 fElIdType(kIdUndef),
35 ceballos 1.12 fElIsoType(kIsoUndef),
36 loizides 1.14 fElectrons(0),
37     fConversions(0),
38 loizides 1.25 fVertices(0)
39 loizides 1.1 {
40     // Constructor.
41     }
42    
43     //--------------------------------------------------------------------------------------------------
44     void ElectronIDMod::Process()
45     {
46     // Process entries of the tree.
47    
48 loizides 1.23 LoadEventObject(fElectronBranchName, fElectrons);
49 loizides 1.1
50 loizides 1.6 ElectronOArr *GoodElectrons = new ElectronOArr;
51     GoodElectrons->SetName(fGoodElectronsName);
52 loizides 1.1
53 ceballos 1.18 for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
54 loizides 1.5 const Electron *e = fElectrons->At(i);
55 loizides 1.1
56 loizides 1.5 if (e->Pt() <= fElectronPtMin)
57     continue;
58 loizides 1.1
59 loizides 1.5 Bool_t idcut = kFALSE;
60     switch (fElIdType) {
61     case kTight:
62     idcut = e->PassTightID();
63     break;
64     case kLoose:
65     idcut = e->PassLooseID();
66     break;
67     case kLikelihood:
68     idcut = (e->IDLikelihood() > fIDLikelihoodCut);
69     break;
70 loizides 1.11 case kNoId:
71     idcut = kTRUE;
72     break;
73 loizides 1.5 case kCustomId:
74     default:
75     break;
76 loizides 1.1 }
77    
78 loizides 1.5 if (!idcut)
79     continue;
80    
81     Bool_t isocut = kFALSE;
82     switch (fElIsoType) {
83     case kTrackCalo:
84     isocut = (e->TrackIsolation() < fTrackIsolationCut) &&
85     (e->CaloIsolation() < fCaloIsolationCut);
86     break;
87     case kTrackJura:
88     isocut = (e->TrackIsolation() < fTrackIsolationCut) &&
89     (e->EcalJurassicIsolation() < fEcalJuraIsoCut) &&
90     (e->HcalIsolation() < fHcalIsolationCut);
91     break;
92     case kTrackJuraSliding:
93 ceballos 1.18 {
94 loizides 1.5 Double_t totalIso = e->TrackIsolation() + e->EcalJurassicIsolation() - 1.5;
95 ceballos 1.12 if ((totalIso < (e->Pt()-10.0)*5.0/15.0 && e->Pt() <= 25) ||
96     (totalIso < 5.0 && e->Pt() > 25) ||
97 ceballos 1.7 totalIso <= 0)
98 loizides 1.5 isocut = kTRUE;
99 ceballos 1.24
100     if (fReverseIsoCut == kTRUE &&
101     isocut == kFALSE && totalIso < 10)
102     isocut = kTRUE;
103     else if(fReverseIsoCut == kTRUE)
104     isocut = kFALSE;
105 loizides 1.5 }
106     break;
107     case kNoIso:
108     isocut = kTRUE;
109     break;
110     case kCustomIso:
111     default:
112     break;
113 loizides 1.1 }
114    
115 ceballos 1.24 if (isocut == kFALSE)
116 loizides 1.5 continue;
117    
118 loizides 1.14 // apply conversion filter
119 ceballos 1.12 Bool_t isGoodConversion = kFALSE;
120 loizides 1.14 if (fApplyConvFilter) {
121 ceballos 1.12 LoadBranch(fConversionBranchName);
122     for (UInt_t ifc=0; ifc<fConversions->GetEntries(); ifc++) {
123    
124     Bool_t ConversionMatchFound = kFALSE;
125     for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
126     const Track *trk = dynamic_cast<const ChargedParticle*>
127     (fConversions->At(ifc)->Daughter(d))->Trk();
128 ceballos 1.13 if (e->GsfTrk() == trk) {
129 ceballos 1.12 ConversionMatchFound = kTRUE;
130     break;
131     }
132     }
133    
134     // if match between the e-track and one of the conversion legs
135     if (ConversionMatchFound == kTRUE){
136 ceballos 1.19 isGoodConversion = (fConversions->At(ifc)->Prob() > 0.0005) &&
137 ceballos 1.12 (fConversions->At(ifc)->Lxy() > 0) &&
138     (fConversions->At(ifc)->Lz() > 0);
139    
140     if (isGoodConversion == kTRUE) {
141     for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
142     const Track *trk = dynamic_cast<const ChargedParticle*>
143     (fConversions->At(ifc)->Daughter(d))->Trk();
144    
145     if (trk) {
146 ceballos 1.20 // These requirements are not used for the GSF track (d == 1)
147     if (!(trk->NHits() > 8 && trk->Prob() > 0.005) && d == 0)
148 ceballos 1.12 isGoodConversion = kFALSE;
149    
150     const StableData *sd = dynamic_cast<const StableData*>
151     (fConversions->At(ifc)->DaughterDat(d));
152     if (sd->NWrongHits() != 0)
153     isGoodConversion = kFALSE;
154    
155     } else {
156     isGoodConversion = kFALSE;
157     }
158     }
159     }
160     }
161    
162     if (isGoodConversion == kTRUE) break;
163    
164     } // loop over all conversions
165    
166     }
167     if (isGoodConversion == kTRUE) continue;
168    
169 ceballos 1.15 if (fApplyD0Cut) {
170 ceballos 1.24 Bool_t d0cut = kFALSE;
171 ceballos 1.15 LoadBranch(fVertexName);
172     // d0 cut
173     double d0_real = 99999;
174     for(uint i0 = 0; i0 < fVertices->GetEntries(); i0++) {
175     double pD0 = e->GsfTrk()->D0Corrected(*fVertices->At(i0));
176     if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
177     }
178 ceballos 1.24 if(d0_real < fD0Cut) d0cut = kTRUE;
179    
180     if (fReverseD0Cut == kTRUE &&
181     d0cut == kFALSE && d0_real < 0.05)
182     d0cut = kTRUE;
183     else if(fReverseD0Cut == kTRUE)
184     d0cut = kFALSE;
185    
186     if (d0cut == kFALSE)
187     continue;
188 ceballos 1.12 }
189    
190 loizides 1.5 // add good electron
191 ceballos 1.12 GoodElectrons->Add(e);
192 loizides 1.5 }
193 loizides 1.1
194 loizides 1.9 // sort according to pt
195     GoodElectrons->Sort();
196    
197 loizides 1.5 // add to event for other modules to use
198 loizides 1.6 AddObjThisEvt(GoodElectrons);
199 loizides 1.1 }
200    
201     //--------------------------------------------------------------------------------------------------
202     void ElectronIDMod::SlaveBegin()
203     {
204     // Run startup code on the computer (slave) doing the actual analysis. Here,
205 loizides 1.5 // we just request the electron collection branch.
206 loizides 1.1
207 loizides 1.23 ReqEventObject(fElectronBranchName, fElectrons, kTRUE);
208 loizides 1.17
209 ceballos 1.16 if (fApplyConvFilter)
210 loizides 1.23 ReqEventObject(fConversionBranchName, fConversions, kTRUE);
211 loizides 1.17
212 ceballos 1.15 if (fApplyD0Cut)
213 loizides 1.23 ReqEventObject(fVertexName, fVertices, kTRUE);
214 loizides 1.1
215 loizides 1.5 if (fElectronIDType.CompareTo("Tight") == 0)
216     fElIdType = kTight;
217     else if (fElectronIDType.CompareTo("Loose") == 0)
218     fElIdType = kLoose;
219     else if (fElectronIDType.CompareTo("Likelihood") == 0)
220     fElIdType = kLikelihood;
221 loizides 1.10 else if (fElectronIDType.CompareTo("NoId") == 0)
222     fElIdType = kNoId;
223 loizides 1.5 else if (fElectronIDType.CompareTo("Custom") == 0) {
224     fElIdType = kCustomId;
225     SendError(kWarning, "SlaveBegin",
226     "Custom electron identification is not yet implemented.");
227     } else {
228     SendError(kAbortAnalysis, "SlaveBegin",
229     "The specified electron identification %s is not defined.",
230     fElectronIDType.Data());
231     return;
232     }
233    
234     if (fElectronIsoType.CompareTo("TrackCalo") == 0 )
235     fElIsoType = kTrackCalo;
236     else if (fElectronIsoType.CompareTo("TrackJura") == 0)
237     fElIsoType = kTrackJura;
238     else if(fElectronIsoType.CompareTo("TrackJuraSliding") == 0)
239     fElIsoType = kTrackJuraSliding;
240     else if (fElectronIsoType.CompareTo("NoIso") == 0 )
241     fElIsoType = kNoIso;
242     else if (fElectronIsoType.CompareTo("Custom") == 0 ) {
243     fElIsoType = kCustomIso;
244     SendError(kWarning, "SlaveBegin",
245     "Custom electron isolation is not yet implemented.");
246     } else {
247     SendError(kAbortAnalysis, "SlaveBegin",
248     "The specified electron isolation %s is not defined.",
249     fElectronIsoType.Data());
250     return;
251     }
252 loizides 1.1 }