ATLAS Offline Software
Classes | Public Member Functions | Protected Attributes | Private Member Functions | List of all members
iGeant4::G4LegacyTransportTool Class Reference

#include <G4LegacyTransportTool.h>

Inheritance diagram for iGeant4::G4LegacyTransportTool:
Collaboration diagram for iGeant4::G4LegacyTransportTool:

Classes

struct  Slot
 

Public Member Functions

 G4LegacyTransportTool (const std::string &, const std::string &, const IInterface *)
 Constructor. More...
 
virtual ~G4LegacyTransportTool ()=default
 Destructor. More...
 
virtual StatusCode initialize () override final
 AlgTool initialize method. More...
 
void initializeOnce ATLAS_NOT_THREAD_SAFE ()
 G4 initialization called only by the first tool instance. More...
 
virtual StatusCode finalize () override final
 AlgTool finalize method. More...
 
void finalizeOnce ()
 G4 finalization called only by the first tool instance. More...
 
virtual StatusCode simulate (const EventContext &ctx, ISF::ISFParticle &isp, ISF::ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, std::shared_ptr< HitCollectionMap >) override
 Simulation call for individual particles. More...
 
virtual StatusCode simulateVector (const EventContext &ctx, const ISF::ISFParticleVector &particles, ISF::ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, std::shared_ptr< HitCollectionMap > hitCollections, McEventCollection *shadowTruth=nullptr) override
 Simulation call for vectors of particles. More...
 
virtual StatusCode setupEvent (const EventContext &, HitCollectionMap &) override
 Create data containers for an event. More...
 
virtual StatusCode releaseEvent (const EventContext &, HitCollectionMap &) override
 Finalise data containers for an event. More...
 
virtual ISF::SimulationFlavor simFlavor () const override
 
virtual StatusCode simulate (const EventContext &, ISFParticle &, ISFParticleContainer &, McEventCollection *)
 Simulation call for individual particles. More...
 
virtual StatusCode simulateVector (const EventContext &, const ISFParticleVector &, ISFParticleContainer &, McEventCollection *, McEventCollection *)
 Simulation call for vectors of particles. More...
 
virtual StatusCode setupEvent (const EventContext &)
 Create data containers for an event. More...
 
virtual StatusCode setupEventST (HitCollectionMap &hitCollections)
 Create data containers for an event (called by ISimulationSvc) More...
 
virtual StatusCode setupEventST ()
 Create data containers for an event (called by ISimulationSvc) More...
 
virtual StatusCode releaseEvent (const EventContext &)
 Finalise data containers for an event. More...
 
virtual StatusCode releaseEventST (HitCollectionMap &hitCollections)
 Finalise data containers for an event (called by ISimulationSvc) More...
 
virtual StatusCode releaseEventST ()
 Finalise data containers for an event (called by ISimulationSvc) More...
 
 BaseSimulatorTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard BaseSimulatorTool constructor. More...
 
virtual StatusCode sysInitialize () override
 Gaudi sysInitialize() methods. More...
 
const ChronoEntity * chronoStart (const IChronoSvc::ChronoTag &tag)
 wrapper call to start chrono with given tag More...
 
const ChronoEntity * chronoStop (const IChronoSvc::ChronoTag &tag)
 wrapper call to stop chrono with given tag More...
 

Protected Attributes

ServiceHandle< IChronoStatSvc > m_chrono {this, "ChronoStatService", "ChronoStatSvc"}
 The timing service for general usage. More...
 

Private Member Functions

void commandLog (int returnCode, const std::string &commandString) const
 This command prints a message about a G4Command depending on its returnCode. More...
 
HepMC::GenEvent * genEvent (McEventCollection *mcEventCollection) const
 

Private Attributes

Configurable Properties
Gaudi::Property< bool > m_doTiming {this, "PrintTimingInfo", true, ""}
 
float m_accumulatedEventTime {0.}
 
float m_accumulatedEventTimeSq {0.}
 
unsigned int m_nrOfEntries {0}
 
G4Timer * m_runTimer {nullptr}
 
G4Timer * m_eventTimer {nullptr}
 
SG::SlotSpecificObj< Slot > m_slots ATLAS_THREAD_SAFE
 
Gaudi::Property< std::string > m_mcEventCollectionName
 
PublicToolHandle< ISF::IG4RunManagerHelperm_g4RunManagerHelper
 Helper Tool to provide G4RunManager. More...
 
G4AtlasRunManagerm_pRunMgr {}
 
Gaudi::Property< std::string > m_libList {this, "Dll", "", ""}
 
Gaudi::Property< std::string > m_physList {this, "Physics", "", ""}
 
Gaudi::Property< std::string > m_fieldMap {this, "FieldMap", "", ""}
 
Gaudi::Property< bool > m_releaseGeoModel {this, "ReleaseGeoModel", true, ""}
 
Gaudi::Property< bool > m_recordFlux {this, "RecordFlux", false, ""}
 
