ATLAS Offline Software
Loading...
Searching...
No Matches
AtRndmGenSvc.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 ATRNDMGENSVC_H
6#define ATRNDMGENSVC_H
16
17#include <map>
18
19//base classes
21#include "GaudiKernel/IIncidentListener.h"
23
24#include "CLHEP/Random/RandomEngine.h"
25#include "CLHEP/Random/RanecuEngine.h"
26
27class IAlgorithm;
28class ISvcLocator;
29class IIncident;
30
31
56class AtRndmGenSvc : public extends<AthService, IAtRndmGenSvc, IIncidentListener>
57{
58public:
60
61 virtual CLHEP::HepRandomEngine* GetEngine ( const std::string& streamName ) override;
62 virtual void CreateStream ( uint32_t seed1, uint32_t seed2,
63 const std::string& streamName ) override;
65
67 typedef std::map<std::string, CLHEP::RanecuEngine*> engineMap;
68 typedef engineMap::iterator engineIter;
69 typedef engineMap::const_iterator engineConstIter;
70 typedef engineMap::value_type engineValType;
71
73
74 engineConstIter begin (void) const;
75 engineConstIter end (void) const;
76 unsigned int number_of_streams (void) const;
77 virtual void print ( const std::string& streamName ) override;
78 virtual void print ( void ) override;
80
81 virtual CLHEP::HepRandomEngine* setOnDefinedSeeds (uint32_t theSeed,
82 const std::string& streamName) override;
83 virtual CLHEP::HepRandomEngine* setOnDefinedSeeds (uint32_t eventNumber,
84 uint32_t runNumber,
85 const std::string& streamName) override;
87 CLHEP::HepRandomEngine* oldSetOnDefinedSeeds (uint32_t theSeed,
88 const std::string& streamName);
90 CLHEP::HepRandomEngine* oldSetOnDefinedSeeds (uint32_t eventNumber,
91 uint32_t runNumber,
92 const std::string& streamName);
94 virtual bool setAllOnDefinedSeeds (uint32_t theSeed) override;
96 virtual bool setAllOnDefinedSeeds (uint32_t eventNumber, uint32_t runNumber) override;
98
99 virtual StatusCode initialize() override;
100 virtual StatusCode finalize() override;
102
104 virtual void handle(const Incident&) override;
105
106
107private:
109
110
111 Gaudi::Property<bool> m_useOldBrokenSeeding{this,"UseOldBrokenSeeding",false};
112 StringArrayProperty m_streams_seeds{this,"Seeds",{},
113 "seeds for the engines, this is a vector of strings of the form ['SequenceName [OFFSET num] Seed1 Seed2', ...] "\
114 "where OFFSET is an optional integer that allows to change the sequence of randoms for a given run/event no " \
115 "and SequenceName combination. Notice that Seed1/Seed2 are dummy when EventReseeding is used",
116 "OrderedSet<std::string>"};
117
118
119 Gaudi::Property<bool> m_read_from_file{this,"ReadFromFile",false,"set/restore the status of the engine from file"};
120 Gaudi::Property<std::string> m_file_to_read{this,"FileToRead",this->name()+".out",
121 "name of a ASCII file, usually produced by AtRndmGenSvc itself at the end of a job, "\
122 "containing the information to fully set/restore the status of Ranecu",
123 };
124 Gaudi::Property<bool> m_save_to_file{this,"SaveToFile", true,"save the status of the engine to file"};
125 Gaudi::Property<std::string> m_file_to_write{this,"FileToWrite",this->name()+".out",
126 "name of an ASCII file which will be produced on finalize, containing the information to fully set/restore the status"};
127
128 Gaudi::Property<bool> m_eventReseed{this,"EventReseeding",true,"reseed every event using a hash of run and event numbers"};
129 StringArrayProperty m_reseedStreamNames{this,"ReseedStreamNames",{}, "the streams we are going to set the seeds of (default: all streams)"};
131
132
135 std::map<std::string, uint32_t> m_reseedingOffsets;
136
139 std::map<std::string, std::vector<long int> > m_engines_copy;
140
141
143
151
152 void SetStreamSeeds( const std::string& streamName );
153
154public:
155
156 // Standard Constructor
157 AtRndmGenSvc(const std::string& name, ISvcLocator* svc);
158
159 // Standard Destructor
160 virtual ~AtRndmGenSvc();
161
162};
163
166{ return m_engines.begin(); }
167
170{ return m_engines.end(); }
171
172inline unsigned int
174{ return m_engines.size(); }
175
176#endif // ATRNDMGENSVC_H
177
178
long m_HERWIG_default_seed1
Gaudi::Property< bool > m_read_from_file
read engine status from file
std::map< std::string, CLHEP::RanecuEngine * > engineMap
CLHEP engines typedefs:
AtRndmGenSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
std::map< std::string, uint32_t > m_reseedingOffsets
optional offsets to combine to run/evt no when reseeding.
virtual bool setAllOnDefinedSeeds(uint32_t theSeed) override
seed all streams we manage, combining theSeed and the stream names
StringArrayProperty m_streams_seeds
Gaudi::Property< bool > m_save_to_file
should current engine status be saved to file ?
long m_HERWIG_default_seed2
Gaudi::Property< std::string > m_file_to_read
name of the file to read the engine status from
engineMap::const_iterator engineConstIter
long m_PYTHIA_default_seed1
virtual void handle(const Incident &) override
IIncidentListener implementation. Handles EndEvent incident.
virtual StatusCode finalize() override
unsigned int number_of_streams(void) const
virtual void print(void) override
engineConstIter begin(void) const
StringArrayProperty m_reseedStreamNames
streams to be reseeded for every event
engineMap::iterator engineIter
engineMap m_engines
void SetStreamSeeds(const std::string &streamName)
Gaudi::Property< std::string > m_file_to_write
name of the file to save the engine status to.
virtual void CreateStream(uint32_t seed1, uint32_t seed2, const std::string &streamName) override
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &streamName) override
virtual CLHEP::HepRandomEngine * setOnDefinedSeeds(uint32_t theSeed, const std::string &streamName) override
virtual StatusCode initialize() override
Gaudi::Property< bool > m_useOldBrokenSeeding
backward compatibility only, broken 32/64 bits
virtual ~AtRndmGenSvc()
Standard Destructor.
engineMap::value_type engineValType
CLHEP::HepRandomEngine * oldSetOnDefinedSeeds(uint32_t theSeed, const std::string &streamName)
broken, temporarily keep for backward compatibility
std::map< std::string, std::vector< long int > > m_engines_copy
Random engine copy (for output to a file)
long m_PYTHIA_default_seed2
engineConstIter end(void) const
Gaudi::Property< bool > m_eventReseed
reseed for every event