CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // $Id: RandBit.h,v 1.3.4.1 2005/03/18 22:26:48 garren Exp $ 00002 // -*- C++ -*- 00003 // 00004 // ----------------------------------------------------------------------- 00005 // HEP Random 00006 // --- RandBit --- 00007 // class header file 00008 // ----------------------------------------------------------------------- 00009 // 00010 00011 // Class defining methods for shooting Flat or Bit random numbers, double or 00012 // integers. 00013 // It provides methods to fill with double flat values arrays of 00014 // specified size, as well as methods for shooting sequences of 0,1 (bits). 00015 // Default boundaries ]0.1[ for operator()(). 00016 00017 // This is derived from RandFlat and is a drop-in replacement. However 00018 // the shootBit() and fireBit() methods are stateless (which makes them 00019 // an order of magnitude slower, but allows save/restore engine status 00020 // to work correctly). 00021 00022 // ======================================================================= 00023 // M. Fischler - Created: 15th Feb 2000 00024 // M Fischler - put and get to/from streams 12/10/04 00025 // M Fischler - static save/restore to streams streams 12/20/04 00026 // ======================================================================= 00027 00028 #ifndef RandBit_h 00029 #define RandBit_h 1 00030 00031 #include "CLHEP/Random/defs.h" 00032 #include "CLHEP/Random/RandFlat.h" 00033 00034 namespace CLHEP { 00035 00040 class RandBit : public RandFlat { 00041 00042 public: 00043 00044 inline RandBit ( HepRandomEngine& anEngine ); 00045 inline RandBit ( HepRandomEngine& anEngine, double width ); 00046 inline RandBit ( HepRandomEngine& anEngine, double a, double b ); 00047 inline RandBit ( HepRandomEngine* anEngine ); 00048 inline RandBit ( HepRandomEngine* anEngine, double width ); 00049 inline RandBit ( HepRandomEngine* anEngine, double a, double b ); 00050 // These constructors should be used to instantiate a RandBit 00051 // distribution object defining a local engine for it. 00052 // The static generator will be skipped using the non-static methods 00053 // defined below. 00054 // If the engine is passed by pointer the corresponding engine object 00055 // will be deleted by the RandBit destructor. 00056 // If the engine is passed by reference the corresponding engine object 00057 // will not be deleted by the RandBit destructor. 00058 00059 virtual ~RandBit(); 00060 // Destructor 00061 00062 // Other than the Bit routines, constructors, and destructor, everything is 00063 // simply inherited from RandFlat. 00064 00065 static inline int shootBit(); 00066 00067 static inline int shootBit( HepRandomEngine* ); 00068 00069 // Methods using the localEngine to shoot random values, by-passing 00070 // the static generator. 00071 00072 inline int fireBit(); 00073 00074 // Save and restore to/from streams 00075 00076 std::ostream & put ( std::ostream & os ) const; 00077 std::istream & get ( std::istream & is ); 00078 00079 std::string name() const; 00080 00081 static std::string distributionName() {return "RandBit";} 00082 // Provides the name of this distribution class 00083 00084 static std::ostream& saveFullState ( std::ostream & os ) 00085 // Saves to stream the state of the engine and cached data. 00086 {return RandFlat::saveFullState(os);} 00087 00088 static std::istream& restoreFullState ( std::istream & is ) 00089 // Restores from stream the state of the engine and cached data. 00090 {return RandFlat::restoreFullState(is);} 00091 00092 static std::ostream& saveDistState ( std::ostream & os ) 00093 // Saves to stream the state of the cached data. 00094 {return RandFlat::saveDistState(os);} 00095 00096 static std::istream& restoreDistState ( std::istream & is ) 00097 // Restores from stream the state of the cached data. 00098 {return RandFlat::restoreDistState(is);} 00099 00100 00101 private: 00102 00103 // Private copy constructor. Defining it here disallows use. 00104 RandBit(const RandBit& d); 00105 00106 // All the engine info, and the default A and B, are in the RandFlat 00107 // base class. 00108 00109 }; 00110 00111 } // namespace CLHEP 00112 00113 #ifdef ENABLE_BACKWARDS_COMPATIBILITY 00114 // backwards compatibility will be enabled ONLY in CLHEP 1.9 00115 using namespace CLHEP; 00116 #endif 00117 00118 #include "CLHEP/Random/RandBit.icc" 00119 00120 #endif