ndhep  0.1.1
 All Classes Functions Variables Pages
Track.cc
1 #include <TString.h>
2 #include <TRandom.h>
3 #include <TMath.h>
4 #include "Track.hh"
5 
7 ClassImp(NDHep::Track);
9 
10 namespace NDHep
11 {
12 
14  : TObject(), fPx(0.0), fPy(0.0), fPz(0.0), fCharge(0), fIsPrimary(0),
15  fTPCSignal(0)
16 {
20 
21  gRandom->SetSeed(0);
22  for (Int_t i = 0; i < 5; ++i)
23  {
24  fPIDNsigma[i] = -999.0;
25  }
26 }
27 
29 {
33 }
34 
36 {
40 
41  Double_t px, py;
42  gRandom->Rannor(px, py);
43  fPx = px;
44  fPy = py;
45  fPz = TMath::Sqrt(px * px + py * py);
46 
47  fIsPrimary = (gRandom->Integer(2) > 0) ? kTRUE : kFALSE;
48 
49  // Generate charge
50  fCharge = (gRandom->Integer(2) > 0) ? 1 : -1;
51 }
52 
53 void Track::Print(Option_t * /*option*/) const
54 {
58 
59  Printf("ch=%d px=%.3f py=%.3f pz=%.3f primary=%d", fCharge, fPx, fPy, fPz,
60  fIsPrimary);
61 }
62 
63 void Track::Clear(Option_t *)
64 {
68 
69  fCharge = 0;
70  fPx = 0;
71  fPy = 0;
72  fPz = 0;
73  fTPCSignal = 0;
74  fIsPrimary = kFALSE;
75 
76  for (Int_t i = 0; i < 5; ++i)
77  {
78  fPIDNsigma[i] = -999.0;
79  }
80 }
81 
82 void Track::SetP(Double_t *p)
83 {
87  fPx = p[0];
88  fPy = p[1];
89  fPz = p[2];
90 }
91 
92 Double_t Track::GetP() const
93 {
97  return TMath::Sqrt(TMath::Power(fPx, 2) + TMath::Power(fPy, 2) +
98  TMath::Power(fPz, 2));
99 }
100 
101 void Track::SetPIDNsigma(Int_t i, Double_t s)
102 {
107 
108  fPIDNsigma[i] = s;
109 }
110 } // namespace NDHep
void BuildRandom()
Definition: Track.cc:35
Double_t fPx
Momentum x.
Definition: Track.hh:92
virtual void Print(Option_t *option="") const
Definition: Track.cc:53
void SetPIDNsigma(Int_t i, Double_t s)
Definition: Track.cc:101
void SetP(Double_t *p)
Definition: Track.cc:82
Double_t fPy
Momentum y.
Definition: Track.hh:93
Short_t fCharge
Charge.
Definition: Track.hh:95
Track object.
Definition: Track.hh:14
Bool_t fIsPrimary
Flag if track was defined as primary.
Definition: Track.hh:96
virtual ~Track()
Definition: Track.cc:28
Double_t fTPCSignal
TPC signal.
Definition: Track.hh:97
Double_t GetP() const
Get momentum value for current track.
Definition: Track.cc:92
virtual void Clear(Option_t *option="")
Definition: Track.cc:63
Double_t fPz
Momentum z.
Definition: Track.hh:94
Double_t fPIDNsigma[5]
PID N Sigma.
Definition: Track.hh:98