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 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
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 44 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().

44  {
45  TrackInformation *trkInfo = new TrackInformation();
46  LogDebug("SimG4CoreApplication") << "NewTrackAction called for " << aTrack->GetTrackID() << " mother "
47  << motherInfo.isPrimary() << " flag " << flag;
48 
49  // Take care of cascade decays
50  if (flag == 1) {
51  trkInfo->isPrimary(true);
52  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
53  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
54  } else {
55  trkInfo->setGenParticlePID(motherInfo.genParticlePID());
56  trkInfo->setGenParticleP(motherInfo.genParticleP());
57  }
58 
59  // Store if decay or conversion
60  if (flag > 0) {
61  trkInfo->storeTrack(true);
62  trkInfo->putInHistory();
63  trkInfo->setIDonCaloSurface(aTrack->GetTrackID(),
64  motherInfo.getIDCaloVolume(),
65  motherInfo.getIDLastVolume(),
66  aTrack->GetDefinition()->GetPDGEncoding(),
67  aTrack->GetMomentum().mag());
68  } else {
69  // transfer calo ID from mother (to be checked in TrackingAction)
70  trkInfo->setIDonCaloSurface(motherInfo.getIDonCaloSurface(),
71  motherInfo.getIDCaloVolume(),
72  motherInfo.getIDLastVolume(),
73  motherInfo.caloSurfaceParticlePID(),
74  motherInfo.caloSurfaceParticleP());
75  }
76 
77  if (motherInfo.hasCastorHit()) {
78  trkInfo->setCastorHitPID(motherInfo.getCastorHitPID());
79  }
80 
81  aTrack->SetUserInformation(trkInfo);
82 }
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  if (aSecondary->GetParentID() != mother.GetTrackID()) {
21  G4Exception("SimG4Core/Notification",
22  "mc001",
23  FatalException,
24  "NewTrackAction: secondary parent ID does not match mother id");
25  } else {
26  TrackInformationExtractor extractor;
27  const TrackInformation &motherInfo(extractor(mother));
28  addUserInfoToSecondary(aSecondary, motherInfo, flag);
29  LogDebug("SimTrackManager") << "NewTrackAction: Add track " << aSecondary->GetTrackID() << " from mother "
30  << mother.GetTrackID();
31  }
32 }
void addUserInfoToSecondary(G4Track *aTrack, const TrackInformation &motherInfo, int) const
#define LogDebug(id)