Gaudi::Property< bool > m_quietMode {this, "QuietMode", false, ""}
 
Gaudi::Property< std::vector< std::string > > m_g4commands
 Commands to send to the G4 UI. More...
 
Gaudi::Property< bool > m_useMT
 Activate multi-threading configuration. More...
 
Gaudi::Property< bool > m_activateParallelGeometries
 
ServiceHandle< IAthRNGSvcm_rndmGenSvc
 
Gaudi::Property< std::string > m_randomStreamName
 Random Stream Name. More...
 
ServiceHandle< IUserLimitsSvcm_userLimitsSvc
 
ServiceHandle< G4UA::IUserActionSvcm_userActionSvc
 user action service More...
 
PublicToolHandle< IDetectorConstructionToolm_detConstruction {this, "DetectorConstruction", "", "Tool handle of the DetectorConstruction"}
 
ServiceHandle< ISF::IInputConverterm_inputConverter
 Service to convert ISF_Particles into a G4Event. More...
 
ServiceHandle< IPhysicsListSvcm_physListSvc
 Physics List Service. More...
 
PublicToolHandle< ISensitiveDetectorMasterToolm_senDetTool
 Sensitive Detector Master Tool. More...
 
PublicToolHandle< IFastSimulationMasterToolm_fastSimTool
 Fast Simulation Master Tool. More...
 
PublicToolHandleArray< IPhysicsInitializationToolm_physicsInitializationTools {this, "PhysicsInitializationTools", {}, "Physics initialization happening after Geant4 initialization"}
 

Detailed Description

Geant4 AlgTool to create a ISFParticle at a volume entry/exit

Author
Robert Harrington

Definition at line 60 of file G4LegacyTransportTool.h.

Constructor & Destructor Documentation

◆ G4LegacyTransportTool()

iGeant4::G4LegacyTransportTool::G4LegacyTransportTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Constructor.

Definition at line 55 of file G4LegacyTransportTool.cxx.

59 {
60  //declareProperty("KillAllNeutrinos", m_KillAllNeutrinos=true);
61  //declareProperty("KillLowEPhotons", m_KillLowEPhotons=-1.);
62 }

◆ ~G4LegacyTransportTool()

virtual iGeant4::G4LegacyTransportTool::~G4LegacyTransportTool ( )
virtualdefault

Destructor.

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

void initializeOnce iGeant4::G4LegacyTransportTool::ATLAS_NOT_THREAD_SAFE ( )

G4 initialization called only by the first tool instance.

This is done (for now) because we get multiple tool instances in hive.

◆ BaseSimulatorTool()

ISF::BaseSimulatorTool::BaseSimulatorTool
inlineinherited

Standard BaseSimulatorTool constructor.

Definition at line 40 of file BaseSimulatorTool.h.

41  : base_class(type, name, parent)
42  {
43  }

◆ chronoStart()

const ChronoEntity* ISF::BaseSimulatorTool::chronoStart ( const IChronoSvc::ChronoTag &  tag)
inlineinherited

wrapper call to start chrono with given tag

Definition at line 98 of file BaseSimulatorTool.h.

98  {
99  if (m_chrono) return m_chrono->chronoStart( tag);
100  return nullptr;
101  }

◆ chronoStop()

const ChronoEntity* ISF::BaseSimulatorTool::chronoStop ( const IChronoSvc::ChronoTag &  tag)
inlineinherited

wrapper call to stop chrono with given tag

Definition at line 104 of file BaseSimulatorTool.h.

104  {
105  if (m_chrono) return m_chrono->chronoStop( tag);
106  return nullptr;
107  }

◆ commandLog()

void iGeant4::G4LegacyTransportTool::commandLog ( int  returnCode,
const std::string &  commandString 
) const
private

This command prints a message about a G4Command depending on its returnCode.

Definition at line 420 of file G4LegacyTransportTool.cxx.

421 {
422  switch(returnCode) {
423  case 0: { ATH_MSG_DEBUG("G4 Command: " << commandString << " - Command Succeeded"); } break;
424  case 100: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Command Not Found!"); } break;
425  case 200: {
426  auto* stateManager = G4StateManager::GetStateManager();
427  ATH_MSG_DEBUG("G4 Command: " << commandString << " - Illegal Application State (" <<
428  stateManager->GetStateString(stateManager->GetCurrentState()) << ")!");
429  } break;
430  case 300: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Out of Range!"); } break;
431  case 400: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Unreadable!"); } break;
432  case 500: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Out of Candidates!"); } break;
433  case 600: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Alias Not Found!"); } break;
434  default: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Unknown Status!"); } break;
435  }
436 
437 }

◆ finalize()

StatusCode iGeant4::G4LegacyTransportTool::finalize ( )
finaloverridevirtual

AlgTool finalize method.

Definition at line 202 of file G4LegacyTransportTool.cxx.

