ATLAS Offline Software
BasicRandom.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
24 #ifndef BASICRANDOM_H
25 #define BASICRANDOM_H
26 
27 #include <iostream>
28 
29 #include "TRandom3.h"
30 
31 
32 class BasicRandom {
33 
34 public:
35 
36  BasicRandom(int shared=true, int seed=4357)
37  : m_shared(shared), m_random(0) {
38  if ( shared ) {
39  static TRandom3 _r(seed);
40  m_random = &_r;
41  }
42  else {
43  m_random = new TRandom3(seed);
44  }
45  }
46  BasicRandom(const BasicRandom &) = delete; //forbid copying
47  BasicRandom operator =(const BasicRandom &) = delete; //forbid assignment
48 
49  // virtual ~Random() { delete m_rand; }
50  virtual ~BasicRandom() { if ( !m_shared ) delete m_random; }
51 
52  double exp() { return m_random->Exp(1); }
53  double gauss() { return m_random->Gaus(); }
54  double uniform() { return m_random->Uniform(); }
55 
56 
57 private:
58 
59  bool m_shared;
60  TRandom3* m_random;
61 
62 };
63 
64 
65 #endif
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
BasicRandom::~BasicRandom
virtual ~BasicRandom()
Definition: BasicRandom.h:50
BasicRandom::BasicRandom
BasicRandom(const BasicRandom &)=delete
BasicRandom::m_shared
bool m_shared
Definition: BasicRandom.h:59
BasicRandom::m_random
TRandom3 * m_random
Definition: BasicRandom.h:60
BasicRandom::BasicRandom
BasicRandom(int shared=true, int seed=4357)
Definition: BasicRandom.h:36
BasicRandom::gauss
double gauss()
Definition: BasicRandom.h:53
BasicRandom
Definition: BasicRandom.h:32
BasicRandom::exp
double exp()
Definition: BasicRandom.h:52
BasicRandom::uniform
double uniform()
Definition: BasicRandom.h:54
BasicRandom::operator=
BasicRandom operator=(const BasicRandom &)=delete