1 |
loizides |
1.23 |
// $Id: MuonIDMod.cc,v 1.22 2009/06/01 17:31:38 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 |
loizides |
1.15 |
fVertexName("PrimaryVertexesBeamSpot"),
|
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 |
|
|
LoadEventObject(fVertexName, fVertices);
|
47 |
loizides |
1.1 |
|
48 |
loizides |
1.7 |
MuonOArr *CleanMuons = new MuonOArr;
|
49 |
|
|
CleanMuons->SetName(fCleanMuonsName);
|
50 |
loizides |
1.1 |
|
51 |
|
|
for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
|
52 |
loizides |
1.8 |
const Muon *mu = fMuons->At(i);
|
53 |
loizides |
1.6 |
|
54 |
|
|
Bool_t pass = kFALSE;
|
55 |
loizides |
1.19 |
Double_t pt = 0; // make sure pt is taken from the correct track!
|
56 |
loizides |
1.6 |
switch (fMuClassType) {
|
57 |
|
|
case kAll:
|
58 |
|
|
pass = kTRUE;
|
59 |
loizides |
1.19 |
if (mu->HasTrk())
|
60 |
|
|
pt = mu->Pt();
|
61 |
loizides |
1.6 |
break;
|
62 |
|
|
case kGlobal:
|
63 |
loizides |
1.19 |
pass = mu->HasGlobalTrk();
|
64 |
loizides |
1.6 |
if (pass)
|
65 |
|
|
pt = mu->GlobalTrk()->Pt();
|
66 |
|
|
break;
|
67 |
|
|
case kSta:
|
68 |
loizides |
1.19 |
pass = mu->HasStandaloneTrk();
|
69 |
loizides |
1.6 |
if (pass)
|
70 |
|
|
pt = mu->StandaloneTrk()->Pt();
|
71 |
|
|
break;
|
72 |
|
|
case kTrackerOnly:
|
73 |
loizides |
1.19 |
pass = mu->HasTrackerTrk();
|
74 |
loizides |
1.6 |
if (pass)
|
75 |
|
|
pt = mu->TrackerTrk()->Pt();
|
76 |
|
|
break;
|
77 |
|
|
default:
|
78 |
|
|
break;
|
79 |
ceballos |
1.5 |
}
|
80 |
loizides |
1.6 |
|
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 |
loizides |
1.18 |
case kNoId:
|
98 |
|
|
idpass = kTRUE;
|
99 |
|
|
break;
|
100 |
loizides |
1.6 |
default:
|
101 |
|
|
break;
|
102 |
ceballos |
1.4 |
}
|
103 |
loizides |
1.6 |
|
104 |
|
|
if (!idpass)
|
105 |
|
|
continue;
|
106 |
|
|
|
107 |
ceballos |
1.22 |
Bool_t isocut = kFALSE;
|
108 |
loizides |
1.6 |
switch (fMuIsoType) {
|
109 |
|
|
case kTrackCalo:
|
110 |
ceballos |
1.22 |
isocut = (mu->IsoR03SumPt() < fTrackIsolationCut) &&
|
111 |
loizides |
1.6 |
(mu->IsoR03EmEt() + mu->IsoR03HadEt() < fCaloIsolationCut);
|
112 |
|
|
break;
|
113 |
|
|
case kTrackCaloCombined:
|
114 |
ceballos |
1.22 |
isocut = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() +
|
115 |
loizides |
1.6 |
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 |
loizides |
1.19 |
if ((totalIso < (pt-10.0)*5.0/15.0 && pt <= 25) ||
|
123 |
ceballos |
1.9 |
(totalIso < 5.0 && mu->Pt() > 25) ||
|
124 |
|
|
totalIso <= 0)
|
125 |
ceballos |
1.22 |
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 |
loizides |
1.6 |
break;
|
134 |
loizides |
1.13 |
case kNoIso:
|
135 |
ceballos |
1.22 |
isocut = kTRUE;
|
136 |
loizides |
1.13 |
break;
|
137 |
loizides |
1.6 |
case kCustomIso:
|
138 |
|
|
default:
|
139 |
|
|
break;
|
140 |
ceballos |
1.4 |
}
|
141 |
ceballos |
1.3 |
|
142 |
ceballos |
1.22 |
if (isocut == kFALSE)
|
143 |
loizides |
1.6 |
continue;
|
144 |
|
|
|
145 |
loizides |
1.21 |
if (fApplyD0Cut) {
|
146 |
ceballos |
1.22 |
Bool_t d0cut = kFALSE;
|
147 |
loizides |
1.21 |
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 |
ceballos |
1.22 |
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 |
loizides |
1.21 |
continue;
|
166 |
ceballos |
1.14 |
}
|
167 |
|
|
|
168 |
loizides |
1.6 |
// add good muon
|
169 |
|
|
CleanMuons->Add(mu);
|
170 |
loizides |
1.1 |
}
|
171 |
|
|
|
172 |
loizides |
1.10 |
// sort according to pt
|
173 |
|
|
CleanMuons->Sort();
|
174 |
|
|
|
175 |
loizides |
1.6 |
// add objects for other modules to use
|
176 |
loizides |
1.7 |
AddObjThisEvt(CleanMuons);
|
177 |
loizides |
1.1 |
}
|
178 |
|
|
|
179 |
|
|
//--------------------------------------------------------------------------------------------------
|
180 |
|
|
void MuonIDMod::SlaveBegin()
|
181 |
|
|
{
|
182 |
|
|
// Run startup code on the computer (slave) doing the actual analysis. Here,
|
183 |
loizides |
1.6 |
// we just request the muon collection branch.
|
184 |
|
|
|
185 |
loizides |
1.21 |
ReqEventObject(fMuonBranchName, fMuons, kTRUE);
|
186 |
|
|
|
187 |
|
|
if (fApplyD0Cut)
|
188 |
|
|
ReqEventObject(fVertexName, fVertices, kTRUE);
|
189 |
loizides |
1.1 |
|
190 |
loizides |
1.6 |
fMuonTools = new MuonTools;
|
191 |
loizides |
1.1 |
|
192 |
loizides |
1.6 |
if (fMuonIDType.CompareTo("Tight") == 0)
|
193 |
|
|
fMuIDType = kTight;
|
194 |
|
|
else if (fMuonIDType.CompareTo("Loose") == 0)
|
195 |
|
|
fMuIDType = kLoose;
|
196 |
loizides |
1.12 |
else if (fMuonIDType.CompareTo("NoId") == 0)
|
197 |
|
|
fMuIDType = kNoId;
|
198 |
loizides |
1.6 |
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 |
loizides |
1.1 |
|
209 |
loizides |
1.6 |
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 |
loizides |
1.1 |
|
228 |
loizides |
1.6 |
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 |
loizides |
1.1 |
}
|