ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MuonIDMod.cc
Revision: 1.27
Committed: Thu Sep 3 13:31:35 2009 UTC (15 years, 8 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a
Changes since 1.26: +3 -4 lines
Log Message:
tighter muon id

File Contents

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