ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Muon.h
Revision: 1.25
Committed: Wed Feb 18 15:38:54 2009 UTC (16 years, 2 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.24: +39 -40 lines
Log Message:
Reworked particle interface to cache FourVectorM

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: Muon.h,v 1.24 2009/02/17 15:09:45 bendavid Exp $
3 //
4 // Muon
5 //
6 // Classified into 3 Types
7 // Standalone : Muon fit from hits in the muon chambers
8 // Tracker : Tracker matched track to muon chambers with segments
9 // Global : Combined track and muon chambers fit
10 //
11 // In the muon class all three muon classes exist and can be determined by checking
12 // whether a fit track exists for such a Muon (eg HasTrackerTrk() == kTRUE). When
13 // BestTrk function is called the global fit is returned, if that does not
14 // exist the tracker fit is returned upon that failure the standalone muon
15 // is subsequently returned. To consult more see:
16 // http://cmsdoc.cern.ch/cms/Physics/muon/MPOG/Notes/MuonReco.pdf
17 //
18 // Quality Varaibles for Selection
19 // Isolation : decomposed to IsoRNNXXXXX
20 // NN = 03,05 to denote R =0.3,0.5 in Isolation Cone
21 // XXXXX = SumPt - Sum of Pt of Tracks in Cone (using all Pt Tracks)
22 // XXXXX = EmEt - Sum of Et of Em component of Calo Towers (Veto=0.08)
23 // XXXXX = HadEt - Sum of Et of Had component of Calo Towers (Veto=0.1)
24 // XXXXX = HoEt - Sum of Pt of Ho component of Calo Towers (Veto=0.1)
25 // XXXXX = NTrk - Number of Tracks within Cone (using all Pt Tracks)
26 // XXXXX = NJet - Sum of Jets inside Cone
27 //
28 // Muon Quality Variables
29 // Extracted from the Muon Tracking Associator
30 // For more se https://twiki.cern.ch/twiki/bin/view/CMS/TrackAssociator
31 // Energy Variables : Energy within (5x5 Ecal Crystal/Hcal/Ho) along Track
32 // using calo towers
33 // S9 Energy Variables : Energy using reconstructed hits calo towers default
34 // Segment Variables :
35 // Segment variables are stored in array of 8:
36 // 0-3: Correspond to segments in 4 DT chambers in->outward(3 has no Y res)
37 // 4-7: Correspond to segments in 4 CSC chambers in->out
38 // If value undetermined 999999 is returned.
39 // Variables:
40 // DX,DY,PullX,PullY: Uncertainties/Pulls of propagated track
41 // with respect to local muon segment
42 // TrackDist,TrackDistErr: Summed Dist/Err (in X,Y) of segment with respect
43 // to propagated track
44 // NSegments : Number of segments in muon using Segment+Track Arbitration
45 // NChambers : Number of muon chambers traversed in propagated track
46 // LastHit : Returns farest (from center) station with a recorded segment
47 // LastStation : Returns farest station using Segment+Track Arbitration
48 //
49 // Muon Id Methods: Please see Muon Id Note(as of now unpublished):
50 // https://www.cmsaf.mit.edu/twiki/pub/CmsHep/HepWAnalysis/MuonID-ingo.pdf
51 // TMOneStation : Returns bool whether muon passes "Tracker Muon One StationId"
52 // -Matching criteria for one of all segments matched to muon
53 // TMLastStation : Returns bool whether muon passes "LastStation Id" criteria
54 // -Matching criteria for last most segment
55 //
56 // Authors: J.Bendavid, C.Loizides, C.Paus, P.Harris
57 //--------------------------------------------------------------------------------------------------
58
59 #ifndef MITANA_DATATREE_MUON_H
60 #define MITANA_DATATREE_MUON_H
61
62 #include "MitAna/DataTree/interface/Track.h"
63 #include "MitAna/DataTree/interface/ChargedParticle.h"
64
65 namespace mithep {
66 class Muon : public ChargedParticle {
67 public:
68 Muon();
69
70 enum EClassType {
71 kNone, //no track assigned
72 kGlobal, //"Global"
73 kTrackerOnly, //"TrackerOnly"
74 kSta, //"Standalone"
75 kAny //any "best" of the above
76 };
77
78 const Track *BestTrk() const;
79 const Track *GlobalTrk() const { return fGlobalTrkRef.Obj(); }
80 const Track *StandaloneTrk() const { return fStaTrkRef.Obj(); }
81 const Track *TrackerTrk() const { return fTrkTrkRef.Obj(); }
82 const Track *Trk() const { return BestTrk(); }
83 Double_t EmEnergy() const { return fEmEnergy; }
84 Double_t EmS9Energy() const { return fEmS9Energy; }
85 Double_t GetDX(Int_t iStation) const;
86 Double_t GetDY(Int_t iStation) const;
87 Double_t GetPullX(Int_t iStation) const;
88 Double_t GetPullY(Int_t iStation) const;
89 Double_t GetTrackDist(Int_t iStation) const;
90 Double_t GetTrackDistErr(Int_t iStation) const;
91 Int_t GetNSegments(Int_t iStation) const;
92 Bool_t Has(EClassType type) const;
93 Bool_t HasTrk() const;
94 Bool_t HasGlobalTrk() const { return fGlobalTrkRef.IsValid(); }
95 Bool_t HasStandaloneTrk() const { return fStaTrkRef.IsValid(); }
96 Bool_t HasTrackerTrk() const { return fTrkTrkRef.IsValid(); }
97 Double_t HadEnergy() const { return fHadEnergy; }
98 Double_t HadS9Energy() const { return fHadS9Energy; }
99 Double_t HoEnergy() const { return fHoEnergy; }
100 Double_t HoS9Energy() const { return fHoS9Energy; }
101 EClassType Is() const;
102 Double_t IsoR03SumPt() const { return fIsoR03SumPt; }
103 Double_t IsoR03EmEt() const { return fIsoR03EmEt; }
104 Double_t IsoR03HadEt() const { return fIsoR03HadEt; }
105 Double_t IsoR03HoEt() const { return fIsoR03HoEt; }
106 Int_t IsoR03NTracks() const { return fIsoR03NTracks; }
107 Int_t IsoR03NJets() const { return fIsoR03NJets; }
108 Double_t IsoR05SumPt() const { return fIsoR05SumPt; }
109 Double_t IsoR05EmEt() const { return fIsoR05EmEt; }
110 Double_t IsoR05HadEt() const { return fIsoR05HadEt; }
111 Double_t IsoR05HoEt() const { return fIsoR05HoEt; }
112 Int_t IsoR05NTracks() const { return fIsoR05NTracks; }
113 Int_t IsoR05NJets() const { return fIsoR05NJets; }
114 Int_t NChambers() const { return fNTraversedChambers; }
115 Int_t NSegments() const { return fStationMask.NBitsSet(); }
116 Int_t LastHit() const;
117 Int_t LastStation(Double_t iMaxD, Double_t iMaxP) const;
118 Int_t LastStation(Int_t iMax=8) const;
119 EObjType ObjType() const { return kMuon; }
120 Bool_t PromptTight(EClassType type) const;
121 Bool_t StationBit(Int_t bit) const { return fStationMask.TestBit(bit); }
122 Bool_t TMLastStation(Double_t iDYMin = 3., Double_t iPYMin = 3.,
123 Double_t iDXMin = 3., Double_t iPXMin = 3.,Int_t iN = 2) const;
124 Bool_t TMOneStation(Double_t iDYMin = 3., Double_t iPYMin = 3.,
125 Double_t iDXMin = 3., Double_t iPXMin = 3.,Int_t iN = 1) const;
126 void SetGlobalTrk(const Track *t) { fGlobalTrkRef = t; }
127 void SetStandaloneTrk(const Track *t) { fStaTrkRef = t; }
128 void SetTrackerTrk(const Track *t) { fTrkTrkRef = t; }
129 void SetDX(Int_t iStation, Double_t iDX);
130 void SetDY(Int_t iStation, Double_t iDY);
131 void SetEmEnergy(Double_t EmEnergy) { fEmEnergy = EmEnergy; }
132 void SetEmS9Energy(Double_t EmS9Energy) { fEmS9Energy = EmS9Energy; }
133 void SetHadEnergy(Double_t HadEnergy) { fHadEnergy = HadEnergy; }
134 void SetHadS9Energy(Double_t HadS9Energy) { fHadS9Energy = HadS9Energy; }
135 void SetHoEnergy(Double_t HoEnergy) { fHoEnergy = HoEnergy; }
136 void SetHoS9Energy(Double_t HoS9Energy) { fHoS9Energy = HoS9Energy; }
137 void SetIsoR03SumPt(Double_t isoR03SumPt) { fIsoR03SumPt = isoR03SumPt; }
138 void SetIsoR03EmEt(Double_t isoR03EmEt) { fIsoR03EmEt = isoR03EmEt; }
139 void SetIsoR03HadEt(Double_t isoR03HadEt) { fIsoR03HadEt = isoR03HadEt; }
140 void SetIsoR03HoEt(Double_t isoR03HoEt) { fIsoR03HoEt = isoR03HoEt; }
141 void SetIsoR03NTracks(Int_t isoR03NTracks) { fIsoR03NTracks = isoR03NTracks; }
142 void SetIsoR03NJets(Int_t isoR03NJets) { fIsoR03NJets = isoR03NJets; }
143 void SetIsoR05SumPt(Double_t isoR05SumPt) { fIsoR05SumPt = isoR05SumPt; }
144 void SetIsoR05EmEt(Double_t isoR05EmEt) { fIsoR05EmEt = isoR05EmEt; }
145 void SetIsoR05HadEt(Double_t isoR05HadEt) { fIsoR05HadEt = isoR05HadEt; }
146 void SetIsoR05HoEt(Double_t isoR05HoEt) { fIsoR05HoEt = isoR05HoEt; }
147 void SetIsoR05NTracks(Int_t isoR05NTracks) { fIsoR05NTracks = isoR05NTracks; }
148 void SetIsoR05NJets(Int_t isoR05NJets) { fIsoR05NJets = isoR05NJets; }
149 void SetNChambers(Int_t iNTraCh) { fNTraversedChambers = iNTraCh; }
150 void SetNSegments(Int_t iStation, Int_t NSegments);
151 void SetPullX(Int_t iStation, Double_t iPullX);
152 void SetPullY(Int_t iStation, Double_t iPullY);
153 void SetStationMask(UInt_t iStMask) { fStationMask.SetBits(iStMask); }
154 void SetTrackDist(Int_t iStation, Double_t iDist);
155 void SetTrackDistErr(Int_t iStation, Double_t iDistErr);
156
157 protected:
158 Double_t GetMass() const { return 105.658369e-3; }
159
160 Ref<Track> fGlobalTrkRef; //global combined track reference
161 Ref<Track> fStaTrkRef; //standalone muon track reference
162 Ref<Track> fTrkTrkRef; //tracker track reference
163 Double32_t fIsoR03SumPt; //isolation size R=0.3 sum pt
164 Double32_t fIsoR03EmEt; //isolation size R=0.3 em trans energy
165 Double32_t fIsoR03HadEt; //isolation size R=0.3 had trans energy
166 Double32_t fIsoR03HoEt; //isolation size R=0.3 ho trans energy
167 Int_t fIsoR03NTracks; //isolation size R=0.3 number of tracks
168 Int_t fIsoR03NJets; //isolation size R=0.3 number of jets
169 Double32_t fIsoR05SumPt; //isolation size R=0.5 sum pt
170 Double32_t fIsoR05EmEt; //isolation size R=0.5 em trans energy
171 Double32_t fIsoR05HadEt; //isolation size R=0.5 had trans energy
172 Double32_t fIsoR05HoEt; //isolation size R=0.5 ho trans energy
173 Int_t fIsoR05NTracks; //isolation size R=0.5 number of tracks
174 Int_t fIsoR05NJets; //isolation size R=0.5 number of jets
175 Double32_t fEmEnergy; //energy deposit in ecal
176 Double32_t fHadEnergy; //energy deposit in hcal
177 Double32_t fHoEnergy; //energy deposit in outer hcal
178 Double32_t fEmS9Energy; //energy deposit in 3x3 ecal
179 Double32_t fHadS9Energy; //energy deposit in 3x3 hcal
180 Double32_t fHoS9Energy; //energy deposit in 3x3 outer hcal
181 Int_t fNTraversedChambers; //number of tranversed chambers
182 BitMask8 fStationMask; //bitmap of station with tracks, 0-3 DT, 4-7 CSCs
183 Double32_t fDX[8]; //uncertainty in x in given muon chamber
184 Double32_t fDY[8]; //uncertainty in y in given muon chamber
185 Double32_t fPullX[8]; //pull in x in given muon chamber
186 Double32_t fPullY[8]; //pull in y in given muon chamber
187 Double32_t fTrackDist[8]; //dist. to track in trans. plane in given muon chamber
188 Double32_t fTrackDistErr[8]; //error of dist. to track in trans. plane in chamber
189 Int_t fNSegments[8]; //number of segments in given muon chamber
190
191 ClassDef(Muon, 1) // Muon class
192 };
193 }
194
195 //--------------------------------------------------------------------------------------------------
196 inline const mithep::Track *mithep::Muon::BestTrk() const
197 {
198 // Return "best" track.
199
200 if (HasGlobalTrk())
201 return GlobalTrk();
202 else if (HasTrackerTrk())
203 return TrackerTrk();
204 else if (HasStandaloneTrk())
205 return StandaloneTrk();
206
207 Error("BestTrk", "No track reference found, returning NULL pointer.");
208 return 0;
209 }
210
211 //--------------------------------------------------------------------------------------------------
212 inline Double_t mithep::Muon::GetDX(Int_t iStation) const
213 {
214 // Return uncertainty in x in given chamber.
215
216 assert(iStation >= 0 && iStation < 8);
217 return fDX[iStation];
218 }
219
220 //--------------------------------------------------------------------------------------------------
221 inline Double_t mithep::Muon::GetDY(Int_t iStation) const
222 {
223 // Return uncertainty in y in given chamber.
224
225 assert(iStation >= 0 && iStation < 8);
226 return fDY[iStation];
227 }
228
229 //--------------------------------------------------------------------------------------------------
230 inline Double_t mithep::Muon::GetPullX(Int_t iStation) const
231 {
232 // Return pull in x in given chamber.
233
234 assert(iStation >= 0 && iStation < 8);
235 return fPullX[iStation];
236 }
237
238 //--------------------------------------------------------------------------------------------------
239 inline Double_t mithep::Muon::GetPullY(Int_t iStation) const
240 {
241 // Return pull in y in given chamber.
242
243 assert(iStation >= 0 && iStation < 8);
244 return fPullY[iStation];
245 }
246
247 //--------------------------------------------------------------------------------------------------
248 inline Double_t mithep::Muon::GetTrackDist(Int_t iStation) const
249 {
250 // Return track distance in given chamber.
251
252 assert(iStation >= 0 && iStation < 8);
253 return fTrackDist[iStation];
254 }
255
256 //--------------------------------------------------------------------------------------------------
257 inline Double_t mithep::Muon::GetTrackDistErr(Int_t iStation) const
258 {
259 // Return error of track distance in given chamber.
260
261 assert(iStation >= 0 && iStation < 8);
262 return fTrackDistErr[iStation];
263 }
264
265 //--------------------------------------------------------------------------------------------------
266 inline Int_t mithep::Muon::GetNSegments(Int_t iStation) const
267 {
268 // Return number of segments in chamber.
269
270 assert(iStation >= 0 && iStation < 8);
271 return fNSegments[iStation];
272 }
273
274 //--------------------------------------------------------------------------------------------------
275 inline Bool_t mithep::Muon::Has(EClassType type) const
276 {
277 // Return true if the muon has a track of given class.
278
279 switch (type) {
280 case kAny:
281 if (HasTrk())
282 return kTRUE;
283 break;
284 case kGlobal:
285 if (HasGlobalTrk())
286 return kTRUE;
287 break;
288 case kTrackerOnly:
289 if (HasTrackerTrk())
290 return kTRUE;
291 break;
292 case kSta:
293 if (HasStandaloneTrk())
294 return kTRUE;
295 break;
296 case kNone:
297 if (!HasTrk())
298 return kTRUE;
299 break;
300 default:
301 break;
302 }
303
304 return kFALSE;
305 }
306
307 //--------------------------------------------------------------------------------------------------
308 inline Bool_t mithep::Muon::HasTrk() const
309 {
310 // Return true if the muon has assigned any kind of track.
311
312 return (HasGlobalTrk() || HasTrackerTrk() || HasStandaloneTrk());
313 }
314
315 //--------------------------------------------------------------------------------------------------
316 inline mithep::Muon::EClassType mithep::Muon::Is() const
317 {
318 // Return the "best" classification of the muon according to the assigned tracks.
319
320 if (HasGlobalTrk())
321 return kGlobal;
322 else if (HasTrackerTrk())
323 return kTrackerOnly;
324 else if (HasStandaloneTrk())
325 return kSta;
326
327 return kNone;
328 }
329
330 //--------------------------------------------------------------------------------------------------
331 inline Int_t mithep::Muon::LastHit() const
332 {
333 // Return the last hit, or -1 if no one found.
334
335 Int_t lId = -1;
336 for (Int_t i0 = 0; i0 < 8; ++i0) {
337 if (GetDX(i0) < 99999 || GetDY(i0) < 99999)
338 lId = i0;
339 }
340 return lId;
341 }
342
343 //--------------------------------------------------------------------------------------------------
344 inline Int_t mithep::Muon::LastStation(Int_t iMax) const
345 {
346 // Return the last station, or -1 of no one found.
347
348 Int_t lId = -1;
349 if(TMath::Abs(iMax) > 8)
350 iMax = 8;
351 for (Int_t i0 = 0; i0 < iMax; ++i0) {
352 if (StationBit(i0) && ((lId % 4) < (i0 % 4)))
353 lId = i0;
354 }
355 return lId;
356 }
357
358 //--------------------------------------------------------------------------------------------------
359 inline Int_t mithep::Muon::LastStation(Double_t iMaxD, Double_t iMaxP) const
360 {
361 // Return the last station for given deviation and relative error, or -1 if no one found.
362
363 Int_t lId = -1;
364 for (Int_t i0 = 0; i0 < 8; ++i0) {
365 if ((lId % 4) > (i0 % 4))
366 continue;
367 if (GetTrackDist(i0) < iMaxD &&
368 GetTrackDist(i0)/GetTrackDistErr(i0) < iMaxP)
369 lId = i0;
370 }
371 return lId;
372 }
373
374 //--------------------------------------------------------------------------------------------------
375 inline Bool_t mithep::Muon::PromptTight(EClassType type) const
376 {
377 // Return whether track for given class matches tight quality criteria.
378
379 const mithep::Track *lTrack = 0;
380 switch (type) {
381 case kAny:
382 lTrack = BestTrk();
383 break;
384 case kGlobal:
385 lTrack = GlobalTrk();
386 break;
387 case kTrackerOnly:
388 lTrack = TrackerTrk();
389 break;
390 case kSta:
391 lTrack = StandaloneTrk();
392 break;
393 default:
394 break;
395 }
396
397 if (lTrack == 0)
398 return kFALSE;
399 if (lTrack->NHits() < 11)
400 return kFALSE;
401 if (lTrack->Chi2()/lTrack->Ndof() > 10.)
402 return kFALSE;
403 if (lTrack->D0() > 0.2)
404 return kFALSE;
405 if ((LastHit() % 4) == 0)
406 return kFALSE;
407 return kTRUE;
408 }
409
410 //--------------------------------------------------------------------------------------------------
411 inline Bool_t mithep::Muon::TMOneStation(Double_t iDYMin, Double_t iPYMin,
412 Double_t iDXMin, Double_t iPXMin, Int_t iN) const
413 {
414 // Check if the muon is matched to at least one station (chamber).
415
416 if (NSegments() < iN)
417 return kFALSE; //second last one
418
419 Bool_t pGoodX = kFALSE;
420 Bool_t pBadY = kFALSE;
421 for (Int_t i0 = 0; i0 < 8; ++i0) {
422 if ((TMath::Abs(GetDX(i0)) < iDXMin ||
423 TMath::Abs(GetPullX(i0)) < iPXMin))
424 pGoodX = kTRUE;
425 if (pGoodX &&
426 (TMath::Abs(GetDY(i0)) < iDYMin ||
427 TMath::Abs(GetPullY(i0)) < iPYMin))
428 return kTRUE;
429 if (TMath::Abs(GetDY(i0)) < 999999)
430 pBadY = kTRUE;
431 if (i0 == 3 && pGoodX && !pBadY)
432 return kTRUE;
433 }
434 return kFALSE;
435 }
436
437 //--------------------------------------------------------------------------------------------------
438 inline Bool_t mithep::Muon::TMLastStation(Double_t iDYMin, Double_t iPYMin,
439 Double_t iDXMin, Double_t iPXMin, Int_t iN) const
440 {
441 // Check if the muon is matched to its last station (chamber).
442
443 if (NSegments() < iN)
444 return kFALSE; //second last one
445
446 Int_t lLast = LastStation(-3.,-3.); // last required station
447 if (lLast < 0)
448 return kFALSE;
449 if (GetDX(lLast) > 9999.)
450 return kFALSE;
451 lLast = LastStation(); //no requirements
452 if (lLast < 0)
453 return kFALSE;
454 if (!(TMath::Abs(GetDX(lLast)) < iDXMin ||
455 TMath::Abs(GetPullX(lLast)) < iPXMin))
456 return kFALSE;
457 if (lLast == 3)
458 lLast = LastStation(3);
459 if (lLast < 0)
460 return kFALSE;
461 if (!(TMath::Abs(GetDY(lLast)) < iDYMin ||
462 TMath::Abs(GetPullY(lLast)) < iPYMin))
463 return kFALSE;
464 return kTRUE;
465 }
466
467 //--------------------------------------------------------------------------------------------------
468 inline void mithep::Muon::SetDX(Int_t iStation, Double_t iDX)
469 {
470 // Return uncertainty in x in given chamber.
471
472 assert(iStation >= 0 && iStation < 8);
473 fDX[iStation] = iDX;
474 }
475
476 //--------------------------------------------------------------------------------------------------
477 inline void mithep::Muon::SetDY(Int_t iStation, Double_t iDY)
478 {
479 // Return uncertainty in y in given chamber.
480
481 assert(iStation >= 0 && iStation < 8);
482 fDY[iStation] = iDY;
483 }
484
485 //--------------------------------------------------------------------------------------------------
486 inline void mithep::Muon::SetPullX(Int_t iStation, Double_t iPullX)
487 {
488 // Set pull in x in given chamber.
489
490 assert(iStation >= 0 && iStation < 8);
491 fPullX[iStation] = iPullX;
492 }
493
494 //--------------------------------------------------------------------------------------------------
495 inline void mithep::Muon::SetPullY(Int_t iStation, Double_t iPullY)
496 {
497 // Set pull in y in given chamber.
498
499 assert(iStation >= 0 && iStation < 8);
500 fPullY[iStation] = iPullY;
501 }
502
503 //--------------------------------------------------------------------------------------------------
504 inline void mithep::Muon::SetTrackDist(Int_t iStation, Double_t iDist)
505
506 {
507 // Set track distance in given chamber.
508
509 assert(iStation >= 0 && iStation < 8);
510 fTrackDist[iStation] = iDist;
511 }
512
513 //--------------------------------------------------------------------------------------------------
514 inline void mithep::Muon::SetTrackDistErr(Int_t iStation, Double_t iDistErr)
515 {
516 // Set error of track distance in given chamber.
517
518 assert(iStation >= 0 && iStation < 8);
519 fTrackDistErr[iStation] = iDistErr;
520 }
521
522 //--------------------------------------------------------------------------------------------------
523 inline void mithep::Muon::SetNSegments(Int_t iStation, Int_t NSegments)
524 {
525 // Set number of segments in chamber.
526
527 assert(iStation >= 0 && iStation < 8);
528 fNSegments[iStation] = NSegments;
529 }
530 #endif
531
532
533
534
535