Geant4 Cross Reference |
>> 1 // $Id:$ 1 // -*- C++ -*- 2 // -*- C++ -*- 2 // 3 // 3 // ------------------------------------------- 4 // ----------------------------------------------------------------------- 4 // HEP Random 5 // HEP Random 5 // --- RandChiSquare - 6 // --- RandChiSquare --- 6 // class header file 7 // class header file 7 // ------------------------------------------- 8 // ----------------------------------------------------------------------- 8 9 9 // Class defining methods for shooting Chi^2 d 10 // Class defining methods for shooting Chi^2 distributed random values, 10 // given a number of degrees of freedom a (def 11 // given a number of degrees of freedom a (default=1.0). 11 // Default values are used for operator()(). 12 // Default values are used for operator()(). 12 13 13 // Valid values of a satisfy a > 1. When inval 14 // Valid values of a satisfy a > 1. When invalid values are presented, 14 // the code silently returns -1.0. 15 // the code silently returns -1.0. 15 16 16 // =========================================== 17 // ======================================================================= 17 // John Marraffino - Created: 12th May 1998 B 18 // John Marraffino - Created: 12th May 1998 Based on the C-Rand package 18 // by Ernst Stadlober and Fr 19 // by Ernst Stadlober and Franz Niederl of the Technical 19 // University of Graz, Austr 20 // University of Graz, Austria. 20 // Gabriele Cosmo - Removed useless methods a 21 // Gabriele Cosmo - Removed useless methods and data: 5th Jan 1999 21 // M Fischler - put and get to/from strea 22 // M Fischler - put and get to/from streams 12/10/04 22 // =========================================== 23 // ======================================================================= 23 24 24 #ifndef RandChiSquare_h 25 #ifndef RandChiSquare_h 25 #define RandChiSquare_h 1 26 #define RandChiSquare_h 1 26 27 27 #include "CLHEP/Random/Random.h" 28 #include "CLHEP/Random/Random.h" 28 #include "CLHEP/Utility/memory.h" 29 #include "CLHEP/Utility/memory.h" 29 30 30 namespace CLHEP { 31 namespace CLHEP { 31 32 32 /** 33 /** 33 * @author 34 * @author 34 * @ingroup random 35 * @ingroup random 35 */ 36 */ 36 class RandChiSquare : public HepRandom { 37 class RandChiSquare : public HepRandom { 37 38 38 public: 39 public: 39 40 40 inline RandChiSquare ( HepRandomEngine& anEn 41 inline RandChiSquare ( HepRandomEngine& anEngine, double a=1 ); 41 inline RandChiSquare ( HepRandomEngine* anEn 42 inline RandChiSquare ( HepRandomEngine* anEngine, double a=1 ); 42 // These constructors should be used to inst 43 // These constructors should be used to instantiate a RandChiSquare 43 // distribution object defining a local engi 44 // distribution object defining a local engine for it. 44 // The static generator will be skipped usin 45 // The static generator will be skipped using the non-static methods 45 // defined below. 46 // defined below. 46 // If the engine is passed by pointer the co 47 // If the engine is passed by pointer the corresponding engine object 47 // will be deleted by the RandChiSquare dest 48 // will be deleted by the RandChiSquare destructor. 48 // If the engine is passed by reference the 49 // If the engine is passed by reference the corresponding engine object 49 // will not be deleted by the RandChiSquare 50 // will not be deleted by the RandChiSquare destructor. 50 51 51 virtual ~RandChiSquare(); 52 virtual ~RandChiSquare(); 52 // Destructor 53 // Destructor 53 54 54 // Static methods to shoot random values usi 55 // Static methods to shoot random values using the static generator 55 56 56 static inline double shoot(); 57 static inline double shoot(); 57 58 58 static double shoot( double a ); 59 static double shoot( double a ); 59 60 60 static void shootArray ( const int size, dou 61 static void shootArray ( const int size, double* vect, 61 double a=1.0 ); 62 double a=1.0 ); 62 63 63 // Static methods to shoot random values us 64 // Static methods to shoot random values using a given engine 64 // by-passing the static generator. 65 // by-passing the static generator. 65 66 66 static inline double shoot( HepRandomEngine* 67 static inline double shoot( HepRandomEngine* anEngine ); 67 68 68 static double shoot( HepRandomEngine* anEngi 69 static double shoot( HepRandomEngine* anEngine, 69 double a ); 70 double a ); 70 71 71 static void shootArray ( HepRandomEngine* an 72 static void shootArray ( HepRandomEngine* anEngine, const int size, 72 double* vect, doub 73 double* vect, double a=1.0 ); 73 74 74 // Methods using the localEngine to shoot r 75 // Methods using the localEngine to shoot random values, by-passing 75 // the static generator. 76 // the static generator. 76 77 77 inline double fire(); 78 inline double fire(); 78 79 79 double fire( double a ); 80 double fire( double a ); 80 81 81 void fireArray ( const int size, double* vec 82 void fireArray ( const int size, double* vect); 82 void fireArray ( const int size, double* vec 83 void fireArray ( const int size, double* vect, 83 double a ); 84 double a ); 84 inline double operator()(); 85 inline double operator()(); 85 inline double operator()( double a ); 86 inline double operator()( double a ); 86 87 87 // Save and restore to/from streams 88 // Save and restore to/from streams 88 89 89 std::ostream & put ( std::ostream & os ) con 90 std::ostream & put ( std::ostream & os ) const; 90 std::istream & get ( std::istream & is ); 91 std::istream & get ( std::istream & is ); 91 92 92 std::string name() const; 93 std::string name() const; 93 HepRandomEngine & engine(); 94 HepRandomEngine & engine(); 94 95 95 static std::string distributionName() {retur 96 static std::string distributionName() {return "RandChiSquare";} 96 // Provides the name of this distribution cl 97 // Provides the name of this distribution class 97 98 98 private: 99 private: 99 100 100 static double genChiSquare( HepRandomEngine 101 static double genChiSquare( HepRandomEngine *anEngine, double a ); 101 102 102 std::shared_ptr<HepRandomEngine> localEngine 103 std::shared_ptr<HepRandomEngine> localEngine; 103 double defaultA; 104 double defaultA; 104 105 105 }; 106 }; 106 107 107 } // namespace CLHEP 108 } // namespace CLHEP 108 109 109 #include "CLHEP/Random/RandChiSquare.icc" 110 #include "CLHEP/Random/RandChiSquare.icc" 110 111 111 #endif 112 #endif 112 113