ATLAS Offline Software
Loading...
Searching...
No Matches
G4UA::iGeant4::TrackProcessorUserActionPassBack Class Reference

#include <TrackProcessorUserActionPassBack.h>

Inheritance diagram for G4UA::iGeant4::TrackProcessorUserActionPassBack:
Collaboration diagram for G4UA::iGeant4::TrackProcessorUserActionPassBack:

Classes

struct  Config

Public Member Functions

 TrackProcessorUserActionPassBack (const Config &config)
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 Attributes

ISF::ISFParticleContainer m_storedSecondaries

Private Member Functions

void ISFSteppingAction (const G4Step *, ISF::ISFParticle *curISP) override final
 Called by the base class after the G4Track->ISFParticle association has been established.
ISF::TruthBindingnewTruthBinding (const G4Track *aTrack, HepMC::GenParticlePtr currentGenParticle) const
 create a new TruthBinding object for the given G4Track (may return 0 if unable)
ISF::ISFParticlenewISFParticle (G4Track *aTrack, const ISF::ISFParticle *parent, HepMC::GenParticlePtr currentGenParticle, AtlasDetDescr::AtlasRegion nextGeoID)
void returnParticleToISF (G4Track *aTrack, const ISF::ISFParticle *parentISP, HepMC::GenParticlePtr currentGenParticle, AtlasDetDescr::AtlasRegion nextGeoID)
 kills the given G4Track, converts it into an ISFParticle and returns it to the ISF particle broker
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

Config m_config
ISF::IParticleBrokerm_particleBrokerQuick {}
 quick access avoiding gaudi overhead
ISF::IGeoIDSvcm_geoIDSvcQuick {}
 quick access avoiding gaudi overhead
ISF::ISFParticlem_curBaseISP {}
 The most recent ISFParticle ancestor that triggers the currently processed G4Track.

Detailed Description

Definition at line 34 of file TrackProcessorUserActionPassBack.h.

Constructor & Destructor Documentation

◆ TrackProcessorUserActionPassBack()

G4UA::iGeant4::TrackProcessorUserActionPassBack::TrackProcessorUserActionPassBack ( const Config & config)

Definition at line 43 of file TrackProcessorUserActionPassBack.cxx.

44 : m_config(config)
45 {
46 if(4<m_config.verboseLevel)
47 {
48 G4cout << "Initializing TrackProcessorUserActionPassBack" << G4endl;
49 }
50
51 if ( !m_config.particleBroker.empty() ) {
52 if (m_config.particleBroker.retrieve().isFailure()) {
53 G4ExceptionDescription description;
54 description << G4String("TrackProcessorUserActionPassBack: ") + "Could not retrieve ISF Particle Broker: " << m_config.particleBroker;
55 G4Exception("iGeant4::TrackProcessorUserActionPassBack", "NoISFParticleBroker", FatalException, description);
56 return; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
57 }
58 m_particleBrokerQuick = &(*m_config.particleBroker);
59 }
60
61 if ( !m_config.geoIDSvc.empty() ) {
62 if (m_config.geoIDSvc.retrieve().isFailure()) {
63 G4ExceptionDescription description;
64 description << G4String("TrackProcessorUserActionPassBack: ") + "Could not retrieve ISF GeoID Svc: " << m_config.geoIDSvc;
65 G4Exception("iGeant4::TrackProcessorUserActionPassBack", "NoISFGeoIDSvc", FatalException, description);
66 return; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
67 }
68
69 m_geoIDSvcQuick = &(*m_config.geoIDSvc);
70 }
71
72 return;
73
74 }
ISF::IParticleBroker * m_particleBrokerQuick
quick access avoiding gaudi overhead
ISF::IGeoIDSvc * m_geoIDSvcQuick
quick access avoiding gaudi overhead
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:93

Member Function Documentation

◆ BeginOfEventAction()

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

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
privateinherited

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 * )
finaloverridevirtualinherited

