ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Muon.h
Revision: 1.21
Committed: Wed Dec 3 16:58:17 2008 UTC (16 years, 5 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.20: +4 -4 lines
Log Message:
Make add and set functions for referencing objects accept const pointers

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: Muon.h,v 1.20 2008/12/01 17:32:34 loizides Exp $
3 //
4 // Muon
5 //
6 // Details to be worked out... TODO by Phil
7 //
8 // Authors: J.Bendavid, C.Loizides, C.Paus, P.Harris
9 //--------------------------------------------------------------------------------------------------
10
11 #ifndef MITANA_DATATREE_MUON_H
12 #define MITANA_DATATREE_MUON_H
13
14 #include <TRef.h>
15 #include "MitAna/DataTree/interface/Track.h"
16 #include "MitAna/DataTree/interface/ChargedParticle.h"
17
18 namespace mithep {
19 class Muon : public ChargedParticle {
20 public:
21 Muon();
22 ~Muon() {}
23
24 enum EClassType {
25 kNone, //no track assigned
26 kGlobal, //"Global"
27 kTrackerOnly, //"TrackerOnly"
28 kSta, //"Standalone"
29 kAny //any "best" of the above
30 };
31
32 const Track *BestTrk() const;
33 const Track *GlobalTrk() const;
34 const Track *StandaloneTrk() const;
35 const Track *TrackerTrk() const;
36 const Track *Trk() const { return BestTrk(); }
37 Double_t IsoR03SumPt() const { return fIsoR03SumPt; }
38 Double_t IsoR03EmEt() const { return fIsoR03EmEt; }
39 Double_t IsoR03HadEt() const { return fIsoR03HadEt; }
40 Double_t IsoR03HoEt() const { return fIsoR03HoEt; }
41 Int_t IsoR03NTracks() const { return fIsoR03NTracks; }
42 Int_t IsoR03NJets() const { return fIsoR03NJets; }
43 Double_t IsoR05SumPt() const { return fIsoR05SumPt; }
44 Double_t IsoR05EmEt() const { return fIsoR05EmEt; }
45 Double_t IsoR05HadEt() const { return fIsoR05HadEt; }
46 Double_t IsoR05HoEt() const { return fIsoR05HoEt; }
47 Int_t IsoR05NTracks() const { return fIsoR05NTracks; }
48 Int_t IsoR05NJets() const { return fIsoR05NJets; }
49 Double_t EmEnergy() const { return fEmEnergy; }
50 Double_t HadEnergy() const { return fHadEnergy; }
51 Double_t HoEnergy() const { return fHoEnergy; }
52 Double_t EmS9Energy() const { return fEmS9Energy; }
53 Double_t HadS9Energy() const { return fHadS9Energy; }
54 Double_t HoS9Energy() const { return fHoS9Energy; }
55 Double_t Mass() const { return 105.658369e-3; }
56 Int_t NChambers() const { return fNTraversedChambers; }
57 Int_t NSegments() const { return fStationMask.NBitsSet(); }
58 Bool_t StationBit(Int_t bit) const { return fStationMask.TestBit(bit); }
59 Double_t GetDX(Int_t iStation) const;
60 Double_t GetDY(Int_t iStation) const;
61 Double_t GetPullX(Int_t iStation) const;
62 Double_t GetPullY(Int_t iStation) const;
63 Double_t GetTrackDist(Int_t iStation) const;
64 Double_t GetTrackDistErr(Int_t iStation) const;
65 Int_t GetNSegments(Int_t iStation) const;
66 Bool_t HasGlobalTrk() const { return fGlobalTrackRef.IsValid(); }
67 Bool_t HasStandaloneTrk() const { return fStandaloneTrackRef.IsValid(); }
68 Bool_t HasTrackerTrk() const { return fTrackerTrackRef.IsValid(); }
69 Bool_t Has(EClassType type) const;
70 EClassType Is() const;
71 Int_t LastHit() const;
72 Int_t LastStation(Double_t iMaxD, Double_t iMaxP) const;
73 Int_t LastStation(Int_t iMax=8) const;
74 Bool_t PromptTight(EClassType type) const;
75 Bool_t TMLastStation(Double_t iDYMin = 3., Double_t iPYMin = 3.,
76 Double_t iDXMin = 3., Double_t iPXMin = 3.,Int_t iN = 2) const;
77 Bool_t TMOneStation(Double_t iDYMin = 3., Double_t iPYMin = 3.,
78 Double_t iDXMin = 3., Double_t iPXMin = 3.,Int_t iN = 1) const;
79 void SetGlobalTrk(const Track *t) { fGlobalTrackRef = const_cast<Track*>(t); }
80 void SetStandaloneTrk(const Track *t) { fStandaloneTrackRef = const_cast<Track*>(t); }
81 void SetTrackerTrk(const Track *t) { fTrackerTrackRef = const_cast<Track*>(t); }
82 void SetIsoR03SumPt(Double_t isoR03SumPt) { fIsoR03SumPt = isoR03SumPt; }
83 void SetIsoR03EmEt(Double_t isoR03EmEt) { fIsoR03EmEt = isoR03EmEt; }
84 void SetIsoR03HadEt(Double_t isoR03HadEt) { fIsoR03HadEt = isoR03HadEt; }
85 void SetIsoR03HoEt(Double_t isoR03HoEt) { fIsoR03HoEt = isoR03HoEt; }
86 void SetIsoR03NTracks(Int_t isoR03NTracks) { fIsoR03NTracks = isoR03NTracks; }
87 void SetIsoR03NJets(Int_t isoR03NJets) { fIsoR03NJets = isoR03NJets; }
88 void SetIsoR05SumPt(Double_t isoR05SumPt) { fIsoR05SumPt = isoR05SumPt; }
89 void SetIsoR05EmEt(Double_t isoR05EmEt) { fIsoR05EmEt = isoR05EmEt; }
90 void SetIsoR05HadEt(Double_t isoR05HadEt) { fIsoR05HadEt = isoR05HadEt; }
91 void SetIsoR05HoEt(Double_t isoR05HoEt) { fIsoR05HoEt = isoR05HoEt; }
92 void SetIsoR05NTracks(Int_t isoR05NTracks) { fIsoR05NTracks = isoR05NTracks; }
93 void SetIsoR05NJets(Int_t isoR05NJets) { fIsoR05NJets = isoR05NJets; }
94 void SetEmEnergy(Double_t EmEnergy) { fEmEnergy = EmEnergy; }
95 void SetHadEnergy(Double_t HadEnergy) { fHadEnergy = HadEnergy; }
96 void SetHoEnergy(Double_t HoEnergy) { fHoEnergy = HoEnergy; }
97 void SetEmS9Energy(Double_t EmS9Energy) { fEmS9Energy = EmS9Energy; }
98 void SetHadS9Energy(Double_t HadS9Energy) { fHadS9Energy = HadS9Energy; }
99 void SetHoS9Energy(Double_t HoS9Energy) { fHoS9Energy = HoS9Energy; }
100 void SetNChambers(Int_t iNTraCh) { fNTraversedChambers = iNTraCh; }
101 void SetStationMask(UInt_t iStMask) { fStationMask.SetBits(iStMask); }
102 void SetDX(Int_t iStation, Double_t iDX);
103 void SetDY(Int_t iStation, Double_t iDY);
104 void SetPullX(Int_t iStation, Double_t iPullX);
105 void SetPullY(Int_t iStation, Double_t iPullY);
106 void SetTrackDist(Int_t iStation, Double_t iDist);
107 void SetTrackDistErr(Int_t iStation, Double_t iDistErr);
108 void SetNSegments(Int_t iStation, Int_t NSegments);
109
110 protected:
111 TRef fGlobalTrackRef; //global combined track reference
112 TRef fStandaloneTrackRef; //standalone muon track reference
113 TRef fTrackerTrackRef; //tracker track reference
114 Double32_t fIsoR03SumPt; //isolation size R=0.3 sum pt
115 Double32_t fIsoR03EmEt; //isolation size R=0.3 em trans energy
116 Double32_t fIsoR03HadEt; //isolation size R=0.3 had trans energy
117 Double32_t fIsoR03HoEt; //isolation size R=0.3 ho trans energy
118 Int_t fIsoR03NTracks; //isolation size R=0.3 number of tracks
119 Int_t fIsoR03NJets; //isolation size R=0.3 number of jets
120 Double32_t fIsoR05SumPt; //isolation size R=0.5 sum pt
121 Double32_t fIsoR05EmEt; //isolation size R=0.5 em trans energy
122 Double32_t fIsoR05HadEt; //isolation size R=0.5 had trans energy
123 Double32_t fIsoR05HoEt; //isolation size R=0.5 ho trans energy
124 Int_t fIsoR05NTracks; //isolation size R=0.5 number of tracks
125 Int_t fIsoR05NJets; //isolation size R=0.5 number of jets
126 Double32_t fEmEnergy; //energy deposit in ecal
127 Double32_t fHadEnergy; //energy deposit in hcal
128 Double32_t fHoEnergy; //energy deposit in outer hcal
129 Double32_t fEmS9Energy; //?
130 Double32_t fHadS9Energy; //?
131 Double32_t fHoS9Energy; //?
132 Int_t fNTraversedChambers; //number of tranversed chambers
133 BitMask8 fStationMask; //bitmap of station with tracks, 0-3 DT, 4-7 CSCs
134 Double32_t fDX[8]; //uncertainty in x in given muon chamber
135 Double32_t fDY[8]; //uncertainty in y in given muon chamber
136 Double32_t fPullX[8]; //pull in x in given muon chamber
137 Double32_t fPullY[8]; //pull in y in given muon chamber
138 Double32_t fTrackDist[8]; //dist. to track in trans. plane in given muon chamber
139 Double32_t fTrackDistErr[8]; //error of dist. to track in trans. plane in chamber
140 Int_t fNSegments[8]; //number of segments in given muon chamber
141
142 ClassDef(Muon, 1) // Muon class
143 };
144 }
145
146 //--------------------------------------------------------------------------------------------------
147 inline const mithep::Track *mithep::Muon::BestTrk() const
148 {
149 // Return "best" track.
150
151 if (GlobalTrk())
152 return GlobalTrk();
153 else if (TrackerTrk())
154 return TrackerTrk();
155 else if (StandaloneTrk())
156 return StandaloneTrk();
157
158 Error("BestTrk", "No track reference found, returning NULL pointer.");
159 return 0;
160 }
161
162 //--------------------------------------------------------------------------------------------------
163 inline const mithep::Track *mithep::Muon::GlobalTrk() const
164 {
165 // Return global combined track.
166
167 return static_cast<const Track*>(fGlobalTrackRef.GetObject());
168 }
169
170 //--------------------------------------------------------------------------------------------------
171 inline const mithep::Track *mithep::Muon::StandaloneTrk() const
172 {
173 // Return standalone track.
174
175 return static_cast<const Track*>(fStandaloneTrackRef.GetObject());
176 }
177
178 //--------------------------------------------------------------------------------------------------
179 inline const mithep::Track *mithep::Muon::TrackerTrk() const
180 {
181 // Return tracker track.
182
183 return static_cast<const Track*>(fTrackerTrackRef.GetObject());
184 }
185
186 //--------------------------------------------------------------------------------------------------
187 inline Double_t mithep::Muon::GetDX(Int_t iStation) const
188 {
189 // Return uncertainty in x in given chamber.
190
191 assert(iStation >= 0 && iStation < 8);
192 return fDX[iStation];
193 }
194
195 //--------------------------------------------------------------------------------------------------
196 inline Double_t mithep::Muon::GetDY(Int_t iStation) const
197 {
198 // Return uncertainty in y in given chamber.
199
200 assert(iStation >= 0 && iStation < 8);
201 return fDY[iStation];
202 }
203
204 //--------------------------------------------------------------------------------------------------
205 inline Double_t mithep::Muon::GetPullX(Int_t iStation) const
206 {
207 // Return pull in x in given chamber.
208
209 assert(iStation >= 0 && iStation < 8);
210 return fPullX[iStation];
211 }
212
213 //--------------------------------------------------------------------------------------------------
214 inline Double_t mithep::Muon::GetPullY(Int_t iStation) const
215 {
216 // Return pull in y in given chamber.
217
218 assert(iStation >= 0 && iStation < 8);
219 return fPullY[iStation];
220 }
221
222 //--------------------------------------------------------------------------------------------------
223 inline Double_t mithep::Muon::GetTrackDist(Int_t iStation) const
224 {
225 // Return track distance in given chamber.
226
227 assert(iStation >= 0 && iStation < 8);
228 return fTrackDist[iStation];
229 }
230
231 //--------------------------------------------------------------------------------------------------
232 inline Double_t mithep::Muon::GetTrackDistErr(Int_t iStation) const
233 {
234 // Return error of track distance in given chamber.
235
236 assert(iStation >= 0 && iStation < 8);
237 return fTrackDistErr[iStation];
238 }
239
240 //--------------------------------------------------------------------------------------------------
241 inline Int_t mithep::Muon::GetNSegments(Int_t iStation) const
242 {
243 // Return number of segments in chamber.
244
245 assert(iStation >= 0 && iStation < 8);
246 return fNSegments[iStation];
247 }
248
249 //--------------------------------------------------------------------------------------------------
250 inline Bool_t mithep::Muon::Has(EClassType type) const
251 {
252 // Return true if the muon has a track of given class.
253
254 switch (type) {
255 case kAny:
256 if (BestTrk())
257 return kTRUE;
258 break;
259 case kGlobal:
260 if (GlobalTrk())
261 return kTRUE;
262 break;
263 case kTrackerOnly:
264 if (TrackerTrk())
265 return kTRUE;
266 break;
267 case kSta:
268 if (StandaloneTrk())
269 return kTRUE;
270 break;
271 case kNone:
272 if (!BestTrk())
273 return kTRUE;
274 break;
275 default:
276 break;
277 }
278
279 return kFALSE;
280 }
281
282 //--------------------------------------------------------------------------------------------------
283 inline mithep::Muon::EClassType mithep::Muon::Is() const
284 {
285 // Return the "best" classification of the muon according to the assigned tracks.
286
287 if (GlobalTrk())
288 return kGlobal;
289 else if (TrackerTrk())
290 return kTrackerOnly;
291 else if (StandaloneTrk())
292 return kSta;
293
294 return kNone;
295 }
296
297 //--------------------------------------------------------------------------------------------------
298 inline Int_t mithep::Muon::LastHit() const
299 {
300 // Return the last hit, or -1 if no one found.
301
302 Int_t lId = -1;
303 for (Int_t i0 = 0; i0 < 8; ++i0) {
304 if (GetDX(i0) < 99999 || GetDY(i0) < 99999)
305 lId = i0;
306 }
307 return lId;
308 }
309
310 //--------------------------------------------------------------------------------------------------
311 inline Int_t mithep::Muon::LastStation(Int_t iMax) const
312 {
313 // Return the last station, or -1 of no one found.
314
315 Int_t lId = -1;
316 if(TMath::Abs(iMax) > 8)
317 iMax = 8;
318 for (Int_t i0 = 0; i0 < iMax; ++i0) {
319 if (StationBit(i0) && ((lId % 4) < (i0 % 4)))
320 lId = i0;
321 }
322 return lId;
323 }
324
325 //--------------------------------------------------------------------------------------------------
326 inline Int_t mithep::Muon::LastStation(Double_t iMaxD, Double_t iMaxP) const
327 {
328 // Return the last station for given deviation and relative error, or -1 if no one found.
329
330 Int_t lId = -1;
331 for (Int_t i0 = 0; i0 < 8; ++i0) {
332 if ((lId % 4) > (i0 % 4))
333 continue;
334 if (GetTrackDist(i0) < iMaxD &&
335 GetTrackDist(i0)/GetTrackDistErr(i0) < iMaxP)
336 lId = i0;
337 }
338 return lId;
339 }
340
341 //--------------------------------------------------------------------------------------------------
342 inline Bool_t mithep::Muon::PromptTight(EClassType type) const
343 {
344 // Return whether track for given class matches tight quality criteria.
345
346 const mithep::Track *lTrack = 0;
347 switch (type) {
348 case kAny:
349 lTrack = BestTrk();
350 break;
351 case kGlobal:
352 lTrack = GlobalTrk();
353 break;
354 case kTrackerOnly:
355 lTrack = TrackerTrk();
356 break;
357 case kSta:
358 lTrack = StandaloneTrk();
359 break;
360 default:
361 break;
362 }
363
364 if (lTrack == 0)
365 return kFALSE;
366 if (lTrack->NHits() < 11)
367 return kFALSE;
368 if (lTrack->Chi2()/lTrack->Ndof() > 10.)
369 return kFALSE;
370 if (lTrack->D0() > 0.2)
371 return kFALSE;
372 if ((LastHit() % 4) == 0)
373 return kFALSE;
374 return kTRUE;
375 }
376
377 //--------------------------------------------------------------------------------------------------
378 inline Bool_t mithep::Muon::TMOneStation(Double_t iDYMin, Double_t iPYMin,
379 Double_t iDXMin, Double_t iPXMin, Int_t iN) const
380 {
381 // Check if the muon is matched to at least one station (chamber).
382
383 if (NSegments() < iN)
384 return kFALSE; //second last one
385
386 Bool_t pGoodX = kFALSE;
387 Bool_t pBadY = kFALSE;
388 for (Int_t i0 = 0; i0 < 8; ++i0) {
389 if ((TMath::Abs(GetDX(i0)) < iDXMin ||
390 TMath::Abs(GetPullX(i0)) < iPXMin))
391 pGoodX = kTRUE;
392 if (pGoodX &&
393 (TMath::Abs(GetDY(i0)) < iDYMin ||
394 TMath::Abs(GetPullY(i0)) < iPYMin))
395 return kTRUE;
396 if (TMath::Abs(GetDY(i0)) < 999999)
397 pBadY = kTRUE;
398 if (i0 == 3 && pGoodX && !pBadY)
399 return kTRUE;
400 }
401 return kFALSE;
402 }
403
404 //--------------------------------------------------------------------------------------------------
405 inline Bool_t mithep::Muon::TMLastStation(Double_t iDYMin, Double_t iPYMin,
406 Double_t iDXMin, Double_t iPXMin, Int_t iN) const
407 {
408 // Check if the muon is matched to its last station (chamber).
409
410 if (NSegments() < iN)
411 return kFALSE; //second last one
412
413 Int_t lLast = LastStation(-3.,-3.); // last required station
414 if (lLast < 0)
415 return kFALSE;
416 if (GetDX(lLast) > 9999.)
417 return kFALSE;
418 lLast = LastStation(); //no requirements
419 if (lLast < 0)
420 return kFALSE;
421 if (!(TMath::Abs(GetDX(lLast)) < iDXMin ||
422 TMath::Abs(GetPullX(lLast)) < iPXMin))
423 return kFALSE;
424 if (lLast == 3)
425 lLast = LastStation(3);
426 if (lLast < 0)
427 return kFALSE;
428 if (!(TMath::Abs(GetDY(lLast)) < iDYMin ||
429 TMath::Abs(GetPullY(lLast)) < iPYMin))
430 return kFALSE;
431 return kTRUE;
432 }
433
434 //--------------------------------------------------------------------------------------------------
435 inline void mithep::Muon::SetDX(Int_t iStation, Double_t iDX)
436 {
437 // Return uncertainty in x in given chamber.
438
439 assert(iStation >= 0 && iStation < 8);
440 fDX[iStation] = iDX;
441 }
442
443 //--------------------------------------------------------------------------------------------------
444 inline void mithep::Muon::SetDY(Int_t iStation, Double_t iDY)
445 {
446 // Return uncertainty in y in given chamber.
447
448 assert(iStation >= 0 && iStation < 8);
449 fDY[iStation] = iDY;
450 }
451
452 //--------------------------------------------------------------------------------------------------
453 inline void mithep::Muon::SetPullX(Int_t iStation, Double_t iPullX)
454 {
455 // Set pull in x in given chamber.
456
457 assert(iStation >= 0 && iStation < 8);
458 fPullX[iStation] = iPullX;
459 }
460
461 //--------------------------------------------------------------------------------------------------
462 inline void mithep::Muon::SetPullY(Int_t iStation, Double_t iPullY)
463 {
464 // Set pull in y in given chamber.
465
466 assert(iStation >= 0 && iStation < 8);
467 fPullY[iStation] = iPullY;
468 }
469
470 //--------------------------------------------------------------------------------------------------
471 inline void mithep::Muon::SetTrackDist(Int_t iStation, Double_t iDist)
472 {
473 // Set track distance in given chamber.
474
475 assert(iStation >= 0 && iStation < 8);
476 fTrackDist[iStation] = iDist;
477 }
478
479 //--------------------------------------------------------------------------------------------------
480 inline void mithep::Muon::SetTrackDistErr(Int_t iStation, Double_t iDistErr)
481 {
482 // Set error of track distance in given chamber.
483
484 assert(iStation >= 0 && iStation < 8);
485 fTrackDistErr[iStation] = iDistErr;
486 }
487
488 //--------------------------------------------------------------------------------------------------
489 inline void mithep::Muon::SetNSegments(Int_t iStation, Int_t NSegments)
490 {
491 // Set number of segments in chamber.
492
493 assert(iStation >= 0 && iStation < 8);
494 fNSegments[iStation] = NSegments;
495 }
496 #endif
497
498
499
500
501