SND@LHC Software
Loading...
Searching...
No Matches
ShipMCTrack Class Reference

#include <ShipMCTrack.h>

Inheritance diagram for ShipMCTrack:
Collaboration diagram for ShipMCTrack:

Public Member Functions

 ShipMCTrack ()
 
 ShipMCTrack (Int_t pdgCode, Int_t motherID, Double_t px, Double_t py, Double_t pz, Double_t E, Double_t x, Double_t y, Double_t z, Double_t t, Int_t nPoints, Double_t w)
 
 ShipMCTrack (const ShipMCTrack &track)
 
 ShipMCTrack (TParticle *particle)
 
virtual ~ShipMCTrack ()
 
void Print (Int_t iTrack=0) const
 
Int_t GetPdgCode () const
 
Int_t GetMotherId () const
 
Double_t GetPx () const
 
Double_t GetPy () const
 
Double_t GetPz () const
 
Double_t GetStartX () const
 
Double_t GetStartY () const
 
Double_t GetStartZ () const
 
Double_t GetStartT () const
 
void SetProcID (Int_t i)
 
Int_t GetProcID () const
 
TString GetProcName () const
 
Double_t GetMass () const
 
Double_t GetEnergy () const
 
Double_t GetPt () const
 
Double_t GetP () const
 
Double_t GetRapidity () const
 
void MultiplyWeight (Double_t w)
 
void SetWeight (Double_t w)
 
Double_t GetWeight () const
 
void GetMomentum (TVector3 &momentum)
 
void Get4Momentum (TLorentzVector &momentum)
 
void GetStartVertex (TVector3 &vertex)
 
Int_t GetNPoints (DetectorId detId) const
 
void SetMotherId (Int_t id)
 
void SetNPoints (Int_t iDet, Int_t np)
 

Private Member Functions

 ClassDef (ShipMCTrack, 8)
 

Private Attributes

Int_t fPdgCode
 
Int_t fMotherId
 
Double32_t fPx
 
Double32_t fPy
 
Double32_t fPz
 
Double32_t fM
 
Double32_t fStartX
 
Double32_t fStartY
 
Double32_t fStartZ
 
Double32_t fStartT
 
Double32_t fW
 
Int_t fProcID
 
Int_t fNPoints
 

Detailed Description

Definition at line 26 of file ShipMCTrack.h.

Constructor & Destructor Documentation

◆ ShipMCTrack() [1/4]

ShipMCTrack::ShipMCTrack ( )

Default constructor

Definition at line 13 of file ShipMCTrack.cxx.

14 : TObject(),
15 fPdgCode(0),
16 fMotherId(-1),
17 fPx(0.),
18 fPy(0.),
19 fPz(0.),
20 fM(-1.),
21 fStartX(0.),
22 fStartY(0.),
23 fStartZ(0.),
24 fStartT(0.),
25 fNPoints(0),
26 fW(1.),
27 fProcID(44)
28{
29}
Double32_t fPy
Int_t fPdgCode
Definition ShipMCTrack.h:96
Double32_t fStartX
Double32_t fW
Double32_t fStartZ
Double32_t fM
Double32_t fStartY
Double32_t fStartT
Int_t fMotherId
Definition ShipMCTrack.h:99
Double32_t fPz
Double32_t fPx

◆ ShipMCTrack() [2/4]

ShipMCTrack::ShipMCTrack ( Int_t  pdgCode,
Int_t  motherID,
Double_t  px,
Double_t  py,
Double_t  pz,
Double_t  E,
Double_t  x,
Double_t  y,
Double_t  z,
Double_t  t,
Int_t  nPoints,
Double_t  w 
)

Standard constructor

Definition at line 35 of file ShipMCTrack.cxx.

38 : TObject(),
39 fPdgCode(pdgCode),
40 fMotherId(motherId),
41 fPx(px),
42 fPy(py),
43 fPz(pz),
44 fM(M),
45 fStartX(x),
46 fStartY(y),
47 fStartZ(z),
48 fStartT(t),
49 fNPoints(nPoints),
50 fW(w)
51{
52}

◆ ShipMCTrack() [3/4]

ShipMCTrack::ShipMCTrack ( const ShipMCTrack track)

Copy constructor

Definition at line 58 of file ShipMCTrack.cxx.

