ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TrackingParticle.h
Revision: 1.3
Committed: Mon Jan 18 14:33:02 2010 UTC (15 years, 3 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025c_branch2, Mit_025c_branch1, Mit_025c_branch0, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i
Branch point for: Mit_025c_branch
Changes since 1.2: +2 -2 lines
Log Message:
Add accessor for HasObject

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: TrackingParticle.h,v 1.2 2010/01/07 17:08:40 loizides Exp $
3 //
4 // TrackingParticle
5 //
6 // Stores additional MC information for tracking truth.
7 //
8 // Authors: J.Bendavid
9 //--------------------------------------------------------------------------------------------------
10
11 #ifndef MITANA_DATATREE_TRACKINGPARTICLE_H
12 #define MITANA_DATATREE_TRACKINGPARTICLE_H
13
14 #include "MitAna/DataCont/interface/Ref.h"
15 #include "MitAna/DataTree/interface/Particle.h"
16 #include "MitAna/DataTree/interface/MCParticle.h"
17 #include "MitAna/DataTree/interface/Track.h"
18 #include "MitAna/DataCont/interface/RefArray.h"
19
20
21 namespace mithep
22 {
23 class TrackingParticle : public Particle
24 {
25 public:
26
27 TrackingParticle() {}
28
29 void AddMCPart(const MCParticle *p)
30 { fMCParts.Add(p); ClearCharge(); ClearMom(); }
31 const MCParticle *DistinctMother() const;
32 const MCParticle *FinalMCPart() const;
33 Bool_t HasMCPart(const MCParticle *p) const { return fMCParts.HasObject(p); }
34 Bool_t Hit(Track::EHitLayer l) const { return fHits.TestBit(l); }
35 const BitMask48 &Hits() const { return fHits; }
36 const MCParticle *InitialMCPart() const;
37 const MCParticle *MCPart(UInt_t i) const { return fMCParts.At(i); }
38 UInt_t NMCParts() const { return fMCParts.Entries(); }
39 UInt_t NHits() const { return fHits.NBitsSet(); }
40 EObjType ObjType() const { return kTrackingParticle; }
41 void SetHit(Track::EHitLayer l) { fHits.SetBit(l); }
42 void SetHits(const BitMask48 &hits) { fHits = hits; }
43
44 protected:
45 Double_t GetCharge() const;
46 void GetMom() const;
47 BitMask48 fHits; //storage for sim hit information
48 RefArray<MCParticle> fMCParts; //reference to corresponding MCParticles
49
50 ClassDef(TrackingParticle,1) // Generated particle class
51 };
52 }
53
54 //--------------------------------------------------------------------------------------------------
55 inline const mithep::MCParticle *mithep::TrackingParticle::DistinctMother() const
56 {
57 // Return mother, walking up the tree until a particle with a different pdg from this one
58 // is found.
59
60 const mithep::MCParticle *mcPart = FinalMCPart();
61
62 if (mcPart)
63 return mcPart->DistinctMother();
64
65 return 0;
66
67 }
68
69 //--------------------------------------------------------------------------------------------------
70 inline const mithep::MCParticle *mithep::TrackingParticle::FinalMCPart() const
71 {
72 // Return last MCParticle in the chain
73
74 if (NMCParts()) {
75 return MCPart(NMCParts() - 1);
76 }
77 else {
78 return 0;
79 }
80
81 }
82
83 //--------------------------------------------------------------------------------------------------
84 inline const mithep::MCParticle *mithep::TrackingParticle::InitialMCPart() const
85 {
86 // Return first MCParticle in the chain
87
88 if (NMCParts()) {
89 return MCPart(0);
90 }
91 else {
92 return 0;
93 }
94
95 }
96
97 //--------------------------------------------------------------------------------------------------
98 inline Double_t mithep::TrackingParticle::GetCharge() const
99 {
100 // Get charge from first MC particle.
101
102 const MCParticle *firstMCPart = InitialMCPart();
103
104 if (firstMCPart) {
105 return firstMCPart->Charge();
106 }
107 else {
108 return 0.0;
109 }
110
111 }
112
113 //--------------------------------------------------------------------------------------------------
114 inline void mithep::TrackingParticle::GetMom() const
115 {
116 // Get momentum from first MC particle.
117
118 const MCParticle *firstMCPart = InitialMCPart();
119
120 if (firstMCPart) {
121 fCachedMom = firstMCPart->Mom();
122 }
123 else {
124 fCachedMom = FourVectorM();
125 }
126
127 }
128
129 #endif