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/Random/RandomEngine.h" 00032 #include "CLHEP/Matrix/Vector.h" 00033 00038 class HepRandomVector { 00039 00040 public: 00041 00042 HepRandomVector(); 00043 HepRandomVector(long seed); 00044 // Contructors with and without a seed using a default engine 00045 // (JamesRandom) which is instantiated for use of this distribution 00046 // instance. If the seed is omitted, multiple instantiations will 00047 // each get unique seeds. 00048 00049 HepRandomVector(HepRandomEngine & engine); 00050 HepRandomVector(HepRandomEngine * engine); 00051 // Constructor taking an alternative engine as argument. If a pointer is 00052 // given the corresponding object will be deleted by the HepRandom 00053 // destructor. 00054 00055 virtual ~HepRandomVector(); 00056 // Destructor 00057 00058 inline HepVector flat(); 00059 // Returns vector of flat values ( interval ]0.1[ ). 00060 00061 inline HepVector flat (HepRandomEngine* theNewEngine); 00062 // Returns a vector of flat values, given a defined Random Engine. 00063 00064 inline void flatArray(const int size, HepVector* vect); 00065 // Fills "vect" array of flat random values, given the size. 00066 // Included for consistency with the HepRandom class. 00067 00068 inline void flatArray(HepRandomEngine* theNewEngine, 00069 const int size, HepVector* vect); 00070 // Fills "vect" array of flat random values, given the size 00071 // and a defined Random Engine. 00072 00073 00074 virtual HepVector operator()(); 00075 // To get a flat random number using the operator (). 00076 00077 00078 private: // -------- Private methods --------- 00079 00080 inline void setSeed(long seed, int lux); 00081 // (Re)Initializes the generator with a seed. 00082 00083 inline long getSeed() const; 00084 // Gets the current seed of the current generator. 00085 00086 inline void setSeeds(const long* seeds, int aux); 00087 // (Re)Initializes the generator with a zero terminated list of seeds. 00088 00089 inline const long* getSeeds () const; 00090 // Gets the current array of seeds of the current generator. 00091 00092 void setEngine (HepRandomEngine* engine) { theEngine = engine; } 00093 // To set the underlying algorithm object 00094 00095 HepRandomEngine * getEngine() const { return theEngine; } 00096 // Returns a pointer to the underlying algorithm object. 00097 00098 void saveStatus( const char filename[] = "Config.conf" ) const; 00099 // Saves to file the current status of the current engine. 00100 00101 void restoreStatus( const char filename[] = "Config.conf" ); 00102 // Restores a saved status (if any) for the current engine. 00103 00104 void showStatus() const; 00105 // Dumps the current engine status on screen. 00106 00107 protected: // -------- Data members --------- 00108 00109 HepRandomEngine * theEngine; 00110 // The corresponding algorithm. 00111 00112 private: // -------- Data members --------- 00113 00114 bool deleteEngine; 00115 // True if the engine should be deleted on destruction. 00116 00117 }; 00118 00119 #include "CLHEP/RandomObjects/RandomVector.icc" 00120 00121 #endif