icemc_random.h
1 #ifndef icemc_random_h
2 #define icemc_random_h
3 
4 #include "TRandom.h"
5 
6 
7 
9 void setSeed(ULong_t seed);
10 
11 /* Convenience helper to get an RNG by name
12  *
13  * Right now there are far too many!
14  *
15  * */
16 enum WhichIceMcRNG
17 {
18  RNG_BALLOON_POSITION,
19  RNG_DIRECTION,
20  RNG_THETA_RF_RESOLUTION,
21  RNG_POSNU,
22  RNG_INTERACTION,
23  RNG_INTERACTION_LOCATION,
24  RNG_ABSORB,
25  RNG_RANDOMISE_POL,
26  RNG_XRNDM,
27  RNG_SIGNAL_FLUCT,
28  RNG_PHASES,
29  RNG_NOISE, //might be merged with above?
30  RNG_SOURCE,
31  RNG_SLOPEY,
32  RNG_SECONDARIES,
33  RNG_SUMMED_TRIGGER,
34  RNG_SECOND_BANG,
35  RNG_SPECTRA,
36  RNG_DEADTIME,
37  RNG_RICIAN,
38  RNG_INJECT,
39  RNG_SMEARED_INCIDENT_ANGLE,
40  HOW_MANY_RNGS_DO_WE_HAVE
41 };
42 
43 TRandom * getRNG(WhichIceMcRNG which);
44 
45 enum WhichIceMcRNGType
46 {
47 
48  RNG_TYPE_TRANDOM3,
49 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,8,0)
50  RNG_TYPE_MT64,
51  RNG_TYPE_MIXMAX256,
52 #endif
53  RNG_TYPE_XOSHIRO256PLUS
54 };
55 
56 
57 WhichIceMcRNGType getRNGType();
58 void setRNGType(WhichIceMcRNGType type);
59 
60 
61 // Another RNG implemetatntion that supports 64-bit seeds
62 
63 class TRandomXoshiro256Plus : public TRandom
64 {
65 
66  private:
67  ULong_t fState[4];
68 
69 
70  public:
71  /* Initialize with seed */
72  TRandomXoshiro256Plus(ULong_t seed = 12345)
73  { SetSeed(seed) ; }
74 
75 
76  /*Initialize with state
77  **/
78  TRandomXoshiro256Plus(ULong_t state0, ULong_t state1, ULong_t state2, ULong_t state3)
79  {
80  fState[0] = state0;
81  fState[1] = state1;
82  fState[2] = state2;
83  fState[3] = state3;
84  }
85 
86  TRandomXoshiro256Plus(ULong_t * state)
87  {
88  fState[0] = state[0];
89  fState[1] = state[1];
90  fState[2] = state[2];
91  fState[3] = state[3];
92  }
93 
94  // this is obviously truncated
95  virtual UInt_t GetSeed() const { return fState[0]; }
96 
98  void getState(ULong_t * state) const { state[0] = fState[0]; state[1] = fState[1]; state[2] = fState[2]; state[3] = fState[3]; }
99  void getState(ULong_t & st0, ULong_t & st1, ULong_t & st2, ULong_t & st3) const { st0 = fState[0]; st1 = fState[1]; st2=fState[2]; st3=fState[3]; }
100 
101  virtual void SetSeed(ULong_t seed = 0);
102 
103  // This is the actual 64-bit value generated by the generator
104  virtual ULong_t RawRndm();
105  virtual Double_t Rndm();
106  virtual Double_t Rndm(Int_t unused) { (void) unused; return Rndm(); }
107  virtual void RndmArray(Int_t n, Float_t * array);
108  virtual void RndmArray(Int_t n, Double_t * array);
109 
110  ClassDef(TRandomXoshiro256Plus,1);
111 };
112 
113 
114 
115 
116 #endif
void getState(ULong_t *state) const
Definition: icemc_random.h:98