Definition at line 52 of file TrackProcessorUserActionBase.cxx.

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

◆ ISFSteppingAction()

void G4UA::iGeant4::TrackProcessorUserActionPassBack::ISFSteppingAction ( const G4Step * aStep,
ISF::ISFParticle * curISP )
finaloverrideprivatevirtual

Called by the base class after the G4Track->ISFParticle association has been established.

Implements G4UA::iGeant4::TrackProcessorUserActionBase.

Definition at line 76 of file TrackProcessorUserActionPassBack.cxx.

78 {
79 G4Track* aTrack = aStep->GetTrack();
80 G4TrackStatus aTrackStatus = aTrack->GetTrackStatus();
81
82 //const G4StepPoint *preStep = aStep->GetPreStepPoint(); // Only used for DEBUG messages
83 const G4StepPoint *postStep = aStep->GetPostStepPoint();
84
85 // get geoID from parent
86 AtlasDetDescr::AtlasRegion curGeoID = curISP->nextGeoID();
87
88 //std::cout<<"retrieved isp "<<curISP<<" for trackID "<<curISP<<std::endl;
89
90 // check geoID of postStep
91 const G4ThreeVector &postPos = postStep->GetPosition();
92 //const G4ThreeVector &postMom = postStep->GetMomentum();
93 //AtlasDetDescr::AtlasRegion nextGeoID = m_geoIDSvcQuick->identifyNextGeoID( postPos.x(),
94 // postPos.y(),
95 // postPos.z(),
96 // postMom.x(),
97 // postMom.y(),
98 // postMom.z() );
99 AtlasDetDescr::AtlasRegion nextGeoID = m_geoIDSvcQuick->identifyGeoID( postPos.x(),
100 postPos.y(),
101 postPos.z() );
102
103 //ATH_MSG_DEBUG("PostStep point resolved to geoID = "<<nextGeoID);
104
105 // return if particle did NOT cross boundary
106 if ( nextGeoID==curGeoID ) {
107 //ATH_MSG_DEBUG(" -> G4Track stays inside geoID = "<<curGeoID);
108
109 // //
110 // // for debugging:
111 // //
112 // if ( msgLvl(MSG::DEBUG) ) {
113 // const G4ThreeVector &prePos = preStep->GetPosition();
114 // AtlasDetDescr::AtlasRegion preStepGeoID = m_geoIDSvcQuick->identifyGeoID( prePos.x(),
115 // prePos.y(),
116 // prePos.z() );
117 // AtlasDetDescr::AtlasRegion postStepGeoID = m_geoIDSvcQuick->identifyGeoID( postPos.x(),
118 // postPos.y(),
119 // postPos.z() );
120
121 // if( preStepGeoID!=postStepGeoID ) {
122 // const G4VPhysicalVolume *preVol = preStep->GetPhysicalVolume();
123 // const G4VPhysicalVolume *postVol = postStep->GetPhysicalVolume();
124 // const G4ThreeVector &preMom = preStep->GetMomentum();
125 // const G4ThreeVector &postMom = postStep->GetMomentum();
126 // const G4TrackVector *secondaryVector = aStep->GetSecondary();
127 // const G4ThreeVector& aTrack_pos = aTrack->GetPosition();
128 // const G4ThreeVector& aTrack_mom = aTrack->GetMomentum();
129 // int pdgID=aTrack->GetDefinition()->GetPDGEncoding();
130 // int aTrackID = aTrack->GetTrackID();
131 // ATH_MSG_WARNING("pre "<<preVol->GetName()<<" x="<<prePos.x()<<" y="<<prePos.y()<<" z="<<prePos.z()<<" p="<<preMom.mag()<<" geoID="<<preStepGeoID<<"; post "<<postVol->GetName()<<" x="<<postPos.x()<<" y="<<postPos.y()<<" z="<<postPos.z()<<" p="<<postMom.mag()<<" geoID="<<nextGeoID<<"; length="<<aStep->GetStepLength()<<"; n2nd="<<secondaryVector->size()<<" track x="<<aTrack_pos.x()<<" y="<<aTrack_pos.y()<<" z="<<aTrack_pos.z()<<" p="<<aTrack_mom.mag()<<" curgeoID="<<curGeoID<<" pdgid="<<pdgID<<" trackID="<<aTrackID<<" ISF="<<curISP<<"; ploss="<<(postMom-preMom).mag());
132 // }
133 // }
134
135 return;
136 }
137
138
139 //
140 // this point is only reached if particle has crossed
141 // a sub-det boundary in the non-Geant4-only mode
142 //
143
144 if ( aTrack->GetKineticEnergy() < m_config.passBackEkinThreshold ) {
145 // kinetic energy of primary particle below threshold
146 // ATH_MSG_DEBUG(" -> G4Track enters geoID = " << nextGeoID <<
147 // " but is below Ekin threshold. Not returned to ISF.");
148 if ( m_config.killBoundaryParticlesBelowThreshold ) {
149 aTrack->SetTrackStatus( fStopAndKill );
150 } else {
151 // TODO: link G4Track to ISF particle with the new GeoID
152 }
153 } else if ( aTrackStatus!=fAlive && aTrackStatus != fStopButAlive ) {
154 // particle is killed by G4 in this step
155 // TODO: do we need to handle this case specifically?
156 // ATH_MSG_DEBUG(" -> G4Track enters geoID = " << nextGeoID <<
157 // " but is destroyed in this step. Not returned to ISF.");
158
159 } else {
160 // particle is above kinetic energy threshold and alive after this step
161 // -> push new ISFParticle back to ISF particle broker
162 // ATH_MSG_DEBUG(" -> G4Track enters geoID = " << nextGeoID <<
163 // " and is returned to ISF.");
164
165 const ISF::ISFParticle* parent = curISP;
166 auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(*aTrack);
167 HepMC::GenParticlePtr currentGenParticle = trackInfo ? trackInfo->GetCurrentGenParticle() : nullptr;
168 this->returnParticleToISF(aTrack, parent, currentGenParticle, nextGeoID); // TODO CHECK THIS LOGIC
169 }
170
171 //
172 // handle secondaries that were created in this G4Step
173 //
174 const std::vector<const G4Track*> *secondaryVector = aStep->GetSecondaryInCurrentStep();
175 // loop over new secondaries
176 if (secondaryVector && !secondaryVector->empty()) {
177 for ( auto* aConstTrack_2nd : *secondaryVector ) {
178 // get a non-const G4Track for current secondary (nasty!)
179 G4Track *aTrack_2nd ATLAS_THREAD_SAFE = const_cast<G4Track*>( aConstTrack_2nd ); // imposed by Geant4 interface
180
181 // check if new secondary position is behind boundary
182 const G4ThreeVector& pos_2nd = aTrack_2nd->GetPosition();
183 AtlasDetDescr::AtlasRegion nextGeoID_2nd = m_geoIDSvcQuick->identifyGeoID( pos_2nd.x(),
184 pos_2nd.y(),
185 pos_2nd.z() );
186 if( nextGeoID_2nd!=curGeoID ) {
187 // secondary was generated in this step and has
188 // a different geoID than the currently tracked one
189
190 if ( aTrack_2nd->GetKineticEnergy() < m_config.passBackEkinThreshold ) {
191 // kinetic energy of secondary particle below threshold
192 // ATH_MSG_DEBUG(" -> Secondary particle generated in this G4Step does not pass Ekin cut." <<
193 // " Not returned to ISF.");
194 if ( m_config.killBoundaryParticlesBelowThreshold ) {
195 // TODO: should we use fKillTrackAndSecondaries instead?
196 aTrack_2nd->SetTrackStatus( fStopAndKill );
197 } else {
198 // TODO: link G4Track to ISF particle with the new GeoID
199 }
200 } else {
201 // secondary particle is above kinetic energy threshold
202 // -> return it to ISF
203 // ATH_MSG_DEBUG(" -> Secondary particle generated in this G4Step is returned to ISF.");
204
205 // attach TrackInformation instance to the new secondary G4Track
206 ISF::ISFParticle *parent = curISP;
207 HepMC::GenParticlePtr generationZeroGenParticle = nullptr;
209 *parent,
211 generationZeroGenParticle );
212
213 HepMC::GenParticlePtr currentGenParticle{};
214 returnParticleToISF(aTrack_2nd, parent, currentGenParticle, nextGeoID_2nd); // TODO CHECK THIS LOGIC
215 }
216 }
217
218 } // <-- end loop over new secondaries
219 } // <-- end if secondary vector has entries
220
221 return;
222 }
#define ATLAS_THREAD_SAFE
void returnParticleToISF(G4Track *aTrack, const ISF::ISFParticle *parentISP, HepMC::GenParticlePtr currentGenParticle, AtlasDetDescr::AtlasRegion nextGeoID)
kills the given G4Track, converts it into an ISFParticle and returns it to the ISF particle broker
AtlasDetDescr::AtlasRegion nextGeoID() const
next geoID the particle will be simulated in
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...
AtlasRegion
A simple enum of ATLAS regions and sub-detectors.
Definition AtlasRegion.h:21
HepMC3::GenParticlePtr GenParticlePtr
Definition GenParticle.h:19

