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

AtlasG4EventUserInfom_atlasG4EvtUserInfo {}
 event-global G4 UserInformation
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 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

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 44 of file TrackProcessorUserActionPassBack.cxx.

45 : m_config(config)
46 {
47 if(4<m_config.verboseLevel)
48 {
49 G4cout << "Initializing TrackProcessorUserActionPassBack" << G4endl;
50 }
51
52 if ( !m_config.particleBroker.empty() ) {
53 if (m_config.particleBroker.retrieve().isFailure()) {
54 G4ExceptionDescription description;
55 description << G4String("TrackProcessorUserActionPassBack: ") + "Could not retrieve ISF Particle Broker: " << m_config.particleBroker;
56 G4Exception("iGeant4::TrackProcessorUserActionPassBack", "NoISFParticleBroker", FatalException, description);
57 return; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
58 }
59 m_particleBrokerQuick = &(*m_config.particleBroker);
60 }
61
62 if ( !m_config.geoIDSvc.empty() ) {
63 if (m_config.geoIDSvc.retrieve().isFailure()) {
64 G4ExceptionDescription description;
65 description << G4String("TrackProcessorUserActionPassBack: ") + "Could not retrieve ISF GeoID Svc: " << m_config.geoIDSvc;
66 G4Exception("iGeant4::TrackProcessorUserActionPassBack", "NoISFGeoIDSvc", FatalException, description);
67 return; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
68 }
69
70 m_geoIDSvcQuick = &(*m_config.geoIDSvc);
71 }
72
73 return;
74
75 }
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:91

Member Function Documentation

◆ BeginOfEventAction()

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

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
privateinherited

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

Definition at line 208 of file TrackProcessorUserActionBase.cxx.

212{
213 // if particle points to a non-zero truth particle it can not just be a 'simple' Secondary
214
215 if (currentGenParticle) {
216 if (currentGenParticle == primaryGenParticle) {
218 }
219 else if (generationZeroGenParticle == primaryGenParticle && regenerationNumber>0) {
221 }
222 else {
224 }
225 }
226
228}

◆ EndOfEventAction()

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

Definition at line 55 of file TrackProcessorUserActionBase.cxx.

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

◆ 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 77 of file TrackProcessorUserActionPassBack.cxx.

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

◆ newISFParticle()

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

Definition at line 242 of file TrackProcessorUserActionPassBack.cxx.

246 {
247 ISF::TruthBinding* tBinding = newTruthBinding(aTrack, currentGenParticle);
248
249 ISF::ISFParticle* isp = ::iGeant4::ISFG4Helper::convertG4TrackToISFParticle( *aTrack,
250 *parentISP,
251 tBinding );
252
254 isp->setNextGeoID( AtlasDetDescr::AtlasRegion(nextGeoID) );
255 isp->setNextSimID( parentISP->nextSimID() );
256 }
257
258 return isp;
259 }
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 222 of file TrackProcessorUserActionPassBack.cxx.

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

◆ PostUserTrackingAction()

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

Definition at line 232 of file TrackProcessorUserActionBase.cxx.

233{
234 m_curBaseISP = nullptr;
235 return;
236}

◆ PreUserTrackingAction()

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

Reimplemented in G4UA::iGeant4::TrackProcessorUserActionFullG4.

Definition at line 98 of file TrackProcessorUserActionBase.cxx.

99{
100 bool isPrimary = ! aTrack->GetParentID();
101 if (isPrimary) {
102 G4Track* nonConstTrack ATLAS_THREAD_SAFE = const_cast<G4Track*> (aTrack); // imposed by Geant4 interface
103 setupPrimary(*nonConstTrack);
104 } else {
105 setupSecondary(*aTrack);
106 }
107
108 return;
109}
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 261 of file TrackProcessorUserActionPassBack.cxx.

265 {
266 // kill track inside G4
267 aTrack->SetTrackStatus( fStopAndKill );
268
269 // create new ISFParticle and attach it to current G4Track
270 ISF::ISFParticle *newISP = newISFParticle( aTrack, parentISP, currentGenParticle, nextGeoID );
271
272 // update TrackInformation
273 auto trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(*aTrack);
274 trackInfo->SetReturnedToISF( true );
275 trackInfo->SetBaseISFParticle( newISP );
276
277 // push the particle back to ISF via the particle broker
279 {
280 [&] ATLAS_NOT_THREAD_SAFE () { // suppress checker warning, in MT mode there is no broker
281 m_particleBrokerQuick->push(newISP, parentISP);
282 }();
283 }
284 else
285 {
286 // store the particle for retrieval in MT mode
287 //parentISP must be non-null by here, it has already been deeferenced
288 if (!newISP->getTruthBinding()) newISP->setTruthBinding(new ISF::TruthBinding(*parentISP->getTruthBinding()));
289 m_storedSecondaries.push_back( newISP );
290 }
291
292 return;
293 }
#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 238 of file TrackProcessorUserActionBase.cxx.

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

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

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

184{
185 auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack);
186
187 HepMC::GenParticlePtr currentGenParticle = trackInfo->GetCurrentGenParticle();
188 HepMC::GenParticlePtr primaryGenParticle = trackInfo->GetPrimaryGenParticle();
189 ISF::ISFParticle* baseISFParticle = trackInfo->GetBaseISFParticle();
190
191 updateCachedParticleInfo(baseISFParticle, primaryGenParticle, currentGenParticle);
192
193 return;
194}

◆ updateCachedParticleInfo()

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

Set the following information as the currently traced particle.

Definition at line 196 of file TrackProcessorUserActionBase.cxx.

199{
200 m_curBaseISP = baseISFParticle;
201 m_atlasG4EvtUserInfo->SetCurrentPrimaryGenParticle( primaryGenParticle );
202 m_atlasG4EvtUserInfo->SetCurrentGenParticle( currentGenParticle );
203 return;
204}

◆ UserSteppingAction()

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

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 //
70 // call the ISFSteppingAction method of the implementation
71 //
73
74 //
75 // propagate the current ISFParticle link to all secondaries
76 //
77 const std::vector<const G4Track*> *secondaryVector = aStep->GetSecondaryInCurrentStep();
78 for ( auto* aConstSecondaryTrack : *secondaryVector ) {
79 // get a non-const G4Track for current secondary (nasty!)
80 G4Track* aSecondaryTrack ATLAS_THREAD_SAFE = const_cast<G4Track*>( aConstSecondaryTrack ); // imposed by Geant4 interface
81
82 auto *trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(*aSecondaryTrack);
83
84 // G4Tracks aready returned to ISF will have a TrackInformation attached to them
85 bool particleReturnedToISF = trackInfo && trackInfo->GetReturnedToISF();
86 if (!particleReturnedToISF) {
87 HepMC::GenParticlePtr generationZeroGenParticle{};
91 generationZeroGenParticle );
92 }
93 } // <- loop over secondaries from this step
94
95 return;
96}
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 {}
protectedinherited

event-global G4 UserInformation

Definition at line 48 of file TrackProcessorUserActionBase.h.

48{};

◆ 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 75 of file TrackProcessorUserActionBase.h.

75{};

◆ 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 50 of file TrackProcessorUserActionBase.h.


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