Skip to content
Merged
Prev Previous commit
Next Next commit
[RF] Add GlobalObservables cmd arg to RooDataSet/Hist constructors
This is to conveniently define the global observables stored in the
`RooDataSet` or `RooDataHist` in the constructor.
  • Loading branch information
guitargeek committed Sep 14, 2021
commit 2a21c38ac996c6f99163fbcf6fa07baf96a9d643
6 changes: 6 additions & 0 deletions roofit/roofitcore/src/RooDataHist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ RooDataHist::RooDataHist(std::string_view name, std::string_view title, const Ro
/// category it will be added on the fly. The import command can be specified
/// multiple times.
/// <tr><td> Import(map<string,TH1*>&) <td> As above, but allows specification of many imports in a single operation
/// <tr><td> `GlobalObservables(const RooArgSet&)` <td> Define the set of global observables to be stored in this RooDataHist.
/// A snapshot of the passed RooArgSet is stored, meaning the values wont't change unexpectedly.
/// </table>
///

RooDataHist::RooDataHist(std::string_view name, std::string_view title, const RooArgList& vars, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3,
Expand All @@ -292,6 +295,7 @@ RooDataHist::RooDataHist(std::string_view name, std::string_view title, const Ro
pc.defineDouble("weight","Weight",0,1) ;
pc.defineObject("dummy1","ImportDataHistSliceMany",0) ;
pc.defineObject("dummy2","ImportHistoSliceMany",0) ;
pc.defineSet("glObs","GlobalObservables",0,0) ;
pc.defineMutex("ImportHisto","ImportHistoSlice","ImportDataHistSlice") ;
pc.defineDependency("ImportHistoSlice","IndexCat") ;
pc.defineDependency("ImportDataHistSlice","IndexCat") ;
Expand All @@ -309,6 +313,8 @@ RooDataHist::RooDataHist(std::string_view name, std::string_view title, const Ro
return ;
}

if(pc.getSet("glObs")) setGlobalObservables(*pc.getSet("glObs"));

TH1* impHist = static_cast<TH1*>(pc.getObject("impHist")) ;
Bool_t impDens = pc.getInt("impDens") ;
Double_t initWgt = pc.getDouble("weight") ;
Expand Down
5 changes: 5 additions & 0 deletions roofit/roofitcore/src/RooDataSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ RooDataSet::RooDataSet() : _wgtVar(0)
/// <td> Interpret the given variable as event weight rather than as observable
/// <tr><td> StoreError(const RooArgSet&) <td> Store symmetric error along with value for given subset of observables
/// <tr><td> StoreAsymError(const RooArgSet&) <td> Store asymmetric error along with value for given subset of observables
/// <tr><td> `GlobalObservables(const RooArgSet&)` <td> Define the set of global observables to be stored in this RooDataSet.
/// A snapshot of the passed RooArgSet is stored, meaning the values wont't change unexpectedly.
/// </table>
///

Expand Down Expand Up @@ -245,6 +247,7 @@ RooDataSet::RooDataSet(std::string_view name, std::string_view title, const RooA
pc.defineObject("dummy2","LinkDataSliceMany",0) ;
pc.defineSet("errorSet","StoreError",0) ;
pc.defineSet("asymErrSet","StoreAsymError",0) ;
pc.defineSet("glObs","GlobalObservables",0,0) ;
pc.defineMutex("ImportTree","ImportData","ImportDataSlice","LinkDataSlice","ImportFromFile") ;
pc.defineMutex("CutSpec","CutVar") ;
pc.defineMutex("WeightVarName","WeightVar") ;
Expand All @@ -266,6 +269,8 @@ RooDataSet::RooDataSet(std::string_view name, std::string_view title, const RooA
return ;
}

if(pc.getSet("glObs")) setGlobalObservables(*pc.getSet("glObs"));

// Extract relevant objects
TTree* impTree = static_cast<TTree*>(pc.getObject("impTree")) ;
RooDataSet* impData = static_cast<RooDataSet*>(pc.getObject("impData")) ;
Expand Down