CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // 00003 // ----------------------------------------------------------------------- 00004 // HEP Random 00005 // --- HepRandomVector --- 00006 // class header file 00007 // ----------------------------------------------------------------------- 00008 // This file is part of CLHEP, extended to match the distributions in RPP. 00009 // 00010 // It's exactly analogous to HepRandom except that the return types for 00011 // the fire() and related methods are std::vector<double> instead of 00012 // double. 00013 // 00014 // Distribution classes returning HepVectors of results inherit from 00015 // HepRandomVector instead of HepRandom. 00016 // 00017 // HepVector is used instead of the more modern looking 00018 // std::vector<double> because the motivating sub-class 00019 // RandMultiGauss uses HepMatrix to supply the correlation 00020 // matrix S anyway. Given that, we might as well stick to 00021 // HepVector when a vector of numbers is needed, as well. 00022 // 00023 // ======================================================================= 00024 // Mark Fischler - Created: 19 Oct, 1998 00025 // 10/20/98 - Removed all shoot-related material 00026 // ======================================================================= 00027 00028 #ifndef HepRandomVector_h 00029 #define HepRandomVector_h 1 00030 00031 #include "CLHEP/RandomObjects/defs.h" 00032 #include "CLHEP/Random/RandomEngine.h" 00033 #include "CLHEP/Matrix/Vector.h" 00034 00035 namespace CLHEP { 00036 00041 class HepRandomVector { 00042 00043 public: 00044 00045 HepRandomVector(); 00046 HepRandomVector(long seed); 00047 // Contructors with and without a seed using a default engine 00048 // (JamesRandom) which is instantiated for use of this distribution 00049 // instance. If the seed is omitted, multiple instantiations will 00050 // each get unique seeds. 00051 00052 HepRandomVector(HepRandomEngine & engine); 00053 HepRandomVector(HepRandomEngine * engine); 00054 // Constructor taking an alternative engine as argument. If a pointer is 00055 // given the corresponding object will be deleted by the HepRandom 00056 // destructor. 00057 00058 virtual ~HepRandomVector(); 00059 // Destructor 00060 00061 inline HepVector flat(); 00062 // Returns vector of flat values ( interval ]0.1[ ). 00063 00064 inline HepVector flat (HepRandomEngine* theNewEngine); 00065 // Returns a vector of flat values, given a defined Random Engine. 00066 00067 inline void flatArray(const int size, HepVector* vect); 00068 // Fills "vect" array of flat random values, given the size. 00069 // Included for consistency with the HepRandom class. 00070 00071 inline void flatArray(HepRandomEngine* theNewEngine, 00072 const int size, HepVector* vect); 00073 // Fills "vect" array of flat random values, given the size 00074 // and a defined Random Engine. 00075 00076 00077 virtual HepVector operator()(); 00078 // To get a flat random number using the operator (). 00079 00080 00081 private: // -------- Private methods --------- 00082 00083 inline void setSeed(long seed, int lux); 00084 // (Re)Initializes the generator with a seed. 00085 00086 inline long getSeed() const; 00087 // Gets the current seed of the current generator. 00088 00089 inline void setSeeds(const long* seeds, int aux); 00090 // (Re)Initializes the generator with a zero terminated list of seeds. 00091 00092 inline const long* getSeeds () const; 00093 // Gets the current array of seeds of the current generator. 00094 00095 void setEngine (HepRandomEngine* engine) { theEngine = engine; } 00096 // To set the underlying algorithm object 00097 00098 HepRandomEngine * getEngine() const { return theEngine; } 00099 // Returns a pointer to the underlying algorithm object. 00100 00101 void saveStatus( const char filename[] = "Config.conf" ) const; 00102 // Saves to file the current status of the current engine. 00103 00104 void restoreStatus( const char filename[] = "Config.conf" ); 00105 // Restores a saved status (if any) for the current engine. 00106 00107 void showStatus() const; 00108 // Dumps the current engine status on screen. 00109 00110 protected: // -------- Data members --------- 00111 00112 HepRandomEngine * theEngine; 00113 // The corresponding algorithm. 00114 00115 private: // -------- Data members --------- 00116 00117 bool deleteEngine; 00118 // True if the engine should be deleted on destruction. 00119 00120 }; 00121 00122 } // namespace CLHEP 00123 00124 #include "CLHEP/RandomObjects/RandomVector.icc" 00125 00126 #ifdef ENABLE_BACKWARDS_COMPATIBILITY 00127 // backwards compatibility will be enabled ONLY in CLHEP 1.9 00128 using namespace CLHEP; 00129 #endif 00130 00131 #endif