10 #ifndef ANALYSIS_TOOLS_ROOFITUTILS_H_ 11 #define ANALYSIS_TOOLS_ROOFITUTILS_H_ 17 #include "RooWorkspace.h" 18 #include "RooRealVar.h" 19 #include "RooAbsPdf.h" 20 #include "RooFormulaVar.h" 21 #include "RooDataSet.h" 22 #include "RooAbsData.h" 32 template<typename T, typename std::enable_if< std::is_base_of<RooCurve, T>::value ||
33 std::is_base_of<RooHist, T>::value,
T >
::type* =
nullptr>
38 T* foo =
static_cast<T*
>(frame.findObject(object_name.c_str(),T::Class()));
39 if(!foo)
throw std::invalid_argument(
"Invalid Object name: " + object_name);
48 T *var =
static_cast<T*
>(w.obj(name.c_str()));
49 if(!var)
throw std::invalid_argument(
"Invalid TObject name: " + name);
54 template<
typename T>
T*
GetRooObjectFromTFile( TFile& file,
const std::string& obj_name,
const std::string& workspace_name =
"workspace"){
58 auto &workspace = *GetFromTFile<RooWorkspace>(file, workspace_name);
59 auto *obj = GetFromRooWorkspace<T>(workspace,obj_name);
63 template<
typename T>
T*
GetRooObjectFromTFile(
const std::string& file_name,
const std::string& obj_name,
const std::string& workspace_name =
"workspace"){
67 auto &workspace = *GetFromTFile<RooWorkspace>(file_name, workspace_name);
68 auto *obj = GetFromRooWorkspace<T>(workspace,obj_name);