203 {
204  ATH_MSG_VERBOSE("++++++++++++ ISF G4 G4LegacyTransportTool finalized ++++++++++++");
205 
206  // One time finalization
207  try {
208  std::call_once(finalizeOnceFlag, &iGeant4::G4LegacyTransportTool::finalizeOnce, this);
209  }
210  catch(const std::exception& e) {
211  ATH_MSG_ERROR("Failure in iGeant4::G4LegacyTransportTool::finalizeOnce: " << e.what());
212  return StatusCode::FAILURE;
213  }
214 
215  if (m_doTiming) {
216  m_runTimer->Stop();
217  float runTime=m_runTimer->GetUserElapsed()+m_runTimer->GetSystemElapsed();
218  float avgTimePerEvent=(m_nrOfEntries>1) ? m_accumulatedEventTime/(m_nrOfEntries-1.) : runTime;
219  float sigma=( m_nrOfEntries>2) ? std::sqrt((m_accumulatedEventTimeSq/float(m_nrOfEntries-1)-
220  avgTimePerEvent*avgTimePerEvent)/float(m_nrOfEntries-2)) : 0;
221  ATH_MSG_INFO("*****************************************"<<endmsg<<
222  "** **"<<endmsg<<
223  " End of run - time spent is "<<std::setprecision(4) <<
224  runTime<<endmsg<<
225  " Average time per event was "<<std::setprecision(4) <<
226  avgTimePerEvent <<" +- "<< std::setprecision(4) << sigma<<endmsg<<
227  "** **"<<endmsg<<
228  "*****************************************");
229  }
230 
231  return StatusCode::SUCCESS;
232 }

◆ finalizeOnce()

void iGeant4::G4LegacyTransportTool::finalizeOnce ( )

G4 finalization called only by the first tool instance.

This is done (for now) because we get multiple tool instances in hive.

Definition at line 235 of file G4LegacyTransportTool.cxx.

236 {
237  ATH_MSG_DEBUG("\t terminating the current G4 run");
238 
240 
241  return;
242 }

◆ genEvent()

HepMC::GenEvent * iGeant4::G4LegacyTransportTool::genEvent ( McEventCollection mcEventCollection) const
private

Definition at line 398 of file G4LegacyTransportTool.cxx.

399 {
400 
401  if(!mcEventCollection) {
402  // retrieve McEventCollection from storegate
403  if (evtStore()->contains<McEventCollection>(m_mcEventCollectionName)) {
404  if (evtStore()->retrieve( mcEventCollection, m_mcEventCollectionName).isFailure()) {
405  ATH_MSG_ERROR( "Unable to retrieve McEventCollection with name=" << m_mcEventCollectionName
406  << ".");
407  return nullptr;
408  }
409  else {
410  ATH_MSG_WARNING( "Fallback. Sucessfully retrieved McEventCollection with name=" << m_mcEventCollectionName);
411  }
412  }
413  else { return nullptr; }
414  }
415  // collect last GenEvent from McEventCollection
416  return mcEventCollection->back();
417 }

◆ initialize()

StatusCode iGeant4::G4LegacyTransportTool::initialize ( )
finaloverridevirtual

AlgTool initialize method.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 65 of file G4LegacyTransportTool.cxx.

66 {
67  ATH_MSG_VERBOSE("initialize");
68 
70 
71  // create G4Timers if enabled
72  if (m_doTiming) {
73  m_runTimer = new G4Timer();
74  m_eventTimer = new G4Timer();
75  m_runTimer->Start();
76  }
77 
78  // Create the scoring manager if requested
79  if (m_recordFlux) G4ScoringManager::GetScoringManager();
80 
81  // One-time initialization
82  try {
83  std::call_once(initializeOnceFlag, &iGeant4::G4LegacyTransportTool::initializeOnce, this);
84  }
85  catch(const std::exception& e) {
86  ATH_MSG_ERROR("Failure in iGeant4::G4LegacyTransportTool::initializeOnce: " << e.what());
87  return StatusCode::FAILURE;
88  }
89 
90  ATH_CHECK( m_rndmGenSvc.retrieve() );
91  ATH_CHECK( m_userActionSvc.retrieve() );
92 
93  ATH_CHECK(m_senDetTool.retrieve());
94  ATH_CHECK(m_fastSimTool.retrieve());
95 
96  ATH_CHECK(m_inputConverter.retrieve());
97 
98  return StatusCode::SUCCESS;
99 }

◆ releaseEvent() [1/2]

virtual StatusCode ISF::BaseSimulatorG4Tool::releaseEvent ( const EventContext &  )
inlinevirtualinherited

Finalise data containers for an event.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 87 of file BaseSimulatorG4Tool.h.

87  {
88  return StatusCode::FAILURE;
89  };

◆ releaseEvent() [2/2]

StatusCode iGeant4::G4LegacyTransportTool::releaseEvent ( const EventContext &  ,
HitCollectionMap  
)
overridevirtual

Finalise data containers for an event.

Todo:
: strip hits of the tracks ...

