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/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
00077 _createFundamental=kTRUE;
00078 _fullNameSchema="self";
00079
00080
00081 _fullObs=new RooArgSet("theFullObs");
00082 _primaryObs=new RooArgSet("thePrimaryObs");
00083 _addonCols=new RooArgSet("theAddOnCols");
00084
00085
00086 createAbsVars("Fields", _fullObs, _primaryObs);
00087
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
00095 createAbsVars("AddOns", _fullObs, _addonCols);
00096
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]);
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 {
00134 RooRealVar *theVar=dynamic_cast<RooRealVar*>(theArg);
00135 if (theVar) {
00136 theVar->setVal(val);
00137 return;
00138 }
00139 }
00140 {
00141 RooCategory *theVar=dynamic_cast<RooCategory*>(theArg);
00142 if (theVar) {
00143 theVar->setIndex((Int_t)val);
00144 return;
00145 }
00146 }
00147 {
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 {
00170 RooStringVar *theVar=dynamic_cast<RooStringVar*>(theArg);
00171 if (theVar) {
00172 theVar->setVal(val);
00173 return;
00174 }
00175 }
00176 {
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 }