BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesBdkRcRandom.cxx
Go to the documentation of this file.
1#include "BesBdkRcRandom.h"
2
3#include "CLHEP/Random/RanluxEngine.h"
4#include <iostream>
5using namespace std;
6using namespace CLHEP;
7
8HepRandomEngine* BesBdkRcRandom::_randomEngine = 0;
9
10void BesBdkRcRandom::setRandomEngine( CLHEP::HepRandomEngine* randomEngine ) {
11 _randomEngine = randomEngine;
12}
13
15
16 if ( _randomEngine == 0 )
17 {
18 cerr << "No random engine available in "
19 << "BesBdkRcRandom::random()." << endl;
20 }
21 return _randomEngine->flat();
22}
23
24double BesBdkRcRandom::Flat( double min, double max ) {
25
26 if ( min > max )
27 { cerr << "min>max in BesBdkRcRandom::Flat(" << min << "," << max << ")" << endl; }
28
29 return BesBdkRcRandom::random() * ( max - min ) + min;
30}
31
32double BesBdkRcRandom::Flat( double max ) { return max * BesBdkRcRandom::random(); }
33
35
36void BesBdkRcRandom::FlatArray( double* vect, const int size ) {
37 if ( _randomEngine == 0 )
38 cout << "Can not get randomEngine pointer in BesBdkRcRandom::FlatArray" << endl;
39 else _randomEngine->flatArray( size, vect );
40}
#define min(a, b)
#define max(a, b)
static double random()
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
static void FlatArray(double *vect, const int size)
static double Flat()