rarDatasetDef.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: rarDatasetDef.cc,v 1.13 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 dataset definition class for RooRarFit
00014 //
00015 // BEGIN_HTML
00016 // This class provides dataset definition 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/RooArgSet.hh"
00026 #include "RooFitCore/RooCategory.hh"
00027 #include "RooFitCore/RooRealVar.hh"
00028 #include "RooFitCore/RooStringVar.hh"
00029 
00030 #include "RooRarFit/rarDatasetDef.hh"
00031 
00032 ClassImp(rarDatasetDef)
00033   ;
00034 
00038 rarDatasetDef::rarDatasetDef()
00039   : rarConfig(),
00040     _primaryObs(0), _addonCols(0)
00041 {
00042   init();
00043 }
00044 
00054 rarDatasetDef::rarDatasetDef(const char *configFile, const char *configSec)
00055   : rarConfig(configFile, configSec, "null", "DatasetDef", "Dataset Def"),
00056     _primaryObs(0), _addonCols(0)
00057 {
00058   init();
00059 }
00060 
00061 rarDatasetDef::~rarDatasetDef()
00062 {
00063 }
00064 
00073 void rarDatasetDef::init()
00074 {
00075   cout<<"init of rarDatasetDef:"<<endl;
00076   // first set #_createFundamental and #_fullNameSchema
00077   _createFundamental=kTRUE;
00078   _fullNameSchema="self";
00079   
00080   // create the full, primary, and addon obs sets.
00081   _fullObs=new RooArgSet("theFullObs");
00082   _primaryObs=new RooArgSet("thePrimaryObs");
00083   _addonCols=new RooArgSet("theAddOnCols");
00084   
00085   // read in field info
00086   createAbsVars("Fields", _fullObs, _primaryObs);
00087   // check number of fields
00088   Int_t nField=_primaryObs->getSize();
00089   if (nField<=0) {
00090     cout<<"no fields defined in RooStringVar \"Fields\" in section \""
00091         <<_configSec<<"\""<<endl;
00092     exit(-1);
00093   }
00094   // now for addon cols
00095   createAbsVars("AddOns", _fullObs, _addonCols);
00096   // print cout full obs
00097   _fullObs->Print("v");
00098   cout<<endl;
00099 }
00100 
00111 RooArgList *rarDatasetDef::getFormulaArgs(rarStrParser fStrParser)
00112 {
00113   RooArgList *depList=new RooArgList;
00114   Int_t nArgs=fStrParser.nArgs();
00115   if (nArgs<=0) return depList;
00116   for (Int_t i=0; i<nArgs; i++) {
00117     if (isNumber(fStrParser[i])) break;
00118     RooAbsArg *theDep=createAbsReal(fStrParser[i], fStrParser[i]); // create it
00119     depList->add(*theDep);
00120   }
00121   
00122   return depList;
00123 }
00124 
00130 void rarDatasetDef::setVal(TString var, Double_t val)
00131 {
00132   RooAbsArg *theArg=_primaryObs->find(var);
00133   { // RooRealVar
00134     RooRealVar *theVar=dynamic_cast<RooRealVar*>(theArg);
00135     if (theVar) {
00136       theVar->setVal(val);
00137       return;
00138     }
00139   }
00140   { // RooCategory
00141     RooCategory *theVar=dynamic_cast<RooCategory*>(theArg);
00142     if (theVar) {
00143       theVar->setIndex((Int_t)val);
00144       return;
00145     }
00146   }
00147   { // RooStringVar
00148     RooStringVar *theVar=dynamic_cast<RooStringVar*>(theArg);
00149     if (theVar) {
00150       theVar->setVal(Form("%8x", (UInt_t) val));
00151       return;
00152     }
00153   }
00154   
00155   static Int_t counter(0);
00156   counter++;
00157   if (counter<100)
00158     cout<<"Can not find "<<var<<endl;
00159 }
00160 
00166 void rarDatasetDef::setVal(TString var, TString val)
00167 {
00168   RooAbsArg *theArg=_primaryObs->find(var);
00169   { // RooStringVar
00170     RooStringVar *theVar=dynamic_cast<RooStringVar*>(theArg);
00171     if (theVar) {
00172       theVar->setVal(val);
00173       return;
00174     }
00175   }
00176   { // RooCategory
00177     RooCategory *theVar=dynamic_cast<RooCategory*>(theArg);
00178     if (theVar) {
00179       theVar->setLabel(val);
00180       return;
00181     }
00182   }
00183   
00184   static Int_t counter(0);
00185   counter++;
00186   if (counter<100)
00187     cout<<"Can not find "<<var<<endl;
00188 }

Generated on 30 Oct 2013 for RooRarFit by  doxygen 1.4.7