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