59 : TObject(track),
60 fPdgCode(track.fPdgCode),
61 fMotherId(track.fMotherId),
62 fPx(track.fPx),
63 fPy(track.fPy),
64 fPz(track.fPz),
65 fM(track.fM),
66 fStartX(track.fStartX),
67 fStartY(track.fStartY),
68 fStartZ(track.fStartZ),
69 fStartT(track.fStartT),
70 fNPoints(track.fNPoints),
71 fProcID(track.GetProcID()),
72 fW(track.GetWeight())
73{
74}

◆ ShipMCTrack() [4/4]

ShipMCTrack::ShipMCTrack ( TParticle *  particle)

Constructor from TParticle

Definition at line 80 of file ShipMCTrack.cxx.

81 : TObject(),
82 fPdgCode(part->GetPdgCode()),
83 fMotherId(part->GetMother(0)),
84 fPx(part->Px()),
85 fPy(part->Py()),
86 fPz(part->Pz()),
87 fM([](const TParticle* p) {
88 Double_t m2 = p->Energy() * p->Energy() - p->P() * p->P();
89 if (m2 >= 0.) return TMath::Sqrt(m2);
90 // Tiny negative: numerical noise for on-shell massless particle
91 Double_t e2 = p->Energy() * p->Energy();
92 if (-m2 < 1e-10 * e2) return 0.;
93 // Genuinely spacelike (virtual photon): store negative mass (ROOT
94 // convention)
95 return -TMath::Sqrt(-m2);
96 }(part)),
97 fStartX(part->Vx()),
98 fStartY(part->Vy()),
99 fStartZ(part->Vz()),
100 fStartT(part->T()*1e09),
101 fNPoints(0),
102 fProcID(part->GetUniqueID()),
103 fW(part->GetWeight())
104{
105}
int m2
Definition hepunit.py:57

◆ ~ShipMCTrack()

ShipMCTrack::~ShipMCTrack ( )
virtual

Destructor

Definition at line 111 of file ShipMCTrack.cxx.

111{ }

Member Function Documentation

◆ ClassDef()

ShipMCTrack::ClassDef ( ShipMCTrack  ,
 
)
private

◆ Get4Momentum()

void ShipMCTrack::Get4Momentum ( TLorentzVector &  momentum)
inline

Definition at line 146 of file ShipMCTrack.h.

147{
148 momentum.SetXYZT(fPx,fPy,fPz,GetEnergy());
149}
Double_t GetEnergy() const

◆ GetEnergy()

Double_t ShipMCTrack::GetEnergy ( ) const

Definition at line 130 of file ShipMCTrack.cxx.

131{
132 if (fM<0){
133// older data, mass not made persistent
134 Double_t mass = GetMass();
135 return TMath::Sqrt(mass*mass + fPx*fPx + fPy*fPy + fPz*fPz );
136 }else{
137 if (fPdgCode==22){return TMath::Sqrt(fPx*fPx + fPy*fPy + fPz*fPz );}
138 return TMath::Sqrt(fM*fM + fPx*fPx + fPy*fPy + fPz*fPz );
139 }
140}
Double_t GetMass() const
mass(particle)
Definition hnl.py:47

◆ GetMass()

Double_t ShipMCTrack::GetMass ( ) const

Definition at line 142 of file ShipMCTrack.cxx.

143{
144 if (fM<0){
145// older data, mass not made persistent
146 if ( TDatabasePDG::Instance() ) {
147 TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(fPdgCode);
148 if ( particle ) { return particle->Mass(); }
149 else { return 0.; }
150 }
151 }else{
152 if (!std::isnan(fM)) { return fM; }
153 else{
154 if ( TDatabasePDG::Instance() ) {
155 TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(fPdgCode);
156 if ( particle && !std::isnan(particle->Mass()) ) { return particle->Mass(); }
157 else { return 0.; }
158 }
159 }
160 }
161}

◆ GetMomentum()

void ShipMCTrack::GetMomentum ( TVector3 &  momentum)
inline

Definition at line 140 of file ShipMCTrack.h.

141{
142 momentum.SetXYZ(fPx,fPy,fPz);
143}

◆ GetMotherId()

Int_t ShipMCTrack::GetMotherId ( ) const
inline

Definition at line 59 of file ShipMCTrack.h.

59{ return fMotherId; }

◆ GetNPoints()

Int_t ShipMCTrack::GetNPoints ( DetectorId  detId) const

Accessors to the number of MCPoints in the detectors

