FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MyProjMCTrack.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 // -------------------------------------------------------------------------
10 // ----- MyProjMCTrack source file -----
11 // ----- M. Al-Turany June 2014 -----
12 // ----- This is a light weight particle class that is saved to disk
13 // ----- instead of saveing the TParticle class
14 // ----- IT is also used for filtring the stack
15 // -------------------------------------------------------------------------
16 
17 #include "MyProjMCTrack.h"
18 
19 #include "FairLogger.h" // for FairLogger, etc
20 
21 #include <TDatabasePDG.h> // for TDatabasePDG
22 #include <TParticle.h> // for TParticle
23 #include <TParticlePDG.h> // for TParticlePDG
24 
25 // ----- Default constructor -------------------------------------------
27  : TObject()
28  , fPdgCode(0)
29  , fMotherId(-1)
30  , fPx(0.)
31  , fPy(0.)
32  , fPz(0.)
33  , fStartX(0.)
34  , fStartY(0.)
35  , fStartZ(0.)
36  , fStartT(0.)
37  , fNPoints(0)
38 {}
39 // -------------------------------------------------------------------------
40 
41 // ----- Standard constructor ------------------------------------------
42 MyProjMCTrack::MyProjMCTrack(Int_t pdgCode,
43  Int_t motherId,
44  Double_t px,
45  Double_t py,
46  Double_t pz,
47  Double_t x,
48  Double_t y,
49  Double_t z,
50  Double_t t,
51  Int_t nPoints = 0)
52  : TObject()
53  , fPdgCode(pdgCode)
54  , fMotherId(motherId)
55  , fPx(px)
56  , fPy(py)
57  , fPz(pz)
58  , fStartX(x)
59  , fStartY(y)
60  , fStartZ(z)
61  , fStartT(t)
62  , fNPoints(nPoints)
63 {}
64 // -------------------------------------------------------------------------
65 
66 // ----- Copy constructor ----------------------------------------------
68  : TObject(track)
69  , fPdgCode(track.fPdgCode)
70  , fMotherId(track.fMotherId)
71  , fPx(track.fPx)
72  , fPy(track.fPy)
73  , fPz(track.fPz)
74  , fStartX(track.fStartX)
75  , fStartY(track.fStartY)
76  , fStartZ(track.fStartZ)
77  , fStartT(track.fStartT)
78  , fNPoints(track.fNPoints)
79 {}
80 // -------------------------------------------------------------------------
81 
82 // ----- Constructor from TParticle ------------------------------------
83 MyProjMCTrack::MyProjMCTrack(TParticle* part)
84  : TObject()
85  , fPdgCode(part->GetPdgCode())
86  , fMotherId(part->GetMother(0))
87  , fPx(part->Px())
88  , fPy(part->Py())
89  , fPz(part->Pz())
90  , fStartX(part->Vx())
91  , fStartY(part->Vy())
92  , fStartZ(part->Vz())
93  , fStartT(part->T() * 1e09)
94  , fNPoints(0)
95 {}
96 // -------------------------------------------------------------------------
97 
98 // ----- Destructor ----------------------------------------------------
100 // -------------------------------------------------------------------------
101 
102 // ----- Public method Print -------------------------------------------
103 void MyProjMCTrack::Print(Int_t trackId) const
104 {
105  LOG(debug) << "Track " << trackId << ", mother : " << fMotherId << ", Type " << fPdgCode << ", momentum (" << fPx
106  << ", " << fPy << ", " << fPz << ") GeV";
107  /* LOG(debug2) << " Ref " << GetNPoints(kREF)
108  << ", TutDet " << GetNPoints(kTutDet)
109  << ", Rutherford " << GetNPoints(kFairRutherford);
110 */
111 }
112 // -------------------------------------------------------------------------
113 
114 // ----- Public method GetMass -----------------------------------------
115 Double_t MyProjMCTrack::GetMass() const
116 {
117  if (TDatabasePDG::Instance()) {
118  TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(fPdgCode);
119  if (particle) {
120  return particle->Mass();
121  } else {
122  return 0.;
123  }
124  }
125  return 0.;
126 }
127 // -------------------------------------------------------------------------
128 
129 // ----- Public method GetRapidity -------------------------------------
130 Double_t MyProjMCTrack::GetRapidity() const
131 {
132  Double_t e = GetEnergy();
133  Double_t y = 0.5 * TMath::Log((e + fPz) / (e - fPz));
134  return y;
135 }
136 // -------------------------------------------------------------------------
137 
138 // ----- Public method GetNPoints --------------------------------------
139 Int_t MyProjMCTrack::GetNPoints(DetectorId detId) const
140 {
141  /* // TODO: Where does this come from
142  if ( detId == kREF ) { return ( fNPoints & 1); }
143  else if ( detId == kTutDet ) { return ( (fNPoints & ( 7 << 1) ) >> 1); }
144  else if ( detId == kFairRutherford ) { return ( (fNPoints & (31 << 4) ) >> 4); }
145  else {
146  LOG(error) << "Unknown detector ID " << detId;
147  return 0;
148  }
149 */
150 }
151 // -------------------------------------------------------------------------
152 
153 // ----- Public method SetNPoints --------------------------------------
154 void MyProjMCTrack::SetNPoints(Int_t iDet, Int_t nPoints)
155 {
156  /*
157  if ( iDet == kREF ) {
158  if ( nPoints < 0 ) { nPoints = 0; }
159  else if ( nPoints > 1 ) { nPoints = 1; }
160  fNPoints = ( fNPoints & ( ~ 1 ) ) | nPoints;
161  }
162 
163  else if ( iDet == kTutDet ) {
164  if ( nPoints < 0 ) { nPoints = 0; }
165  else if ( nPoints > 7 ) { nPoints = 7; }
166  fNPoints = ( fNPoints & ( ~ ( 7 << 1 ) ) ) | ( nPoints << 1 );
167  }
168 
169  else if ( iDet == kFairRutherford ) {
170  if ( nPoints < 0 ) { nPoints = 0; }
171  else if ( nPoints > 31 ) { nPoints = 31; }
172  fNPoints = ( fNPoints & ( ~ ( 31 << 4 ) ) ) | ( nPoints << 4 );
173  }
174 
175  else LOG(error) << "Unknown detector ID " << iDet;
176 */
177 }
178 // -------------------------------------------------------------------------
179 
DetectorId
ClassImp(FairEventBuilder)
Int_t GetNPoints(DetectorId detId) const
Double_t GetMass() const
Double_t GetEnergy() const
void Print(Int_t iTrack=0) const
Double_t GetRapidity() const
void SetNPoints(Int_t iDet, Int_t np)
virtual ~MyProjMCTrack()