CMS 3D CMS Logo

NewTrackAction.cc
Go to the documentation of this file.
1 
4 
6 
7 #include "G4Track.hh"
8 
10 
11 void NewTrackAction::primary(const G4Track *aTrack) const { primary(const_cast<G4Track *>(aTrack)); }
12 
13 void NewTrackAction::primary(G4Track *aTrack) const { addUserInfoToPrimary(aTrack); }
14 
15 void NewTrackAction::secondary(const G4Track *aSecondary, const G4Track &mother, int flag) const {
16  secondary(const_cast<G4Track *>(aSecondary), mother, flag);
17 }
18 
19 void NewTrackAction::secondary(G4Track *aSecondary, const G4Track &mother, int flag) const {
20  const TrackInformation *motherInfo = static_cast<const TrackInformation *>(mother.GetUserInformation());
21  addUserInfoToSecondary(aSecondary, *motherInfo, flag);
22  LogDebug("SimTrackManager") << "NewTrackAction: Add track " << aSecondary->GetTrackID() << " from mother "
23  << mother.GetTrackID();
24 }
25 
26 void NewTrackAction::addUserInfoToPrimary(G4Track *aTrack) const {
27  TrackInformation *trkInfo = new TrackInformation();
28  trkInfo->isPrimary(true);
29  trkInfo->storeTrack(true);
30  trkInfo->putInHistory();
31  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
32  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
33  aTrack->SetUserInformation(trkInfo);
34 }
35 
36 void NewTrackAction::addUserInfoToSecondary(G4Track *aTrack, const TrackInformation &motherInfo, int flag) const {
37  TrackInformation *trkInfo = new TrackInformation();
38  LogDebug("SimG4CoreApplication") << "NewTrackAction called for " << aTrack->GetTrackID() << " mother "
39  << motherInfo.isPrimary() << " flag " << flag;
40 
41  // Take care of cascade decays
42  if (flag == 1) {
43  trkInfo->isPrimary(true);
44  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
45  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
46  } else {
47  trkInfo->setGenParticlePID(motherInfo.genParticlePID());
48  trkInfo->setGenParticleP(motherInfo.genParticleP());
49  }
50 
51  // Store if decay or conversion
52  if (flag > 0) {
53  trkInfo->storeTrack(true);
54  trkInfo->putInHistory();
55  trkInfo->setIDonCaloSurface(aTrack->GetTrackID(),
56  motherInfo.getIDCaloVolume(),
57  motherInfo.getIDLastVolume(),
58  aTrack->GetDefinition()->GetPDGEncoding(),
59  aTrack->GetMomentum().mag());
60  } else {
61  // transfer calo ID from mother (to be checked in TrackingAction)
62  trkInfo->setIDonCaloSurface(motherInfo.getIDonCaloSurface(),
63  motherInfo.getIDCaloVolume(),
64  motherInfo.getIDLastVolume(),
65  motherInfo.caloSurfaceParticlePID(),
66  motherInfo.caloSurfaceParticleP());
67  }
68 
69  if (motherInfo.hasCastorHit()) {
70  trkInfo->setCastorHitPID(motherInfo.getCastorHitPID());
71  }
72 
73  aTrack->SetUserInformation(trkInfo);
74 }
bool storeTrack() const
double genParticleP() const
bool isPrimary() const
int getIDCaloVolume() const
int getCastorHitPID() const
void addUserInfoToSecondary(G4Track *aTrack, const TrackInformation &motherInfo, int) const
bool hasCastorHit() const
void addUserInfoToPrimary(G4Track *aTrack) const
void setGenParticlePID(int id)
void setCastorHitPID(const int pid)
double caloSurfaceParticleP() const
int caloSurfaceParticlePID() const
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
int getIDonCaloSurface() const
int getIDLastVolume() const
int genParticlePID() const
void setGenParticleP(double p)
void primary(const G4Track *aSecondary) const
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
#define LogDebug(id)