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

# Content
1 // $Id: ElectronIDMod.cc,v 1.25 2009/06/02 05:30:44 loizides Exp $
2
3 #include "MitPhysics/Mods/interface/ElectronIDMod.h"
4 #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 #include "MitPhysics/Init/interface/ModNames.h"
9
10 using namespace mithep;
11
12 ClassImp(mithep::ElectronIDMod)
13
14 //--------------------------------------------------------------------------------------------------
15 ElectronIDMod::ElectronIDMod(const char *name, const char *title) :
16 BaseMod(name,title),
17 fElectronBranchName(Names::gkElectronBrn),
18 fConversionBranchName(Names::gkMvfConversionBrn),
19 fGoodElectronsName(ModNames::gkGoodElectronsName),
20 fVertexName(string("PrimaryVertexesBeamSpot").c_str()),
21 fElectronIDType("Tight"),
22 fElectronIsoType("TrackJuraSliding"),
23 fElectronPtMin(10),
24 fIDLikelihoodCut(0.9),
25 fTrackIsolationCut(5.0),
26 fCaloIsolationCut(5.0),
27 fEcalJuraIsoCut(5.0),
28 fHcalIsolationCut(5.0),
29 fApplyConvFilter(kTRUE),
30 fApplyD0Cut(kTRUE),
31 fD0Cut(0.025),
32 fReverseIsoCut(kFALSE),
33 fReverseD0Cut(kFALSE),
34 fElIdType(kIdUndef),
35 fElIsoType(kIsoUndef),
36 fElectrons(0),
37 fConversions(0),
38 fVertices(0)
39 {
40 // Constructor.
41 }
42
43 //--------------------------------------------------------------------------------------------------
44 void ElectronIDMod::Process()
45 {
46 // Process entries of the tree.
47
48 LoadEventObject(fElectronBranchName, fElectrons);
49
50 ElectronOArr *GoodElectrons = new ElectronOArr;
51 GoodElectrons->SetName(fGoodElectronsName);
52
53 for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
54 const Electron *e = fElectrons->At(i);
55
56 if (e->Pt() <= fElectronPtMin)
57 continue;
58
59 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 case kNoId:
71 idcut = kTRUE;
72 break;
73 case kCustomId:
74 default:
75 break;
76 }
77
78 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 {
94 Double_t totalIso = e->TrackIsolation() + e->EcalJurassicIsolation() - 1.5;
95 if ((totalIso < (e->Pt()-10.0)*5.0/15.0 && e->Pt() <= 25) ||
96 (totalIso < 5.0 && e->Pt() > 25) ||
97 totalIso <= 0)
98 isocut = kTRUE;
99
100 if (fReverseIsoCut == kTRUE &&
101 isocut == kFALSE && totalIso < 10)
102 isocut = kTRUE;
103 else if(fReverseIsoCut == kTRUE)
104 isocut = kFALSE;
105 }
106 break;
107 case kNoIso:
108 isocut = kTRUE;
109 break;
110 case kCustomIso:
111 default:
112 break;
113 }
114
115 if (isocut == kFALSE)
116 continue;
117
118 // apply conversion filter
119 Bool_t isGoodConversion = kFALSE;
120 if (fApplyConvFilter) {
121 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 if (e->GsfTrk() == trk) {
129 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 isGoodConversion = (fConversions->At(ifc)->Prob() > 0.0005) &&
137 (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 // These requirements are not used for the GSF track (d == 1)
147 if (!(trk->NHits() > 8 && trk->Prob() > 0.005) && d == 0)
148 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 if (fApplyD0Cut) {
170 Bool_t d0cut = kFALSE;
171 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 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 }
189
190 // add good electron
191 GoodElectrons->Add(e);
192 }
193
194 // sort according to pt
195 GoodElectrons->Sort();
196
197 // add to event for other modules to use
198 AddObjThisEvt(GoodElectrons);
199 }
200
201 //--------------------------------------------------------------------------------------------------
202 void ElectronIDMod::SlaveBegin()
203 {
204 // Run startup code on the computer (slave) doing the actual analysis. Here,
205 // we just request the electron collection branch.
206
207 ReqEventObject(fElectronBranchName, fElectrons, kTRUE);
208
209 if (fApplyConvFilter)
210 ReqEventObject(fConversionBranchName, fConversions, kTRUE);
211
212 if (fApplyD0Cut)
213 ReqEventObject(fVertexName, fVertices, kTRUE);
214
215 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 else if (fElectronIDType.CompareTo("NoId") == 0)
222 fElIdType = kNoId;
223 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 }