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