◆ newISFParticle()

ISF::ISFParticle * G4UA::iGeant4::TrackProcessorUserActionPassBack::newISFParticle ( G4Track * aTrack,
const ISF::ISFParticle * parent,
HepMC::GenParticlePtr currentGenParticle,
AtlasDetDescr::AtlasRegion nextGeoID )
private

Definition at line 244 of file TrackProcessorUserActionPassBack.cxx.

248 {
249 ISF::TruthBinding* tBinding = newTruthBinding(aTrack, currentGenParticle);
250
251 ISF::ISFParticle* isp = ::iGeant4::ISFG4Helper::convertG4TrackToISFParticle( *aTrack,
252 *parentISP,
253 tBinding );
254
256 isp->setNextGeoID( AtlasDetDescr::AtlasRegion(nextGeoID) );
257 isp->setNextSimID( parentISP->nextSimID() );
258 }
259
260 return isp;
261 }
ISF::TruthBinding * newTruthBinding(const G4Track *aTrack, HepMC::GenParticlePtr currentGenParticle) const
create a new TruthBinding object for the given G4Track (may return 0 if unable)
void setNextSimID(SimSvcID simID)
register the next SimSvcID
void setNextGeoID(AtlasDetDescr::AtlasRegion geoID)
register the next AtlasDetDescr::AtlasRegion
static ISF::ISFParticle * convertG4TrackToISFParticle(const G4Track &aTrack, const ISF::ISFParticle &parent, ISF::TruthBinding *truth=nullptr)
convert the given G4Track into an ISFParticle

