ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TrackingParticle.h
Revision: 1.5
Committed: Thu Mar 29 23:41:55 2012 UTC (13 years, 1 month ago) by paus
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, HEAD
Changes since 1.4: +5 -6 lines
Log Message:
Version with working skimming and last 4.4 tag.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: TrackingParticle.h,v 1.4 2012/03/28 12:15:35 paus 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 // Some structural tools
45 void Mark(UInt_t i=1) const;
46
47 protected:
48 Double_t GetCharge() const;
49 void GetMom() const;
50 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 inline void mithep::TrackingParticle::Mark(UInt_t ib) const
59 {
60 // mark myself
61 mithep::DataObject::Mark(ib);
62 // mark my dependencies if they are there
63 fMCParts.Mark(ib);
64 }
65
66 //--------------------------------------------------------------------------------------------------
67 inline const mithep::MCParticle *mithep::TrackingParticle::DistinctMother() const
68 {
69 // Return mother, walking up the tree until a particle with a different pdg from this one
70 // is found.
71
72 const mithep::MCParticle *mcPart = FinalMCPart();
73
74 if (mcPart)
75 return mcPart->DistinctMother();
76
77 return 0;
78
79 }
80
81 //--------------------------------------------------------------------------------------------------
82 inline const mithep::MCParticle *mithep::TrackingParticle::FinalMCPart() const
83 {
84 // Return last MCParticle in the chain
85
86 if (NMCParts()) {
87 return MCPart(NMCParts() - 1);
88 }
89 else {
90 return 0;
91 }
92
93 }
94
95 //--------------------------------------------------------------------------------------------------
96 inline const mithep::MCParticle *mithep::TrackingParticle::InitialMCPart() const
97 {
98 // Return first MCParticle in the chain
99
100 if (NMCParts()) {
101 return MCPart(0);
102 }
103 else {
104 return 0;
105 }
106
107 }
108
109 //--------------------------------------------------------------------------------------------------
110 inline Double_t mithep::TrackingParticle::GetCharge() const
111 {
112 // Get charge from first MC particle.
113
114 const MCParticle *firstMCPart = InitialMCPart();
115
116 if (firstMCPart) {
117 return firstMCPart->Charge();
118 }
119 else {
120 return 0.0;
121 }
122
123 }
124
125 //--------------------------------------------------------------------------------------------------
126 inline void mithep::TrackingParticle::GetMom() const
127 {
128 // Get momentum from first MC particle.
129
130 const MCParticle *firstMCPart = InitialMCPart();
131
132 if (firstMCPart) {
133 fCachedMom = firstMCPart->Mom();
134 }
135 else {
136 fCachedMom = FourVectorM();
137 }
138
139 }
140
141 #endif