Implements ISF::BaseSimulatorG4Tool.

Definition at line 352 of file G4LegacyTransportTool.cxx.

353  {
354  ATH_MSG_DEBUG ( "release Event" );
357  /* todo: ELLI: the following is copied in from the PyG4AtlasAlg:
358  -> this somehow needs to be moved into C++
359  and put into releaseEvent() ( or setupEvent() ?)
360 
361  from ISF_Geant4Example import AtlasG4Eng
362  from ISF_Geant4Example.ISF_SimFlags import simFlags
363  if self.doFirstEventG4SeedsCheck :
364  if simFlags.SeedsG4.statusOn:
365  rnd = AtlasG4Eng.G4Eng.menu_G4RandomNrMenu()
366  rnd.set_Seed(simFlags.SeedsG4.get_Value())
367  self.doFirstEventG4SeedsCheck = False
368  if self.RndG4Menu.SaveStatus:
369  self.RndG4Menu.Menu.saveStatus('G4Seeds.txt')
370  */
371 
372  // print per-event timing info if enabled
373  if (m_doTiming) {
374  m_eventTimer->Stop();
375 
376  double eventTime=m_eventTimer->GetUserElapsed()+m_eventTimer->GetSystemElapsed();
377  if (m_nrOfEntries>1) {
378  m_accumulatedEventTime +=eventTime;
379  m_accumulatedEventTimeSq+=eventTime*eventTime;
380  }
381 
382  float avgTimePerEvent=(m_nrOfEntries>1) ? m_accumulatedEventTime/(m_nrOfEntries-1.) : eventTime;
383  float sigma=(m_nrOfEntries>2) ? std::sqrt((m_accumulatedEventTimeSq/float(m_nrOfEntries-1)-
384  avgTimePerEvent*avgTimePerEvent)/float(m_nrOfEntries-2)) : 0.;
385 
386  ATH_MSG_INFO("\t Run:Event "<<ctx.eventID().run_number()<<":"<<ctx.eventID().event_number() << "\t ("<<m_nrOfEntries<<"th event for this worker) took " << std::setprecision(4) <<
387  eventTime << " s. New average " << std::setprecision(4) <<
388  avgTimePerEvent<<" +- "<<std::setprecision(4) << sigma);
389  }
390 
391  ATH_CHECK(m_senDetTool->EndOfAthenaEvent(hitCollections));
392  ATH_CHECK(m_fastSimTool->EndOfAthenaEvent());
393 
394  return StatusCode::SUCCESS;
395 }

◆ releaseEventST() [1/2]

virtual StatusCode ISF::BaseSimulatorG4Tool::releaseEventST ( )
inlinevirtualinherited

Finalise data containers for an event (called by ISimulationSvc)

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 92 of file BaseSimulatorG4Tool.h.

92 { return StatusCode::FAILURE; };

◆ releaseEventST() [2/2]

virtual StatusCode ISF::BaseSimulatorG4Tool::releaseEventST ( HitCollectionMap hitCollections)
inlinevirtualinherited

Finalise data containers for an event (called by ISimulationSvc)

Definition at line 58 of file BaseSimulatorG4Tool.h.

58  {
59  return releaseEvent(Gaudi::Hive::currentContext(), hitCollections);
60  }

◆ setupEvent() [1/2]

virtual StatusCode ISF::BaseSimulatorG4Tool::setupEvent ( const EventContext &  )
inlinevirtualinherited

Create data containers for an event.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 79 of file BaseSimulatorG4Tool.h.

79  {
80  return StatusCode::FAILURE;
81  };

◆ setupEvent() [2/2]

StatusCode iGeant4::G4LegacyTransportTool::setupEvent ( const EventContext &  ,
HitCollectionMap  
)
overridevirtual

Create data containers for an event.

Implements ISF::BaseSimulatorG4Tool.

Definition at line 331 of file G4LegacyTransportTool.cxx.

332  {
333  ATH_MSG_DEBUG ( "setup Event" );
334 
335  // Set the RNG to use for this event. We need to reset it for MT jobs
336  // because of the mismatch between Gaudi slot-local and G4 thread-local RNG.
337  ATHRNG::RNGWrapper* rngWrapper = m_rndmGenSvc->getEngine(this, m_randomStreamName);
338  rngWrapper->setSeed( m_randomStreamName, ctx );
339  G4Random::setTheEngine(rngWrapper->getEngine(ctx));
340  ATH_CHECK(m_senDetTool->BeginOfAthenaEvent(hitCollections));
341 
342  m_nrOfEntries++;
343  if (m_doTiming) m_eventTimer->Start();
344 
345  // make sure SD collections are properly initialized in every Athena event
346  G4SDManager::GetSDMpointer()->PrepareNewEvent();
347 
348  return StatusCode::SUCCESS;
349 }

◆ setupEventST() [1/2]

virtual StatusCode ISF::BaseSimulatorG4Tool::setupEventST ( )
inlinevirtualinherited

