Skip to content
Merged
Prev Previous commit
Next Next commit
[RF] Start using new category interfaces in roofit/.
Make use of the fact that the new category interface also accepts
std::string.
  • Loading branch information
hageboeck committed May 5, 2020
commit ec5866587305d55f53102b8277d788fe94ec5537
2 changes: 1 addition & 1 deletion roofit/roofitcore/src/RooBinningCategory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ RooAbsCategory::value_type RooBinningCategory::evaluate() const
if (!hasIndex(ibin)) {
string name = (_bname.Length()>0) ? Form("%s_%s_bin%d",_inputVar.arg().GetName(),_bname.Data(),ibin)
: Form("%s_bin%d",_inputVar.arg().GetName(),ibin) ;
const_cast<RooBinningCategory*>(this)->defineState(name.c_str(),ibin);
const_cast<RooBinningCategory*>(this)->defineState(name,ibin);
}

return ibin;
Expand Down
8 changes: 4 additions & 4 deletions roofit/roofitcore/src/RooDataHist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,11 @@ void RooDataHist::importTH1Set(const RooArgList& vars, RooCategory& indexCat, ma
}
// Define state labels in index category (both in provided indexCat and in internal copy in dataset)
if (!indexCat.lookupType(hiter->first.c_str())) {
indexCat.defineType(hiter->first.c_str()) ;
indexCat.defineType(hiter->first) ;
coutI(InputArguments) << "RooDataHist::importTH1Set(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat.GetName() << endl ;
}
if (!icat->lookupType(hiter->first.c_str())) {
icat->defineType(hiter->first.c_str()) ;
icat->defineType(hiter->first) ;
}
}

Expand Down Expand Up @@ -544,11 +544,11 @@ void RooDataHist::importDHistSet(const RooArgList& /*vars*/, RooCategory& indexC

// Define state labels in index category (both in provided indexCat and in internal copy in dataset)
if (!indexCat.lookupType(diter->first.c_str())) {
indexCat.defineType(diter->first.c_str()) ;
indexCat.defineType(diter->first) ;
coutI(InputArguments) << "RooDataHist::importDHistSet(" << GetName() << ") defining state \"" << diter->first << "\" in index category " << indexCat.GetName() << endl ;
}
if (!icat->lookupType(diter->first.c_str())) {
icat->defineType(diter->first.c_str()) ;
icat->defineType(diter->first) ;
}
}

Expand Down
17 changes: 8 additions & 9 deletions roofit/roofitcore/src/RooDataSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ RooDataSet::RooDataSet(const char* name, const char* title, const RooArgSet& var
for (map<string,RooAbsData*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
// Define state labels in index category (both in provided indexCat and in internal copy in dataset)
if (indexCat && !indexCat->lookupType(hiter->first.c_str())) {
indexCat->defineType(hiter->first.c_str()) ;
indexCat->defineType(hiter->first) ;
coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
}
if (icat && !icat->lookupType(hiter->first.c_str())) {
icat->defineType(hiter->first.c_str()) ;
icat->defineType(hiter->first) ;
}
icat->setLabel(hiter->first.c_str()) ;
storeMap[icat->getCurrentLabel()]=hiter->second->store() ;
Expand Down Expand Up @@ -432,11 +432,11 @@ RooDataSet::RooDataSet(const char* name, const char* title, const RooArgSet& var
for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
// Define state labels in index category (both in provided indexCat and in internal copy in dataset)
if (!indexCat->lookupType(hiter->first.c_str())) {
indexCat->defineType(hiter->first.c_str()) ;
indexCat->defineType(hiter->first) ;
coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
}
if (!icat->lookupType(hiter->first.c_str())) {
icat->defineType(hiter->first.c_str()) ;
icat->defineType(hiter->first) ;
}
icat->setLabel(hiter->first.c_str()) ;

Expand Down Expand Up @@ -496,11 +496,11 @@ RooDataSet::RooDataSet(const char* name, const char* title, const RooArgSet& var
for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
// Define state labels in index category (both in provided indexCat and in internal copy in dataset)
if (!indexCat->lookupType(hiter->first.c_str())) {
indexCat->defineType(hiter->first.c_str()) ;
indexCat->defineType(hiter->first) ;
coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
}
if (!icat->lookupType(hiter->first.c_str())) {
icat->defineType(hiter->first.c_str()) ;
icat->defineType(hiter->first) ;
}
icat->setLabel(hiter->first.c_str()) ;
_dstore->loadValues(hiter->second->store(),cutVar,cutRange) ;
Expand Down Expand Up @@ -551,18 +551,17 @@ RooDataSet::RooDataSet(const char* name, const char* title, const RooArgSet& var
for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
// Define state labels in index category (both in provided indexCat and in internal copy in dataset)
if (!indexCat->lookupType(hiter->first.c_str())) {
indexCat->defineType(hiter->first.c_str()) ;
indexCat->defineType(hiter->first) ;
coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
}
if (!icat->lookupType(hiter->first.c_str())) {
icat->defineType(hiter->first.c_str()) ;
icat->defineType(hiter->first) ;
}
icat->setLabel(hiter->first.c_str()) ;
// Case 2c --- Import multiple RooDataSets as slices
_dstore->loadValues(hiter->second->store(),0,cutRange) ;
}


} else if (impData) {
// Case 3c --- Import RooDataSet
_dstore->loadValues(impData->store(),0,cutRange);
Expand Down