CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
NewTrackAction Class Reference

#include <NewTrackAction.h>

Public Member Functions

 NewTrackAction ()
 
void primary (const G4Track *aSecondary) const
 
void primary (G4Track *aSecondary) const
 
void secondary (const G4Track *aSecondary, const G4Track &mother, int) const
 
void secondary (G4Track *aSecondary, const G4Track &mother, int) const
 

Private Member Functions

void addUserInfoToPrimary (G4Track *aTrack) const
 
void addUserInfoToSecondary (G4Track *aTrack, const TrackInformation &motherInfo, int) const
 

Detailed Description

SimG4Core Action for new G4tracks. This action is called each time a new G4Track is formed. Since formation (i.e. filling of data members) is done gradually, the best moment to call NewTrackAction is not very clear. Currently done from StackingAction...

Definition at line 14 of file NewTrackAction.h.

Constructor & Destructor Documentation

NewTrackAction::NewTrackAction ( )

Definition at line 12 of file NewTrackAction.cc.

12 {}

Member Function Documentation

void NewTrackAction::addUserInfoToPrimary ( G4Track *  aTrack) const
private

Definition at line 34 of file NewTrackAction.cc.

References TrackInformation::isPrimary(), TrackInformation::putInHistory(), TrackInformation::setGenParticleP(), TrackInformation::setGenParticlePID(), and TrackInformation::storeTrack().

Referenced by primary().

34  {
35  TrackInformation *trkInfo = new TrackInformation();
36  trkInfo->isPrimary(true);
37  trkInfo->storeTrack(true);
38  trkInfo->putInHistory();
39  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
40  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
41  aTrack->SetUserInformation(trkInfo);
42 }
bool storeTrack() const
void setGenParticlePID(int id)
void setGenParticleP(double p)
bool isPrimary() const
void NewTrackAction::addUserInfoToSecondary ( G4Track *  aTrack,
const TrackInformation motherInfo,
int  flag 
) const
private

Definition at line 44 of file NewTrackAction.cc.

References TrackInformation::caloSurfaceParticleP(), TrackInformation::caloSurfaceParticlePID(), TrackInformation::genParticleP(), TrackInformation::genParticlePID(), TrackInformation::getCastorHitPID(), TrackInformation::getIDCaloVolume(), TrackInformation::getIDLastVolume(), TrackInformation::getIDonCaloSurface(), TrackInformation::hasCastorHit(), TrackInformation::isPrimary(), TrackInformation::putInHistory(), TrackInformation::setCastorHitPID(), TrackInformation::setGenParticleP(), TrackInformation::setGenParticlePID(), TrackInformation::setIDonCaloSurface(), and TrackInformation::storeTrack().

Referenced by secondary().

44  {
45  // ralf.ulrich@kit.edu: it is more efficient to use the constructor to copy all data and modify later only when needed
46 
47  TrackInformation *trkInfo = new TrackInformation();
48  // LogDebug("SimG4CoreApplication") << "NewTrackAction called for "
49  // << aTrack->GetTrackID()
50  // << " mother " << motherInfo.isPrimary()
51  // << " flag " << flag;
52 
53  // Take care of cascade decays
54  if (flag == 1) {
55  trkInfo->isPrimary(true);
56  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
57  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
58  } else {
59  trkInfo->setGenParticlePID(motherInfo.genParticlePID());
60  trkInfo->setGenParticleP(motherInfo.genParticleP());
61  }
62 
63  // Store if decay or conversion
64  if (flag > 0) {
65  trkInfo->storeTrack(true);
66  trkInfo->putInHistory();
67  trkInfo->setIDonCaloSurface(aTrack->GetTrackID(),
68  motherInfo.getIDCaloVolume(),
69  motherInfo.getIDLastVolume(),
70  aTrack->GetDefinition()->GetPDGEncoding(),
71  aTrack->GetMomentum().mag());
72  } else {
73  // transfer calo ID from mother (to be checked in TrackingAction)
74  trkInfo->setIDonCaloSurface(motherInfo.getIDonCaloSurface(),
75  motherInfo.getIDCaloVolume(),
76  motherInfo.getIDLastVolume(),
77  motherInfo.caloSurfaceParticlePID(),
78  motherInfo.caloSurfaceParticleP());
79  }
80 
81  if (motherInfo.hasCastorHit()) {
82  trkInfo->setCastorHitPID(motherInfo.getCastorHitPID());
83  }
84 
85  aTrack->SetUserInformation(trkInfo);
86 }
int getCastorHitPID() const
bool storeTrack() const
int getIDonCaloSurface() const
double genParticleP() const
void setGenParticlePID(int id)
void setCastorHitPID(const int pid)
int getIDCaloVolume() const
int genParticlePID() const
int caloSurfaceParticlePID() const
int getIDLastVolume() const
bool hasCastorHit() const
void setGenParticleP(double p)
bool isPrimary() const
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
double caloSurfaceParticleP() const
void NewTrackAction::primary ( const G4Track *  aSecondary) const

Definition at line 14 of file NewTrackAction.cc.

Referenced by KillSecondariesStackingAction::ClassifyNewTrack(), and StackingAction::ClassifyNewTrack().

14 { primary(const_cast<G4Track *>(aTrack)); }
void primary(const G4Track *aSecondary) const
void NewTrackAction::primary ( G4Track *  aSecondary) const

Definition at line 16 of file NewTrackAction.cc.

References addUserInfoToPrimary().

16 { addUserInfoToPrimary(aTrack); }
void addUserInfoToPrimary(G4Track *aTrack) const
void NewTrackAction::secondary ( const G4Track *  aSecondary,
const G4Track &  mother,
int  flag 
) const

Definition at line 18 of file NewTrackAction.cc.

References secondary().

Referenced by KillSecondariesStackingAction::ClassifyNewTrack(), StackingAction::ClassifyNewTrack(), and secondary().

18  {
19  secondary(const_cast<G4Track *>(aSecondary), mother, flag);
20 }
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
void NewTrackAction::secondary ( G4Track *  aSecondary,
const G4Track &  mother,
int  flag 
) const

Definition at line 22 of file NewTrackAction.cc.

References addUserInfoToSecondary(), and LogDebug.

22  {
23  if (aSecondary->GetParentID() != mother.GetTrackID())
24  throw SimG4Exception("NewTrackAction: secondary parent ID does not match mother id");
25  TrackInformationExtractor extractor;
26  const TrackInformation &motherInfo(extractor(mother));
27  addUserInfoToSecondary(aSecondary, motherInfo, flag);
28 #ifdef DebugLog
29  LogDebug("SimTrackManager") << "NewTrackAction: Add track " << aSecondary->GetTrackID() << " from mother "
30  << mother.GetTrackID();
31 #endif
32 }
#define LogDebug(id)
void addUserInfoToSecondary(G4Track *aTrack, const TrackInformation &motherInfo, int) const