|
||||
File indexing completed on 2025-01-18 09:54:38
0001 // -*- C++ -*- 0002 // 0003 // ----------------------------------------------------------------------- 0004 // HEP Random 0005 // --- HepRandomVector --- 0006 // class header file 0007 // ----------------------------------------------------------------------- 0008 // This file is part of CLHEP, extended to match the distributions in RPP. 0009 // 0010 // It's exactly analogous to HepRandom except that the return types for 0011 // the fire() and related methods are std::vector<double> instead of 0012 // double. 0013 // 0014 // Distribution classes returning HepVectors of results inherit from 0015 // HepRandomVector instead of HepRandom. 0016 // 0017 // HepVector is used instead of the more modern looking 0018 // std::vector<double> because the motivating sub-class 0019 // RandMultiGauss uses HepMatrix to supply the correlation 0020 // matrix S anyway. Given that, we might as well stick to 0021 // HepVector when a vector of numbers is needed, as well. 0022 // 0023 // ======================================================================= 0024 // Mark Fischler - Created: 19 Oct, 1998 0025 // 10/20/98 - Removed all shoot-related material 0026 // ======================================================================= 0027 0028 #ifndef HepRandomVector_h 0029 #define HepRandomVector_h 1 0030 0031 #include "CLHEP/RandomObjects/defs.h" 0032 #include "CLHEP/Random/RandomEngine.h" 0033 #include "CLHEP/Matrix/Vector.h" 0034 0035 namespace CLHEP { 0036 0037 /** 0038 * @author Mark Fischler <mf@fnal.gov> 0039 * @ingroup robjects 0040 */ 0041 class HepRandomVector { 0042 0043 public: 0044 0045 HepRandomVector(); 0046 HepRandomVector(long seed); 0047 // Contructors with and without a seed using a default engine 0048 // (JamesRandom) which is instantiated for use of this distribution 0049 // instance. If the seed is omitted, multiple instantiations will 0050 // each get unique seeds. 0051 0052 HepRandomVector(HepRandomEngine & engine); 0053 HepRandomVector(HepRandomEngine * engine); 0054 // Constructor taking an alternative engine as argument. If a pointer is 0055 // given the corresponding object will be deleted by the HepRandom 0056 // destructor. 0057 0058 virtual ~HepRandomVector(); 0059 // Destructor 0060 0061 inline HepVector flat(); 0062 // Returns vector of flat values ( interval ]0.1[ ). 0063 0064 inline HepVector flat (HepRandomEngine* theNewEngine); 0065 // Returns a vector of flat values, given a defined Random Engine. 0066 0067 inline void flatArray(const int size, HepVector* vect); 0068 // Fills "vect" array of flat random values, given the size. 0069 // Included for consistency with the HepRandom class. 0070 0071 inline void flatArray(HepRandomEngine* theNewEngine, 0072 const int size, HepVector* vect); 0073 // Fills "vect" array of flat random values, given the size 0074 // and a defined Random Engine. 0075 0076 0077 virtual HepVector operator()(); 0078 // To get a flat random number using the operator (). 0079 0080 0081 private: // -------- Private methods --------- 0082 0083 inline void setSeed(long seed, int lux); 0084 // (Re)Initializes the generator with a seed. 0085 0086 inline long getSeed() const; 0087 // Gets the current seed of the current generator. 0088 0089 inline void setSeeds(const long* seeds, int aux); 0090 // (Re)Initializes the generator with a zero terminated list of seeds. 0091 0092 inline const long* getSeeds () const; 0093 // Gets the current array of seeds of the current generator. 0094 0095 void setEngine (HepRandomEngine* engine) { theEngine = engine; } 0096 // To set the underlying algorithm object 0097 0098 HepRandomEngine * getEngine() const { return theEngine; } 0099 // Returns a pointer to the underlying algorithm object. 0100 0101 void saveStatus( const char filename[] = "Config.conf" ) const; 0102 // Saves to file the current status of the current engine. 0103 0104 void restoreStatus( const char filename[] = "Config.conf" ); 0105 // Restores a saved status (if any) for the current engine. 0106 0107 void showStatus() const; 0108 // Dumps the current engine status on screen. 0109 0110 protected: // -------- Data members --------- 0111 0112 HepRandomEngine * theEngine; 0113 // The corresponding algorithm. 0114 0115 private: // -------- Data members --------- 0116 0117 bool deleteEngine; 0118 // True if the engine should be deleted on destruction. 0119 0120 }; 0121 0122 } // namespace CLHEP 0123 0124 #include "CLHEP/RandomObjects/RandomVector.icc" 0125 0126 #ifdef ENABLE_BACKWARDS_COMPATIBILITY 0127 // backwards compatibility will be enabled ONLY in CLHEP 1.9 0128 using namespace CLHEP; 0129 #endif 0130 0131 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |