CLHEP VERSION 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.5 2010/06/16 17:24:53 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 #include "CLHEP/Utility/memory.h"
00031 
00032 namespace CLHEP {
00033 
00038 class RandChiSquare : public HepRandom {
00039 
00040 public:
00041 
00042   inline RandChiSquare ( HepRandomEngine& anEngine, double a=1 );
00043   inline RandChiSquare ( HepRandomEngine* anEngine, double a=1 );
00044   // These constructors should be used to instantiate a RandChiSquare
00045   // distribution object defining a local engine for it.
00046   // The static generator will be skipped using the non-static methods
00047   // defined below.
00048   // If the engine is passed by pointer the corresponding engine object
00049   // will be deleted by the RandChiSquare destructor.
00050   // If the engine is passed by reference the corresponding engine object
00051   // will not be deleted by the RandChiSquare destructor.
00052 
00053   virtual ~RandChiSquare();
00054   // Destructor
00055 
00056   // Static methods to shoot random values using the static generator
00057 
00058   static inline double shoot();
00059 
00060   static double shoot( double a );
00061 
00062   static void shootArray ( const int size, double* vect,
00063                             double a=1.0 );
00064 
00065   //  Static methods to shoot random values using a given engine
00066   //  by-passing the static generator.
00067 
00068   static inline double shoot( HepRandomEngine* anEngine );
00069 
00070   static double shoot( HepRandomEngine* anEngine, 
00071                                   double a );
00072 
00073   static void shootArray ( HepRandomEngine* anEngine, const int size,
00074                             double* vect, double a=1.0 );
00075 
00076   //  Methods using the localEngine to shoot random values, by-passing
00077   //  the static generator.
00078 
00079   inline double fire();
00080 
00081   double fire( double a );
00082   
00083   void fireArray ( const int size, double* vect);
00084   void fireArray ( const int size, double* vect,
00085                    double a );
00086   inline double operator()();
00087   inline double operator()( double a );
00088 
00089   // Save and restore to/from streams
00090   
00091   std::ostream & put ( std::ostream & os ) const;
00092   std::istream & get ( std::istream & is );
00093 
00094   std::string name() const;
00095   HepRandomEngine & engine();
00096 
00097   static std::string distributionName() {return "RandChiSquare";}  
00098   // Provides the name of this distribution class
00099 
00100 private:
00101 
00102   static double genChiSquare( HepRandomEngine *anEngine, double a );
00103 
00104   shared_ptr<HepRandomEngine> localEngine;
00105   double defaultA;
00106 
00107 };
00108 
00109 }  // namespace CLHEP
00110 
00111 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00112 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00113 using namespace CLHEP;
00114 #endif
00115 
00116 #include "CLHEP/Random/RandChiSquare.icc"
00117 
00118 #endif

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7