00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "RooFit.h"
00020
00021 #include "Riostream.h"
00022 #include "Riostream.h"
00023 #include <math.h>
00024 #include "TMath.h"
00025 #include "RooChiSquarePdf.h"
00026 #include "RooAbsReal.h"
00027 #include "RooRealVar.h"
00028
00029 ClassImp(RooChiSquarePdf)
00030 ;
00031
00032
00033
00034 RooChiSquarePdf::RooChiSquarePdf()
00035 {
00036 }
00037
00038
00039
00040 RooChiSquarePdf::RooChiSquarePdf(const char* name, const char* title,
00041 RooAbsReal& x, RooAbsReal& ndof):
00042 RooAbsPdf(name, title),
00043 _x("x", "Dependent", this, x),
00044 _ndof("ndof","ndof", this, ndof)
00045 {
00046 }
00047
00048
00049
00050
00051 RooChiSquarePdf::RooChiSquarePdf(const RooChiSquarePdf& other, const char* name) :
00052 RooAbsPdf(other, name),
00053 _x("x", this, other._x),
00054 _ndof("ndof",this,other._ndof)
00055 {
00056 }
00057
00058
00059
00060 Double_t RooChiSquarePdf::evaluate() const
00061 {
00062
00063 if(_x <= 0) return 0;
00064
00065 return pow(_x,(_ndof/2.)-1.) * exp(-_x/2.) / TMath::Gamma(_ndof/2.) / pow(2.,_ndof/2.);
00066
00067
00068 }
00069
00070
00071
00072 Int_t RooChiSquarePdf::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName) const
00073 {
00074
00075 if (rangeName && strlen(rangeName)) {
00076 return 0 ;
00077 }
00078
00079
00080 if (matchArgs(allVars, analVars, _x)) return 1;
00081 return 0;
00082 }
00083
00084
00085
00086 Double_t RooChiSquarePdf::analyticalIntegral(Int_t code, const char* rangeName) const
00087 {
00088 assert(code==1) ;
00089 Double_t xmin = _x.min(rangeName); Double_t xmax = _x.max(rangeName);
00090
00091
00092
00093
00094
00095
00096
00097 Double_t pmin = TMath::Gamma(_ndof/2,xmin/2);
00098 Double_t pmax = TMath::Gamma(_ndof/2,xmax/2);
00099
00100
00101 return pmax-pmin;
00102 }
00103