Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:37

0001 // $Id: RandBit.h,v 1.5 2010/06/16 17:24:53 garren Exp $
0002 // -*- C++ -*-
0003 //
0004 // -----------------------------------------------------------------------
0005 //                             HEP Random
0006 //                           --- RandBit ---
0007 //                          class header file
0008 // -----------------------------------------------------------------------
0009 // 
0010 
0011 // Class defining methods for shooting Flat or Bit random numbers, double or
0012 // integers.
0013 // It provides methods to fill with double flat values arrays of
0014 // specified size, as well as methods for shooting sequences of 0,1 (bits).
0015 // Default boundaries ]0.1[ for operator()().
0016 
0017 // This is derived from RandFlat and is a drop-in replacement.  However
0018 // the shootBit() and fireBit() methods are stateless (which makes them
0019 // an order of magnitude slower, but allows save/restore engine status
0020 // to work correctly).
0021 
0022 // =======================================================================
0023 // M. Fischler    - Created: 15th Feb 2000
0024 // M Fischler      - put and get to/from streams 12/10/04
0025 // M Fischler      - static save/restore to streams streams 12/20/04
0026 // =======================================================================
0027 
0028 #ifndef RandBit_h
0029 #define RandBit_h 1
0030 
0031 #include "CLHEP/Random/defs.h"
0032 #include "CLHEP/Random/RandFlat.h"
0033 
0034 namespace CLHEP {
0035 
0036 /**
0037  * @author
0038  * @ingroup random
0039  */
0040 class RandBit : public RandFlat {
0041 
0042 public:
0043 
0044   inline RandBit ( HepRandomEngine& anEngine );
0045   inline RandBit ( HepRandomEngine& anEngine, double width );
0046   inline RandBit ( HepRandomEngine& anEngine, double a, double b );
0047   inline RandBit ( HepRandomEngine* anEngine );
0048   inline RandBit ( HepRandomEngine* anEngine, double width );
0049   inline RandBit ( HepRandomEngine* anEngine, double a, double b );
0050   // These constructors should be used to instantiate a RandBit
0051   // distribution object defining a local engine for it.
0052   // The static generator will be skipped using the non-static methods
0053   // defined below.
0054   // If the engine is passed by pointer the corresponding engine object
0055   // will be deleted by the RandBit destructor.
0056   // If the engine is passed by reference the corresponding engine object
0057   // will not be deleted by the RandBit destructor.
0058 
0059   virtual ~RandBit();
0060   // Destructor
0061 
0062   // Other than the Bit routines, constructors, and destructor, everything is
0063   // simply inherited from RandFlat.
0064 
0065   static  inline int shootBit();
0066 
0067   static  inline int shootBit( HepRandomEngine* );
0068 
0069   //  Methods using the localEngine to shoot random values, by-passing
0070   //  the static generator.
0071 
0072   inline int fireBit();
0073 
0074   // Save and restore to/from streams
0075   
0076   std::ostream & put ( std::ostream & os ) const;
0077   std::istream & get ( std::istream & is );
0078 
0079   std::string name() const;
0080 
0081   static std::string distributionName() {return "RandBit";}  
0082   // Provides the name of this distribution class
0083 
0084   static std::ostream& saveFullState ( std::ostream & os ) 
0085   // Saves to stream the state of the engine and cached data.
0086                     {return RandFlat::saveFullState(os);}
0087                     
0088   static std::istream& restoreFullState ( std::istream & is )
0089   // Restores from stream the state of the engine and cached data.
0090                     {return RandFlat::restoreFullState(is);}
0091 
0092   static std::ostream& saveDistState ( std::ostream & os )
0093   // Saves to stream the state of the cached data.
0094                     {return RandFlat::saveDistState(os);}
0095 
0096   static std::istream& restoreDistState ( std::istream & is )
0097   // Restores from stream the state of the cached data.
0098                     {return RandFlat::restoreDistState(is);}
0099 
0100 
0101 private:
0102 
0103   // All the engine info, and the default A and B, are in the RandFlat
0104   // base class.
0105 
0106 };
0107 
0108 }  // namespace CLHEP
0109 
0110 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0111 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
0112 using namespace CLHEP;
0113 #endif
0114 
0115 #include "CLHEP/Random/RandBit.icc"
0116 
0117 #endif