/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Generator/BesEvtGen/BesEvtGen-00-03-58/src/EvtGen/EvtGenBase/EvtRandom.cc

Go to the documentation of this file.
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 #include "EvtGenBase/EvtPatches.hh"
00023 
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <math.h>
00027 #include <iostream>
00028 #include "EvtGenBase/EvtRandomEngine.hh"
00029 #include "EvtGenBase/EvtRandom.hh"
00030 #include "EvtGenBase/EvtReport.hh"
00031 using std::endl;
00032 
00033 
00034 EvtRandomEngine* EvtRandom::_randomEngine=0;
00035 
00036 void EvtRandom::setRandomEngine(EvtRandomEngine* randomEngine){
00037   _randomEngine=randomEngine;
00038 }
00039 
00040 
00041 double EvtRandom::random(){
00042 
00043   if (_randomEngine==0){
00044     report(ERROR,"EvtGen") <<"No random engine available in "
00045                            <<"EvtRandom::random()."<<endl;
00046     ::abort();
00047   }
00048 
00049   return _randomEngine->random();
00050 
00051 }
00052 
00053 
00054 // Random number routine to generate numbers between
00055 // min and max.  By djl on July 27, 1995.
00056 double EvtRandom::Flat( double min, double max){
00057 
00058   if ( min > max ) {
00059     report(ERROR,"EvtGen") << "min>max in EvtRandom::Flat(" << min << "," << max << ")" <<endl;
00060     ::abort();
00061   }
00062 
00063   return EvtRandom::random()*( max - min )+min;
00064 
00065 } 
00066 
00067 double EvtRandom::Flat(double max){
00068 
00069   return max*EvtRandom::random();
00070 
00071 } 
00072 
00073 double EvtRandom::Flat(){
00074 
00075   return EvtRandom::random();
00076 
00077 } 
00078 
00079 
00080 

Generated on Tue Nov 29 23:12:14 2016 for BOSS_7.0.2 by  doxygen 1.4.7