Create data containers for an event (called by ISimulationSvc)

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 84 of file BaseSimulatorG4Tool.h.

84 { return StatusCode::FAILURE; };

◆ setupEventST() [2/2]

virtual StatusCode ISF::BaseSimulatorG4Tool::setupEventST ( HitCollectionMap hitCollections)
inlinevirtualinherited

Create data containers for an event (called by ISimulationSvc)

Definition at line 49 of file BaseSimulatorG4Tool.h.

49  {
50  return setupEvent(Gaudi::Hive::currentContext(), hitCollections);
51  }

◆ simFlavor()

virtual ISF::SimulationFlavor iGeant4::G4LegacyTransportTool::simFlavor ( ) const
inlineoverridevirtual

Definition at line 107 of file G4LegacyTransportTool.h.

107  {
108  return ISF::Geant4;
109  };

◆ simulate() [1/2]

virtual StatusCode ISF::BaseSimulatorG4Tool::simulate ( const EventContext &  ,
ISFParticle ,
ISFParticleContainer ,
McEventCollection  
)
inlinevirtualinherited

Simulation call for individual particles.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 65 of file BaseSimulatorG4Tool.h.

66  {
67  return StatusCode::FAILURE;
68  };

◆ simulate() [2/2]

StatusCode iGeant4::G4LegacyTransportTool::simulate ( const EventContext &  ctx,
ISF::ISFParticle isp,
ISF::ISFParticleContainer secondaries,
McEventCollection mcEventCollection,
std::shared_ptr< HitCollectionMap  
)
overridevirtual

Simulation call for individual particles.

Process ParticleState from particle stack

Implements ISF::BaseSimulatorG4Tool.

Definition at line 245 of file G4LegacyTransportTool.cxx.

248  {
249 
250  // give a screen output that you entered Geant4SimSvc
251  ATH_MSG_VERBOSE( "Particle " << isp << " received for simulation." );
252 
254  // wrap the given ISFParticle into a STL vector of ISFParticles with length 1
255  // (minimizing code duplication)
256  const ISF::ISFParticleVector ispVector(1, &isp);
257  StatusCode success = this->simulateVector(ctx, ispVector, secondaries,
258  mcEventCollection, hitCollections);
259  ATH_MSG_VERBOSE( "Simulation done" );
260 
261  // Geant4 call done
262  return success;
263 }

◆ simulateVector() [1/2]

virtual StatusCode ISF::BaseSimulatorG4Tool::simulateVector ( const EventContext &  ,
const ISFParticleVector ,
ISFParticleContainer ,
McEventCollection ,
McEventCollection  
)
inlinevirtualinherited

Simulation call for vectors of particles.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 71 of file BaseSimulatorG4Tool.h.

74  {
75  return StatusCode::FAILURE;
76  };

◆ simulateVector() [2/2]

StatusCode iGeant4::G4LegacyTransportTool::simulateVector ( const EventContext &  ctx,
const ISF::ISFParticleVector particles,
ISF::ISFParticleContainer secondaries,
McEventCollection mcEventCollection,
std::shared_ptr< HitCollectionMap HitCollectionMap,
McEventCollection shadowTruth = nullptr 
)
overridevirtual

Simulation call for vectors of particles.

Process ParticleState from particle stack

Implements ISF::BaseSimulatorG4Tool.

Definition at line 266 of file G4LegacyTransportTool.cxx.

270  {
271 
272  ATH_MSG_DEBUG (name() << ".simulateVector(...) : Received a vector of " << particles.size() << " particles for simulation.");
274  // Lambda prevents using the unique_ptr
275  bool abort = [&] ATLAS_NOT_THREAD_SAFE {
276  auto eventInfo = std::make_unique<AtlasG4EventUserInfo>();
277  eventInfo->SetHitCollectionMap(hitCollections);
278 
279  auto inputEvent = std::make_unique<G4Event>(ctx.eventID().event_number());
280  inputEvent->SetUserInformation(eventInfo.release());
281 
282  m_inputConverter->ISF_to_G4Event(*inputEvent, particles,
283  genEvent(mcEventCollection));
284 
285  ATH_MSG_DEBUG("Calling ISF_Geant4 ProcessEvent");
286  return m_pRunMgr->ProcessEvent(inputEvent.release());
287  }();
288 
289  if (abort) {
290  ATH_MSG_WARNING("Event was aborted !! ");
291  //ATH_MSG_WARNING("Simulation will now go on to the next event ");
292  //ATH_MSG_WARNING("setFilterPassed is now False");
293  //setFilterPassed(false);
294  return StatusCode::FAILURE;
295  }
296 
297 
298  // const DataHandle <TrackRecordCollection> tracks;
299 
300  // StatusCode sc = evtStore()->retrieve(tracks,m_trackCollName);
301 
302  // if (sc.isFailure()) {
303  // ATH_MSG_WARNING(" Cannot retrieve TrackRecordCollection " << m_trackCollName);
304  // }
305 
306  // not implemented yet... need to get particle stack from Geant4 and convert to ISFParticle
307  ATH_MSG_VERBOSE( "Simulation done" );
308 
309  Slot& slot = *m_slots;
310  Slot::lock_t lock (slot.m_mutex);
311 
312  for (auto* cisp : particles) {
313  // return any secondaries associated with this particle
314  auto searchResult = slot.m_secondariesMap.find( cisp );
315  if ( searchResult == slot.m_secondariesMap.end() ) {
316 
317  ATH_MSG_VERBOSE( "Found no secondaries" );
318 
319  } else {
320 
321  ATH_MSG_VERBOSE( "Found secondaries: " << searchResult->second.size() );
322  secondaries.splice( end(secondaries), std::move(searchResult->second) ); //append vector
323  slot.m_secondariesMap.erase( searchResult );
324  }
325  }
326  // Geant4 call done
327  return StatusCode::SUCCESS;
328 }

