ATLAS Offline Software
AtDSFMTGenSvc.h
Go to the documentation of this file.
1 //Dear emacs, this is -*-c++-*-
2 /*
3  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 #ifndef ATDSFMTGENSVC_H
7 #define ATDSFMTGENSVC_H
8 
15 #include <map>
16 
17 //base classes
19 #include "GaudiKernel/IIncidentListener.h"
21 
22 #include "CLHEP/Random/RandomEngine.h"
23 #include "Gaudi/Property.h"
24 
25 class IAlgorithm;
26 class ISvcLocator;
27 class IIncident;
28 
29 
51 class AtDSFMTGenSvc : public extends<AthService, IAtRndmGenSvc, IIncidentListener>
52 {
53 public:
55 
56  virtual CLHEP::HepRandomEngine* GetEngine ( const std::string& streamName ) override;
57  virtual void CreateStream ( uint32_t seed1, uint32_t seed2, const std::string& streamName ) override;
58  bool CreateStream (const std::vector<uint32_t>& seeds, const std::string& streamName);
60 
62  typedef std::map<std::string, CLHEP::HepRandomEngine*> engineMap;
64  typedef engineMap::const_iterator engineConstIter;
65  typedef engineMap::value_type engineValType;
66 
68 
69  engineConstIter begin (void) const;
70  engineConstIter end (void) const;
71  unsigned int number_of_streams (void) const;
72  virtual void print ( const std::string& streamName ) override;
73  virtual void print ( void ) override;
75 
76  virtual CLHEP::HepRandomEngine* setOnDefinedSeeds (uint32_t theSeed,const std::string& streamName) override;
77  virtual CLHEP::HepRandomEngine* setOnDefinedSeeds (uint32_t eventNumber, uint32_t runNumber, const std::string& streamName) override;
79  virtual bool setAllOnDefinedSeeds (uint32_t theSeed) override;
83 
84  virtual StatusCode initialize() override;
85  virtual StatusCode finalize() override;
87 
89  virtual void handle(const Incident&) override;
90 
91 private:
93 
94  StringArrayProperty m_streams_seeds{this,"Seeds",{},
96  "seeds for the engines, this is a vector of strings of the form "\
97  "['SequenceName [OFFSET num] Seed1 Seed2', ...] where OFFSET is an "\
98  "optional integer that allows to change the sequence of randoms for a "\
99  "given run/event no and SequenceName combination. Notice that "\
100  "Seed1/Seed2 are dummy when EventReseeding is used",
101  "OrderedSet<std::string>"};
102 
103 
104  Gaudi::Property<bool> m_read_from_file{this,"ReadFromFile",false,"set/restore the status of the engine from file"};
105  Gaudi::Property<std::string> m_file_to_read{this,"FileToRead",this->name()+".out",
106  "name of a ASCII file, usually produced by AtDSFMTGenSvc itself at the end of a job, containing the information to fully set/restore the status"
107  };
108  Gaudi::Property<bool> m_save_to_file{this,"SaveToFile", true,"save the status of the engine to file"};
109  Gaudi::Property<std::string> m_file_to_write{this,"FileToWrite",this->name()+".out",
110  "name of an ASCII file which will be produced on finalize, containing the information to fully set/restore the status"};
111 
112  Gaudi::Property<bool> m_eventReseed{this,"EventReseeding",true,"reseed every event using a hash of run and event numbers"};
113  StringArrayProperty m_reseedStreamNames{this,"ReseedStreamNames",{}, "the streams we are going to set the seeds of (default: all streams)"};
115 
116 
119  std::map<std::string, uint32_t> m_reseedingOffsets;
120 
123  std::map<std::string, std::vector<uint32_t> > m_engines_copy;
124 
125 
127 
135 
136  void SetStreamSeeds( const std::string& StreamName );
137 
138 public:
139 
140  // Standard Constructor
141  AtDSFMTGenSvc(const std::string& name, ISvcLocator* svc);
142 
143  // Standard Destructor
144  virtual ~AtDSFMTGenSvc();
145 
146 };
147 
150 { return m_engines.begin(); }
151 
153 AtDSFMTGenSvc::end (void) const
154 { return m_engines.end(); }
155 
156 inline unsigned int
158 { return m_engines.size(); }
159 
160 #endif // ATDSFMTGENSVC_H
161 
162 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AtDSFMTGenSvc::AtDSFMTGenSvc
AtDSFMTGenSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: AtDSFMTGenSvc.cxx:27
AtDSFMTGenSvc::engineIter
engineMap::iterator engineIter
Definition: AtDSFMTGenSvc.h:63
AtDSFMTGenSvc::m_PYTHIA_default_seed2
long m_PYTHIA_default_seed2
Definition: AtDSFMTGenSvc.h:131
AtDSFMTGenSvc::handle
virtual void handle(const Incident &) override
IIncidentListener implementation. Handles EndEvent incident.
Definition: AtDSFMTGenSvc.cxx:155
AtDSFMTGenSvc::m_engines_copy
std::map< std::string, std::vector< uint32_t > > m_engines_copy
Random engine copy (for output to a file)
Definition: AtDSFMTGenSvc.h:123
AtDSFMTGenSvc::engineConstIter
engineMap::const_iterator engineConstIter
Definition: AtDSFMTGenSvc.h:64
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
AtDSFMTGenSvc::m_default_seed1
long m_default_seed1
Definition: AtDSFMTGenSvc.h:128
AtDSFMTGenSvc::m_save_to_file
Gaudi::Property< bool > m_save_to_file
should current engine status be saved to file ?
Definition: AtDSFMTGenSvc.h:108
AtDSFMTGenSvc::setOnDefinedSeeds
virtual CLHEP::HepRandomEngine * setOnDefinedSeeds(uint32_t theSeed, const std::string &streamName) override
AtDSFMTGenSvc::m_read_from_file
Gaudi::Property< bool > m_read_from_file
read engine status from file
Definition: AtDSFMTGenSvc.h:104
AtDSFMTGenSvc::engineMap
std::map< std::string, CLHEP::HepRandomEngine * > engineMap
CLHEP engines typedefs:
Definition: AtDSFMTGenSvc.h:62
AtDSFMTGenSvc::GetEngine
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &streamName) override
Definition: AtDSFMTGenSvc.cxx:269
AtDSFMTGenSvc::number_of_streams
unsigned int number_of_streams(void) const
Definition: AtDSFMTGenSvc.h:157
AtDSFMTGenSvc::finalize
virtual StatusCode finalize() override
Definition: AtDSFMTGenSvc.cxx:244
AtDSFMTGenSvc::m_eventReseed
Gaudi::Property< bool > m_eventReseed
reseed for every event
Definition: AtDSFMTGenSvc.h:112
AtDSFMTGenSvc::print
virtual void print(const std::string &streamName) override
AtDSFMTGenSvc::SetStreamSeeds
void SetStreamSeeds(const std::string &StreamName)
Definition: AtDSFMTGenSvc.cxx:303
genPbPbJobOpt.seed2
seed2
Definition: genPbPbJobOpt.py:57
AtDSFMTGenSvc::m_PYTHIA_default_seed1
long m_PYTHIA_default_seed1
Definition: AtDSFMTGenSvc.h:130
AtDSFMTGenSvc::initialize
virtual StatusCode initialize() override
Definition: AtDSFMTGenSvc.cxx:48
AtDSFMTGenSvc::end
engineConstIter end(void) const
Definition: AtDSFMTGenSvc.h:153
AtDSFMTGenSvc::print
virtual void print(void) override
AtDSFMTGenSvc
A random number engine manager, based on dSFMT.
Definition: AtDSFMTGenSvc.h:52
AtDSFMTGenSvc::m_file_to_read
Gaudi::Property< std::string > m_file_to_read
name of the file to read the engine status from
Definition: AtDSFMTGenSvc.h:105
EventInfoWrite.StreamName
string StreamName
Definition: EventInfoWrite.py:28
AtDSFMTGenSvc::m_engines
engineMap m_engines
Definition: AtDSFMTGenSvc.h:121
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AtDSFMTGenSvc::m_reseedStreamNames
StringArrayProperty m_reseedStreamNames
streams to be reseeded for every event
Definition: AtDSFMTGenSvc.h:113
AtDSFMTGenSvc::setOnDefinedSeeds
virtual CLHEP::HepRandomEngine * setOnDefinedSeeds(uint32_t eventNumber, uint32_t runNumber, const std::string &streamName) override
AtDSFMTGenSvc::m_reseedingOffsets
std::map< std::string, uint32_t > m_reseedingOffsets
optional offsets to combine to run/evt no when reseeding.
Definition: AtDSFMTGenSvc.h:119
AtDSFMTGenSvc::m_HERWIG_default_seed1
long m_HERWIG_default_seed1
Definition: AtDSFMTGenSvc.h:132
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
AtDSFMTGenSvc::setAllOnDefinedSeeds
virtual bool setAllOnDefinedSeeds(uint32_t theSeed) override
seed all streams we manage, combining theSeed and the stream names
IAtRndmGenSvc.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
AtDSFMTGenSvc::setAllOnDefinedSeeds
virtual bool setAllOnDefinedSeeds(uint32_t eventNumber, uint32_t runNumber) override
seed all streams, combining eventNumber, runNumber and the stream names
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
AtDSFMTGenSvc::begin
engineConstIter begin(void) const
Definition: AtDSFMTGenSvc.h:149
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
AtDSFMTGenSvc::CreateStream
virtual void CreateStream(uint32_t seed1, uint32_t seed2, const std::string &streamName) override
genPbPbJobOpt.seed1
seed1
Definition: genPbPbJobOpt.py:56
AthService.h
AtDSFMTGenSvc::~AtDSFMTGenSvc
virtual ~AtDSFMTGenSvc()
Standard Destructor.
Definition: AtDSFMTGenSvc.cxx:42
AtDSFMTGenSvc::m_default_seed2
long m_default_seed2
Definition: AtDSFMTGenSvc.h:129
AtDSFMTGenSvc::engineValType
engineMap::value_type engineValType
Definition: AtDSFMTGenSvc.h:65
AtDSFMTGenSvc::m_streams_seeds
StringArrayProperty m_streams_seeds
seeds for the engines, this is a vector of strings of the form "EnginName Seed1 Seed2"
Definition: AtDSFMTGenSvc.h:95
AtDSFMTGenSvc::m_HERWIG_default_seed2
long m_HERWIG_default_seed2
Definition: AtDSFMTGenSvc.h:133
AtDSFMTGenSvc::m_file_to_write
Gaudi::Property< std::string > m_file_to_write
name of the file to save the engine status to.
Definition: AtDSFMTGenSvc.h:109