00001 //-------------------------------------------------------------------------- 00002 // 00003 // Environment: 00004 // This software is part of the EvtGen package developed jointly 00005 // for the BaBar and CLEO collaborations. If you use all or part 00006 // of it, please give an appropriate acknowledgement. 00007 // 00008 // Copyright Information: See EvtGen/COPYRIGHT 00009 // Copyright (C) 1998 Caltech, UCSB 00010 // 00011 // Module: EvtRandom.cc 00012 // 00013 // Description: routines to get random numbers from 00014 // random number generator. 00015 // 00016 // Modification history: 00017 // 00018 // DJL/RYD September 25, 1996 Module created 00019 // 00020 //------------------------------------------------------------------------ 00021 // 00022 00023 #include "KKMC/KKMCRandom.h" 00024 00025 #include "CLHEP/Random/RanluxEngine.h" 00026 #include <iostream> 00027 using namespace std; 00028 using namespace CLHEP; 00029 00030 HepRandomEngine* KKMCRandom::_randomEngine=0; 00031 00032 void KKMCRandom::setRandomEngine(CLHEP::HepRandomEngine* randomEngine){ 00033 _randomEngine=randomEngine; 00034 } 00035 00036 00037 double KKMCRandom::random(){ 00038 00039 if (_randomEngine==0){ 00040 cerr <<"No random engine available in " 00041 <<"KKMCRandom::random()."<<endl; 00042 } 00043 00044 return _randomEngine->flat(); 00045 } 00046 00047 00048 00049 double KKMCRandom::Flat( double min, double max){ 00050 00051 if ( min > max ) { 00052 cerr<< "min>max in KKMCRandom::Flat(" << min << "," << max << ")" <<endl; 00053 } 00054 00055 return KKMCRandom::random()*( max - min )+min; 00056 00057 } 00058 00059 double KKMCRandom::Flat(double max){ 00060 00061 return max*KKMCRandom::random(); 00062 00063 } 00064 00065 double KKMCRandom::Flat(){ 00066 00067 return KKMCRandom::random(); 00068 00069 } 00070 00071 void KKMCRandom::FlatArray(double* vect, const int size){ 00072 if(_randomEngine == 0) cout<<"Can not get randomEngine pointer in KKMCRandom::FlatArray"<<endl; 00073 else _randomEngine->flatArray(size,vect); 00074 } 00075 00076