ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MuonIDMod.cc
Revision: 1.32
Committed: Thu Aug 19 14:37:17 2010 UTC (14 years, 8 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.31: +12 -5 lines
Log Message:
fixing flaws for weird data events

File Contents

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