ATLAS Offline Software
Loading...
Searching...
No Matches
G4UA::iGeant4::TrackProcessorUserActionBase Class Referenceabstract

#include <TrackProcessorUserActionBase.h>

Inheritance diagram for G4UA::iGeant4::TrackProcessorUserActionBase:
Collaboration diagram for G4UA::iGeant4::TrackProcessorUserActionBase:

Public Member Functions

 TrackProcessorUserActionBase ()=default
virtual void BeginOfEventAction (const G4Event *) override final
virtual void EndOfEventAction (const G4Event *) override final
virtual void PreUserTrackingAction (const G4Track *) override
virtual void PostUserTrackingAction (const G4Track *) override final
virtual void UserSteppingAction (const G4Step *) override final
ISF::ISFParticleContainer ReturnSecondaries (ISF::ISFParticle const *parent)

Protected Member Functions

virtual void ISFSteppingAction (const G4Step *, ISF::ISFParticle *)=0
 This method is called by TrackProcessorUserActionBase after the G4Track->ISFParticle association has been established for the current G4Track.

Protected Attributes

AtlasG4EventUserInfom_atlasG4EvtUserInfo {}
 event-global G4 UserInformation
ISF::ISFParticleContainer m_storedSecondaries

Private Member Functions

void setupPrimary (G4Track &)
 Setup the given G4Track as the current primary particle which we'll process.
void setupSecondary (const G4Track &)
 Setup the given G4Track as the current secondary particle which we'll process.
void updateCachedParticleInfo (ISF::ISFParticle *baseISFParticle, HepMC::ConstGenParticlePtr primaryGenParticle, HepMC::GenParticlePtr currentGenParticle)
 Set the following information as the currently traced particle.
VTrackInformation::TrackClassification classify (HepMC::ConstGenParticlePtr primaryGenParticle, HepMC::ConstGenParticlePtr generationZeroGenParticle, HepMC::ConstGenParticlePtr currentGenParticle, int regenerationNumber) const
 Classify the particle represented by the given set of truth links.

Private Attributes

ISF::ISFParticlem_curBaseISP {}
 The most recent ISFParticle ancestor that triggers the currently processed G4Track.

Detailed Description

Definition at line 30 of file TrackProcessorUserActionBase.h.

Constructor & Destructor Documentation

◆ TrackProcessorUserActionBase()

G4UA::iGeant4::TrackProcessorUserActionBase::TrackProcessorUserActionBase ( )
default

Member Function Documentation

◆ BeginOfEventAction()

void G4UA::iGeant4::TrackProcessorUserActionBase::BeginOfEventAction ( const G4Event * )
finaloverridevirtual

Definition at line 48 of file TrackProcessorUserActionBase.cxx.

49{
50 m_curBaseISP = nullptr;
52 return;
53}
AtlasG4EventUserInfo * m_atlasG4EvtUserInfo
event-global G4 UserInformation
ISF::ISFParticle * m_curBaseISP
The most recent ISFParticle ancestor that triggers the currently processed G4Track.
static AtlasG4EventUserInfo * getAtlasG4EventUserInfo()
return pointer to current AtlasG4EventUserInfo

◆ classify()

VTrackInformation::TrackClassification G4UA::iGeant4::TrackProcessorUserActionBase::classify ( HepMC::ConstGenParticlePtr primaryGenParticle,
HepMC::ConstGenParticlePtr generationZeroGenParticle,
HepMC::ConstGenParticlePtr currentGenParticle,
int regenerationNumber ) const
private

Classify the particle represented by the given set of truth links.

Definition at line 222 of file TrackProcessorUserActionBase.cxx.

226{
227 // if particle points to a non-zero truth particle it can not just be a 'simple' Secondary
228
229 if (currentGenParticle) {
230 if (currentGenParticle == primaryGenParticle) {
232 }
233 else if (generationZeroGenParticle == primaryGenParticle && regenerationNumber>0) {
235 }
236 else {
238 }
239 }
240
242}

◆ EndOfEventAction()

void G4UA::iGeant4::TrackProcessorUserActionBase::EndOfEventAction ( const G4Event * )
finaloverridevirtual

