CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

CumulativeChiSquare.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: CumulativeChiSquare.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
00003 // ---------------------------------------------------------------------------
00004 
00005 #include "CLHEP/GenericFunctions/CumulativeChiSquare.hh"
00006 #include "CLHEP/GenericFunctions/IncompleteGamma.hh"
00007 #include "CLHEP/GenericFunctions/Variable.hh"
00008 
00009 namespace Genfun {
00010 FUNCTION_OBJECT_IMP(CumulativeChiSquare)
00011 
00012 //---------------------------------------------------------------------------------//
00013 // Implementation notes:  The Cumulative Chi Square function is implemented in     //
00014 // terms of the incomplete gamma function.                                         //
00015 //---------------------------------------------------------------------------------//
00016 
00017 CumulativeChiSquare::CumulativeChiSquare(unsigned int ndf):
00018   _nDof(ndf)
00019 {
00020   create();
00021 }
00022 
00023 CumulativeChiSquare::~CumulativeChiSquare() {
00024   delete _function;
00025 }
00026 
00027 CumulativeChiSquare::CumulativeChiSquare(const CumulativeChiSquare & right):
00028 AbsFunction(right),
00029 _nDof(right._nDof)
00030 {
00031   create();
00032 }
00033 
00034 double CumulativeChiSquare::operator() (double x) const {
00035   return (*_function)(x);
00036 }
00037 
00038 unsigned int CumulativeChiSquare::nDof() const {
00039   return _nDof;
00040 }
00041 
00042 void CumulativeChiSquare::create() {
00043   Variable x;
00044   IncompleteGamma incompleteGamma;
00045   incompleteGamma.a().setValue(_nDof/2.0);
00046   _function = (incompleteGamma(x/2.0)).clone();
00047 } 
00048 } // namespace Genfun

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7