00001 // $Id: RandBit.h,v 1.5 2002/04/12 15:02:44 evc 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 // ======================================================================= 00025 00026 #ifndef RandBit_h 00027 #define RandBit_h 1 00028 00029 #include "CLHEP/Random/RandFlat.h" 00030 00035 class RandBit : public RandFlat { 00036 00037 public: 00038 00039 inline RandBit ( HepRandomEngine& anEngine ); 00040 inline RandBit ( HepRandomEngine& anEngine, double width ); 00041 inline RandBit ( HepRandomEngine& anEngine, double a, double b ); 00042 inline RandBit ( HepRandomEngine* anEngine ); 00043 inline RandBit ( HepRandomEngine* anEngine, double width ); 00044 inline RandBit ( HepRandomEngine* anEngine, double a, double b ); 00045 // These constructors should be used to instantiate a RandBit 00046 // distribution object defining a local engine for it. 00047 // The static generator will be skipped using the non-static methods 00048 // defined below. 00049 // If the engine is passed by pointer the corresponding engine object 00050 // will be deleted by the RandBit destructor. 00051 // If the engine is passed by reference the corresponding engine object 00052 // will not be deleted by the RandBit destructor. 00053 00054 virtual ~RandBit(); 00055 // Destructor 00056 00057 // Other than the Bit routines, constructors, and destructor, everything is 00058 // simply inherited from RandFlat. 00059 00060 static inline int shootBit(); 00061 00062 static inline int shootBit( HepRandomEngine* ); 00063 00064 // Methods using the localEngine to shoot random values, by-passing 00065 // the static generator. 00066 00067 inline int fireBit(); 00068 00069 private: 00070 00071 // Private copy constructor. Defining it here disallows use. 00072 RandBit(const RandBit& d); 00073 00074 // All the engine info, and the default A nad B, are in the RandFlat 00075 // base class. 00076 00077 }; 00078 00079 #include "CLHEP/Random/RandBit.icc" 00080 00081 #endif