SND@LHC Software
Loading...
Searching...
No Matches
ShipMCTrack.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- ShipMCTrack source file -----
3// -------------------------------------------------------------------------
4#include "ShipMCTrack.h"
5
6#include "FairLogger.h" // for FairLogger, etc
7
8#include "TDatabasePDG.h" // for TDatabasePDG
9#include "TParticle.h" // for TParticle
10#include "TParticlePDG.h" // for TParticlePDG
11
12// ----- Default constructor -------------------------------------------
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}
30// -------------------------------------------------------------------------
31
32
33
34// ----- Standard constructor ------------------------------------------
35ShipMCTrack::ShipMCTrack(Int_t pdgCode, Int_t motherId, Double_t px,
36 Double_t py, Double_t pz, Double_t M, Double_t x, Double_t y,
37 Double_t z, Double_t t, Int_t nPoints, Double_t w)
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}
53// -------------------------------------------------------------------------
54
55
56
57// ----- Copy constructor ----------------------------------------------
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}
75// -------------------------------------------------------------------------
76
77
78
79// ----- Constructor from TParticle ------------------------------------
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(TMath::Sqrt( part->Energy()*part->Energy()-part->P()*part->P() )),
88 fStartX(part->Vx()),
89 fStartY(part->Vy()),
90 fStartZ(part->Vz()),
91 fStartT(part->T()*1e09),
92 fNPoints(0),
93 fProcID(part->GetUniqueID()),
94 fW(part->GetWeight())
95{
96}
97// -------------------------------------------------------------------------
98
99
100
101// ----- Destructor ----------------------------------------------------
103// -------------------------------------------------------------------------
104
105
106
107// ----- Public method Print -------------------------------------------
108void ShipMCTrack::Print(Int_t trackId) const
109{
110 LOG(DEBUG) << "Track " << trackId << ", mother : " << fMotherId << ", Type "
111 << fPdgCode << ", momentum (" << fPx << ", " << fPy << ", "
112 << fPz << ") GeV" ;
113 /* LOG(DEBUG2) << " Ref " << GetNPoints(kREF)
114 << ", TutDet " << GetNPoints(kTutDet)
115 << ", Rutherford " << GetNPoints(kFairRutherford) ;
116*/
117}
118// -------------------------------------------------------------------------
119// ----- Public method GetEnergy -----------------------------------------
120
122{
123 if (fM<0){
124// older data, mass not made persistent
125 Double_t mass = GetMass();
126 return TMath::Sqrt(mass*mass + fPx*fPx + fPy*fPy + fPz*fPz );
127 }else{
128 if (fPdgCode==22){return TMath::Sqrt(fPx*fPx + fPy*fPy + fPz*fPz );}
129 return TMath::Sqrt(fM*fM + fPx*fPx + fPy*fPy + fPz*fPz );
130 }
131}
132// ----- Public method GetMass -----------------------------------------
133Double_t ShipMCTrack::GetMass() const
134{
135 if (fM<0){
136// older data, mass not made persistent
137 if ( TDatabasePDG::Instance() ) {
138 TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(fPdgCode);
139 if ( particle ) { return particle->Mass(); }
140 else { return 0.; }
141 }
142 }
143 return fM;
144}
145// -------------------------------------------------------------------------
146
147
148// ----- Public method GetWeight -------------------------------------
150{
151 return fW;
152}
153// -------------------------------------------------------------------------
154
155
156// ----- Public method GetRapidity -------------------------------------
158{
159 Double_t e = GetEnergy();
160 Double_t y = 0.5 * TMath::Log( (e+fPz) / (e-fPz) );
161 return y;
162}
163// -------------------------------------------------------------------------
164
165
166
167
168// ----- Public method GetNPoints --------------------------------------
170{
171/* // TODO: Where does this come from
172 if ( detId == kREF ) { return ( fNPoints & 1); }
173 else if ( detId == kTutDet ) { return ( (fNPoints & ( 7 << 1) ) >> 1); }
174 else if ( detId == kFairRutherford ) { return ( (fNPoints & (31 << 4) ) >> 4); }
175 else {
176 LOG(ERROR) << "Unknown detector ID " << detId ;
177 return 0;
178 }
179*/
180 return 0;
181}
182// -------------------------------------------------------------------------
183
184
185
186// ----- Public method SetNPoints --------------------------------------
187void ShipMCTrack::SetNPoints(Int_t iDet, Int_t nPoints)
188{
189/*
190 if ( iDet == kREF ) {
191 if ( nPoints < 0 ) { nPoints = 0; }
192 else if ( nPoints > 1 ) { nPoints = 1; }
193 fNPoints = ( fNPoints & ( ~ 1 ) ) | nPoints;
194 }
195
196 else if ( iDet == kTutDet ) {
197 if ( nPoints < 0 ) { nPoints = 0; }
198 else if ( nPoints > 7 ) { nPoints = 7; }
199 fNPoints = ( fNPoints & ( ~ ( 7 << 1 ) ) ) | ( nPoints << 1 );
200 }
201
202 else if ( iDet == kFairRutherford ) {
203 if ( nPoints < 0 ) { nPoints = 0; }
204 else if ( nPoints > 31 ) { nPoints = 31; }
205 fNPoints = ( fNPoints & ( ~ ( 31 << 4 ) ) ) | ( nPoints << 4 );
206 }
207
208 else LOG(ERROR) << "Unknown detector ID " << iDet ;
209*/
210}
211// -------------------------------------------------------------------------
212
213
214
215
DetectorId
Double_t GetWeight() const
void Print(Int_t iTrack=0) const
Double32_t fPy
Int_t fPdgCode
Definition ShipMCTrack.h:96
Double_t GetRapidity() const
Double_t GetMass() const
Double32_t fW
Double32_t fM
Double_t GetEnergy() const
Int_t GetNPoints(DetectorId detId) const
void SetNPoints(Int_t iDet, Int_t np)
Int_t fMotherId
Definition ShipMCTrack.h:99
Double32_t fPz
virtual ~ShipMCTrack()
Double32_t fPx
ClassImp(ecalContFact) ecalContFact