rarSimPdf.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: rarSimPdf.cc,v 1.17 2011/06/16 13:18:50 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 Simultaneous Pdf class for RooRarFit
00014 //
00015 // BEGIN_HTML
00016 // This class provides Simultaneous Pdf class for RooRarFit
00017 // END_HTML
00018 //
00019 
00020 #include "RooRarFit/rarVersion.hh"
00021 
00022 #include "Riostream.h"
00023 //#include <sstream>
00024 
00025 #include "RooFitCore/RooAbsPdf.hh"
00026 #include "RooFitCore/RooArgList.hh"
00027 #include "RooFitCore/RooDataSet.hh"
00028 #include "RooFitCore/RooFitResult.hh"
00029 #include "RooFitCore/RooProdPdf.hh"
00030 #include "RooFitCore/RooRealVar.hh"
00031 #include "RooFitCore/RooSimPdfBuilder.hh"
00032 #include "RooFitCore/RooStringVar.hh"
00033 
00034 #include "RooRarFit/rarMLFitter.hh"
00035 #include "RooRarFit/rarSimPdf.hh"
00036 
00037 ClassImp(rarSimPdf)
00038   ;
00039 
00043 rarSimPdf::rarSimPdf()
00044   : rarCompBase(),
00045     _simBuilder(0), _simConfig(0)
00046 {
00047   init();
00048 }
00049 
00063 rarSimPdf::rarSimPdf(const char *configFile, const char *configSec,
00064                      const char *configStr,
00065                      rarDatasets *theDatasets, RooDataSet *theData,
00066                      const char *name, const char *title)
00067   : rarCompBase(configFile, configSec, configStr,
00068                 theDatasets, theData, name, title, kFALSE),
00069     _simBuilder(0), _simConfig(0)
00070 {
00071   init();
00072 }
00073 
00074 rarSimPdf::~rarSimPdf()
00075 {
00076 }
00077 
00087 void rarSimPdf::init()
00088 {
00089   // it should always have fitData
00090   if (!_theData) {
00091     cout<<" No dataset for Sim Pdf"<<endl;
00092     exit(-1);
00093   }
00094   // create SimPdfBuilder
00095   _simBuilder=new RooSimPdfBuilder(_subPdfs);
00096   _simConfig=_simBuilder->createProtoBuildConfig();
00097   _simConfig->readFromFile(_configFile, 0, getVarSec());
00098   cout<<"simPdfBuilder configs in the config file:"<<endl;
00099   _simConfig->Print("v");
00100   // do we need to use _simBuilder->addSpecializations?
00101   // Yes, let's do it
00102   if (getFitter()->getSimBuilder()) {
00103     RooSimPdfBuilder *theFitterBuilder=getFitter()->getSimBuilder();
00104     _simBuilder->addSpecializations(theFitterBuilder->splitLeafList());
00105   }
00106   // build SimPdf
00107   _thePdf=(RooAbsPdf*)_simBuilder->buildPdf(*_simConfig, _theData, 0, kTRUE);
00108   _thePdf->SetName(Form("the_%s", GetName()));
00109   // fit the total pdf for pdfFit as well
00110   setControlBits("UseAlsoBasePdfFit");
00111   
00112   //_thePdf->Print();
00113   //_thePdf->Print("v");
00114   //_thePdf->getComponents()->Print("v");
00115   cout<<"done init of rarSimPdf for "<<GetName()<<endl<<endl;
00116 }
00117 
00125 RooAbsPdf *rarSimPdf::getPdfWOvar(RooArgList ignoredObs)
00126 {
00127   RooAbsPdf *thePdf=_thePdf;
00128   cout<<"This pdf can not be used in model"<<endl;
00129   exit(-1);
00130   ignoredObs.getHashTableSize() ; // avoid "unused" warning
00131   return thePdf;
00132 }
00133 
00138 RooAbsPdf *rarSimPdf::getProtGen()
00139 {
00140   cout<<"This pdf can not be used in model"<<endl;
00141   exit(-1);
00142   return _theProtGen;
00143 }

Generated on 30 Oct 2013 for RooRarFit by  doxygen 1.4.7