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 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 * )
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 232 of file TrackProcessorUserActionBase.cxx.

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

◆ PreUserTrackingAction()

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

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}
#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 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)
private

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.
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:91
GenParticle * GenParticlePtr
Definition GenParticle.h:37

◆ 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 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 )
private

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)
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 //
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 {}
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: