ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TrackingParticle.h
Revision: 1.1
Committed: Thu Jan 7 11:03:41 2010 UTC (15 years, 3 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Log Message:
Add TrackingParticle class for more detailed sim info

File Contents

# User Rev Content
1 bendavid 1.1 //--------------------------------------------------------------------------------------------------
2     // $Id: TrackingParticle.h,v 1.23 2009/09/25 08:38:18 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    
30     Bool_t Hit(Track::EHitLayer l) const { return fHits.TestBit(l); }
31     const BitMask48 &Hits() const { return fHits; }
32     UInt_t NHits() const { return fHits.NBitsSet(); }
33     void SetHit(Track::EHitLayer l) { fHits.SetBit(l); }
34     void SetHits(const BitMask48 &hits) { fHits = hits; }
35     const MCParticle *DistinctMother() const;
36     EObjType ObjType() const { return kTrackingParticle; }
37     void AddMCPart(const MCParticle *p) { fMCParts.Add(p); ClearCharge(); ClearMom(); }
38     const MCParticle *InitialMCPart() const;
39     const MCParticle *FinalMCPart() const;
40     const MCParticle *MCPart(UInt_t i) const { return fMCParts.At(i); }
41     UInt_t NMCParts() const { return fMCParts.Entries(); }
42    
43    
44     protected:
45     Double_t GetCharge() const;
46     void GetMom() const;
47    
48     BitMask48 fHits; //storage for sim hit information
49     RefArray<MCParticle> fMCParts; //reference to corresponding MCParticles
50    
51     ClassDef(TrackingParticle,1) // Generated particle class
52     };
53     }
54    
55     //--------------------------------------------------------------------------------------------------
56     inline const mithep::MCParticle *mithep::TrackingParticle::DistinctMother() const
57     {
58     // Return mother, walking up the tree until a particle with a different pdg from this one
59     // is found.
60    
61     const mithep::MCParticle *mcPart = FinalMCPart();
62    
63     if (mcPart)
64     return mcPart->DistinctMother();
65    
66     return 0;
67    
68     }
69    
70     //--------------------------------------------------------------------------------------------------
71     inline const mithep::MCParticle *mithep::TrackingParticle::FinalMCPart() const
72     {
73     // Return last MCParticle in the chain
74    
75     if (NMCParts()) {
76     return MCPart(NMCParts() - 1);
77     }
78     else {
79     return 0;
80     }
81    
82     }
83    
84     //--------------------------------------------------------------------------------------------------
85     inline const mithep::MCParticle *mithep::TrackingParticle::InitialMCPart() const
86     {
87     // Return first MCParticle in the chain
88    
89     if (NMCParts()) {
90     return MCPart(0);
91     }
92     else {
93     return 0;
94     }
95    
96     }
97    
98     //--------------------------------------------------------------------------------------------------
99     inline Double_t mithep::TrackingParticle::GetCharge() const
100     {
101     // Get charge from first MC particle.
102    
103     const MCParticle *firstMCPart = InitialMCPart();
104    
105     if (firstMCPart) {
106     return firstMCPart->Charge();
107     }
108     else {
109     return 0.0;
110     }
111    
112     }
113    
114     //--------------------------------------------------------------------------------------------------
115     inline void mithep::TrackingParticle::GetMom() const
116     {
117     // Get momentum from first MC particle.
118    
119     const MCParticle *firstMCPart = InitialMCPart();
120    
121     if (firstMCPart) {
122     fCachedMom = firstMCPart->Mom();
123     }
124     else {
125     fCachedMom = FourVectorM();
126     }
127    
128     }
129    
130     #endif