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 12 of file NewTrackAction.cc.

12 {}

Member Function Documentation

◆ addUserInfoToPrimary()

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

Definition at line 34 of file NewTrackAction.cc.

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 }

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

Referenced by primary().

◆ addUserInfoToSecondary()

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

Definition at line 44 of file NewTrackAction.cc.

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  trkInfo->setIDfineCalo(motherInfo.getIDfineCalo());
73  } else {
74  // transfer calo ID from mother (to be checked in TrackingAction)
75  trkInfo->setIDonCaloSurface(motherInfo.getIDonCaloSurface(),
76  motherInfo.getIDCaloVolume(),
77  motherInfo.getIDLastVolume(),
78  motherInfo.caloSurfaceParticlePID(),
79  motherInfo.caloSurfaceParticleP());
80  trkInfo->setIDfineCalo(motherInfo.getIDfineCalo());
81  }
82 
83  if (motherInfo.hasCastorHit()) {
84  trkInfo->setCastorHitPID(motherInfo.getCastorHitPID());
85  }
86 
87  aTrack->SetUserInformation(trkInfo);
88 }

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

Referenced by secondary().

◆ primary() [1/2]

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

Definition at line 14 of file NewTrackAction.cc.

14 { primary(const_cast<G4Track *>(aTrack)); }

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

◆ primary() [2/2]

void NewTrackAction::primary ( G4Track *  aSecondary) const

Definition at line 16 of file NewTrackAction.cc.

16 { addUserInfoToPrimary(aTrack); }

References addUserInfoToPrimary().

◆ secondary() [1/2]

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

Definition at line 18 of file NewTrackAction.cc.

18  {
19  secondary(const_cast<G4Track *>(aSecondary), mother, flag);
20 }

References RemoveAddSevLevel::flag, and secondary().

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

◆ secondary() [2/2]

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

Definition at line 22 of file NewTrackAction.cc.

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 }

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

TrackInformation::caloSurfaceParticleP
double caloSurfaceParticleP() const
Definition: TrackInformation.h:53
NewTrackAction::addUserInfoToPrimary
void addUserInfoToPrimary(G4Track *aTrack) const
Definition: NewTrackAction.cc:34
TrackInformation::getIDonCaloSurface
int getIDonCaloSurface() const
Definition: TrackInformation.h:39
NewTrackAction::addUserInfoToSecondary
void addUserInfoToSecondary(G4Track *aTrack, const TrackInformation &motherInfo, int) const
Definition: NewTrackAction.cc:44
TrackInformation::getIDLastVolume
int getIDLastVolume() const
Definition: TrackInformation.h:48
SimG4Exception
Definition: SimG4Exception.h:13
TrackInformation::setIDonCaloSurface
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
Definition: TrackInformation.h:40
TrackInformation::putInHistory
void putInHistory()
Definition: TrackInformation.h:33
TrackInformation::genParticlePID
int genParticlePID() const
Definition: TrackInformation.h:59
TrackInformation::setIDfineCalo
void setIDfineCalo(int id)
Definition: TrackInformation.h:56
TrackInformation::setGenParticleP
void setGenParticleP(double p)
Definition: TrackInformation.h:62
TrackInformationExtractor
Definition: TrackInformationExtractor.h:20
TrackInformation::isPrimary
bool isPrimary() const
Definition: TrackInformation.h:23
NewTrackAction::secondary
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
Definition: NewTrackAction.cc:18
TrackInformation::getIDCaloVolume
int getIDCaloVolume() const
Definition: TrackInformation.h:47
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
TrackInformation::getCastorHitPID
int getCastorHitPID() const
Definition: TrackInformation.h:71
TrackInformation::getIDfineCalo
int getIDfineCalo() const
Definition: TrackInformation.h:55
TrackInformation::setGenParticlePID
void setGenParticlePID(int id)
Definition: TrackInformation.h:60
TrackInformation
Definition: TrackInformation.h:8
TrackInformation::storeTrack
bool storeTrack() const
Definition: TrackInformation.h:14
TrackInformation::genParticleP
double genParticleP() const
Definition: TrackInformation.h:61
TrackInformation::hasCastorHit
bool hasCastorHit() const
Definition: TrackInformation.h:66
TrackInformation::caloSurfaceParticlePID
int caloSurfaceParticlePID() const
Definition: TrackInformation.h:51
TrackInformation::setCastorHitPID
void setCastorHitPID(const int pid)
Definition: TrackInformation.h:67
NewTrackAction::primary
void primary(const G4Track *aSecondary) const
Definition: NewTrackAction.cc:14
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116