CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RandChiSquare.h

Go to the documentation of this file.
00001 // $Id: RandChiSquare.h,v 1.3.4.1 2005/03/18 22:26:48 garren 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 // M Fischler      - put and get to/from streams 12/10/04
00023 // =======================================================================
00024 
00025 #ifndef RandChiSquare_h
00026 #define RandChiSquare_h 1
00027 
00028 #include "CLHEP/Random/defs.h"
00029 #include "CLHEP/Random/Random.h"
00030 
00031 namespace CLHEP {
00032 
00037 class RandChiSquare : public HepRandom {
00038 
00039 public:
00040 
00041   inline RandChiSquare ( HepRandomEngine& anEngine, double a=1 );
00042   inline RandChiSquare ( HepRandomEngine* anEngine, double a=1 );
00043   // These constructors should be used to instantiate a RandChiSquare
00044   // distribution object defining a local engine for it.
00045   // The static generator will be skipped using the non-static methods
00046   // defined below.
00047   // If the engine is passed by pointer the corresponding engine object
00048   // will be deleted by the RandChiSquare destructor.
00049   // If the engine is passed by reference the corresponding engine object
00050   // will not be deleted by the RandChiSquare destructor.
00051 
00052   virtual ~RandChiSquare();
00053   // Destructor
00054 
00055   // Static methods to shoot random values using the static generator
00056 
00057   static inline double shoot();
00058 
00059   static double shoot( double a );
00060 
00061   static void shootArray ( const int size, double* vect,
00062                             double a=1.0 );
00063 
00064   //  Static methods to shoot random values using a given engine
00065   //  by-passing the static generator.
00066 
00067   static inline double shoot( HepRandomEngine* anEngine );
00068 
00069   static double shoot( HepRandomEngine* anEngine, 
00070                                   double a );
00071 
00072   static void shootArray ( HepRandomEngine* anEngine, const int size,
00073                             double* vect, double a=1.0 );
00074 
00075   //  Methods using the localEngine to shoot random values, by-passing
00076   //  the static generator.
00077 
00078   inline double fire();
00079 
00080   double fire( double a );
00081   
00082   void fireArray ( const int size, double* vect);
00083   void fireArray ( const int size, double* vect,
00084                    double a );
00085   inline double operator()();
00086   inline double operator()( double a );
00087 
00088   // Save and restore to/from streams
00089   
00090   std::ostream & put ( std::ostream & os ) const;
00091   std::istream & get ( std::istream & is );
00092 
00093   std::string name() const;
00094   HepRandomEngine & engine();
00095 
00096   static std::string distributionName() {return "RandChiSquare";}  
00097   // Provides the name of this distribution class
00098 
00099 private:
00100 
00101   // Private copy constructor. Defining it here disallows use.
00102   RandChiSquare(const RandChiSquare& d);
00103 
00104   static double genChiSquare( HepRandomEngine *anEngine, double a );
00105 
00106   HepRandomEngine* localEngine;
00107   bool deleteEngine;
00108   double defaultA;
00109 
00110 };
00111 
00112 }  // namespace CLHEP
00113 
00114 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00115 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00116 using namespace CLHEP;
00117 #endif
00118 
00119 #include "CLHEP/Random/RandChiSquare.icc"
00120 
00121 #endif

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7