CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 37 of file NewTrackAction.cc.

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

Referenced by primary().

37  {
38  TrackInformation * trkInfo = new TrackInformation();
39  trkInfo->isPrimary(true);
40  trkInfo->storeTrack(true);
41  trkInfo->putInHistory();
42  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
43  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
44  aTrack->SetUserInformation(trkInfo);
45 }
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 47 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().

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

Definition at line 18 of file NewTrackAction.cc.

References addUserInfoToPrimary().

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

Definition at line 22 of file NewTrackAction.cc.

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

22  {
23  secondary(const_cast<G4Track *>(aSecondary),mother,flag);
24 }
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
void NewTrackAction::secondary ( G4Track *  aSecondary,
const G4Track &  mother,
int  flag 
) const

Definition at line 26 of file NewTrackAction.cc.

References addUserInfoToSecondary(), and LogDebug.

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