Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RandBit.h
Go to the documentation of this file.
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RandBit ---
7 // class header file
8 // -----------------------------------------------------------------------
9 //
10 
11 // Class defining methods for shooting Flat or Bit random numbers, double or
12 // integers.
13 // It provides methods to fill with double flat values arrays of
14 // specified size, as well as methods for shooting sequences of 0,1 (bits).
15 // Default boundaries ]0.1[ for operator()().
16 
17 // This is derived from RandFlat and is a drop-in replacement. However
18 // the shootBit() and fireBit() methods are stateless (which makes them
19 // an order of magnitude slower, but allows save/restore engine status
20 // to work correctly).
21 
22 // =======================================================================
23 // M. Fischler - Created: 15th Feb 2000
24 // M Fischler - put and get to/from streams 12/10/04
25 // M Fischler - static save/restore to streams streams 12/20/04
26 // =======================================================================
27 
28 #ifndef RandBit_h
29 #define RandBit_h 1
30 
31 #include "CLHEP/Random/RandFlat.h"
32 
33 namespace CLHEP {
34 
39 class RandBit : public RandFlat {
40 
41 public:
42 
43  inline RandBit ( HepRandomEngine& anEngine );
44  inline RandBit ( HepRandomEngine& anEngine, double width );
45  inline RandBit ( HepRandomEngine& anEngine, double a, double b );
46  inline RandBit ( HepRandomEngine* anEngine );
47  inline RandBit ( HepRandomEngine* anEngine, double width );
48  inline RandBit ( HepRandomEngine* anEngine, double a, double b );
49  // These constructors should be used to instantiate a RandBit
50  // distribution object defining a local engine for it.
51  // The static generator will be skipped using the non-static methods
52  // defined below.
53  // If the engine is passed by pointer the corresponding engine object
54  // will be deleted by the RandBit destructor.
55  // If the engine is passed by reference the corresponding engine object
56  // will not be deleted by the RandBit destructor.
57 
58  virtual ~RandBit();
59  // Destructor
60 
61  // Other than the Bit routines, constructors, and destructor, everything is
62  // simply inherited from RandFlat.
63 
64  static inline int shootBit();
65 
66  static inline int shootBit( HepRandomEngine* );
67 
68  // Methods using the localEngine to shoot random values, by-passing
69  // the static generator.
70 
71  inline int fireBit();
72 
73  // Save and restore to/from streams
74 
75  std::ostream & put ( std::ostream & os ) const;
76  std::istream & get ( std::istream & is );
77 
78  std::string name() const;
79 
80  static std::string distributionName() {return "RandBit";}
81  // Provides the name of this distribution class
82 
83  static std::ostream& saveFullState ( std::ostream & os )
84  // Saves to stream the state of the engine and cached data.
85  {return RandFlat::saveFullState(os);}
86 
87  static std::istream& restoreFullState ( std::istream & is )
88  // Restores from stream the state of the engine and cached data.
89  {return RandFlat::restoreFullState(is);}
90 
91  static std::ostream& saveDistState ( std::ostream & os )
92  // Saves to stream the state of the cached data.
93  {return RandFlat::saveDistState(os);}
94 
95  static std::istream& restoreDistState ( std::istream & is )
96  // Restores from stream the state of the cached data.
97  {return RandFlat::restoreDistState(is);}
98 
99 
100 private:
101 
102  // All the engine info, and the default A and B, are in the RandFlat
103  // base class.
104 
105 };
106 
107 } // namespace CLHEP
108 
109 #include "CLHEP/Random/RandBit.icc"
110 
111 #endif
RandBit(HepRandomEngine &anEngine)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
#define width
std::ostream & put(std::ostream &os) const
Definition: RandBit.cc:27
static std::istream & restoreDistState(std::istream &is)
Definition: RandFlat.cc:211
tuple b
Definition: test.py:12
virtual ~RandBit()
Definition: RandBit.cc:24
static std::istream & restoreFullState(std::istream &is)
Definition: RandFlat.cc:242
static std::ostream & saveDistState(std::ostream &os)
Definition: RandFlat.cc:202
static std::ostream & saveDistState(std::ostream &os)
Definition: RandBit.h:91
static std::ostream & saveFullState(std::ostream &os)
Definition: RandFlat.cc:236
static std::string distributionName()
Definition: RandBit.h:80
static std::ostream & saveFullState(std::ostream &os)
Definition: RandBit.h:83
static std::istream & restoreDistState(std::istream &is)
Definition: RandBit.h:95
static std::istream & restoreFullState(std::istream &is)
Definition: RandBit.h:87
static int shootBit()
std::string name() const
Definition: RandBit.cc:22