Definition at line 55 of file TrackProcessorUserActionBase.cxx.

56{
57 m_curBaseISP = nullptr;
58 m_atlasG4EvtUserInfo = nullptr;
59 return;
60}

◆ ISFSteppingAction()

virtual void G4UA::iGeant4::TrackProcessorUserActionBase::ISFSteppingAction ( const G4Step * ,
ISF::ISFParticle *  )
protectedpure virtual

This method is called by TrackProcessorUserActionBase after the G4Track->ISFParticle association has been established for the current G4Track.

Implemented in G4UA::iGeant4::TrackProcessorUserActionFullG4, and G4UA::iGeant4::TrackProcessorUserActionPassBack.

◆ PostUserTrackingAction()

void G4UA::iGeant4::TrackProcessorUserActionBase::PostUserTrackingAction ( const G4Track * )
finaloverridevirtual

Definition at line 246 of file TrackProcessorUserActionBase.cxx.

247{
248 m_curBaseISP = nullptr;
249 return;
250}

◆ PreUserTrackingAction()

void G4UA::iGeant4::TrackProcessorUserActionBase::PreUserTrackingAction ( const G4Track * aTrack)
overridevirtual

Reimplemented in G4UA::iGeant4::TrackProcessorUserActionFullG4.

Definition at line 106 of file TrackProcessorUserActionBase.cxx.

107{
108 // AdePT currently does not return the G4Secondary vector per G4Step. As the vector is required to attach
109 // the G4VUserInfo below the G4VUserInfo is not available, which would lead to nullptr access crashes
110#ifdef ATHSIMULATION_USE_ADEPT
111 return;
112#endif
113
114 bool isPrimary = ! aTrack->GetParentID();
115 if (isPrimary) {
116 G4Track* nonConstTrack ATLAS_THREAD_SAFE = const_cast<G4Track*> (aTrack); // imposed by Geant4 interface
117 setupPrimary(*nonConstTrack);
118 } else {
119 setupSecondary(*aTrack);
120 }
121
122 return;
123}
#define ATLAS_THREAD_SAFE
void setupPrimary(G4Track &)
Setup the given G4Track as the current primary particle which we'll process.
void setupSecondary(const G4Track &)
Setup the given G4Track as the current secondary particle which we'll process.
@ isPrimary
true if matched track has a hit in first or second pixel layer

◆ ReturnSecondaries()

ISF::ISFParticleContainer G4UA::iGeant4::TrackProcessorUserActionBase::ReturnSecondaries ( ISF::ISFParticle const * parent)

Definition at line 252 of file TrackProcessorUserActionBase.cxx.

253{
254 // For now, just return all particles
257 return result;
258}
std::list< ISF::ISFParticle * > ISFParticleContainer
generic ISFParticle container (not necessarily a std::list!)
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)

◆ setupPrimary()

void G4UA::iGeant4::TrackProcessorUserActionBase::setupPrimary ( G4Track & aTrack)
private

Setup the given G4Track as the current primary particle which we'll process.

Definition at line 125 of file TrackProcessorUserActionBase.cxx.

