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

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 updateCurrentBaseISFParticle (ISF::ISFParticle *baseISFParticle)
 Set the base ISFParticle for 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 27 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 46 of file TrackProcessorUserActionBase.cxx.

47{
48 m_curBaseISP = nullptr;
49 return;
50}
ISF::ISFParticle * m_curBaseISP
The most recent ISFParticle ancestor that triggers the currently processed G4Track.

◆ 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 212 of file TrackProcessorUserActionBase.cxx.

216{
217 // if particle points to a non-zero truth particle it can not just be a 'simple' Secondary
218
219 if (currentGenParticle) {
220 if (currentGenParticle == primaryGenParticle) {
222 }
223 else if (generationZeroGenParticle == primaryGenParticle && regenerationNumber>0) {
225 }
226 else {
228 }
229 }
230
232}

◆ EndOfEventAction()

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

Definition at line 52 of file TrackProcessorUserActionBase.cxx.

53{
54 m_curBaseISP = nullptr;
55 return;
56}

◆ 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 236 of file TrackProcessorUserActionBase.cxx.

237{
238 m_curBaseISP = nullptr;
239 return;
240}

◆ PreUserTrackingAction()

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

Reimplemented in G4UA::iGeant4::TrackProcessorUserActionFullG4.

Definition at line 102 of file TrackProcessorUserActionBase.cxx.

103{
104 // AdePT currently does not return the G4Secondary vector per G4Step. As the vector is required to attach
105 // the G4VUserInfo below the G4VUserInfo is not available, which would lead to nullptr access crashes
106#ifdef ATHSIMULATION_USE_ADEPT
107 return;
108#endif
109
110 bool isPrimary = ! aTrack->GetParentID();
111 if (isPrimary) {
112 G4Track* nonConstTrack ATLAS_THREAD_SAFE = const_cast<G4Track*> (aTrack); // imposed by Geant4 interface
113 setupPrimary(*nonConstTrack);
114 } else {
115 setupSecondary(*aTrack);
116 }
117
118 return;
119}
#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 242 of file TrackProcessorUserActionBase.cxx.

243{
244 // For now, just return all particles
247 return result;
248}
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 121 of file TrackProcessorUserActionBase.cxx.

122{
123 //
124 // Get PrimaryParticleInformation from G4PrimaryParticle (assigned by TransportTool::addPrimaryVertex)
125 //
126
127 auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack);
128 if ( trackInfo ) {
129 G4ExceptionDescription description;
130 description << G4String("PreUserTrackingAction: ")
131 << "Started simulation of primary particle which already has a TrackInformation/TrackBarcodeInfo object attached (trackID: "
132 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
133 << ", parentID " << aTrack.GetParentID() << ")";
134 G4Exception("iGeant4::TrackProcessorUserActionBase", "TrackInformationAlreadyExists", FatalException, description);
135 return; // The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
136 }
137
138 auto* primaryPartInfo = dynamic_cast <PrimaryParticleInformation*> (aTrack.GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation());
139 if (!primaryPartInfo) {
140 G4ExceptionDescription description;
141 description << G4String("PreUserTrackingAction: ") + "NULL PrimaryParticleInformation pointer for current G4Step (trackID "
142 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
143 << ", parentID " << aTrack.GetParentID() << ")";
144 G4Exception("iGeant4::TrackProcessorUserActionBase", "NoPPInfo", FatalException, description);
145 return; // The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
146 }
147
148 // get base ISFParticle and link to TrackInformation
149 auto* baseISP = primaryPartInfo->GetISFParticle();
150 if (!baseISP) {
151 G4ExceptionDescription description;
152 description << G4String("PreUserTrackingAction: ") + "No ISFParticle associated with primary particle (trackID: "
153 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
154 << ", parentID " << aTrack.GetParentID() << ")";
155 G4Exception("iGeant4::TrackProcessorUserActionBase", "NoISFParticle", FatalException, description);
156 return; // The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
157 }
158
159 ISF::TruthBinding* truthBinding = baseISP->getTruthBinding();
160 if (!truthBinding) {
161 G4ExceptionDescription description;
162 description << G4String("PreUserTrackingAction: ") + "No ISF::TruthBinding associated with primary particle (trackID: "
163 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
164 << ", parentID " << aTrack.GetParentID() << ")";
165 G4Exception("iGeant4::TrackProcessorUserActionBase", "NoISFTruthBinding", FatalException, description);
166 return; // The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
167 }
168
169 int regenerationNr = primaryPartInfo->GetRegenerationNr();
170
171 // Keep the legacy classification based on generation-zero identity; the
172 // true primary is stored separately on TrackInformation by ISFG4Helper.
173 HepMC::GenParticlePtr generationZeroGenParticle = truthBinding->getGenerationZeroGenParticle();
174 HepMC::GenParticlePtr primaryGenParticle = generationZeroGenParticle;
175 HepMC::GenParticlePtr currentGenParticle = truthBinding->getCurrentGenParticle();
176
177 auto classification = classify(primaryGenParticle,
178 generationZeroGenParticle,
179 currentGenParticle,
180 regenerationNr);
181
182 auto* newTrackInfo = ::iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track(aTrack,
183 *baseISP,
184 classification,
185 generationZeroGenParticle );
186 newTrackInfo->SetRegenerationNr(regenerationNr);
187
189
190 return;
191}
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 updateCurrentBaseISFParticle(ISF::ISFParticle *baseISFParticle)
Set the base ISFParticle for 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 193 of file TrackProcessorUserActionBase.cxx.

194{
195 auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack);
196
197 ISF::ISFParticle* baseISFParticle = trackInfo->GetBaseISFParticle();
198
199 updateCurrentBaseISFParticle(baseISFParticle);
200
201 return;
202}

◆ updateCurrentBaseISFParticle()

void G4UA::iGeant4::TrackProcessorUserActionBase::updateCurrentBaseISFParticle ( ISF::ISFParticle * baseISFParticle)
private

Set the base ISFParticle for the currently traced particle.

Definition at line 204 of file TrackProcessorUserActionBase.cxx.

205{
206 m_curBaseISP = baseISFParticle;
207 return;
208}

◆ UserSteppingAction()

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

Definition at line 58 of file TrackProcessorUserActionBase.cxx.

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

Member Data Documentation

◆ m_curBaseISP

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

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

Definition at line 68 of file TrackProcessorUserActionBase.h.

68{};

◆ m_storedSecondaries

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

Definition at line 45 of file TrackProcessorUserActionBase.h.


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