|
ATLAS Offline Software
|
A random number engine manager, based on dSFMT.
More...
#include <AtDSFMTGenSvc.h>
|
|
StringArrayProperty | m_streams_seeds |
| seeds for the engines, this is a vector of strings of the form "EnginName Seed1 Seed2" More...
|
|
Gaudi::Property< bool > | m_read_from_file {this,"ReadFromFile",false,"set/restore the status of the engine from file"} |
| read engine status from file More...
|
|
Gaudi::Property< std::string > | m_file_to_read |
| name of the file to read the engine status from More...
|
|
Gaudi::Property< bool > | m_save_to_file {this,"SaveToFile", true,"save the status of the engine to file"} |
| should current engine status be saved to file ? More...
|
|
Gaudi::Property< std::string > | m_file_to_write |
| name of the file to save the engine status to. More...
|
|
Gaudi::Property< bool > | m_eventReseed {this,"EventReseeding",true,"reseed every event using a hash of run and event numbers"} |
| reseed for every event More...
|
|
StringArrayProperty | m_reseedStreamNames {this,"ReseedStreamNames",{}, "the streams we are going to set the seeds of (default: all streams)"} |
| streams to be reseeded for every event
More...
|
|
std::map< std::string, uint32_t > | m_reseedingOffsets |
| optional offsets to combine to run/evt no when reseeding. More...
|
|
engineMap | m_engines |
|
std::map< std::string, std::vector< uint32_t > > | m_engines_copy |
| Random engine copy (for output to a file) More...
|
|
A random number engine manager, based on dSFMT.
this service mantains a number of named, independent random number sequences. Each sequence is initialized by an entry of the form "SequenceName Seed1 Seed2" in the Seeds property. For example
Seeds = [
"PYTHIA 4789899 989240512",
"PYTHIA_INIT 820021 2347532",
"JIMMY 390020611 821000366", "JIMMY_INIT 820021 2347532",
"HERWIG 390020611 821000366", "HERWIG_INIT 820021 2347532" ]
At the end of the job in AtDSFMTGenSvc::finalize(), the status of the engine is dumped as an array of unsigned long to the ASCII file "AtDSFMTGenSvc.out". This file can be used to restore the status of the engine in another job by setting the properties
ReadFromFile = true
FileToRead = path_to_ascii_file
Definition at line 51 of file AtDSFMTGenSvc.h.
◆ engineConstIter
◆ engineIter
◆ engineMap
◆ engineValType
◆ AtDSFMTGenSvc()
AtDSFMTGenSvc::AtDSFMTGenSvc |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
svc |
|
) |
| |
◆ ~AtDSFMTGenSvc()
AtDSFMTGenSvc::~AtDSFMTGenSvc |
( |
| ) |
|
|
virtual |
◆ begin()
◆ CreateStream() [1/2]
bool AtDSFMTGenSvc::CreateStream |
( |
const std::vector< uint32_t > & |
seeds, |
|
|
const std::string & |
streamName |
|
) |
| |
Definition at line 293 of file AtDSFMTGenSvc.cxx.
298 std::vector<unsigned long> longSeeds(seeds.size());
299 for (
size_t i=0;
i<seeds.size(); ++
i) longSeeds[
i]=seeds[
i];
300 return (((*iter).second)->getState( longSeeds ));
◆ CreateStream() [2/2]
void AtDSFMTGenSvc::CreateStream |
( |
uint32_t |
seed1, |
|
|
uint32_t |
seed2, |
|
|
const std::string & |
streamName |
|
) |
| |
|
overridevirtual |
Definition at line 282 of file AtDSFMTGenSvc.cxx.
284 long seeds[3] = { (long)
seed1, (
long)
seed2, 0 };
285 const long*
s = seeds;
290 ((*iter).second)->setSeeds(
s, 0);
◆ end()
◆ finalize()
StatusCode AtDSFMTGenSvc::finalize |
( |
| ) |
|
|
overridevirtual |
Definition at line 244 of file AtDSFMTGenSvc.cxx.
254 for (std::map<std::string, std::vector<uint32_t> >::const_iterator
i =
m_engines_copy.begin();
258 for (std::vector<uint32_t>::const_iterator j = (*i).second.begin(); j !=(*i).second.end(); ++j){
266 return StatusCode::SUCCESS;
◆ GetEngine()
CLHEP::HepRandomEngine * AtDSFMTGenSvc::GetEngine |
( |
const std::string & |
streamName | ) |
|
|
overridevirtual |
Definition at line 269 of file AtDSFMTGenSvc.cxx.
279 return (CLHEP::HepRandomEngine*)(*iter).second;
◆ handle()
void AtDSFMTGenSvc::handle |
( |
const Incident & |
inc | ) |
|
|
overridevirtual |
IIncidentListener implementation. Handles EndEvent incident.
Definition at line 155 of file AtDSFMTGenSvc.cxx.
158 if ( inc.type() ==
"EndEvent" ||
159 inc.type() ==
"AfterReseedIncident" )
164 CLHEP::HepRandomEngine* engine =
GetEngine(iE->first);
165 std::vector<unsigned long>
v = engine->put();
166 std::vector<uint32_t> tseeds(
v.size());
167 for (
size_t i=0;
i<
v.size(); ++
i) {
175 tseeds[
i] = (
v[
i] & 0xffffffff
u);
182 }
else if (inc.type() ==
"BeginEvent") {
184 EventContext context = inc.context();
185 const EventIDBase& ei = context.eventID();
196 throw GaudiException(
"can not reseed all streams ",
name(), StatusCode::FAILURE);
199 const string& strName(*
i++);
203 throw GaudiException(
string(
"can not reseed stream ") + strName,
204 name(), StatusCode::FAILURE);
207 <<
" for random service " <<
endmsg;
212 else if (inc.type() ==
"ReseedIncident") {
213 typedef ContextIncident<std::pair<unsigned,unsigned> > Ctxt;
214 const Ctxt* incident =
dynamic_cast<const Ctxt*
>(&inc);
215 const std::pair<unsigned,unsigned>&
data = incident->tag();
226 throw GaudiException(
"can not reseed all streams ",
name(), StatusCode::FAILURE);
229 const string& strName(*
i++);
233 throw GaudiException(
string(
"can not reseed stream ") + strName,
234 name(), StatusCode::FAILURE);
237 <<
" for random service " <<
endmsg;
◆ initialize()
StatusCode AtDSFMTGenSvc::initialize |
( |
| ) |
|
|
overridevirtual |
Incident Service
Definition at line 48 of file AtDSFMTGenSvc.cxx.
51 (
"Initializing " <<
name() <<
"\n INITIALISING RANDOM NUMBER STREAMS. ");
60 static const int PRIORITY = 100;
61 pIncSvc->addListener(
this,
"EndEvent", PRIORITY);
62 pIncSvc->addListener(
this,
"AfterReseedIncident", PRIORITY);
67 pIncSvc->addListener(
this,
"BeginEvent", PRIORITY);
68 pIncSvc->addListener(
this,
"ReseedIncident", PRIORITY);
70 pIncSvc.release().ignore();
77 return StatusCode::FAILURE;
82 std::vector<uint32_t> seeds;
86 <<
" INITIALISING " <<
stream <<
" stream with seeds ";
87 for (std::vector<uint32_t>::const_iterator
i = seeds.begin();
i != seeds.end(); ++
i){
95 msg() << ((*i) & 0xffffffff
u) <<
" ";
100 <<
stream <<
" stream initialized succesfully" <<
endmsg;
104 return StatusCode::FAILURE;
110 return StatusCode::FAILURE;
124 <<
", reseeding offset " <<
offset);
127 return StatusCode::FAILURE;
131 bool not_found(
true);
134 while (
sf !=
end() && (not_found=((*sf).first !=
stream))) ++
sf;
139 (
" INITIALISING " <<
stream <<
" stream with seeds "
152 return StatusCode::SUCCESS;
◆ number_of_streams()
unsigned int AtDSFMTGenSvc::number_of_streams |
( |
void |
| ) |
const |
|
inline |
◆ print() [1/2]
void AtDSFMTGenSvc::print |
( |
const std::string & |
streamName | ) |
|
|
overridevirtual |
Definition at line 332 of file AtDSFMTGenSvc.cxx.
338 std::vector<unsigned long>
v = ((*citer).second)->put();
340 for (std::vector<unsigned long>::const_iterator
i =
v.begin();
i !=
v.end(); ++
i){
348 msg() << ((*i) & 0xffffffff
u) <<
" ";
◆ print() [2/2]
void AtDSFMTGenSvc::print |
( |
void |
| ) |
|
|
overridevirtual |
◆ setAllOnDefinedSeeds() [1/2]
bool AtDSFMTGenSvc::setAllOnDefinedSeeds |
( |
uint32_t |
eventNumber, |
|
|
uint32_t |
runNumber |
|
) |
| |
|
overridevirtual |
seed all streams, combining eventNumber, runNumber and the stream names
Definition at line 392 of file AtDSFMTGenSvc.cxx.
◆ setAllOnDefinedSeeds() [2/2]
bool AtDSFMTGenSvc::setAllOnDefinedSeeds |
( |
uint32_t |
theSeed | ) |
|
|
overridevirtual |
seed all streams we manage, combining theSeed and the stream names
Definition at line 407 of file AtDSFMTGenSvc.cxx.
◆ setOnDefinedSeeds() [1/2]
CLHEP::HepRandomEngine * AtDSFMTGenSvc::setOnDefinedSeeds |
( |
uint32_t |
eventNumber, |
|
|
uint32_t |
runNumber, |
|
|
const std::string & |
streamName |
|
) |
| |
|
overridevirtual |
◆ setOnDefinedSeeds() [2/2]
CLHEP::HepRandomEngine * AtDSFMTGenSvc::setOnDefinedSeeds |
( |
uint32_t |
theSeed, |
|
|
const std::string & |
streamName |
|
) |
| |
|
overridevirtual |
create engine if not found. FIXME this may not be a good idea
Definition at line 376 of file AtDSFMTGenSvc.cxx.
386 CLHEP::HepRandomEngine* eng = (*iter).second;
387 eng->setSeed( theSeed, 0 );
388 return (CLHEP::HepRandomEngine*)eng;
◆ SetStreamSeeds()
void AtDSFMTGenSvc::SetStreamSeeds |
( |
const std::string & |
StreamName | ) |
|
|
private |
Definition at line 303 of file AtDSFMTGenSvc.cxx.
323 (
" INITIALISING " <<
StreamName <<
" stream with DEFAULT seeds "
326 long seeds[3] = { (long)
seed1, (
long)
seed2, 0 };
327 const long*
s = seeds;
329 ((*iter).second)->setSeeds(
s,0);
◆ m_default_seed1
long AtDSFMTGenSvc::m_default_seed1 |
|
private |
◆ m_default_seed2
long AtDSFMTGenSvc::m_default_seed2 |
|
private |
◆ m_engines
◆ m_engines_copy
std::map<std::string, std::vector<uint32_t> > AtDSFMTGenSvc::m_engines_copy |
|
private |
◆ m_eventReseed
Gaudi::Property<bool> AtDSFMTGenSvc::m_eventReseed {this,"EventReseeding",true,"reseed every event using a hash of run and event numbers"} |
|
private |
◆ m_file_to_read
Gaudi::Property<std::string> AtDSFMTGenSvc::m_file_to_read |
|
private |
Initial value:{
this,
"FileToRead",this->
name()+
".out",
"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"
}
name of the file to read the engine status from
Definition at line 105 of file AtDSFMTGenSvc.h.
◆ m_file_to_write
Gaudi::Property<std::string> AtDSFMTGenSvc::m_file_to_write |
|
private |
Initial value:{
this,
"FileToWrite",this->
name()+
".out",
"name of an ASCII file which will be produced on finalize, containing the information to fully set/restore the status"}
name of the file to save the engine status to.
Definition at line 109 of file AtDSFMTGenSvc.h.
◆ m_HERWIG_default_seed1
long AtDSFMTGenSvc::m_HERWIG_default_seed1 |
|
private |
◆ m_HERWIG_default_seed2
long AtDSFMTGenSvc::m_HERWIG_default_seed2 |
|
private |
◆ m_PYTHIA_default_seed1
long AtDSFMTGenSvc::m_PYTHIA_default_seed1 |
|
private |
◆ m_PYTHIA_default_seed2
long AtDSFMTGenSvc::m_PYTHIA_default_seed2 |
|
private |
◆ m_read_from_file
Gaudi::Property<bool> AtDSFMTGenSvc::m_read_from_file {this,"ReadFromFile",false,"set/restore the status of the engine from file"} |
|
private |
◆ m_reseedingOffsets
std::map<std::string, uint32_t> AtDSFMTGenSvc::m_reseedingOffsets |
|
private |
optional offsets to combine to run/evt no when reseeding.
Set using OFFSET keyword of the Seeds property
Definition at line 119 of file AtDSFMTGenSvc.h.
◆ m_reseedStreamNames
StringArrayProperty AtDSFMTGenSvc::m_reseedStreamNames {this,"ReseedStreamNames",{}, "the streams we are going to set the seeds of (default: all streams)"} |
|
private |
◆ m_save_to_file
Gaudi::Property<bool> AtDSFMTGenSvc::m_save_to_file {this,"SaveToFile", true,"save the status of the engine to file"} |
|
private |
should current engine status be saved to file ?
Definition at line 108 of file AtDSFMTGenSvc.h.
◆ m_streams_seeds
StringArrayProperty AtDSFMTGenSvc::m_streams_seeds |
|
private |
Initial value:{this,"Seeds",{},
"seeds for the engines, this is a vector of strings of the form "
"['SequenceName [OFFSET num] Seed1 Seed2', ...] where OFFSET is an "
"optional integer that allows to change the sequence of randoms for a "
"given run/event no and SequenceName combination. Notice that "
"Seed1/Seed2 are dummy when EventReseeding is used",
"OrderedSet<std::string>"}
seeds for the engines, this is a vector of strings of the form "EnginName Seed1 Seed2"
Definition at line 95 of file AtDSFMTGenSvc.h.
The documentation for this class was generated from the following files:
char data[hepevt_bytes_allocation_ATLAS]
engineMap::iterator engineIter
long m_PYTHIA_default_seed2
std::map< std::string, std::vector< uint32_t > > m_engines_copy
Random engine copy (for output to a file)
engineMap::const_iterator engineConstIter
Gaudi::Property< bool > m_save_to_file
should current engine status be saved to file ?
virtual bool setAllOnDefinedSeeds(uint32_t theSeed) override
seed all streams we manage, combining theSeed and the stream names
virtual void CreateStream(uint32_t seed1, uint32_t seed2, const std::string &streamName) override
virtual void print(void) override
Gaudi::Property< bool > m_read_from_file
read engine status from file
#define ATH_MSG_VERBOSE(x)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &streamName) override
unsigned int number_of_streams(void) const
@ u
Enums for curvilinear frames.
Gaudi::Property< bool > m_eventReseed
reseed for every event
void SetStreamSeeds(const std::string &StreamName)
long m_PYTHIA_default_seed1
uint32_t crc_combine(uint32_t seed, uint32_t v)
using crc32 for architecture independence in combining the seeds
engineConstIter end(void) const
Gaudi::Property< std::string > m_file_to_read
name of the file to read the engine status from
StringArrayProperty m_reseedStreamNames
streams to be reseeded for every event
std::map< std::string, uint32_t > m_reseedingOffsets
optional offsets to combine to run/evt no when reseeding.
long m_HERWIG_default_seed1
virtual CLHEP::HepRandomEngine * setOnDefinedSeeds(uint32_t theSeed, const std::string &streamName) override
bool interpretSeeds(const std::string &buffer, std::string &stream, uint32_t &seed1, uint32_t &seed2, short &luxury, uint32_t &offset)
AthROOTErrorHandlerSvc * svc
void setFlag(TrigPassFlags *flags, const T *obj, const CONTAINER *container, const std::vector< bool > &flag)
Set the flag at index position.
engineConstIter begin(void) const
#define ATH_MSG_WARNING(x)
engineMap::value_type engineValType
StringArrayProperty m_streams_seeds
seeds for the engines, this is a vector of strings of the form "EnginName Seed1 Seed2"
long m_HERWIG_default_seed2
Gaudi::Property< std::string > m_file_to_write
name of the file to save the engine status to.