ATLAS Offline Software
dSFMTEngine.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 // dSFMTEngine.h
6 // base source code copied from CLHEP 1.9.4.7 version of MTwistEngine, than
7 // adopted to use dSFMT
8 // author Michael Duehrssen
9 
10 #ifndef dSFMTEngine_h
11 #define dSFMTEngine_h
12 
13 #include <stdexcept>
14 #include <atomic>
15 #include "CLHEP/Random/defs.h"
16 #include "CLHEP/Random/RandomEngine.h"
17 
18 #include <stdint.h>
19 // forward declare the base data struct of the dSFMT method
20 // dSFMT internally uses dsfmt_t, which is
21 // typedef struct DSFMT_T dsfmt_t;
22 // unfortunately, typedefs can't be forward declared
23 struct DSFMT_T;
24 
25 namespace CLHEP {
26 
31 class dSFMTEngine : public HepRandomEngine {
32 
33 public:
34  dSFMTEngine();
35  dSFMTEngine( long seed );
36  dSFMTEngine( const long * seeds );
37  virtual ~dSFMTEngine();
38  // Constructors and destructor.
39 
40  dSFMTEngine( const dSFMTEngine & p );
41  dSFMTEngine & operator=( const dSFMTEngine & p );
42  // Copy constructor and operator=.
43 
44  virtual double flat() override;
45  // Returns a pseudo random number between 0 and 1 (excluding the end points).
46 
47  virtual void flatArray(const int size, double* vect) override;
48  // Fills an array "vect" of specified size with flat random values.
49 
50  virtual void setSeed(long seed, int k=0) override;
51  // Sets the state of the algorithm according to seed.
52 
53  void setSeeds(const uint32_t * seeds, int k=0);
54  // Sets the state of the algorithm according to the zero terminated
55  // array of seeds. It is allowed to ignore one or many seeds in this array.
56 
57  virtual void setSeeds(const long * seeds, int k=0) override;
58  // Sets the state of the algorithm according to the zero terminated
59  // array of seeds. It is allowed to ignore one or many seeds in this array.
60 
61  virtual void saveStatus( const char filename[] = "MTwist.conf") const override;
62  // Saves the current engine status in the named file
63 
64  virtual void restoreStatus( const char filename[] = "MTwist.conf" ) override;
65  // Reads from named file the the last saved engine status and restores it.
66 
67  virtual void showStatus() const override;
68  // Dumps the current engine status on the screen.
69 
70  using HepRandomEngine::operator double;
71  virtual operator float() override; // returns flat, without worrying about filling bits
72  virtual operator unsigned int() override; // 32-bit flat, quickest of all
73 
74  virtual std::ostream & put (std::ostream & os) const override;
75  virtual std::istream & get (std::istream & is) override;
76  static std::string beginTag ( );
77  virtual std::istream & getState ( std::istream & is ) override;
78 
79  virtual std::string name() const override;
80  static std::string engineName() {return "MTwistEngine";}
81 
82  virtual std::vector<unsigned long> put () const override;
83  virtual bool get (const std::vector<unsigned long> & v) override;
84  virtual bool getState (const std::vector<unsigned long> & v) override;
85 
86 private:
87  DSFMT_T* m_dsfmt;
88  void init_dsfmt();
89 
90  static std::atomic<int> numEngines;
91  static constexpr int maxIndex = 215;
92 }; // dSFMTEngine
93 
94 } // namespace CLHEP
95 
96 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
97 // backwards compatibility will be enabled ONLY in CLHEP 1.9
98 using namespace CLHEP;
99 #endif
100 
101 #endif // dSFMTEngine_h
CLHEP::dSFMTEngine::dSFMTEngine
dSFMTEngine()
Definition: dSFMTEngine.cxx:47
CLHEP::dSFMTEngine
Definition: dSFMTEngine.h:31
CLHEP::dSFMTEngine::restoreStatus
virtual void restoreStatus(const char filename[]="MTwist.conf") override
Definition: dSFMTEngine.cxx:169
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CLHEP::dSFMTEngine::engineName
static std::string engineName()
Definition: dSFMTEngine.h:80
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CLHEP::dSFMTEngine::showStatus
virtual void showStatus() const override
Definition: dSFMTEngine.cxx:184
CLHEP::dSFMTEngine::numEngines
static std::atomic< int > numEngines
Definition: dSFMTEngine.h:90
CLHEP::dSFMTEngine::name
virtual std::string name() const override
Definition: dSFMTEngine.cxx:41
CLHEP::dSFMTEngine::beginTag
static std::string beginTag()
Definition: dSFMTEngine.cxx:258
CLHEP::dSFMTEngine::flatArray
virtual void flatArray(const int size, double *vect) override
Definition: dSFMTEngine.cxx:117
CLHEP::dSFMTEngine::operator=
dSFMTEngine & operator=(const dSFMTEngine &p)
Definition: dSFMTEngine.cxx:105
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CLHEP::dSFMTEngine::setSeeds
void setSeeds(const uint32_t *seeds, int k=0)
Definition: dSFMTEngine.cxx:126
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
CLHEP::dSFMTEngine::saveStatus
virtual void saveStatus(const char filename[]="MTwist.conf") const override
Definition: dSFMTEngine.cxx:157
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
CLHEP::dSFMTEngine::setSeed
virtual void setSeed(long seed, int k=0) override
Definition: dSFMTEngine.cxx:121
CLHEP::dSFMTEngine::m_dsfmt
DSFMT_T * m_dsfmt
Definition: dSFMTEngine.h:87
CLHEP::dSFMTEngine::put
virtual std::vector< unsigned long > put() const override
Definition: dSFMTEngine.cxx:227
CLHEP::dSFMTEngine::init_dsfmt
void init_dsfmt()
Definition: dSFMTEngine.cxx:79
CLHEP::dSFMTEngine::~dSFMTEngine
virtual ~dSFMTEngine()
Definition: dSFMTEngine.cxx:90
CLHEP::dSFMTEngine::maxIndex
static constexpr int maxIndex
Definition: dSFMTEngine.h:91
python.PyAthena.v
v
Definition: PyAthena.py:154
CLHEP::dSFMTEngine::getState
virtual std::istream & getState(std::istream &is) override
Definition: dSFMTEngine.cxx:262
CLHEP::dSFMTEngine::get
virtual std::istream & get(std::istream &is) override
Definition: dSFMTEngine.cxx:240
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
CLHEP::dSFMTEngine::flat
virtual double flat() override
Definition: dSFMTEngine.cxx:112
readCCLHist.float
float
Definition: readCCLHist.py:83
fitman.k
k
Definition: fitman.py:528