// $Id: EsafRandom.cc,v 1.5 2005/04/22 15:16:47 thea Exp $
// M.Pallavicini created Feb, 11 2002
/*****************************************************************************
* ESAF: Euso Simulation and Analysis Framework *
* *
* Id: EsafRandom *
* Package: Optics *
* Coordinator: Marco.Pallavicini *
* *
*****************************************************************************/
//_____________________________________________________________________________
//
// ESAF random numbers generator manager
// =====================================
//
// TODO
#include "EsafRandom.hh"
#include "Config.hh"
EsafRandom *EsafRandom::fgMe = NULL;
ClassImp(EsafRandom)
//______________________________________________________________________________
EsafRandom::EsafRandom() : EsafConfigurable() {
//
// Constructor
//
string type = Conf()->GetStr("EsafRandom.fType");
if (type == "TRandom" ) {
fRndm = new TRandom();
} else if (type == "TRandom2" ) {
fRndm = new TRandom2();
} else if (type == "TRandom3" ) {
fRndm = new TRandom3();
}
else
throw runtime_error("EsafRandom: "+type+" random generator type not known");
// read seed from config file
Int_t seed = (Int_t)Conf()->GetNum("EsafRandom.fSeed");
fRndm->SetSeed(seed);
}
//______________________________________________________________________________
EsafRandom::~EsafRandom() {
//
// Destructor
//
}
//______________________________________________________________________________
TRandom* EsafRandom::Get() {
//
// Get
//
if (fgMe==NULL) {
fgMe = new EsafRandom();
}
return fgMe->GetRandom();
}