00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00015
00016
00017
00018
00019
00020 #include "RooRarFit/rarVersion.hh"
00021
00022 #include "Riostream.h"
00023
00024 #include "RooFitCore/RooArgList.hh"
00025 #include "RooFitCore/RooDataSet.hh"
00026 #include "RooFitCore/RooProdPdf.hh"
00027 #include "RooFitCore/RooRealVar.hh"
00028 #include "RooFitCore/RooStringVar.hh"
00029
00030 #include "RooRarFit/RooBinnedPdf.hh"
00031
00032 #include "RooRarFit/rarBinned.hh"
00033
00034 ClassImp(rarBinned)
00035 ;
00036
00040 rarBinned::rarBinned()
00041 : rarBasePdf(),
00042 _x(0), _nBins(0), _limits(0)
00043 {
00044 init();
00045 }
00046
00059 rarBinned::rarBinned(const char *configFile, const char *configSec,
00060 const char *configStr, rarDatasets *theDatasets,
00061 RooDataSet *theData, const char *name, const char *title)
00062 : rarBasePdf(configFile, configSec, configStr,
00063 theDatasets, theData, name, title),
00064 _x(0), _nBins(0), _limits(0)
00065 {
00066 init();
00067 }
00068
00069 rarBinned::~rarBinned()
00070 {
00071 }
00072
00080 void rarBinned::init()
00081 {
00082 cout<<"init of rarBinned for "<<GetName()<<":"<<endl;
00083
00084
00085 _x=createAbsReal("x", "observable"); assert(_x);
00086 RooRealVar *x=(RooRealVar *)RooArgList(_obsSet).at(0); assert(x);
00087
00088 _nBins=atoi(readConfStr("nBins", "0", getVarSec()));
00089 if (_nBins<=0) _nBins=
00090 atoi(readConfStr(Form("plotBins_%s", x->GetName()),"0", getVarSec()));
00091 if (_nBins<=0) _nBins=x->getBins();
00092 _limits= new TArrayD(_nBins+1);
00093
00094 TString limitStr=readConfStr("limits", "", getVarSec());
00095 rarStrParser limitStrParser=limitStr;
00096 Int_t nLimits=limitStrParser.nArgs();
00097 if (_nBins+1==nLimits) {
00098 for (Int_t i=0; i<_nBins+1; i++) {
00099 (*_limits)[i]=atof(limitStrParser[i]);
00100 }
00101 } else {
00102 Double_t binned=(x->getMax() - x->getMin())/_nBins;
00103 for (Int_t i=0; i<_nBins+1; i++) {
00104 (*_limits)[i]=x->getMin()+i*binned;
00105 }
00106 }
00107
00108
00109
00110
00111 for (Int_t i=0; i<_nBins-1; i++) {
00112 RooAbsReal *H=createAbsReal(Form("H%02d",i),Form("h_{%d}", i),.1,0,1000);
00113 _coeffs.add(*H);
00114 }
00115 _params.Print("v");
00116
00117
00118 _thePdf=
00119 new RooBinnedPdf(Form("the_%s", GetName()),
00120 _pdfType+" "+GetTitle(),
00121 *_x, _coeffs, *_limits);
00122 }