ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TrackingParticle.h
Revision: 1.4
Committed: Wed Mar 28 12:15:35 2012 UTC (13 years, 1 month ago) by paus
Content type: text/plain
Branch: MAIN
Changes since 1.3: +14 -1 lines
Log Message:
Enable skimming.

File Contents

# User Rev Content
1 bendavid 1.1 //--------------------------------------------------------------------------------------------------
2 paus 1.4 // $Id: TrackingParticle.h,v 1.3 2010/01/18 14:33:02 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 loizides 1.2 void AddMCPart(const MCParticle *p)
30     { fMCParts.Add(p); ClearCharge(); ClearMom(); }
31     const MCParticle *DistinctMother() const;
32     const MCParticle *FinalMCPart() const;
33 bendavid 1.3 Bool_t HasMCPart(const MCParticle *p) const { return fMCParts.HasObject(p); }
34 loizides 1.2 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 paus 1.4 // Some structural tools
45     void Mark() const;
46    
47 bendavid 1.1 protected:
48 loizides 1.2 Double_t GetCharge() const;
49     void GetMom() const;
50 bendavid 1.1 BitMask48 fHits; //storage for sim hit information
51     RefArray<MCParticle> fMCParts; //reference to corresponding MCParticles
52    
53     ClassDef(TrackingParticle,1) // Generated particle class
54     };
55     }
56    
57     //--------------------------------------------------------------------------------------------------
58 paus 1.4 inline void mithep::TrackingParticle::Mark() const
59     {
60     // mark myself
61     mithep::DataObject::Mark();
62     // mark my dependencies if they are there
63     for (UInt_t i=0; i<fMCParts.Entries(); i++)
64     fMCParts.At(i)->Mark();
65     }
66    
67     //--------------------------------------------------------------------------------------------------
68 bendavid 1.1 inline const mithep::MCParticle *mithep::TrackingParticle::DistinctMother() const
69     {
70     // Return mother, walking up the tree until a particle with a different pdg from this one
71     // is found.
72    
73     const mithep::MCParticle *mcPart = FinalMCPart();
74    
75     if (mcPart)
76     return mcPart->DistinctMother();
77    
78     return 0;
79    
80     }
81    
82     //--------------------------------------------------------------------------------------------------
83     inline const mithep::MCParticle *mithep::TrackingParticle::FinalMCPart() const
84     {
85     // Return last MCParticle in the chain
86    
87     if (NMCParts()) {
88     return MCPart(NMCParts() - 1);
89     }
90     else {
91     return 0;
92     }
93    
94     }
95    
96     //--------------------------------------------------------------------------------------------------
97     inline const mithep::MCParticle *mithep::TrackingParticle::InitialMCPart() const
98     {
99     // Return first MCParticle in the chain
100    
101     if (NMCParts()) {
102     return MCPart(0);
103     }
104     else {
105     return 0;
106     }
107    
108     }
109    
110     //--------------------------------------------------------------------------------------------------
111     inline Double_t mithep::TrackingParticle::GetCharge() const
112     {
113     // Get charge from first MC particle.
114    
115     const MCParticle *firstMCPart = InitialMCPart();
116    
117     if (firstMCPart) {
118     return firstMCPart->Charge();
119     }
120     else {
121     return 0.0;
122     }
123    
124     }
125    
126     //--------------------------------------------------------------------------------------------------
127     inline void mithep::TrackingParticle::GetMom() const
128     {
129     // Get momentum from first MC particle.
130    
131     const MCParticle *firstMCPart = InitialMCPart();
132    
133     if (firstMCPart) {
134     fCachedMom = firstMCPart->Mom();
135     }
136     else {
137     fCachedMom = FourVectorM();
138     }
139    
140     }
141    
142     #endif