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