◆ newTruthBinding()

ISF::TruthBinding * G4UA::iGeant4::TrackProcessorUserActionPassBack::newTruthBinding ( const G4Track * aTrack,
HepMC::GenParticlePtr currentGenParticle ) const
private

create a new TruthBinding object for the given G4Track (may return 0 if unable)

Definition at line 224 of file TrackProcessorUserActionPassBack.cxx.

225 {
226 auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(*aTrack);
227 if (!trackInfo) {
228 G4ExceptionDescription description;
229 description << G4String("newTruthBinding: ") + "No TrackInformation associated with G4Track (trackID: "
230 << aTrack->GetTrackID() << ", track pos: "<<aTrack->GetPosition() << ", mom: "<<aTrack->GetMomentum()
231 << ", parentID " << aTrack->GetParentID() << ")";
232 G4Exception("iGeant4::TrackProcessorUserActionPassBack", "NoTrackInformation", FatalException, description);
233 return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
234 }
235
236 HepMC::GenParticlePtr primaryGenParticle = trackInfo->GetPrimaryGenParticle();
237 HepMC::GenParticlePtr generationZeroGenParticle = trackInfo->GetGenerationZeroGenParticle();
238
239 ISF::TruthBinding* tBinding = new ISF::TruthBinding(currentGenParticle, primaryGenParticle, generationZeroGenParticle);
240
241 return tBinding;
242 }

