ATLAS Offline Software
GenModule.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GENERATORMODULES_GENMODULE_H
6 #define GENERATORMODULES_GENMODULE_H
7 
10 #include "CLHEP/Random/RandomEngine.h"
11 #include "CLHEP/Random/RandPoisson.h"
12 #include <memory>
13 #include "AtlasHepMC/GenEvent.h"
14 
15 
39 class GenModule : public GenBase {
40 public:
41 
43 
44  GenModule(const std::string& name, ISvcLocator* pSvcLocator);
47  virtual ~GenModule() { }
49 
50 
52 
57 
58 
60 
61  virtual StatusCode genInitialize() { return StatusCode::SUCCESS; }
64  virtual StatusCode genuserInitialize() { return StatusCode::SUCCESS; }
66  virtual StatusCode callGenerator() { return StatusCode::SUCCESS; }
68  virtual StatusCode fillEvt(HepMC::GenEvent* evt) = 0;
70  virtual StatusCode genFinalize() { return StatusCode::SUCCESS; }
72 
73 
74 protected:
75 
77 
78  CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, const EventContext& ctx) const;
79  CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, unsigned long int randomSeedOffset, const EventContext& ctx) const;
80  CLHEP::HepRandomEngine* getRandomEngineDuringInitialize(const std::string& streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun=1, unsigned int lbn=1) const;
82 
84  IntegerProperty m_randomSeed{this, "RandomSeed", 1234567, "Random seed for the built-in random engine"}; // FIXME make this into an unsigned long int?
85 
87  BooleanProperty m_isAfterburner{this, "IsAfterburner", false, "Set true if generator modifies existing events rather than creating new ones"};
88 
89 #ifdef HEPMC3
90  std::shared_ptr<HepMC3::GenRunInfo> m_runinfo{};
92 #endif
93 
94 private:
95 
97 
98  // Random number service
99  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc"};
101  ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc"};
103 
104 };
105 
106 
107 #endif
GenEvent.h
GenModule::fillEvt
virtual StatusCode fillEvt(HepMC::GenEvent *evt)=0
For filling the HepMC event object.
GenModule::callGenerator
virtual StatusCode callGenerator()
For calling the generator on each iteration of the event loop.
Definition: GenModule.h:66
GenModule::finalize
StatusCode finalize()
Definition: GenModule.h:55
GenModule::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Handle on the incident service.
Definition: GenModule.h:101
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
GenModule::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition: GenModule.cxx:34
GenModule
Base class for common behaviour of generator interfaces.
Definition: GenModule.h:39
GenModule::genuserInitialize
virtual StatusCode genuserInitialize()
For initialization of user code, if required. Called after genInitialize.
Definition: GenModule.h:64
GenModule::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Data members.
Definition: GenModule.h:99
GenModule::genInitialize
virtual StatusCode genInitialize()
For initializing the generator, if required.
Definition: GenModule.h:62
GenModule::initialize
StatusCode initialize()
Definition: GenModule.cxx:21
GenBase
Base class for common behaviour of MC truth algorithms.
Definition: GenBase.h:47
GenModule::~GenModule
virtual ~GenModule()
Virtual destructor.
Definition: GenModule.h:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
GenModule::m_isAfterburner
BooleanProperty m_isAfterburner
Flag for normal vs. afterburner generators.
Definition: GenModule.h:87
GenModule::genFinalize
virtual StatusCode genFinalize()
For finalising the generator, if required.
Definition: GenModule.h:70
GenModule::GenModule
GenModule(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: GenModule.cxx:14
GenBase.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
GenModule::m_randomSeed
IntegerProperty m_randomSeed
Seed for random number engine.
Definition: GenModule.h:84
GenModule::execute
StatusCode execute()
Definition: GenModule.cxx:70
GenModule::getRandomEngineDuringInitialize
CLHEP::HepRandomEngine * getRandomEngineDuringInitialize(const std::string &streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun=1, unsigned int lbn=1) const
Definition: GenModule.cxx:53
LB_AnalMapSplitter.lbn
lbn
Definition: LB_AnalMapSplitter.py:28
IAthRNGSvc.h
ServiceHandle< IAthRNGSvc >