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
32namespace Resplot {
33
35
36public:
37
38 BasicRandom(int shared=true, int seed=4357)
39 : m_shared(shared), m_random(0) {
40 if ( shared ) {
43 // static TRandom3 r(seed);
45 if ( seed!=4357) m_random->SetSeed(seed);
46 }
47 else {
48 // m_random = new TRandom3(seed);
50 if ( seed ) m_random->SetSeed(seed);
51 }
52 }
53 BasicRandom(const BasicRandom &) = delete; //forbid copying
54 BasicRandom operator =(const BasicRandom &) = delete; //forbid assignment
55
56 // virtual ~Random() { delete m_rand; }
57 virtual ~BasicRandom() { if ( !m_shared ) delete m_random; }
58
59 double exp() { return m_random->Exp(1); }
60 double gauss() { return m_random->Gaus(); }
61 double uniform() { return m_random->Uniform(); }
62
63
64private:
65
67 static inline thread_local TRandom3 s_random = {4357};
68 TRandom3* m_random;
69
70};
71
72}
73
74#endif
75
76
77
78
79
80
81
82
83
84
BasicRandom(const BasicRandom &)=delete
BasicRandom operator=(const BasicRandom &)=delete
BasicRandom(int shared=true, int seed=4357)
do we ever use a different seed ?? We probably should
Definition BasicRandom.h:38
static TRandom3 s_random
Definition BasicRandom.h:67