ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MuonIDMod.cc
Revision: 1.33
Committed: Sun Aug 22 11:17:42 2010 UTC (14 years, 8 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_014e, Mit_014d
Changes since 1.32: +1 -3 lines
Log Message:
small clean up

File Contents

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