Definition at line 186 of file ShipMCTrack.cxx.

187{
188/* // TODO: Where does this come from
189 if ( detId == kREF ) { return ( fNPoints & 1); }
190 else if ( detId == kTutDet ) { return ( (fNPoints & ( 7 << 1) ) >> 1); }
191 else if ( detId == kFairRutherford ) { return ( (fNPoints & (31 << 4) ) >> 4); }
192 else {
193 LOG(ERROR) << "Unknown detector ID " << detId ;
194 return 0;
195 }
196*/
197 return 0;
198}

◆ GetP()

Double_t ShipMCTrack::GetP ( ) const
inline

Definition at line 73 of file ShipMCTrack.h.

73{ return TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz); }

◆ GetPdgCode()

Int_t ShipMCTrack::GetPdgCode ( ) const
inline

Accessors

Definition at line 58 of file ShipMCTrack.h.

58{ return fPdgCode; }

◆ GetProcID()

Int_t ShipMCTrack::GetProcID ( ) const
inline

Definition at line 68 of file ShipMCTrack.h.

68{ return fProcID; }

◆ GetProcName()

TString ShipMCTrack::GetProcName ( ) const
inline

Definition at line 69 of file ShipMCTrack.h.

69{ return TMCProcessName[fProcID]; }

◆ GetPt()

Double_t ShipMCTrack::GetPt ( ) const
inline

Definition at line 72 of file ShipMCTrack.h.

72{ return TMath::Sqrt(fPx*fPx+fPy*fPy); }

◆ GetPx()

Double_t ShipMCTrack::GetPx ( ) const
inline

Definition at line 60 of file ShipMCTrack.h.

60{ return fPx; }

◆ GetPy()

Double_t ShipMCTrack::GetPy ( ) const
inline

Definition at line 61 of file ShipMCTrack.h.

61{ return fPy; }

◆ GetPz()

Double_t ShipMCTrack::GetPz ( ) const
inline

Definition at line 62 of file ShipMCTrack.h.

62{ return fPz; }

◆ GetRapidity()

Double_t ShipMCTrack::GetRapidity ( ) const

Definition at line 174 of file ShipMCTrack.cxx.

175{
176 Double_t e = GetEnergy();
177 Double_t y = 0.5 * TMath::Log( (e+fPz) / (e-fPz) );
178 return y;
179}

◆ GetStartT()

Double_t ShipMCTrack::GetStartT ( ) const
inline

Definition at line 66 of file ShipMCTrack.h.

66{ return fStartT; }

◆ GetStartVertex()

void ShipMCTrack::GetStartVertex ( TVector3 &  vertex)
inline

Definition at line 152 of file ShipMCTrack.h.

153{
154 vertex.SetXYZ(fStartX,fStartY,fStartZ);
155}

◆ GetStartX()

Double_t ShipMCTrack::GetStartX ( ) const
inline

Definition at line 63 of file ShipMCTrack.h.

63{ return fStartX; }

◆ GetStartY()

Double_t ShipMCTrack::GetStartY ( ) const
inline

Definition at line 64 of file ShipMCTrack.h.

64{ return fStartY; }

◆ GetStartZ()

Double_t ShipMCTrack::GetStartZ ( ) const
inline

Definition at line 65 of file ShipMCTrack.h.

65{ return fStartZ; }

◆ GetWeight()

Double_t ShipMCTrack::GetWeight ( ) const

Definition at line 166 of file ShipMCTrack.cxx.

167{
168 return fW;
169}

◆ MultiplyWeight()

void ShipMCTrack::MultiplyWeight ( Double_t  w)
inline

Definition at line 75 of file ShipMCTrack.h.

75{fW = fW*w;}

◆ Print()

void ShipMCTrack::Print ( Int_t  iTrack = 0) const

Output to screen

Definition at line 117 of file ShipMCTrack.cxx.

118{
119 LOG(DEBUG) << "Track " << trackId << ", mother : " << fMotherId << ", Type "
120 << fPdgCode << ", momentum (" << fPx << ", " << fPy << ", "
121 << fPz << ") GeV" ;
122 /* LOG(DEBUG2) << " Ref " << GetNPoints(kREF)
123 << ", TutDet " << GetNPoints(kTutDet)
124 << ", Rutherford " << GetNPoints(kFairRutherford) ;
125*/
126}

◆ SetMotherId()

