1 |
bendavid |
1.1 |
//--------------------------------------------------------------------------------------------------
|
2 |
paus |
1.5 |
// $Id: TrackingParticle.h,v 1.4 2012/03/28 12:15:35 paus 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 |
paus |
1.5 |
void Mark(UInt_t i=1) const;
|
46 |
paus |
1.4 |
|
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.5 |
inline void mithep::TrackingParticle::Mark(UInt_t ib) const
|
59 |
paus |
1.4 |
{
|
60 |
|
|
// mark myself
|
61 |
paus |
1.5 |
mithep::DataObject::Mark(ib);
|
62 |
paus |
1.4 |
// mark my dependencies if they are there
|
63 |
paus |
1.5 |
fMCParts.Mark(ib);
|
64 |
paus |
1.4 |
}
|
65 |
|
|
|
66 |
|
|
//--------------------------------------------------------------------------------------------------
|
67 |
bendavid |
1.1 |
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
|