ATLAS Offline Software
Loading...
Searching...
No Matches
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
14
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
25class IAlgorithm;
26class ISvcLocator;
27class IIncident;
28
29
51class AtDSFMTGenSvc : public extends<AthService, IAtRndmGenSvc, IIncidentListener>
52{
53public:
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;
63 typedef engineMap::iterator engineIter;
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;
81 virtual bool setAllOnDefinedSeeds (uint32_t eventNumber, uint32_t runNumber) override;
83
84 virtual StatusCode initialize() override;
85 virtual StatusCode finalize() override;
87
89 virtual void handle(const Incident&) override;
90
91private:
93
94
95 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
138public:
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
154{ return m_engines.end(); }
155
156inline unsigned int
158{ return m_engines.size(); }
159
160#endif // ATDSFMTGENSVC_H
161
162
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 handle(const Incident &) override
IIncidentListener implementation. Handles EndEvent incident.
engineConstIter end(void) const
unsigned int number_of_streams(void) const
long m_PYTHIA_default_seed1
virtual StatusCode initialize() override
engineMap::const_iterator engineConstIter
virtual void print(void) override
engineMap::value_type engineValType
Gaudi::Property< bool > m_eventReseed
reseed for every event
std::map< std::string, CLHEP::HepRandomEngine * > engineMap
CLHEP engines typedefs:
virtual void CreateStream(uint32_t seed1, uint32_t seed2, const std::string &streamName) override
long m_PYTHIA_default_seed2
virtual CLHEP::HepRandomEngine * setOnDefinedSeeds(uint32_t theSeed, const std::string &streamName) override
virtual ~AtDSFMTGenSvc()
Standard Destructor.
virtual bool setAllOnDefinedSeeds(uint32_t theSeed) override
seed all streams we manage, combining theSeed and the stream names
std::map< std::string, uint32_t > m_reseedingOffsets
optional offsets to combine to run/evt no when reseeding.
virtual StatusCode finalize() override
engineMap m_engines
Gaudi::Property< bool > m_read_from_file
read engine status from file
Gaudi::Property< bool > m_save_to_file
should current engine status be saved to file ?
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &streamName) override
engineMap::iterator engineIter
long m_HERWIG_default_seed2
StringArrayProperty m_reseedStreamNames
streams to be reseeded for every event
engineConstIter begin(void) const
std::map< std::string, std::vector< uint32_t > > m_engines_copy
Random engine copy (for output to a file)
StringArrayProperty m_streams_seeds
seeds for the engines, this is a vector of strings of the form "EnginName Seed1 Seed2"
Gaudi::Property< std::string > m_file_to_read
name of the file to read the engine status from
long m_HERWIG_default_seed1
AtDSFMTGenSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.