|
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. | |
| virtual void | process (Event &event) final |
| Processing an event for a Producer is calling produce. | |
Public Member Functions inherited from framework::EventProcessor | |
| DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &) | |
| declare that we have a factory for this class | |
| EventProcessor (const std::string &name, Process &process) | |
| Class constructor. | |
| virtual | ~EventProcessor ()=default |
| Class destructor. | |
| virtual void | onFileOpen (EventFile &event_file) |
| Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened. | |
| virtual void | onFileClose (EventFile &event_file) |
| 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 | num_events_began_ {0} |
| Number of events started. | |
| int | num_events_completed_ {0} |
| Number of events completed. | |
| int | run_ {-1} |
| the run number (for accessing the run header in onFileClose | |
Additional Inherited Members | |
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 | conditions_intf_ |
| Conditions interface. | |
| G4UImanager * | ui_manager_ {nullptr} |
| User interface handle. | |
| std::unique_ptr< RunManager > | run_manager_ |
| Manager controlling G4 simulation run. | |
| std::unique_ptr< LoggedSession > | session_handle_ |
| Handle to the G4Session -> how to deal with G4cout and G4cerr. | |
| framework::config::Parameters | parameters_ |
| The parameters used to configure the simulation. | |
| std::vector< std::string > | pre_init_commands_ |
| std::vector< std::string > | post_init_commands_ |
Protected Attributes inherited from framework::EventProcessor | |
| HistogramPool | histograms_ |
| helper object for making and filling histograms | |
| NtupleManager & | ntuple_ {NtupleManager::getInstance()} |
| Manager for any ntuples. | |
| logging::logger | the_log_ |
| The logger for this EventProcessor. | |
Static Protected Attributes inherited from simcore::SimulatorBase | |
| static const std::vector< std::string > | INVALID_COMMANDS |
| 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 87 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 12 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::EventProcessor.
Definition at line 19 of file Simulator.cxx.
References framework::config::Parameters::get(), simcore::DetectorConstruction::getDetectorName(), 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 15 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 86 of file Simulator.cxx.
References framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME, framework::EventProcessor::getCondition(), ldmx::RunHeader::getRunNumber(), framework::RandomNumberSeedService::getSeed(), run_, and setSeeds().
|
overridevirtual |
Callback called once processing is complete.
Reimplemented from framework::EventProcessor.
Definition at line 145 of file Simulator.cxx.
References num_events_began_, num_events_completed_, and simcore::SimulatorBase::onProcessEnd().
|
overridevirtual |
Run simulation and export results to output event.
| event | The event to process. |
Implements simcore::SimulatorBase.
Definition at line 98 of file Simulator.cxx.
References framework::EventProcessor::abortEvent(), framework::Event::getEventHeader(), ldmx::EventHeader::getEventNumber(), num_events_began_, num_events_completed_, and simcore::SimulatorBase::run_manager_.
|
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 152 of file Simulator.cxx.
Referenced by onNewRun().
|
private |
Number of events started.
Definition at line 154 of file Simulator.h.
Referenced by onProcessEnd(), and produce().
|
private |
Number of events completed.
Definition at line 157 of file Simulator.h.
Referenced by onProcessEnd(), and produce().
|
private |
the run number (for accessing the run header in onFileClose
Definition at line 160 of file Simulator.h.
Referenced by onNewRun().