rarProd.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: rarProd.cc,v 1.13 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 ProdPdf class for RooRarFit
00014 //
00015 // BEGIN_HTML
00016 // This class provides ProdPdf 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 #include "RooFitCore/RooGlobalFunc.hh"
00030 using namespace RooFit;
00031 
00032 #include "RooRarFit/rarProd.hh"
00033 
00034 ClassImp(rarProd)
00035   ;
00036 
00040 rarProd::rarProd()
00041   : rarCompBase()
00042 {
00043   init();
00044 }
00045 
00058 rarProd::rarProd(const char *configFile, const char *configSec,
00059                  const char *configStr,
00060                  rarDatasets *theDatasets, RooDataSet *theData,
00061                  const char *name, const char *title)
00062   : rarCompBase(configFile, configSec, configStr,
00063                 theDatasets, theData, name, title, kFALSE)
00064 {
00065   init();
00066 }
00067 
00068 rarProd::~rarProd()
00069 {
00070 }
00071 
00078 void rarProd::init()
00079 {
00080   // Config pdfs done by parent Pdf
00081   // list configed pdfs done by parent pdf
00082   
00083   // set control bits
00084   setControlBit("noUseBasePdfFit", "ndFit");
00085   
00086   // list of cmd
00087   RooLinkedList cmdList;
00088 
00089   // do we have conditional obseervables?
00090   RooArgSet condObsSet(getArgSet(readConfStr("CondObss",""),kFALSE));
00091   // do we have conditional Pdf ?
00092   rarStrParser condPdfsStr=readConfStr("CondPdfs","");
00093   while (condPdfsStr.nArgs()>0) {
00094     rarBasePdf *condPdf=(rarBasePdf*)_pdfList.FindObject(condPdfsStr[0]);
00095     condPdfsStr.Remove();
00096     if (condPdf) {
00097       _condPdfList.Add(condPdf);
00098       _condPdfs.add(*condPdf->getPdf());
00099       // now set CondObss to this pdf
00100       //RooArgSet *thisPdfSet=new RooArgSet;
00101       //thisPdfSet->add(*condPdf->getPdf());
00102       RooArgSet *thisPdfSet=new RooArgSet(*condPdf->getPdf());
00103       RooArgSet *thisCondObsSet=new RooArgSet(condObsSet);
00104       thisCondObsSet->
00105         add(getArgSet(readConfStr
00106                       (Form("CondObss_%s",condPdf->GetName()),""),kFALSE));
00107       condPdf->setCondObss(*thisCondObsSet);
00108       cmdList.Add(Conditional(*thisPdfSet,*thisCondObsSet).Clone());
00109       cout<<" "<<condPdf->GetName()<<" is conditional PDF"<<endl;
00110       cout<<" The normalization of this PDF is on "<<endl;
00111       thisCondObsSet->Print();
00112     }
00113   }
00114   // Pdfs without conditional
00115   RooArgList subPdfs(_subPdfs);
00116   subPdfs.remove(_condPdfs);
00117   if (_condPdfs.getSize()>0) {
00118     // do not use ndFit by default
00119     //setControlBit("UseBasePdfFit", "ndFit");
00120     // cout...
00121     cout<<"The following PDFs are conditional PDFs:"<<endl;
00122     _condPdfs.Print();
00123     cout<<endl;
00124     //cout<<"The normalization of those PDFs are on observables:"<<endl;
00125     //condObsSet.Print();
00126     //cout<<endl;
00127     cout<<"The remaining PDFs in the production are:"<<endl;
00128     subPdfs.Print();
00129     cout<<endl;
00130   }
00131   
00132   // build ProdPdf
00133   //cmdList.Print("v");
00134   _thePdf=new RooProdPdf(Form("the_%s", GetName()), _pdfType+" "+GetTitle(),
00135                          subPdfs, cmdList);
00136   
00137   cout<<"done init of rarProd for "<<GetName()<<endl<<endl;
00138 }
00139 
00147 RooAbsPdf *rarProd::getPdfWOvar(RooArgList ignoredObs)
00148 {
00149   RooAbsPdf *thePdf=_thePdf;
00150   // check if thePdf depends on theVar
00151   if (!(thePdf->dependsOn(ignoredObs))) return thePdf;
00152   // create individual Pdf
00153   TString theName=Form("the_%s_%s", ignoredObs[0].GetName(), GetName());
00154   TString theTitle=Form("%s w/o %s", GetTitle(), ignoredObs[0].GetName());
00155   RooArgList myPdfList=getPdfsWOvar(ignoredObs);
00156   thePdf=new RooProdPdf(theName, theTitle, myPdfList);
00157   //thePdf->Print("v");
00158   //thePdf->Print();
00159   if (!(thePdf->dependsOn(ignoredObs))) return thePdf;
00160   delete thePdf;
00161   // create a dummy for it
00162   thePdf=new RooGenericPdf(theName, theTitle, "1",
00163                            *_thePdf->getParameters(_fullObs));
00164   //thePdf->Print("v");
00165   //thePdf->Print();
00166   return thePdf;
00167 }
00168 
00175 RooAbsPdf *rarProd::getDPdfWvar(RooRealVar *theVar)
00176 {
00177   RooAbsPdf *retVal(0);
00178   for (Int_t i=0; i<_nComp; i++) {
00179     rarBasePdf *thePdf=(rarBasePdf*)_pdfList.At(i);
00180     retVal=thePdf->getDPdfWvar(theVar);
00181     if (retVal) return retVal;
00182   }
00183   return retVal;
00184 }
00185 
00190 RooAbsPdf *rarProd::getProtGen()
00191 {
00192   if (_theProtGen) return _theProtGen;
00193   // call super class' getProtGen
00194   rarCompBase::getProtGen();
00195   _theProtGen=_myDummyPdf;
00196   RooArgList pdfList(_protGenPdfs);
00197   if (!getControlBit("dummySubGenPdfs")) pdfList.add(_subProtGenPdfs);
00198   else pdfList.add(*_theProtGen);
00199   if ((pdfList.getSize()>1)||(!getControlBit("dummySubGenPdfs")))
00200     _theProtGen = new RooProdPdf (Form("protGen_%s",GetName()),
00201                                   Form("Prot Gen for %s", GetName()), pdfList);
00202   
00203   return _theProtGen;
00204 }

Generated on 30 Oct 2013 for RooRarFit by  doxygen 1.4.7