126{
127 //
128 // Get PrimaryParticleInformation from G4PrimaryParticle (assigned by TransportTool::addPrimaryVertex)
129 //
130
131 auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack);
132 if ( trackInfo ) {
133 G4ExceptionDescription description;
134 description << G4String("PreUserTrackingAction: ")
135 << "Started simulation of primary particle which already has a TrackInformation/TrackBarcodeInfo object attached (trackID: "
136 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
137 << ", parentID " << aTrack.GetParentID() << ")";
138 G4Exception("iGeant4::TrackProcessorUserActionBase", "TrackInformationAlreadyExists", FatalException, description);
139 return; // The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
140 }
141
142 auto* primaryPartInfo = dynamic_cast <PrimaryParticleInformation*> (aTrack.GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation());
143 if (!primaryPartInfo) {
144 G4ExceptionDescription description;
145 description << G4String("PreUserTrackingAction: ") + "NULL PrimaryParticleInformation pointer for current G4Step (trackID "
146 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
147 << ", parentID " << aTrack.GetParentID() << ")";
148 G4Exception("iGeant4::TrackProcessorUserActionBase", "NoPPInfo", FatalException, description);
149 return; // The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
150 }
151
152 // get base ISFParticle and link to TrackInformation
153 auto* baseISP = primaryPartInfo->GetISFParticle();
154 if (!baseISP) {
155 G4ExceptionDescription description;
156 description << G4String("PreUserTrackingAction: ") + "No ISFParticle associated with primary particle (trackID: "
157 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
158 << ", parentID " << aTrack.GetParentID() << ")";
159 G4Exception("iGeant4::TrackProcessorUserActionBase", "NoISFParticle", FatalException, description);
160 return; // The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
161 }
162
163 ISF::TruthBinding* truthBinding = baseISP->getTruthBinding();
164 if (!truthBinding) {
165 G4ExceptionDescription description;
166 description << G4String("PreUserTrackingAction: ") + "No ISF::TruthBinding associated with primary particle (trackID: "
167 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
168 << ", parentID " << aTrack.GetParentID() << ")";
169 G4Exception("iGeant4::TrackProcessorUserActionBase", "NoISFTruthBinding", FatalException, description);
170 return; // The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
171 }
172
173 int regenerationNr = primaryPartInfo->GetRegenerationNr();
174
175 HepMC::GenParticlePtr primaryGenParticle = truthBinding->getGenerationZeroGenParticle();
176 HepMC::GenParticlePtr generationZeroGenParticle = truthBinding->getGenerationZeroGenParticle();
177 HepMC::GenParticlePtr currentGenParticle = truthBinding->getCurrentGenParticle();
178
179 auto classification = classify(primaryGenParticle,
180 generationZeroGenParticle,
181 currentGenParticle,
182 regenerationNr);
183
184 auto* newTrackInfo = ::iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track(aTrack,
185 *baseISP,
186 classification,
187 generationZeroGenParticle );
188 newTrackInfo->SetRegenerationNr(regenerationNr);
189
191 primaryGenParticle,
192 currentGenParticle);
193
194 return;
195}
VTrackInformation::TrackClassification classify(HepMC::ConstGenParticlePtr primaryGenParticle, HepMC::ConstGenParticlePtr generationZeroGenParticle, HepMC::ConstGenParticlePtr currentGenParticle, int regenerationNumber) const
Classify the particle represented by the given set of truth links.
void updateCachedParticleInfo(ISF::ISFParticle *baseISFParticle, HepMC::ConstGenParticlePtr primaryGenParticle, HepMC::GenParticlePtr currentGenParticle)
Set the following information as the currently traced particle.
HepMC::GenParticlePtr getCurrentGenParticle()
pointer to the particle in the simulation truth
HepMC::GenParticlePtr getGenerationZeroGenParticle()
pointer to the simulation truth particle before any regeneration happened (eg.
static VTrackInformation * getISFTrackInfo(const G4Track &aTrack)
return a valid UserInformation object of the G4Track for use within the ISF
static TrackInformation * attachTrackInfoToNewG4Track(G4Track &aTrack, ISF::ISFParticle &baseIsp, VTrackInformation::TrackClassification classification, HepMC::GenParticlePtr generationZeroGenParticle=nullptr)
attach a new TrackInformation object to the given new (!) G4Track (the G4Track must not have a UserIn...
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:93
HepMC3::GenParticlePtr GenParticlePtr
Definition GenParticle.h:19

◆ setupSecondary()

void G4UA::iGeant4::TrackProcessorUserActionBase::setupSecondary ( const G4Track & aTrack)
private

Setup the given G4Track as the current secondary particle which we'll process.

Definition at line 197 of file TrackProcessorUserActionBase.cxx.

198{
199 auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack);
200
201 HepMC::GenParticlePtr currentGenParticle = trackInfo->GetCurrentGenParticle();
202 HepMC::GenParticlePtr primaryGenParticle = trackInfo->GetPrimaryGenParticle();
203 ISF::ISFParticle* baseISFParticle = trackInfo->GetBaseISFParticle();
204
205 updateCachedParticleInfo(baseISFParticle, primaryGenParticle, currentGenParticle);
206
207 return;
208}

◆ updateCachedParticleInfo()

void G4UA::iGeant4::TrackProcessorUserActionBase::updateCachedParticleInfo ( ISF::ISFParticle * baseISFParticle,
HepMC::ConstGenParticlePtr primaryGenParticle,
HepMC::GenParticlePtr currentGenParticle )
private

Set the following information as the currently traced particle.

Definition at line 210 of file TrackProcessorUserActionBase.cxx.

213{
214 m_curBaseISP = baseISFParticle;
215 m_atlasG4EvtUserInfo->SetCurrentPrimaryGenParticle( primaryGenParticle );
216 m_atlasG4EvtUserInfo->SetCurrentGenParticle( currentGenParticle );
217 return;
218}

◆ UserSteppingAction()

void G4UA::iGeant4::TrackProcessorUserActionBase::UserSteppingAction ( const G4Step * aStep)
finaloverridevirtual

Definition at line 62 of file TrackProcessorUserActionBase.cxx.

63{
64 // get geoID from parent
65 //TODO ELLI AtlasDetDescr::AtlasRegion curGeoID = m_curBaseISP->nextGeoID();
66 //TODO ELLI ATH_MSG_DEBUG( "Currently simulating TrackID = " << aStep->GetTrack()->GetTrackID() <<
67 //TODO ELLI " inside geoID = " << curGeoID );
68
69 // AdePT currently does not return the G4Secondary vector per G4Step. As the vector is required to attach
70 // the G4VUserInfo in the PreUserTrackingAction below, the G4VUserInfo is not available, which
71 // would lead to nullptr access crashes
72#ifdef ATHSIMULATION_USE_ADEPT
73 return;
74#endif
75 //
76 // call the ISFSteppingAction method of the implementation
77 //
79
80 //
81 // propagate the current ISFParticle link to all secondaries
82 //
83 const std::vector<const G4Track*> *secondaryVector = aStep->GetSecondaryInCurrentStep();
84 if (secondaryVector && !secondaryVector->empty()) {
85 for ( auto* aConstSecondaryTrack : *secondaryVector ) {
86 // get a non-const G4Track for current secondary (nasty!)
87 G4Track* aSecondaryTrack ATLAS_THREAD_SAFE = const_cast<G4Track*>( aConstSecondaryTrack ); // imposed by Geant4 interface
88
89 auto *trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(*aSecondaryTrack);
90
91 // G4Tracks aready returned to ISF will have a TrackInformation attached to them
92 bool particleReturnedToISF = trackInfo && trackInfo->GetReturnedToISF();
93 if (!particleReturnedToISF) {
94 HepMC::GenParticlePtr generationZeroGenParticle{};
98 generationZeroGenParticle );
99 }
100 } // <- loop over secondaries from this step
101 }
102
103 return;
104}
virtual void ISFSteppingAction(const G4Step *, ISF::ISFParticle *)=0
This method is called by TrackProcessorUserActionBase after the G4Track->ISFParticle association has ...

Member Data Documentation

◆ m_atlasG4EvtUserInfo

AtlasG4EventUserInfo* G4UA::iGeant4::TrackProcessorUserActionBase::m_atlasG4EvtUserInfo {}
protected

event-global G4 UserInformation

Definition at line 48 of file TrackProcessorUserActionBase.h.

48{};

◆ m_curBaseISP

ISF::ISFParticle* G4UA::iGeant4::TrackProcessorUserActionBase::m_curBaseISP {}
private

The most recent ISFParticle ancestor that triggers the currently processed G4Track.

Definition at line 75 of file TrackProcessorUserActionBase.h.

75{};

◆ m_storedSecondaries

ISF::ISFParticleContainer G4UA::iGeant4::TrackProcessorUserActionBase::m_storedSecondaries
protected

Definition at line 50 of file TrackProcessorUserActionBase.h.


The documentation for this class was generated from the following files: