CMS 3D CMS Logo

TrackWithHistory.cc
Go to the documentation of this file.
5 
7 
8 #include "G4VProcess.hh"
9 #include "G4DynamicParticle.hh"
10 #include "G4PrimaryParticle.hh"
11 #include "G4ThreeVector.hh"
12 
13 #include <iostream>
14 
15 G4ThreadLocal G4Allocator<TrackWithHistory>* fpTrackWithHistoryAllocator = nullptr;
16 
17 TrackWithHistory::TrackWithHistory(const G4Track* g4trk, int pID) {
18  trackID_ = g4trk->GetTrackID();
20  parentID_ = pID;
21  auto mom = g4trk->GetMomentum();
22  momentum_ = math::XYZVectorD(mom.x(), mom.y(), mom.z());
23  totalEnergy_ = g4trk->GetTotalEnergy();
24  auto pos = g4trk->GetPosition();
25  vertexPosition_ = math::XYZVectorD(pos.x(), pos.y(), pos.z());
26  time_ = g4trk->GetGlobalTime();
27  auto p = g4trk->GetCreatorProcess();
28  procType_ = (nullptr != p) ? p->GetProcessSubType() : 0;
29  TrackInformation* trkinfo = static_cast<TrackInformation*>(g4trk->GetUserInformation());
30  storeTrack_ = trkinfo->storeTrack();
31  auto vgprimary = g4trk->GetDynamicParticle()->GetPrimaryParticle();
32  if (vgprimary != nullptr) {
33  auto priminfo = static_cast<GenParticleInfo*>(vgprimary->GetUserInformation());
34  if (nullptr != priminfo) {
35  genParticleID_ = priminfo->id();
36  }
37  }
38  // V.I. weight is computed in the same way as before
39  // without usage of G4Track::GetWeight()
40  weight_ = 10000 * genParticleID_;
41 }
42 
43 TrackWithHistory::TrackWithHistory(const G4PrimaryParticle* ptr, int trackID, const math::XYZVectorD& pos, double time) {
44  trackID_ = trackID;
47  auto mom = ptr->GetMomentum();
48  momentum_ = math::XYZVectorD(mom.x(), mom.y(), mom.z());
49  totalEnergy_ = ptr->GetTotalEnergy();
50  vertexPosition_ = math::XYZVectorD(pos.x(), pos.y(), pos.z());
51  time_ = time;
52  storeTrack_ = true;
53  auto priminfo = static_cast<GenParticleInfo*>(ptr->GetUserInformation());
54  if (nullptr != priminfo) {
55  genParticleID_ = priminfo->id();
56  }
57  weight_ = 10000. * genParticleID_;
58 }
bool storeTrack() const
G4ThreadLocal G4Allocator< TrackWithHistory > * fpTrackWithHistoryAllocator
math::XYZVectorD vertexPosition_
math::XYZVectorD momentum_
double time() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
static int particleID(const G4Track *)
TrackWithHistory(const G4Track *g4track, int pID)
int trackID() const