ndmspc  0.20250128.0
HepTrack.cxx
1 #include <TString.h>
2 #include <TRandom.h>
3 #include <TMath.h>
4 #include "HepTrack.h"
5 
7 ClassImp(Ndmspc::Hep::Track);
9 
10 namespace Ndmspc {
11 namespace Hep {
12 
13 Track::Track() : TObject(), fPx(0.0), fPy(0.0), fPz(0.0), fCharge(0), fIsPrimary(0), fTPCSignal(0)
14 {
18 
19  gRandom->SetSeed(0);
20  for (Int_t i = 0; i < 5; ++i) {
21  fPIDNsigma[i] = -999.0;
22  }
23 }
24 
26 {
30 }
31 
33 {
37 
38  Double_t px, py;
39  gRandom->Rannor(px, py);
40  fPx = px;
41  fPy = py;
42  fPz = TMath::Sqrt(px * px + py * py);
43 
44  fIsPrimary = (gRandom->Integer(2) > 0) ? kTRUE : kFALSE;
45 
46  // Generate charge
47  fCharge = (gRandom->Integer(2) > 0) ? 1 : -1;
48 }
49 
50 void Track::Print(Option_t * /*option*/) const
51 {
55 
56  Printf("ch=%d px=%.3f py=%.3f pz=%.3f primary=%d", fCharge, fPx, fPy, fPz, fIsPrimary);
57 }
58 
59 void Track::Clear(Option_t *)
60 {
64 
65  fCharge = 0;
66  fPx = 0;
67  fPy = 0;
68  fPz = 0;
69  fTPCSignal = 0;
70  fIsPrimary = kFALSE;
71 
72  for (Int_t i = 0; i < 5; ++i) {
73  fPIDNsigma[i] = -999.0;
74  }
75 }
76 
77 void Track::SetP(Double_t * p)
78 {
82  fPx = p[0];
83  fPy = p[1];
84  fPz = p[2];
85 }
86 
87 Double_t Track::GetP() const
88 {
92  return TMath::Sqrt(TMath::Power(fPx, 2) + TMath::Power(fPy, 2) + TMath::Power(fPz, 2));
93 }
94 
95 void Track::SetPIDNsigma(Int_t i, Double_t s)
96 {
101 
102  fPIDNsigma[i] = s;
103 }
104 } // namespace Hep
105 } // namespace Ndmspc
Track object.
Definition: HepTrack.h:15
virtual void Print(Option_t *option="") const
Definition: HepTrack.cxx:50
virtual void Clear(Option_t *option="")
Definition: HepTrack.cxx:59
Short_t fCharge
Charge.
Definition: HepTrack.h:95
Double_t fPz
Momentum z.
Definition: HepTrack.h:94
void SetP(Double_t *p)
Definition: HepTrack.cxx:77
virtual ~Track()
Definition: HepTrack.cxx:25
Double_t fPIDNsigma[5]
PID N Sigma.
Definition: HepTrack.h:98
Double_t GetP() const
Get momentum value for current track.
Definition: HepTrack.cxx:87
Bool_t fIsPrimary
Flag if track was defined as primary.
Definition: HepTrack.h:96
Double_t fPx
Momentum x.
Definition: HepTrack.h:92
Double_t fTPCSignal
TPC signal.
Definition: HepTrack.h:97
Double_t fPy
Momentum y.
Definition: HepTrack.h:93
void SetPIDNsigma(Int_t i, Double_t s)
Definition: HepTrack.cxx:95