Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RandChiSquare.h
Go to the documentation of this file.
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RandChiSquare ---
7 // class header file
8 // -----------------------------------------------------------------------
9 
10 // Class defining methods for shooting Chi^2 distributed random values,
11 // given a number of degrees of freedom a (default=1.0).
12 // Default values are used for operator()().
13 
14 // Valid values of a satisfy a > 1. When invalid values are presented,
15 // the code silently returns -1.0.
16 
17 // =======================================================================
18 // John Marraffino - Created: 12th May 1998 Based on the C-Rand package
19 // by Ernst Stadlober and Franz Niederl of the Technical
20 // University of Graz, Austria.
21 // Gabriele Cosmo - Removed useless methods and data: 5th Jan 1999
22 // M Fischler - put and get to/from streams 12/10/04
23 // =======================================================================
24 
25 #ifndef RandChiSquare_h
26 #define RandChiSquare_h 1
27 
28 #include "CLHEP/Random/Random.h"
29 #include "CLHEP/Utility/memory.h"
30 
31 namespace CLHEP {
32 
37 class RandChiSquare : public HepRandom {
38 
39 public:
40 
41  inline RandChiSquare ( HepRandomEngine& anEngine, double a=1 );
42  inline RandChiSquare ( HepRandomEngine* anEngine, double a=1 );
43  // These constructors should be used to instantiate a RandChiSquare
44  // distribution object defining a local engine for it.
45  // The static generator will be skipped using the non-static methods
46  // defined below.
47  // If the engine is passed by pointer the corresponding engine object
48  // will be deleted by the RandChiSquare destructor.
49  // If the engine is passed by reference the corresponding engine object
50  // will not be deleted by the RandChiSquare destructor.
51 
52  virtual ~RandChiSquare();
53  // Destructor
54 
55  // Static methods to shoot random values using the static generator
56 
57  static inline double shoot();
58 
59  static double shoot( double a );
60 
61  static void shootArray ( const int size, double* vect,
62  double a=1.0 );
63 
64  // Static methods to shoot random values using a given engine
65  // by-passing the static generator.
66 
67  static inline double shoot( HepRandomEngine* anEngine );
68 
69  static double shoot( HepRandomEngine* anEngine,
70  double a );
71 
72  static void shootArray ( HepRandomEngine* anEngine, const int size,
73  double* vect, double a=1.0 );
74 
75  // Methods using the localEngine to shoot random values, by-passing
76  // the static generator.
77 
78  inline double fire();
79 
80  double fire( double a );
81 
82  void fireArray ( const int size, double* vect);
83  void fireArray ( const int size, double* vect,
84  double a );
85  inline double operator()();
86  inline double operator()( double a );
87 
88  // Save and restore to/from streams
89 
90  std::ostream & put ( std::ostream & os ) const;
91  std::istream & get ( std::istream & is );
92 
93  std::string name() const;
95 
96  static std::string distributionName() {return "RandChiSquare";}
97  // Provides the name of this distribution class
98 
99 private:
100 
101  static double genChiSquare( HepRandomEngine *anEngine, double a );
102 
103  std::shared_ptr<HepRandomEngine> localEngine;
104  double defaultA;
105 
106 };
107 
108 } // namespace CLHEP
109 
110 #include "CLHEP/Random/RandChiSquare.icc"
111 
112 #endif
void fireArray(const int size, double *vect)
RandChiSquare(HepRandomEngine &anEngine, double a=1)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
static void shootArray(const int size, double *vect, double a=1.0)
static double shoot()
std::string name() const
std::ostream & put(std::ostream &os) const
static std::string distributionName()
Definition: RandChiSquare.h:96
HepRandomEngine & engine()