rarBinned.cc

Go to the documentation of this file.
00001 /*****************************************************************************
00002 * Project: BaBar detector at the SLAC PEP-II B-factory
00003 * Package: RooRarFit
00004  *    File: $Id: rarBinned.cc,v 1.4 2011/06/16 13:18:49 fwilson Exp $
00005  * Authors: Lei Zhang
00006  * History:
00007  * 
00008  * Copyright (C) 2005-2012, University of California, Riverside
00009  *****************************************************************************/
00010 
00011 // -- CLASS DESCRIPTION [RooRarFit] --
00012 // This class provides Binned Pdf class for RooRarFit
00014 //
00015 // BEGIN_HTML
00016 // This class provides Binned Pdf class for RooRarFit
00017 // END_HTML
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   // first get its dependent/observable
00085   _x=createAbsReal("x", "observable"); assert(_x);
00086   RooRealVar *x=(RooRealVar *)RooArgList(_obsSet).at(0); assert(x);
00087   // Config pdf params
00088   _nBins=atoi(readConfStr("nBins", "0", getVarSec()));
00089   if (_nBins<=0) _nBins= // from plotBins
00090     atoi(readConfStr(Form("plotBins_%s", x->GetName()),"0", getVarSec()));
00091   if (_nBins<=0) _nBins=x->getBins(); // get bins from its obs
00092   _limits= new TArrayD(_nBins+1);
00093   // read in limit info
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 { // set equal interval
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   // set lo and hi limits
00108   //(*_limits)[0]=x->getMin();
00109   //(*_limits)[_nBins]=x->getMax();
00110   // read in coeffs
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   // create pdf
00118   _thePdf=
00119     new RooBinnedPdf(Form("the_%s", GetName()),
00120                      _pdfType+" "+GetTitle(),
00121                      *_x, _coeffs, *_limits);
00122 }

Generated on 30 Oct 2013 for RooRarFit by  doxygen 1.4.7