Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:54

0001 #ifndef GammaFunctionGenerator_H
0002 #define GammaFunctionGenerator_H
0003 
0004 /**
0005  * This class provides a gamma function generator (a<12)
0006  * The threshold works correctly only for integer values of the shape parameter (alpha)
0007  * \author Florian Beaudette
0008  * $Date: 28 Jan 2005 19:30 */
0009 
0010 // FAMOS headers
0011 #include "FastSimulation/Utilities/interface/GammaNumericalGenerator.h"
0012 
0013 // CLHEP
0014 #include "CLHEP/GenericFunctions/IncompleteGamma.hh"
0015 
0016 //STL
0017 #include <vector>
0018 
0019 class RandomEngineAndDistribution;
0020 
0021 class GammaFunctionGenerator {
0022 public:
0023   /// Constructor
0024   GammaFunctionGenerator();
0025 
0026   /// Destructor
0027   virtual ~GammaFunctionGenerator();
0028 
0029   /// shoot along a gamma distribution with shape parameter alpha and scale beta
0030   /// values > xmin
0031   double shoot(RandomEngineAndDistribution const*) const;
0032 
0033   /// The parameters must be set before shooting
0034   void setParameters(double a, double b, double xm);
0035 
0036 private:
0037   /// values 0<a<1.
0038   double gammaFrac(RandomEngineAndDistribution const*) const;
0039   /// integer values
0040   double gammaInt(RandomEngineAndDistribution const*) const;
0041 
0042 private:
0043   // The integer numerical functions
0044   std::vector<GammaNumericalGenerator> theGammas;
0045 
0046   // The gamma distribution core coefficients
0047   std::vector<double> coreCoeff;
0048 
0049   // The gamma distribution core proba
0050   double coreProba;
0051 
0052   // possibility to store different limits
0053   std::vector<double> approxLimit;
0054 
0055   // boundaries
0056   double xmin;
0057   double xmax;
0058 
0059   // closest lower integer
0060   unsigned na;
0061   // alpha-na
0062   double frac;
0063   // alpha function parameters
0064   double alpha, beta;
0065   //  Incomlete Gamma = Int(0,x)[t^(alpha-1)exp(-t)dt]/Gamma(alpha);
0066   Genfun::IncompleteGamma myIncompleteGamma;
0067 
0068   // some useful integrals
0069   std::vector<double> integralToApproxLimit;
0070 
0071   // if xmin>xmax
0072   bool badRange;
0073 };
0074 #endif