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