CLHEP/Random/RandChiSquare.h

00001 // $Id: RandChiSquare.h,v 1.8 2002/04/12 15:02:44 evc Exp $
00002 // -*- C++ -*-
00003 //
00004 // -----------------------------------------------------------------------
00005 //                             HEP Random
00006 //                         --- RandChiSquare ---
00007 //                          class header file
00008 // -----------------------------------------------------------------------
00009 
00010 // Class defining methods for shooting Chi^2 distributed random values,
00011 // given a number of degrees of freedom a (default=1.0).
00012 // Default values are used for operator()().
00013 
00014 // Valid values of a satisfy a > 1. When invalid values are presented,
00015 // the code silently returns -1.0.
00016 
00017 // =======================================================================
00018 // John Marraffino - Created: 12th May 1998  Based on the C-Rand package
00019 //                   by Ernst Stadlober and Franz Niederl of the Technical
00020 //                   University of Graz, Austria.
00021 // Gabriele Cosmo  - Removed useless methods and data: 5th Jan 1999
00022 // =======================================================================
00023 
00024 #ifndef RandChiSquare_h
00025 #define RandChiSquare_h 1
00026 
00027 #include "CLHEP/Random/Random.h"
00028 
00033 class RandChiSquare : public HepRandom {
00034 
00035 public:
00036 
00037   inline RandChiSquare ( HepRandomEngine& anEngine, double a=1 );
00038   inline RandChiSquare ( HepRandomEngine* anEngine, double a=1 );
00039   // These constructors should be used to instantiate a RandChiSquare
00040   // distribution object defining a local engine for it.
00041   // The static generator will be skipped using the non-static methods
00042   // defined below.
00043   // If the engine is passed by pointer the corresponding engine object
00044   // will be deleted by the RandChiSquare destructor.
00045   // If the engine is passed by reference the corresponding engine object
00046   // will not be deleted by the RandChiSquare destructor.
00047 
00048   virtual ~RandChiSquare();
00049   // Destructor
00050 
00051   // Static methods to shoot random values using the static generator
00052 
00053   static inline double shoot();
00054 
00055   static double shoot( double a );
00056 
00057   static void shootArray ( const int size, double* vect,
00058                             double a=1.0 );
00059 
00060   //  Static methods to shoot random values using a given engine
00061   //  by-passing the static generator.
00062 
00063   static inline double shoot( HepRandomEngine* anEngine );
00064 
00065   static double shoot( HepRandomEngine* anEngine, 
00066                                   double a );
00067 
00068   static void shootArray ( HepRandomEngine* anEngine, const int size,
00069                             double* vect, double a=1.0 );
00070 
00071   //  Methods using the localEngine to shoot random values, by-passing
00072   //  the static generator.
00073 
00074   inline double fire();
00075 
00076   double fire( double a );
00077   
00078   void fireArray ( const int size, double* vect);
00079   void fireArray ( const int size, double* vect,
00080                    double a );
00081   inline double operator()();
00082   inline double operator()( double a );
00083 
00084 private:
00085 
00086   // Private copy constructor. Defining it here disallows use.
00087   RandChiSquare(const RandChiSquare& d);
00088 
00089   static double genChiSquare( HepRandomEngine *anEngine, double a );
00090 
00091   HepRandomEngine* localEngine;
00092   bool deleteEngine;
00093   const double defaultA;
00094 
00095 };
00096 
00097 #include "CLHEP/Random/RandChiSquare.icc"
00098 
00099 #endif

Class Library for High Energy Physics (version 1.8)