◆ sysInitialize()

virtual StatusCode ISF::BaseSimulatorTool::sysInitialize ( )
inlineoverridevirtualinherited

Gaudi sysInitialize() methods.

Definition at line 49 of file BaseSimulatorTool.h.

50  {
52  ATH_CHECK( m_chrono.retrieve() );
53  return StatusCode::SUCCESS;
54  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

SG::SlotSpecificObj<Slot> m_slots iGeant4::G4LegacyTransportTool::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 139 of file G4LegacyTransportTool.h.

◆ m_accumulatedEventTime

float iGeant4::G4LegacyTransportTool::m_accumulatedEventTime {0.}
private

Definition at line 124 of file G4LegacyTransportTool.h.

◆ m_accumulatedEventTimeSq

float iGeant4::G4LegacyTransportTool::m_accumulatedEventTimeSq {0.}
private

Definition at line 125 of file G4LegacyTransportTool.h.

◆ m_activateParallelGeometries

Gaudi::Property<bool> iGeant4::G4LegacyTransportTool::m_activateParallelGeometries
private
Initial value:
{
this, "ActivateParallelWorlds", false,
"Toggle on/off the G4 parallel geometry system"}

Definition at line 160 of file G4LegacyTransportTool.h.

◆ m_chrono

ServiceHandle<IChronoStatSvc> ISF::BaseSimulatorTool::m_chrono {this, "ChronoStatService", "ChronoStatSvc"}
protectedinherited

The timing service for general usage.

Definition at line 115 of file BaseSimulatorTool.h.

◆ m_detConstruction

PublicToolHandle<IDetectorConstructionTool> iGeant4::G4LegacyTransportTool::m_detConstruction {this, "DetectorConstruction", "", "Tool handle of the DetectorConstruction"}
private

Definition at line 175 of file G4LegacyTransportTool.h.

◆ m_doTiming

Gaudi::Property<bool> iGeant4::G4LegacyTransportTool::m_doTiming {this, "PrintTimingInfo", true, ""}
private

Definition at line 122 of file G4LegacyTransportTool.h.

◆ m_eventTimer

G4Timer* iGeant4::G4LegacyTransportTool::m_eventTimer {nullptr}
private

Definition at line 129 of file G4LegacyTransportTool.h.

◆ m_fastSimTool

PublicToolHandle<IFastSimulationMasterTool> iGeant4::G4LegacyTransportTool::m_fastSimTool
private
Initial value:
{
this, "FastSimMasterTool", "FastSimulationMasterTool", ""}

Fast Simulation Master Tool.

Definition at line 186 of file G4LegacyTransportTool.h.

◆ m_fieldMap

Gaudi::Property<std::string> iGeant4::G4LegacyTransportTool::m_fieldMap {this, "FieldMap", "", ""}
private

Definition at line 150 of file G4LegacyTransportTool.h.

◆ m_g4commands

Gaudi::Property<std::vector<std::string> > iGeant4::G4LegacyTransportTool::m_g4commands
private
Initial value:
{
this, "G4Commands", {}, "Commands to send to the G4UI"}

Commands to send to the G4 UI.

Definition at line 155 of file G4LegacyTransportTool.h.

◆ m_g4RunManagerHelper

PublicToolHandle<ISF::IG4RunManagerHelper> iGeant4::G4LegacyTransportTool::m_g4RunManagerHelper
private
Initial value:
{
this, "G4RunManagerHelper",
"iGeant4::G4RunManagerHelper/G4RunManagerHelper", ""}

Helper Tool to provide G4RunManager.

Definition at line 143 of file G4LegacyTransportTool.h.

◆ m_inputConverter

ServiceHandle<ISF::IInputConverter> iGeant4::G4LegacyTransportTool::m_inputConverter
private
Initial value:
{
this, "InputConverter", "ISF_InputConverter", ""}

Service to convert ISF_Particles into a G4Event.

Definition at line 177 of file G4LegacyTransportTool.h.

◆ m_libList

Gaudi::Property<std::string> iGeant4::G4LegacyTransportTool::m_libList {this, "Dll", "", ""}
private

Definition at line 148 of file G4LegacyTransportTool.h.

◆ m_mcEventCollectionName

Gaudi::Property<std::string> iGeant4::G4LegacyTransportTool::m_mcEventCollectionName
private
Initial value:
{
this, "McEventCollection", "TruthEvent", ""}

Definition at line 140 of file G4LegacyTransportTool.h.

◆ m_nrOfEntries

unsigned int iGeant4::G4LegacyTransportTool::m_nrOfEntries {0}
private

Definition at line 126 of file G4LegacyTransportTool.h.

◆ m_physicsInitializationTools

PublicToolHandleArray<IPhysicsInitializationTool> iGeant4::G4LegacyTransportTool::m_physicsInitializationTools {this, "PhysicsInitializationTools", {}, "Physics initialization happening after Geant4 initialization"}
private

Definition at line 188 of file G4LegacyTransportTool.h.

◆ m_physList

Gaudi::Property<std::string> iGeant4::G4LegacyTransportTool::m_physList {this, "Physics", "", ""}
private

Definition at line 149 of file G4LegacyTransportTool.h.

◆ m_physListSvc

ServiceHandle<IPhysicsListSvc> iGeant4::G4LegacyTransportTool::m_physListSvc
private
Initial value:
{this, "PhysicsListSvc",
"PhysicsListSvc", ""}

Physics List Service.

Definition at line 180 of file G4LegacyTransportTool.h.

◆ m_pRunMgr

G4AtlasRunManager* iGeant4::G4LegacyTransportTool::m_pRunMgr {}
private

Definition at line 146 of file G4LegacyTransportTool.h.

◆ m_quietMode

Gaudi::Property<bool> iGeant4::G4LegacyTransportTool::m_quietMode {this, "QuietMode", false, ""}
private

Definition at line 153 of file G4LegacyTransportTool.h.

◆ m_randomStreamName

Gaudi::Property<std::string> iGeant4::G4LegacyTransportTool::m_randomStreamName
private
Initial value:
{this, "RandomStreamName",
"Geant4", ""}

Random Stream Name.

Definition at line 167 of file G4LegacyTransportTool.h.

◆ m_recordFlux

Gaudi::Property<bool> iGeant4::G4LegacyTransportTool::m_recordFlux {this, "RecordFlux", false, ""}
private

Definition at line 152 of file G4LegacyTransportTool.h.

◆ m_releaseGeoModel

Gaudi::Property<bool> iGeant4::G4LegacyTransportTool::m_releaseGeoModel {this, "ReleaseGeoModel", true, ""}
private

Definition at line 151 of file G4LegacyTransportTool.h.

◆ m_rndmGenSvc

ServiceHandle<IAthRNGSvc> iGeant4::G4LegacyTransportTool::m_rndmGenSvc
private
Initial value:
{this, "RandomNumberService",
"AthRNGSvc", ""}

Definition at line 164 of file G4LegacyTransportTool.h.

◆ m_runTimer

G4Timer* iGeant4::G4LegacyTransportTool::m_runTimer {nullptr}
private

Definition at line 128 of file G4LegacyTransportTool.h.

◆ m_senDetTool

PublicToolHandle<ISensitiveDetectorMasterTool> iGeant4::G4LegacyTransportTool::m_senDetTool
private
Initial value:
{
this, "SenDetMasterTool", "SensitiveDetectorMasterTool", ""}

Sensitive Detector Master Tool.

Definition at line 183 of file G4LegacyTransportTool.h.

◆ m_useMT

Gaudi::Property<bool> iGeant4::G4LegacyTransportTool::m_useMT
private
Initial value:
{this, "MultiThreading", false,
"Multi-threading specific settings"}

Activate multi-threading configuration.

Definition at line 158 of file G4LegacyTransportTool.h.

◆ m_userActionSvc

ServiceHandle<G4UA::IUserActionSvc> iGeant4::G4LegacyTransportTool::m_userActionSvc
private
Initial value:
{this, "UserActionSvc", "",
""}

user action service

Definition at line 173 of file G4LegacyTransportTool.h.

◆ m_userLimitsSvc

ServiceHandle<IUserLimitsSvc> iGeant4::G4LegacyTransportTool::m_userLimitsSvc
private
Initial value:
{this, "UserLimitsSvc",
"UserLimitsSvc", ""}

Definition at line 170 of file G4LegacyTransportTool.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
pdg_comparison.sigma
sigma
Definition: pdg_comparison.py:324
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
G4AtlasRunManager::RunTermination
void RunTermination() override final
G4 function called at end of run.
Definition: G4AtlasRunManager.cxx:118
iGeant4::G4LegacyTransportTool::finalizeOnce
void finalizeOnce()
G4 finalization called only by the first tool instance.
Definition: G4LegacyTransportTool.cxx:235
ISF::BaseSimulatorG4Tool::releaseEvent
virtual StatusCode releaseEvent(const EventContext &, HitCollectionMap &)=0
Finalise data containers for an event.
iGeant4::G4LegacyTransportTool::m_accumulatedEventTime
float m_accumulatedEventTime
Definition: G4LegacyTransportTool.h:124
python.RatesEmulationExample.lock
lock
Definition: RatesEmulationExample.py:148
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
iGeant4::G4LegacyTransportTool::m_accumulatedEventTimeSq
float m_accumulatedEventTimeSq
Definition: G4LegacyTransportTool.h:125
iGeant4::G4LegacyTransportTool::m_userActionSvc
ServiceHandle< G4UA::IUserActionSvc > m_userActionSvc
user action service
Definition: G4LegacyTransportTool.h:173
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
iGeant4::G4LegacyTransportTool::m_pRunMgr
G4AtlasRunManager * m_pRunMgr
Definition: G4LegacyTransportTool.h:146
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
ISF::BaseSimulatorG4Tool::setupEvent
virtual StatusCode setupEvent(const EventContext &, HitCollectionMap &)=0
Create data containers for an event.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
iGeant4::G4LegacyTransportTool::simulateVector
virtual StatusCode simulateVector(const EventContext &ctx, const ISF::ISFParticleVector &particles, ISF::ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, std::shared_ptr< HitCollectionMap > hitCollections, McEventCollection *shadowTruth=nullptr) override
Simulation call for vectors of particles.
Definition: G4LegacyTransportTool.cxx:266
iGeant4::G4LegacyTransportTool::m_rndmGenSvc
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
Definition: G4LegacyTransportTool.h:164
ISF::Geant4
@ Geant4
Definition: SimulationFlavor.h:23
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ISF::BaseSimulatorTool::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
The timing service for general usage.
Definition: BaseSimulatorTool.h:115
ISF::ISFParticleVector
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.
Definition: ISFParticleContainer.h:26
calibdata.exception
exception
Definition: calibdata.py:495
G4AtlasRunManager::ProcessEvent
bool ProcessEvent(G4Event *event)
Does the work of simulating an ATLAS event.
Definition: G4AtlasRunManager.cxx:94
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
iGeant4::G4LegacyTransportTool::m_doTiming
Gaudi::Property< bool > m_doTiming
Definition: G4LegacyTransportTool.h:122
iGeant4::G4LegacyTransportTool::m_runTimer
G4Timer * m_runTimer
Definition: G4LegacyTransportTool.h:128
DataVector::back
const T * back() const
Access the last element in the collection as an rvalue.
iGeant4::G4LegacyTransportTool::m_inputConverter
ServiceHandle< ISF::IInputConverter > m_inputConverter
Service to convert ISF_Particles into a G4Event.
Definition: G4LegacyTransportTool.h:177
iGeant4::G4LegacyTransportTool::m_nrOfEntries
unsigned int m_nrOfEntries
Definition: G4LegacyTransportTool.h:126
iGeant4::G4LegacyTransportTool::m_recordFlux
Gaudi::Property< bool > m_recordFlux
Definition: G4LegacyTransportTool.h:152
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
iGeant4::G4LegacyTransportTool::m_eventTimer
G4Timer * m_eventTimer
Definition: G4LegacyTransportTool.h:129
AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize
virtual StatusCode sysInitialize() override
Perform system initialization for an algorithm.
iGeant4::G4LegacyTransportTool::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Definition: G4LegacyTransportTool.h:167
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition: RNGWrapper.h:134
iGeant4::G4LegacyTransportTool::m_senDetTool
PublicToolHandle< ISensitiveDetectorMasterTool > m_senDetTool
Sensitive Detector Master Tool.
Definition: G4LegacyTransportTool.h:183
ISF::BaseSimulatorTool::initialize
virtual StatusCode initialize() override
Definition: BaseSimulatorTool.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
iGeant4::G4LegacyTransportTool::Slot::lock_t
std::lock_guard< mutex_t > lock_t
Definition: G4LegacyTransportTool.h:136
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
iGeant4::G4LegacyTransportTool::ATLAS_NOT_THREAD_SAFE
void initializeOnce ATLAS_NOT_THREAD_SAFE()
G4 initialization called only by the first tool instance.
ISF::BaseSimulatorG4Tool
Definition: BaseSimulatorG4Tool.h:28
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
iGeant4::G4LegacyTransportTool::m_mcEventCollectionName
Gaudi::Property< std::string > m_mcEventCollectionName
Definition: G4LegacyTransportTool.h:140
iGeant4::G4LegacyTransportTool::genEvent
HepMC::GenEvent * genEvent(McEventCollection *mcEventCollection) const
Definition: G4LegacyTransportTool.cxx:398
iGeant4::G4LegacyTransportTool::m_fastSimTool
PublicToolHandle< IFastSimulationMasterTool > m_fastSimTool
Fast Simulation Master Tool.
Definition: G4LegacyTransportTool.h:186