EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PndMCTrack.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PndMCTrack.cxx
1 // -------------------------------------------------------------------------
2 // ----- PndMCTrack source file -----
3 // ----- Created 03/08/04 by V. Friese (CbmMCTrack) -----
4 // ----- Created 11/02/09 by M. Al-Turany -----
5 // -------------------------------------------------------------------------
6 
7 
8 #include <iostream>
9 
10 #include "PndMCTrack.h"
11 #include <limits>
12 using namespace std;
13 // ----- Default constructor -------------------------------------------
15  fPdgCode(0),
16  fMotherID(-1),
17  fSecondMotherID(-1),
18  fPoints(0),
19  fStartX(0), fStartY(0), fStartZ(0), fStartT(0),
20  fPx(0), fPy(0), fPz(0), fE(0),
21  fGeneratorFlags(0)
22 {
23 }
24 // -------------------------------------------------------------------------
25 
26 
27 
28 // ----- Standard constructor ------------------------------------------
29 /*// Not used at all?
30 PndMCTrack::PndMCTrack(Int_t pdgCode, Int_t motherID, TVector3 startVertex,
31  Double_t startTime, TLorentzVector momentum, Int_t nPoint){
32  fPdgCode = pdgCode;
33  fMotherID = motherID;
34  fSecondMotherID = -1;
35  fStartX = startVertex.X();
36  fStartY = startVertex.Y();
37  fStartZ = startVertex.Z();
38  fStartT = startTime;
39  fPx = momentum.Px();
40  fPy = momentum.Py();
41  fPz = momentum.Pz();
42  fE = momentum.E();
43  if (nPoint >= 0) fPoints = nPoint;
44  else fPoints = 0;
45  fGeneratorFlags=0;
46 }
47 */
48 // -------------------------------------------------------------------------
49 
50 
51 
52 // ----- Copy constructor ----------------------------------------------
54  fPdgCode(track.fPdgCode),
55  fMotherID(track.fMotherID),
56  fSecondMotherID(track.fSecondMotherID),
57  fPoints(track.fPoints),
58  fStartX(track.fStartX), fStartY(track.fStartY), fStartZ(track.fStartZ), fStartT(track.fStartT),
59  fPx(track.fPx), fPy(track.fPy), fPz(track.fPz), fE(track.fE),
60  fGeneratorFlags(track.fGeneratorFlags)
61 {
62 }
63 // -------------------------------------------------------------------------
64 
65 
66 
67 // ----- Constructor from TParticle ------------------------------------
69  fPdgCode(part->GetPdgCode()),
70  fMotherID(part->GetMother(0)),
71  fSecondMotherID(part->GetMother(1)),
72  fStartX(part->Vx()),
73  fStartY(part->Vy()),
74  fStartZ(part->Vz()),
75  fStartT(part->T()*1e09),
76  fPx(part->Px()),
77  fPy(part->Py()),
78  fPz(part->Pz()),
79  fE(part->Energy()),
80  fPoints(0),
81  fGeneratorFlags(0)
82 {
83 }
84 // -------------------------------------------------------------------------
85 
86 
87 
88 // ----- Destructor ----------------------------------------------------
90 // -------------------------------------------------------------------------
91 
92 
93 
94 // ----- Public method Print -------------------------------------------
95 void PndMCTrack::Print(Int_t trackID) const {
96  cout << "Track " << trackID << ", mother : " << fMotherID <<", secondmother : " << fSecondMotherID << ", Type "
97  << fPdgCode << ", momentum (" << fPx << ", " << fPy << ", " << fPz<< ", " << fE
98  << ") GeV" << " , Generatorflags: "<<fGeneratorFlags<<endl;
99 }
100 // -------------------------------------------------------------------------
101 
102 TLorentzVector PndMCTrack::Get4Momentum() const {
103 /*
104  Double_t mass=0.0;
105  Double_t ene=0.0;
106  TParticlePDG*
107  fParticlePDG = TDatabasePDG::Instance()->GetParticle(fPdgCode);
108 
109  if (fParticlePDG)
110  mass = fParticlePDG->Mass();
111 
112  if ( mass >= 0 ) {
113  ene = TMath::Sqrt(mass*mass + fPx*fPx +fPy*fPy +fPz*fPz);
114  }
115 */
116  return TLorentzVector(fPx,fPy,fPz,fE);
117 }
118 
119 // ----- Public method GetNPoints --------------------------------------
120 Int_t PndMCTrack::GetNPoints(DetectorId detId) const {
121  if ( detId == kDRC ) return ( (fPoints & (3 << 0) ) >> 0 );
122  else if ( detId == kMDT ) return ( (fPoints & (3 << 2) ) >> 2 );
123  else if ( detId == kMVD ) return ( (fPoints & (3 << 4) ) >> 4 );
124  else if ( detId == kRICH) return ( (fPoints & (3 << 6) ) >> 6 );
125  else if ( detId == kEMC ) return ( (fPoints & (3 << 8) ) >> 8 );
126  else if ( detId == kSTT ) return ( (fPoints & (3 << 10) ) >> 10 );
127  else if ( detId == kFTOF) return ( (fPoints & (3 << 12) ) >> 12 );
128  else if ( detId == kTOF ) return ( (fPoints & (3 << 14) ) >> 14 );
129  else if ( detId == kGEM ) return ( (fPoints & (3 << 16) ) >> 16 );
130  else if ( detId == kDSK ) return ( (fPoints & (3 << 18) ) >> 18 );
131  else if ( detId == kHYP ) return ( (fPoints & (3 << 20) ) >> 20 );
132  else if ( detId == kRPC ) return ( (fPoints & (3 << 22) ) >> 22 );
133  else if ( detId == kLUMI) return ( (fPoints & (3 << 24) ) >> 24 );
134  else if ( detId == kHYPG) return ( (fPoints & (3 << 26) ) >> 26 );
135  else if ( detId == kFTS) return ( (fPoints & (3 << 28) ) >> 28 );
136 
137  else {
138  cout << "-E- PndMCTrack::GetNPoints: Unknown detector ID "
139  << detId << endl;
140  return 0;
141  }
142 }
143 void PndMCTrack::SetNPoints(Int_t iDet, Int_t nPoints) {
144 
145  if ( iDet == kDRC ) {
146  if ( nPoints < 0 ) nPoints = 0;
147  else if ( nPoints > 3 ) nPoints = 3;
148  fPoints = ( fPoints & ( ~ ( 3 << 0 ) ) ) | ( nPoints << 0 );
149  }
150 
151  else if ( iDet == kMDT ) {
152  if ( nPoints < 0 ) nPoints = 0;
153  else if ( nPoints > 3 ) nPoints = 3;
154  fPoints = ( fPoints & ( ~ ( 3 << 2 ) ) ) | ( nPoints << 2 );
155  }
156 
157  else if ( iDet == kMVD ) {
158  if ( nPoints < 0 ) nPoints = 0;
159  else if ( nPoints > 3 ) nPoints = 3;
160  fPoints = ( fPoints & ( ~ ( 3 << 4 ) ) ) | ( nPoints << 4 );
161  }
162 
163  else if ( iDet == kRICH ) {
164  if ( nPoints < 0 ) nPoints = 0;
165  else if ( nPoints > 3 ) nPoints = 3;
166  fPoints = ( fPoints & ( ~ ( 3 << 6 ) ) ) | ( nPoints << 6);
167  }
168 
169  else if ( iDet == kEMC ) {
170  if ( nPoints < 0 ) nPoints = 0;
171  else if ( nPoints > 3 ) nPoints = 3;
172  fPoints = ( fPoints & ( ~ ( 3 << 8 ) ) ) | ( nPoints << 8 );
173  }
174 
175  else if ( iDet == kSTT ) {
176  if ( nPoints < 0 ) nPoints = 0;
177  else if ( nPoints > 3 ) nPoints = 3;
178  fPoints = ( fPoints & ( ~ ( 3 << 10 ) ) ) | ( nPoints << 10 );
179  }
180 
181  else if ( iDet == kFTOF ) {
182  if ( nPoints < 0 ) nPoints = 0;
183  else if ( nPoints > 3 ) nPoints = 3;
184  fPoints = ( fPoints & ( ~ ( 3 << 12 ) ) ) | ( nPoints << 12 );
185  }
186 
187  else if ( iDet == kTOF ) {
188  if ( nPoints < 0 ) nPoints = 0;
189  else if ( nPoints > 3 ) nPoints = 3;
190  fPoints = ( fPoints & ( ~ ( 3 << 14 ) ) ) | ( nPoints << 14 );
191  }
192 
193  else if ( iDet == kGEM ) {
194  if ( nPoints < 0 ) nPoints = 0;
195  else if ( nPoints > 3 ) nPoints = 3;
196  fPoints = ( fPoints & ( ~ ( 3 << 16 ) ) ) | ( nPoints << 16 );
197  }
198  else if ( iDet == kDSK ) {
199  if ( nPoints < 0 ) nPoints = 0;
200  else if ( nPoints > 3 ) nPoints = 3;
201  fPoints = ( fPoints & ( ~ ( 3 << 18 ) ) ) | ( nPoints << 18 );
202  }
203 
204  else if ( iDet == kHYP ) {
205  if ( nPoints < 0 ) nPoints = 0;
206  else if ( nPoints > 3 ) nPoints = 3;
207  fPoints = ( fPoints & ( ~ ( 3 << 20 ) ) ) | ( nPoints << 20 );
208  }
209  else if ( iDet == kRPC ) {
210  if ( nPoints < 0 ) nPoints = 0;
211  else if ( nPoints > 3 ) nPoints = 3;
212  fPoints = ( fPoints & ( ~ ( 3 << 22 ) ) ) | ( nPoints << 22 );
213  }
214 
215  else if ( iDet == kLUMI ) {
216  if ( nPoints < 0 ) nPoints = 0;
217  else if ( nPoints > 3 ) nPoints = 3;
218  fPoints = ( fPoints & ( ~ ( 3 << 24 ) ) ) | ( nPoints << 24 );
219  }
220 
221  else if ( iDet == kHYPG ) {
222  if ( nPoints < 0 ) nPoints = 0;
223  else if ( nPoints > 3 ) nPoints = 3;
224  fPoints = ( fPoints & ( ~ ( 3 << 26 ) ) ) | ( nPoints << 26 );
225  }
226 
227  else if ( iDet == kFTS ) {
228  if ( nPoints < 0 ) nPoints = 0;
229  else if ( nPoints > 3 ) nPoints = 3;
230  fPoints = ( fPoints & ( ~ ( 3 << 28 ) ) ) | ( nPoints << 28 );
231  }
232 
233 
234 
235  else cout << "-E- PndMCTrack::SetNPoints: Unknown detector ID "
236  << iDet << endl;
237 
238 }
239 //
240 
241