ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TrackingParticle.h
Revision: 1.2
Committed: Thu Jan 7 17:08:40 2010 UTC (15 years, 3 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_012h
Changes since 1.1: +16 -17 lines
Log Message:
Cosmetics

File Contents

# User Rev Content
1 bendavid 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.2 // $Id: TrackingParticle.h,v 1.1 2010/01/07 11:03:41 bendavid Exp $
3 bendavid 1.1 //
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 loizides 1.2 void AddMCPart(const MCParticle *p)
31     { fMCParts.Add(p); ClearCharge(); ClearMom(); }
32     const MCParticle *DistinctMother() const;
33     const MCParticle *FinalMCPart() const;
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 bendavid 1.1
44     protected:
45 loizides 1.2 Double_t GetCharge() const;
46     void GetMom() const;
47 bendavid 1.1 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