LDMX Software
|
Producer that runs Geant4 simulation inside of ldmx-app. More...
#include <Simulator.h>
Public Member Functions | |
Simulator (const std::string &name, framework::Process &process) | |
Constructor. | |
virtual | ~Simulator ()=default |
Destructor. | |
void | configure (framework::config::Parameters ¶meters) override |
Callback for the processor to configure itself from the given set of parameters. | |
void | beforeNewRun (ldmx::RunHeader &header) override |
Given a non-const reference to the new RunHeader, we can add parameters from the simulation here before the run starts. | |
void | onNewRun (const ldmx::RunHeader &header) override |
Before the run starts (but after the conditions are configured) set up the random seeds for this run. | |
virtual void | produce (framework::Event &event) override |
Run simulation and export results to output event. | |
void | onProcessEnd () override |
Callback called once processing is complete. | |
Public Member Functions inherited from simcore::SimulatorBase | |
SimulatorBase (const std::string &name, framework::Process &process) | |
void | configure (framework::config::Parameters ¶meters) override |
Callback for the EventProcessor to configure itself from the given set of parameters. | |
Public Member Functions inherited from framework::Producer | |
Producer (const std::string &name, Process &process) | |
Class constructor. | |
Public Member Functions inherited from framework::EventProcessor | |
EventProcessor (const std::string &name, Process &process) | |
Class constructor. | |
virtual | ~EventProcessor () |
Class destructor. | |
virtual void | onFileOpen (EventFile &eventFile) |
Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened. | |
virtual void | onFileClose (EventFile &eventFile) |
Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed. | |
template<class T > | |
const T & | getCondition (const std::string &condition_name) |
Access a conditions object for the current event. | |
TDirectory * | getHistoDirectory () |
Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples. | |
void | setStorageHint (framework::StorageControl::Hint hint) |
Mark the current event as having the given storage control hint from this module. | |
void | setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString) |
Mark the current event as having the given storage control hint from this module and the given purpose string. | |
int | getLogFrequency () const |
Get the current logging frequency from the process. | |
int | getRunNumber () const |
Get the run number from the process. | |
std::string | getName () const |
Get the processor name. | |
void | createHistograms (const std::vector< framework::config::Parameters > &histos) |
Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create. | |
Private Member Functions | |
void | setSeeds (std::vector< int > seeds) |
Set the seeds to be used by the Geant4 random engine. | |
Private Attributes | |
int | numEventsBegan_ {0} |
Number of events started. | |
int | numEventsCompleted_ {0} |
Number of events completed. | |
int | run_ {-1} |
the run number (for accessing the run header in onFileClose | |
Additional Inherited Members | |
Static Public Member Functions inherited from framework::EventProcessor | |
static void | declare (const std::string &classname, int classtype, EventProcessorMaker *) |
Internal function which is part of the PluginFactory machinery. | |
Static Public Attributes inherited from framework::Producer | |
static const int | CLASSTYPE {1} |
Constant used to track EventProcessor types by the PluginFactory. | |
Protected Member Functions inherited from simcore::SimulatorBase | |
void | onProcessEnd () override |
Callback called once processing is complete. | |
void | onProcessStart () override |
Initialization of simulation. | |
virtual void | updateEventHeader (ldmx::EventHeader &eventHeader) const |
virtual void | saveTracks (framework::Event &event) |
virtual void | saveSDHits (framework::Event &event) |
Protected Member Functions inherited from framework::EventProcessor | |
void | abortEvent () |
Abort the event immediately. | |
Protected Attributes inherited from simcore::SimulatorBase | |
ConditionsInterface | conditionsIntf_ |
Conditions interface. | |
G4UImanager * | uiManager_ {nullptr} |
User interface handle. | |
std::unique_ptr< RunManager > | runManager_ |
Manager controlling G4 simulation run. | |
std::unique_ptr< G4UIsession > | sessionHandle_ |
Handle to the G4Session -> how to deal with G4cout and G4cerr. | |
int | verbosity_ {1} |
Vebosity for the simulation. | |
framework::config::Parameters | parameters_ |
The parameters used to configure the simulation. | |
std::vector< std::string > | preInitCommands_ |
std::vector< std::string > | postInitCommands_ |
Protected Attributes inherited from framework::EventProcessor | |
HistogramHelper | histograms_ |
Interface class for making and filling histograms. | |
NtupleManager & | ntuple_ {NtupleManager::getInstance()} |
Manager for any ntuples. | |
logging::logger | theLog_ |
The logger for this EventProcessor. | |
Static Protected Attributes inherited from simcore::SimulatorBase | |
static const std::vector< std::string > | invalidCommands_ |
Commands not allowed to be passed from python config file This is because Simulator already runs them. | |
Producer that runs Geant4 simulation inside of ldmx-app.
Most (if not all) of the heavy lifting is done in the classes in the Sim* modules. This producer is mainly focused on calling appropriate functions at the right time in the processing chain.
Definition at line 46 of file Simulator.h.
simcore::Simulator::Simulator | ( | const std::string & | name, |
framework::Process & | process | ||
) |
Constructor.
Blank Producer constructor Constructs object that are non-configurable.
name | Name for this instance of the class. |
process | The Process class assocaited with EventProcessor, provided by the Framework. |
Definition at line 45 of file Simulator.cxx.
|
overridevirtual |
Given a non-const reference to the new RunHeader, we can add parameters from the simulation here before the run starts.
header | of new run |
Reimplemented from framework::Producer.
Definition at line 52 of file Simulator.cxx.
References simcore::Factory< Prototype, PrototypePtr, PrototypeConstructorArgs >::apply(), simcore::Factory< Prototype, PrototypePtr, PrototypeConstructorArgs >::get(), simcore::DetectorConstruction::getDetectorName(), framework::config::Parameters::getParameter(), simcore::SimulatorBase::parameters_, ldmx::RunHeader::setDescription(), ldmx::RunHeader::setDetectorName(), ldmx::RunHeader::setFloatParameter(), ldmx::RunHeader::setIntParameter(), and ldmx::RunHeader::setStringParameter().
|
overridevirtual |
Callback for the processor to configure itself from the given set of parameters.
parameters | ParameterSet for configuration. |
Reimplemented from framework::EventProcessor.
Definition at line 48 of file Simulator.cxx.
References simcore::SimulatorBase::configure().
|
overridevirtual |
Before the run starts (but after the conditions are configured) set up the random seeds for this run.
[in] | header | RunHeader for this run, unused |
Reimplemented from framework::EventProcessor.
Definition at line 119 of file Simulator.cxx.
References framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME, ldmx::RunHeader::getRunNumber(), framework::RandomNumberSeedService::getSeed(), run_, and setSeeds().
|
overridevirtual |
Callback called once processing is complete.
Reimplemented from framework::EventProcessor.
Definition at line 169 of file Simulator.cxx.
References numEventsBegan_, numEventsCompleted_, and simcore::SimulatorBase::onProcessEnd().
|
overridevirtual |
Run simulation and export results to output event.
event | The event to process. |
Implements simcore::SimulatorBase.
Definition at line 131 of file Simulator.cxx.
References framework::EventProcessor::abortEvent(), simcore::Factory< Prototype, PrototypePtr, PrototypeConstructorArgs >::apply(), simcore::Factory< Prototype, PrototypePtr, PrototypeConstructorArgs >::get(), framework::Event::getEventHeader(), ldmx::EventHeader::getEventNumber(), numEventsBegan_, numEventsCompleted_, and simcore::SimulatorBase::runManager_.
|
private |
Set the seeds to be used by the Geant4 random engine.
[in] | seeds | A vector of seeds to pass to the G4 random engine. The vector must contain at least 2 seeds otherwise an exception is thrown. |
Definition at line 176 of file Simulator.cxx.
Referenced by onNewRun().
|
private |
Number of events started.
Definition at line 113 of file Simulator.h.
Referenced by onProcessEnd(), and produce().
|
private |
Number of events completed.
Definition at line 116 of file Simulator.h.
Referenced by onProcessEnd(), and produce().
|
private |
the run number (for accessing the run header in onFileClose
Definition at line 119 of file Simulator.h.
Referenced by onNewRun().