LCOV - code coverage report
Current view: top level - TEvtGen/EvtGen/EvtGenBase - EvtRandom.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 16 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 6 0.0 %

          Line data    Source code
       1             : //--------------------------------------------------------------------------
       2             : //
       3             : // Environment:
       4             : //      This software is part of the EvtGen package developed jointly
       5             : //      for the BaBar and CLEO collaborations.  If you use all or part
       6             : //      of it, please give an appropriate acknowledgement.
       7             : //
       8             : // Copyright Information: See EvtGen/COPYRIGHT
       9             : //      Copyright (C) 1998      Caltech, UCSB
      10             : //
      11             : // Module: EvtRandom.cc
      12             : //
      13             : // Description: routines to get random numbers from 
      14             : //              random number generator.
      15             : //
      16             : // Modification history:
      17             : //
      18             : //    DJL/RYD   September 25, 1996           Module created
      19             : //
      20             : //------------------------------------------------------------------------
      21             : //
      22             : #include "EvtGenBase/EvtPatches.hh"
      23             : 
      24             : #include <stdlib.h>
      25             : #include <stdio.h>
      26             : #include <math.h>
      27             : #include <iostream>
      28             : #include "EvtGenBase/EvtRandomEngine.hh"
      29             : #include "EvtGenBase/EvtRandom.hh"
      30             : #include "EvtGenBase/EvtReport.hh"
      31             : #include "EvtGenBase/EvtConst.hh"
      32             : 
      33             : using std::endl;
      34             : 
      35             : 
      36             : EvtRandomEngine* EvtRandom::_randomEngine=0;
      37             : 
      38             : void EvtRandom::setRandomEngine(EvtRandomEngine* randomEngine){
      39           0 :   _randomEngine=randomEngine;
      40           0 : }
      41             : 
      42             : 
      43             : double EvtRandom::random(){
      44             : 
      45           0 :   if (_randomEngine==0){
      46           0 :     report(Severity::Error,"EvtGen") <<"No random engine available in "
      47           0 :                            <<"EvtRandom::random()."<<endl;
      48           0 :     ::abort();
      49             :   }
      50             : 
      51           0 :   return _randomEngine->random();
      52             : 
      53             : }
      54             : 
      55             : 
      56             : // Random number routine to generate numbers between
      57             : // min and max.  By djl on July 27, 1995.
      58             : double EvtRandom::Flat( double min, double max){
      59             : 
      60           0 :   if ( min > max ) {
      61           0 :     report(Severity::Error,"EvtGen") << "min>max in EvtRandom::Flat(" << min << "," << max << ")" <<endl;
      62           0 :     ::abort();
      63             :   }
      64             : 
      65           0 :   return EvtRandom::random()*( max - min )+min;
      66             : 
      67             : } 
      68             : 
      69             : double EvtRandom::Flat(double max){
      70             : 
      71           0 :   return max*EvtRandom::random();
      72             : 
      73             : } 
      74             : 
      75             : double EvtRandom::Flat(){
      76             : 
      77           0 :   return EvtRandom::random();
      78             : 
      79             : } 
      80             : 
      81             : double EvtRandom::Gaussian(){
      82             : 
      83           0 :   double x=EvtRandom::random();
      84           0 :   double y=EvtRandom::random();
      85             : 
      86           0 :   return cos(x*EvtConst::twoPi)*sqrt(-2.0*log(1-y));
      87             : 
      88             : }
      89             : 
      90             : 

Generated by: LCOV version 1.11