ATLAS Offline Software
Loading...
Searching...
No Matches
BasicRandom.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
22
23
24#ifndef BASICRANDOM_H
25#define BASICRANDOM_H
26
27#include <iostream>
28
29#include "TRandom3.h"
30
31
33
34public:
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
57private:
58
60 TRandom3* m_random;
61
62};
63
64
65#endif
66
67
68
69
70
71
72
73
74
75
BasicRandom operator=(const BasicRandom &)=delete
double uniform()
Definition BasicRandom.h:54
BasicRandom(int shared=true, int seed=4357)
Definition BasicRandom.h:36
double gauss()
Definition BasicRandom.h:53
virtual ~BasicRandom()
Definition BasicRandom.h:50
BasicRandom(const BasicRandom &)=delete
double exp()
Definition BasicRandom.h:52
TRandom3 * m_random
Definition BasicRandom.h:60
int r
Definition globals.cxx:22