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::NewTrackAction ( )

Definition at line 9 of file NewTrackAction.cc.

9 {}

Member Function Documentation

◆ addUserInfoToPrimary()

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

Definition at line 26 of file NewTrackAction.cc.

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

Referenced by primary().

26  {
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 }
bool storeTrack() const
bool isPrimary() const
void setGenParticlePID(int id)
void setGenParticleP(double p)

◆ addUserInfoToSecondary()

void NewTrackAction::addUserInfoToSecondary ( G4Track *  aTrack,
const TrackInformation motherInfo,
int  flag 
) const
private

Definition at line 36 of file NewTrackAction.cc.

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

Referenced by secondary().

36  {
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
bool hasCastorHit() const
void setGenParticlePID(int id)
void setCastorHitPID(const int pid)
double caloSurfaceParticleP() const
int caloSurfaceParticlePID() const
int getIDonCaloSurface() const
int getIDLastVolume() const
int genParticlePID() const
void setGenParticleP(double p)
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
#define LogDebug(id)

◆ primary() [1/2]

void NewTrackAction::primary ( const G4Track *  aSecondary) const

Definition at line 11 of file NewTrackAction.cc.

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

11 { primary(const_cast<G4Track *>(aTrack)); }
void primary(const G4Track *aSecondary) const

◆ primary() [2/2]

void NewTrackAction::primary ( G4Track *  aSecondary) const

Definition at line 13 of file NewTrackAction.cc.

References addUserInfoToPrimary().

13 { addUserInfoToPrimary(aTrack); }
void addUserInfoToPrimary(G4Track *aTrack) const

◆ secondary() [1/2]

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

Definition at line 15 of file NewTrackAction.cc.

References RemoveAddSevLevel::flag.

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

15  {
16  secondary(const_cast<G4Track *>(aSecondary), mother, flag);
17 }
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const

◆ secondary() [2/2]

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

Definition at line 19 of file NewTrackAction.cc.

References addUserInfoToSecondary(), RemoveAddSevLevel::flag, and LogDebug.

19  {
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 }
void addUserInfoToSecondary(G4Track *aTrack, const TrackInformation &motherInfo, int) const
#define LogDebug(id)