ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MuonIDMod.cc
Revision: 1.23
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.22: +3 -1 lines
Log Message:
Added proper fwd defs plus split up complilation of MitAna/DataTree LinkDefs.

File Contents

# Content
1 // $Id: MuonIDMod.cc,v 1.22 2009/06/01 17:31:38 ceballos Exp $
2
3 #include "MitPhysics/Mods/interface/MuonIDMod.h"
4 #include "MitCommon/MathTools/interface/MathUtils.h"
5 #include "MitAna/DataTree/interface/MuonCol.h"
6 #include "MitAna/DataTree/interface/VertexCol.h"
7 #include "MitPhysics/Init/interface/ModNames.h"
8
9 using namespace mithep;
10
11 ClassImp(mithep::MuonIDMod)
12
13 //--------------------------------------------------------------------------------------------------
14 MuonIDMod::MuonIDMod(const char *name, const char *title) :
15 BaseMod(name,title),
16 fMuonBranchName(Names::gkMuonBrn),
17 fCleanMuonsName(ModNames::gkCleanMuonsName),
18 fVertexName("PrimaryVertexesBeamSpot"),
19 fMuonIDType("Loose"),
20 fMuonIsoType("TrackCaloSliding"),
21 fMuonClassType("Global"),
22 fTrackIsolationCut(3.0),
23 fCaloIsolationCut(3.0),
24 fCombIsolationCut(5.0),
25 fMuonPtMin(10),
26 fApplyD0Cut(kTRUE),
27 fD0Cut(0.025),
28 fReverseIsoCut(kFALSE),
29 fReverseD0Cut(kFALSE),
30 fMuIDType(kIdUndef),
31 fMuIsoType(kIsoUndef),
32 fMuClassType(kClassUndef),
33 fMuons(0),
34 fVertices(0),
35 fMuonTools(0)
36 {
37 // Constructor.
38 }
39
40 //--------------------------------------------------------------------------------------------------
41 void MuonIDMod::Process()
42 {
43 // Process entries of the tree.
44
45 LoadEventObject(fMuonBranchName, fMuons);
46 LoadEventObject(fVertexName, fVertices);
47
48 MuonOArr *CleanMuons = new MuonOArr;
49 CleanMuons->SetName(fCleanMuonsName);
50
51 for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
52 const Muon *mu = fMuons->At(i);
53
54 Bool_t pass = kFALSE;
55 Double_t pt = 0; // make sure pt is taken from the correct track!
56 switch (fMuClassType) {
57 case kAll:
58 pass = kTRUE;
59 if (mu->HasTrk())
60 pt = mu->Pt();
61 break;
62 case kGlobal:
63 pass = mu->HasGlobalTrk();
64 if (pass)
65 pt = mu->GlobalTrk()->Pt();
66 break;
67 case kSta:
68 pass = mu->HasStandaloneTrk();
69 if (pass)
70 pt = mu->StandaloneTrk()->Pt();
71 break;
72 case kTrackerOnly:
73 pass = mu->HasTrackerTrk();
74 if (pass)
75 pt = mu->TrackerTrk()->Pt();
76 break;
77 default:
78 break;
79 }
80
81 if (!pass)
82 continue;
83
84 if (pt <= fMuonPtMin)
85 continue;
86
87 Bool_t idpass = kFALSE;
88 switch (fMuIDType) {
89 case kLoose:
90 idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationLoose) &&
91 fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityLoose);
92 break;
93 case kTight:
94 idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationTight) &&
95 fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityTight);
96 break;
97 case kNoId:
98 idpass = kTRUE;
99 break;
100 default:
101 break;
102 }
103
104 if (!idpass)
105 continue;
106
107 Bool_t isocut = kFALSE;
108 switch (fMuIsoType) {
109 case kTrackCalo:
110 isocut = (mu->IsoR03SumPt() < fTrackIsolationCut) &&
111 (mu->IsoR03EmEt() + mu->IsoR03HadEt() < fCaloIsolationCut);
112 break;
113 case kTrackCaloCombined:
114 isocut = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() +
115 1.0 * mu->IsoR03HadEt() < fCombIsolationCut);
116 break;
117 case kTrackCaloSliding:
118 {
119 Double_t totalIso = 1.0 * mu->IsoR03SumPt() +
120 1.0 * mu->IsoR03EmEt() +
121 1.0 * mu->IsoR03HadEt();
122 if ((totalIso < (pt-10.0)*5.0/15.0 && pt <= 25) ||
123 (totalIso < 5.0 && mu->Pt() > 25) ||
124 totalIso <= 0)
125 isocut = kTRUE;
126
127 if (fReverseIsoCut == kTRUE &&
128 isocut == kFALSE && totalIso < 10)
129 isocut = kTRUE;
130 else if(fReverseIsoCut == kTRUE)
131 isocut = kFALSE;
132 }
133 break;
134 case kNoIso:
135 isocut = kTRUE;
136 break;
137 case kCustomIso:
138 default:
139 break;
140 }
141
142 if (isocut == kFALSE)
143 continue;
144
145 if (fApplyD0Cut) {
146 Bool_t d0cut = kFALSE;
147 const Track *mt = mu->BestTrk();
148 if (!mt)
149 continue;
150 Double_t d0_real = 1e30;
151 for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
152 Double_t pD0 = mt->D0Corrected(*fVertices->At(i0));
153 if(TMath::Abs(pD0) < TMath::Abs(d0_real))
154 d0_real = TMath::Abs(pD0);
155 }
156 if(d0_real < fD0Cut) d0cut = kTRUE;
157
158 if (fReverseD0Cut == kTRUE &&
159 d0cut == kFALSE && d0_real < 0.05)
160 d0cut = kTRUE;
161 else if(fReverseD0Cut == kTRUE)
162 d0cut = kFALSE;
163
164 if (d0cut == kFALSE)
165 continue;
166 }
167
168 // add good muon
169 CleanMuons->Add(mu);
170 }
171
172 // sort according to pt
173 CleanMuons->Sort();
174
175 // add objects for other modules to use
176 AddObjThisEvt(CleanMuons);
177 }
178
179 //--------------------------------------------------------------------------------------------------
180 void MuonIDMod::SlaveBegin()
181 {
182 // Run startup code on the computer (slave) doing the actual analysis. Here,
183 // we just request the muon collection branch.
184
185 ReqEventObject(fMuonBranchName, fMuons, kTRUE);
186
187 if (fApplyD0Cut)
188 ReqEventObject(fVertexName, fVertices, kTRUE);
189
190 fMuonTools = new MuonTools;
191
192 if (fMuonIDType.CompareTo("Tight") == 0)
193 fMuIDType = kTight;
194 else if (fMuonIDType.CompareTo("Loose") == 0)
195 fMuIDType = kLoose;
196 else if (fMuonIDType.CompareTo("NoId") == 0)
197 fMuIDType = kNoId;
198 else if (fMuonIDType.CompareTo("Custom") == 0) {
199 fMuIDType = kCustomId;
200 SendError(kWarning, "SlaveBegin",
201 "Custom muon identification is not yet implemented.");
202 } else {
203 SendError(kAbortAnalysis, "SlaveBegin",
204 "The specified muon identification %s is not defined.",
205 fMuonIDType.Data());
206 return;
207 }
208
209 if (fMuonIsoType.CompareTo("TrackCalo") == 0)
210 fMuIsoType = kTrackCalo;
211 else if (fMuonIsoType.CompareTo("TrackCaloCombined") == 0)
212 fMuIsoType = kTrackCaloCombined;
213 else if (fMuonIsoType.CompareTo("TrackCaloSliding") == 0)
214 fMuIsoType = kTrackCaloSliding;
215 else if (fMuonIsoType.CompareTo("NoIso") == 0)
216 fMuIsoType = kNoIso;
217 else if (fMuonIsoType.CompareTo("Custom") == 0) {
218 fMuIsoType = kCustomIso;
219 SendError(kWarning, "SlaveBegin",
220 "Custom muon isolation is not yet implemented.");
221 } else {
222 SendError(kAbortAnalysis, "SlaveBegin",
223 "The specified muon isolation %s is not defined.",
224 fMuonIsoType.Data());
225 return;
226 }
227
228 if (fMuonClassType.CompareTo("All") == 0)
229 fMuClassType = kAll;
230 else if (fMuonClassType.CompareTo("Global") == 0)
231 fMuClassType = kGlobal;
232 else if (fMuonClassType.CompareTo("Standalone") == 0)
233 fMuClassType = kSta;
234 else if (fMuonClassType.CompareTo("TrackerOnly") == 0)
235 fMuClassType = kTrackerOnly;
236 else {
237 SendError(kAbortAnalysis, "SlaveBegin",
238 "The specified muon class %s is not defined.",
239 fMuonClassType.Data());
240 return;
241 }
242 }