FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairMCTrack.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -------------------------------------------------------------------------
9 // ----- FairMCTrack source file -----
10 // ----- Created 03/08/04 by V. Friese -----
11 // -------------------------------------------------------------------------
12 #include "FairMCTrack.h"
13 
14 #include "FairLogger.h" // for FairLogger, etc
15 
16 #include <TDatabasePDG.h> // for TDatabasePDG
17 #include <TParticle.h> // for TParticle
18 #include <TParticlePDG.h> // for TParticlePDG
19 
21  : TObject()
22  , fPdgCode(0)
23  , fMotherId(-1)
24  , fPx(0.)
25  , fPy(0.)
26  , fPz(0.)
27  , fStartX(0.)
28  , fStartY(0.)
29  , fStartZ(0.)
30  , fStartT(0.)
31  , fNPoints(0)
32 {}
33 
35  Int_t motherId,
36  Double_t px,
37  Double_t py,
38  Double_t pz,
39  Double_t x,
40  Double_t y,
41  Double_t z,
42  Double_t t,
43  Int_t nPoints = 0)
44  : TObject()
45  , fPdgCode(pdgCode)
46  , fMotherId(motherId)
47  , fPx(px)
48  , fPy(py)
49  , fPz(pz)
50  , fStartX(x)
51  , fStartY(y)
52  , fStartZ(z)
53  , fStartT(t)
54  , fNPoints(nPoints)
55 {}
56 
58  : TObject(track)
59  , fPdgCode(track.fPdgCode)
60  , fMotherId(track.fMotherId)
61  , fPx(track.fPx)
62  , fPy(track.fPy)
63  , fPz(track.fPz)
64  , fStartX(track.fStartX)
65  , fStartY(track.fStartY)
66  , fStartZ(track.fStartZ)
67  , fStartT(track.fStartT)
68  , fNPoints(track.fNPoints)
69 {}
70 
71 FairMCTrack::FairMCTrack(TParticle* part)
72  : TObject()
73  , fPdgCode(part->GetPdgCode())
74  , fMotherId(part->GetMother(0))
75  , fPx(part->Px())
76  , fPy(part->Py())
77  , fPz(part->Pz())
78  , fStartX(part->Vx())
79  , fStartY(part->Vy())
80  , fStartZ(part->Vz())
81  , fStartT(part->T() * 1e09)
82  , fNPoints(0)
83 {}
84 
86 
87 void FairMCTrack::Print(Int_t trackId) const
88 {
89  LOG(debug) << "Track " << trackId << ", mother : " << fMotherId << ", Type " << fPdgCode << ", momentum (" << fPx
90  << ", " << fPy << ", " << fPz << ") GeV";
91  LOG(debug2) << " Ref " << GetNPoints(kREF) << ", TutDet " << GetNPoints(kTutDet) << ", Rutherford "
93 }
94 
95 Double_t FairMCTrack::GetMass() const
96 {
97  if (TDatabasePDG::Instance()) {
98  TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(fPdgCode);
99  if (particle) {
100  return particle->Mass();
101  } else {
102  return 0.;
103  }
104  }
105  return 0.;
106 }
107 
108 Double_t FairMCTrack::GetRapidity() const
109 {
110  Double_t e = GetEnergy();
111  Double_t y = 0.5 * TMath::Log((e + fPz) / (e - fPz));
112  return y;
113 }
114 
116 {
117  // TODO: Where does this come from
118  if (detId == kREF) {
119  return (fNPoints & 1);
120  } else if (detId == kTutDet) {
121  return ((fNPoints & (7 << 1)) >> 1);
122  } else if (detId == kFairRutherford) {
123  return ((fNPoints & (31 << 4)) >> 4);
124  } else {
125  LOG(error) << "Unknown detector ID " << detId;
126  return 0;
127  }
128 }
129 
130 void FairMCTrack::SetNPoints(Int_t iDet, Int_t nPoints)
131 {
132  if (iDet == kREF) {
133  if (nPoints < 0) {
134  nPoints = 0;
135  } else if (nPoints > 1) {
136  nPoints = 1;
137  }
138  fNPoints = (fNPoints & (~1)) | nPoints;
139  }
140 
141  else if (iDet == kTutDet) {
142  if (nPoints < 0) {
143  nPoints = 0;
144  } else if (nPoints > 7) {
145  nPoints = 7;
146  }
147  fNPoints = (fNPoints & (~(7 << 1))) | (nPoints << 1);
148  }
149 
150  else if (iDet == kFairRutherford) {
151  if (nPoints < 0) {
152  nPoints = 0;
153  } else if (nPoints > 31) {
154  nPoints = 31;
155  }
156  fNPoints = (fNPoints & (~(31 << 4))) | (nPoints << 4);
157  }
158 
159  else
160  LOG(error) << "Unknown detector ID " << iDet;
161 }
162 
DetectorId
Int_t GetNPoints(DetectorId detId) const
void SetNPoints(Int_t iDet, Int_t np)
Double_t GetMass() const
Definition: FairMCTrack.cxx:95
ClassImp(FairEventBuilder)
Double_t GetRapidity() const
virtual void Print(Int_t iTrack) const
Definition: FairMCTrack.cxx:87
Double_t GetEnergy() const
Definition: FairMCTrack.h:133
virtual ~FairMCTrack()
Definition: FairMCTrack.cxx:85