ATLAS Offline Software
Loading...
Searching...
No Matches
AtRanluxGenSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ATRANLUXGENSVC_H
6#define ATRANLUXGENSVC_H
13
14#include <map>
15
16//base classes
18#include "GaudiKernel/IIncidentListener.h"
20#include "Gaudi/Property.h"
21
22#include "CLHEP/Random/Ranlux64Engine.h"
23
54class AtRanluxGenSvc : public extends<AthService, IAtRndmGenSvc, IIncidentListener>
55{
56public:
58
59 virtual CLHEP::HepRandomEngine* GetEngine(const std::string& streamName) override;
60 virtual void CreateStream(uint32_t seed1, uint32_t seed2,
61 const std::string& streamName) override;
62 bool CreateStream(const std::vector<uint32_t>& seeds,
63 const std::string& streamName);
65
67
68 typedef std::map<std::string, CLHEP::Ranlux64Engine*> engineMap;
69 typedef engineMap::iterator engineIter;
70 typedef engineMap::const_iterator engineConstIter;
71 typedef engineMap::value_type engineValType;
73
75
76 engineConstIter begin (void) const;
77 engineConstIter end (void) const;
78 unsigned int number_of_streams (void) const;
79 virtual void print ( const std::string& streamName ) override;
80 virtual void print ( void ) override;
82 void createStream(uint32_t seed1, uint32_t seed2,
83 const std::string& streamName, short luxLevel);
85
86 virtual CLHEP::HepRandomEngine* setOnDefinedSeeds (uint32_t theSeed,
87 const std::string& streamName) override;
88 virtual CLHEP::HepRandomEngine* setOnDefinedSeeds (uint32_t eventNumber,
89 uint32_t runNumber,
90 const std::string& streamName) override;
92 CLHEP::HepRandomEngine* oldSetOnDefinedSeeds (uint32_t theSeed,
93 const std::string& streamName);
95 CLHEP::HepRandomEngine* oldSetOnDefinedSeeds (uint32_t eventNumber,
96 uint32_t runNumber,
97 const std::string& streamName);
99 virtual bool setAllOnDefinedSeeds (uint32_t theSeed) override;
101 virtual bool setAllOnDefinedSeeds (uint32_t eventNumber, uint32_t runNumber) override;
102
104
105 virtual StatusCode initialize() override;
106 virtual StatusCode finalize() override;
108
110 virtual void handle(const Incident&) override;
111
112
113private:
115
116
117 StringArrayProperty m_streams_seeds{this,"Seeds",{},
118 "seeds for the engines, a string of the form ['SequenceName [LUXURY luxLevel (range 0:2 default 1)()] " \
119 "[OFFSET num] Seed1 Seed2', ...] where OFFSET is an optional integer that allows to change the " \
120 "sequence of randoms for a given run/event no and SequenceName combination. Notice that " \
121 "Seed1/Seed2 are dummy when EventReseeding is used",
122 "OrderedSet<std::string>"};
123
124
125 Gaudi::Property<bool> m_read_from_file{this,"ReadFromFile",false,"set/restore the status of the engine from file"};
126 Gaudi::Property<std::string> m_file_to_read{this,"FileToRead",this->name()+".out",
127 "name of a ASCII file, usually produced by AtRanLuxGenSvc itself at the end of a job, " \
128 "containing the information to fully set/restore the status of Ranlux64"
129 };
130 Gaudi::Property<bool> m_save_to_file{this,"SaveToFile", true,"save the status of the engine to file"};
131 Gaudi::Property<std::string> m_file_to_write{this,"FileToWrite",this->name()+".out",
132 "name of an ASCII file which will be produced on finalize, containing the information to fully set/restore the status"};
133
134 Gaudi::Property<bool> m_eventReseed{this,"EventReseeding",true,"reseed every event using a hash of run and event numbers"};
135 StringArrayProperty m_reseedStreamNames{this,"ReseedStreamNames",{}, "the streams we are going to set the seeds of (default: all streams)"};
137
138 Gaudi::Property<bool> m_useOldBrokenSeeding{this,"UseOldBrokenSeeding",false};
140
143 std::map<std::string, uint32_t> m_reseedingOffsets;
144
147 std::map<std::string, std::vector<uint32_t> > m_engines_copy;
149
150
152
160
161 void SetStreamSeeds( const std::string& streamName );
162
163public:
164
166 AtRanluxGenSvc(const std::string& name, ISvcLocator* svc);
167
168 virtual ~AtRanluxGenSvc();
169
170};
171
174{ return m_engines.begin(); }
175
178{ return m_engines.end(); }
179
180inline unsigned int
182{ return m_engines.size(); }
183
184#endif // ATRANLUXGENSVC_H
185
186
uint32_t m_PYTHIA_default_seed2
uint32_t m_HERWIG_default_seed1
virtual void CreateStream(uint32_t seed1, uint32_t seed2, const std::string &streamName) override
void SetStreamSeeds(const std::string &streamName)
AtRanluxGenSvc(const std::string &name, ISvcLocator *svc)
Standard Gaudi Constructor.
unsigned int number_of_streams(void) const
engineConstIter end(void) const
std::map< std::string, uint32_t > m_reseedingOffsets
optional offsets to combine to run/evt no when reseeding.
short m_defaultLuxLevel
Ranlux luxury level to be used by default.
virtual ~AtRanluxGenSvc()
Standard Destructor.
Gaudi::Property< std::string > m_file_to_read
name of the file to read the engine status from
virtual bool setAllOnDefinedSeeds(uint32_t theSeed) override
seed all streams we manage, combining theSeed and the stream names
virtual StatusCode initialize() override
StringArrayProperty m_reseedStreamNames
streams to be reseeded for every event
void createStream(uint32_t seed1, uint32_t seed2, const std::string &streamName, short luxLevel)
allows to specify luxLevel
std::map< std::string, std::vector< uint32_t > > m_engines_copy
Random engine copy (for output to a file)
uint32_t m_default_seed1
engineConstIter begin(void) const
engineMap::iterator engineIter
CLHEP::HepRandomEngine * oldSetOnDefinedSeeds(uint32_t theSeed, const std::string &streamName)
broken, temporarily keep for backward compatibility
virtual StatusCode finalize() override
StringArrayProperty m_streams_seeds
seeds for the engines, this is a vector of strings of the form "EnginName Seed1 Seed2"
virtual CLHEP::HepRandomEngine * setOnDefinedSeeds(uint32_t theSeed, const std::string &streamName) override
uint32_t m_default_seed2
Gaudi::Property< bool > m_eventReseed
reseed for every event
Gaudi::Property< std::string > m_file_to_write
name of the file to save the engine status to.
engineMap::const_iterator engineConstIter
uint32_t m_HERWIG_default_seed2
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &streamName) override
engineMap::value_type engineValType
Gaudi::Property< bool > m_read_from_file
read engine status from file
virtual void print(void) override
Gaudi::Property< bool > m_save_to_file
should current engine status be saved to file ?
engineMap m_engines
uint32_t m_PYTHIA_default_seed1
std::map< std::string, CLHEP::Ranlux64Engine * > engineMap
Gaudi::Property< bool > m_useOldBrokenSeeding
backward compatibility only, broken 32/64 bits
virtual void handle(const Incident &) override
IIncidentListener implementation. Handles EndEvent incident.