fire v0.19.0
Framework for sImulation and Reconstruction of Events
RandomNumberSeedService.h
Go to the documentation of this file.
1
7#ifndef FIRE_RANDOMNUMBERSEEDSERVICE_H_
8#define FIRE_RANDOMNUMBERSEEDSERVICE_H_
9
10#include "fire/ConditionsObject.h"
11#include "fire/ConditionsProvider.h"
12
13namespace fire {
14
33 public ConditionsProvider {
34 public:
37
49
61 virtual void onNewRun(RunHeader& header) final override;
62
74 uint64_t getSeed(const std::string& name) const;
75
82
88 uint64_t getRootSeed() const { return root_; }
89
101 getCondition(const EventHeader& context) final override;
102
109 virtual void release(const ConditionsObject* co) final override {}
110
116 void stream(std::ostream& s) const;
117
127 const RandomNumberSeedService& o) {
128 o.stream(s);
129 return s;
130 }
131
132 private:
134 bool initialized_{false};
135
137 int mode_{0};
138
140 uint64_t root_{0};
141
144};
145
146} // namespace fire
147
148#endif // FRAMEWORK_RANDOMNUMBERSEEDSERVICE_H_
Base class for all conditions objects, very simple.
Definition: ConditionsObject.h:11
Base class for all providers of conditions objects.
Definition: ConditionsProvider.h:83
Header information of an event such as event number and timestamp.
Definition: EventHeader.h:27
System for consistent seeding of random number generators.
Definition: RandomNumberSeedService.h:33
uint64_t getSeed(const std::string &name) const
Access a given seed by name.
Definition: RandomNumberSeedService.cxx:59
uint64_t root_
what the root seed actually is
Definition: RandomNumberSeedService.h:140
bool initialized_
whether the root seed has been initialized
Definition: RandomNumberSeedService.h:134
friend std::ostream & operator<<(std::ostream &s, const RandomNumberSeedService &o)
Output streaming operator.
Definition: RandomNumberSeedService.h:126
std::map< std::string, uint64_t > seeds_
cache of seeds by name
Definition: RandomNumberSeedService.h:143
virtual void release(const ConditionsObject *co) final override
This object is both the provider of the seed service and the conditions object itself,...
Definition: RandomNumberSeedService.h:109
RandomNumberSeedService(const fire::config::Parameters &parameters)
Create the random number seed service conditions object.
Definition: RandomNumberSeedService.cxx:27
virtual void onNewRun(RunHeader &header) final override
Configure the seed service when a new run starts.
Definition: RandomNumberSeedService.cxx:51
virtual std::pair< const ConditionsObject *, ConditionsIntervalOfValidity > getCondition(const EventHeader &context) final override
Get the seed service as a conditions object.
Definition: RandomNumberSeedService.cxx:83
int mode_
what mode of root seed are we using
Definition: RandomNumberSeedService.h:137
void stream(std::ostream &s) const
Stream the configuration of this object to the input ostream.
Definition: RandomNumberSeedService.cxx:16
uint64_t getRootSeed() const
Access the root seed.
Definition: RandomNumberSeedService.h:88
std::vector< std::string > getSeedNames() const
Get a list of all the known seeds.
Definition: RandomNumberSeedService.cxx:74
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
Definition: RandomNumberSeedService.h:36
Container for run parameters.
Definition: RunHeader.h:27
Class encapsulating parameters for configuring a processor.
Definition: Parameters.h:28