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