void ShipMCTrack::SetMotherId ( Int_t  id)
inline

Modifiers

Definition at line 88 of file ShipMCTrack.h.

◆ SetNPoints()

void ShipMCTrack::SetNPoints ( Int_t  iDet,
Int_t  np 
)

Definition at line 204 of file ShipMCTrack.cxx.

205{
206/*
207 if ( iDet == kREF ) {
208 if ( nPoints < 0 ) { nPoints = 0; }
209 else if ( nPoints > 1 ) { nPoints = 1; }
210 fNPoints = ( fNPoints & ( ~ 1 ) ) | nPoints;
211 }
212
213 else if ( iDet == kTutDet ) {
214 if ( nPoints < 0 ) { nPoints = 0; }
215 else if ( nPoints > 7 ) { nPoints = 7; }
216 fNPoints = ( fNPoints & ( ~ ( 7 << 1 ) ) ) | ( nPoints << 1 );
217 }
218
219 else if ( iDet == kFairRutherford ) {
220 if ( nPoints < 0 ) { nPoints = 0; }
221 else if ( nPoints > 31 ) { nPoints = 31; }
222 fNPoints = ( fNPoints & ( ~ ( 31 << 4 ) ) ) | ( nPoints << 4 );
223 }
224
225 else LOG(ERROR) << "Unknown detector ID " << iDet ;
226*/
227}

◆ SetProcID()

void ShipMCTrack::SetProcID ( Int_t  i)
inline

Definition at line 67 of file ShipMCTrack.h.

67{ fProcID = i; }
int i
Definition ShipAna.py:86

◆ SetWeight()

void ShipMCTrack::SetWeight ( Double_t  w)
inline

Definition at line 76 of file ShipMCTrack.h.

76{fW = w;}

Member Data Documentation

◆ fM

Double32_t ShipMCTrack::fM
private

Definition at line 102 of file ShipMCTrack.h.

◆ fMotherId

Int_t ShipMCTrack::fMotherId
private

Index of mother track. -1 for primary particles.

Definition at line 99 of file ShipMCTrack.h.

◆ fNPoints

Int_t ShipMCTrack::fNPoints
private

Bitvector representing the number of MCPoints for this track in each subdetector. The detectors are represented by REF: Bit 0 (1 bit, max. value 1) MVD: Bit 1 - 3 (3 bits, max. value 7) STS: Bit 4 - 8 (5 bits, max. value 31) RICH: Bit 9 (1 bit, max. value 1) MUCH: Bit 10 - 14 (5 bits, max. value 31) TRD: Bit 15 - 19 (5 bits, max. value 31) TOF: Bit 20 - 23 (4 bits, max. value 15) ECAL: Bit 24 (1 bit, max. value 1) ZDC: Bit 25 (1 bit, max. value 1) The respective point numbers can be accessed and modified with the inline functions. Bits 26-31 are spare for potential additional detectors.

Definition at line 128 of file ShipMCTrack.h.

◆ fPdgCode

Int_t ShipMCTrack::fPdgCode
private

PDG particle code

Definition at line 96 of file ShipMCTrack.h.

◆ fProcID

Int_t ShipMCTrack::fProcID
private

Geant4 process ID which created the particle

Definition at line 111 of file ShipMCTrack.h.

◆ fPx

Double32_t ShipMCTrack::fPx
private

Momentum components at start vertex [GeV]

Definition at line 102 of file ShipMCTrack.h.

◆ fPy

Double32_t ShipMCTrack::fPy
private

Definition at line 102 of file ShipMCTrack.h.

◆ fPz

Double32_t ShipMCTrack::fPz
private

Definition at line 102 of file ShipMCTrack.h.

◆ fStartT

Double32_t ShipMCTrack::fStartT
private

Definition at line 105 of file ShipMCTrack.h.

◆ fStartX

Double32_t ShipMCTrack::fStartX
private

Coordinates of start vertex [cm, ns]

Definition at line 105 of file ShipMCTrack.h.

◆ fStartY

Double32_t ShipMCTrack::fStartY
private

Definition at line 105 of file ShipMCTrack.h.

◆ fStartZ

Double32_t ShipMCTrack::fStartZ
private

Definition at line 105 of file ShipMCTrack.h.

◆ fW

Double32_t ShipMCTrack::fW
private

weight

Definition at line 108 of file ShipMCTrack.h.


The documentation for this class was generated from the following files: