28 #include "marley/Error.hh"
29 #include "marley/NeutrinoSource.hh"
31 namespace marley_root {
40 template<
typename T> T* get_root_object(
const std::string& tfile_name,
41 const std::string& namecycle);
43 std::unique_ptr<marley::GridNeutrinoSource>
44 make_root_neutrino_source(
int pdg_code,
const TH1* th1);
46 std::unique_ptr<marley::GridNeutrinoSource>
47 make_root_neutrino_source(
int pdg_code,
const TGraph* tgraph);
50 template<
typename T> T*
51 marley_root::get_root_object(
const std::string& tfile_name,
52 const std::string& namecycle)
57 std::unique_ptr<TFile> file(TFile::Open(tfile_name.c_str(),
63 T* obj =
dynamic_cast<T*
>(file->Get(namecycle.c_str()));
71 TH1* th1_test =
dynamic_cast<TH1*
>(obj);
72 if (th1_test) th1_test->SetDirectory(
nullptr);
74 return dynamic_cast<T*
>(obj);
78 else throw marley::Error(std::string(
"Failed to open") +
" ROOT file '"
Base class for all exceptions thrown by MARLEY functions.
Definition: Error.hh:32