source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/common/base/src/EsafRandom.cc @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 2.1 KB
Line 
1// $Id: EsafRandom.cc 2085 2005-08-25 15:51:58Z thea $
2// M.Pallavicini created Feb, 11 2002
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: EsafRandom                                                           *
8 *  Package: Base                                                            *
9 *  Coordinator: Marco.Pallavicini                                           *
10 *                                                                           *
11 *****************************************************************************/
12
13//_____________________________________________________________________________
14// 
15//  ESAF random numbers generator manager
16//  =====================================
17//
18//  TODO
19
20#include "EsafRandom.hh"
21#include "Config.hh"
22
23EsafRandom *EsafRandom::fgMe   = NULL;
24
25ClassImp(EsafRandom)
26
27//______________________________________________________________________________
28EsafRandom::EsafRandom() : EsafConfigurable() {
29    //
30    // Constructor
31    //
32
33    string type = Conf()->GetStr("EsafRandom.fType");
34    if (type == "TRandom" ) {
35        fRndm = new TRandom();
36    } else if (type == "TRandom2" ) {
37        fRndm = new TRandom2();
38    } else if (type == "TRandom3" ) {
39        fRndm = new TRandom3();
40    } 
41    else 
42        FatalError("EsafRandom: "+type+" random generator type not known");
43
44    // read seed from config file
45    Int_t seed = (Int_t)Conf()->GetNum("EsafRandom.fSeed");
46
47    MsgForm(EsafMsg::Debug,"Seed set to %d",seed);
48    fRndm->SetSeed(seed);
49
50    // set frndm as root rndm number generator.
51    gRandom = fRndm;
52
53}
54
55//______________________________________________________________________________
56EsafRandom::~EsafRandom() {
57    //
58    // Destructor
59    //
60}
61
62//______________________________________________________________________________
63TRandom* EsafRandom::Get() {
64    //
65    // Get
66    //
67
68    if (fgMe==NULL) {
69        fgMe = new EsafRandom(); 
70    }
71
72    return fgMe->GetRandom();
73}
74
75
76
Note: See TracBrowser for help on using the repository browser.