◆ PostUserTrackingAction()

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

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)
overridevirtualinherited

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}
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

◆ returnParticleToISF()

void G4UA::iGeant4::TrackProcessorUserActionPassBack::returnParticleToISF ( G4Track * aTrack,
const ISF::ISFParticle * parentISP,
HepMC::GenParticlePtr currentGenParticle,
AtlasDetDescr::AtlasRegion nextGeoID )
private

kills the given G4Track, converts it into an ISFParticle and returns it to the ISF particle broker

Definition at line 263 of file TrackProcessorUserActionPassBack.cxx.

267 {
268 // kill track inside G4
269 aTrack->SetTrackStatus( fStopAndKill );
270
271 // create new ISFParticle and attach it to current G4Track
272 ISF::ISFParticle *newISP = newISFParticle( aTrack, parentISP, currentGenParticle, nextGeoID );
273
274 // update TrackInformation
275 auto trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(*aTrack);
276 trackInfo->SetReturnedToISF( true );
277 trackInfo->SetBaseISFParticle( newISP );
278
279 // push the particle back to ISF via the particle broker
281 {
282 [&] ATLAS_NOT_THREAD_SAFE () { // suppress checker warning, in MT mode there is no broker
283 m_particleBrokerQuick->push(newISP, parentISP);
284 }();
285 }
286 else
287 {
288 // store the particle for retrieval in MT mode
289 //parentISP must be non-null by here, it has already been deeferenced
290 if (!newISP->getTruthBinding()) newISP->setTruthBinding(new ISF::TruthBinding(*parentISP->getTruthBinding()));
291 m_storedSecondaries.push_back( newISP );
292 }
293
294 return;
295 }
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
ISF::ISFParticle * newISFParticle(G4Track *aTrack, const ISF::ISFParticle *parent, HepMC::GenParticlePtr currentGenParticle, AtlasDetDescr::AtlasRegion nextGeoID)
const TruthBinding * getTruthBinding() const
pointer to the simulation truth - optional, can be 0
void setTruthBinding(TruthBinding *truth)

◆ ReturnSecondaries()

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

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)
privateinherited

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.

◆ setupSecondary()

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

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)
privateinherited

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)
finaloverridevirtualinherited

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_config

Config G4UA::iGeant4::TrackProcessorUserActionPassBack::m_config
private

Definition at line 55 of file TrackProcessorUserActionPassBack.h.

◆ m_curBaseISP

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

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

Definition at line 68 of file TrackProcessorUserActionBase.h.

68{};

◆ m_geoIDSvcQuick

ISF::IGeoIDSvc* G4UA::iGeant4::TrackProcessorUserActionPassBack::m_geoIDSvcQuick {}
private

quick access avoiding gaudi overhead

Definition at line 72 of file TrackProcessorUserActionPassBack.h.

72{};

◆ m_particleBrokerQuick

ISF::IParticleBroker* G4UA::iGeant4::TrackProcessorUserActionPassBack::m_particleBrokerQuick {}
private

quick access avoiding gaudi overhead

Definition at line 71 of file TrackProcessorUserActionPassBack.h.

71{};

◆ m_storedSecondaries

ISF::ISFParticleContainer G4UA::iGeant4::TrackProcessorUserActionBase::m_storedSecondaries
protectedinherited

Definition at line 45 of file TrackProcessorUserActionBase.h.


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