diff --git a/src/THcParmList.cxx b/src/THcParmList.cxx index 4e0a781d68cea0f047bc20560ad5de2099be718a..7f34246627ae0899878fe2bbddf8dc23d74d5093 100644 --- a/src/THcParmList.cxx +++ b/src/THcParmList.cxx @@ -693,6 +693,7 @@ std::string THcParmList::PrintJSON(int run_number ) const { obj->Print(); } } + nlohmann::json jrun; jrun[std::to_string(run_number)] = j; //std::cout << j.dump(2) << "\n"; diff --git a/src/THcParmList.h b/src/THcParmList.h index 35490d33244a58ae90f4987a977fa2c9e880bd99..38b192a1c61050f35d6f6e0db8a23255ef203f26 100644 --- a/src/THcParmList.h +++ b/src/THcParmList.h @@ -23,7 +23,6 @@ using namespace ccdb; using namespace std; - class THcParmList : public THaVarList { public: @@ -77,5 +76,23 @@ protected: ClassDef(THcParmList,0) // List of analyzer global parameters }; + + +namespace hcana{ + namespace json { + + template<typename T = double> + T FindVarValueOr(THcParmList* parms, std::string var, T value){ + auto p = parms->Find(var.c_str()); + if(!p) { + return value; + } + const auto res = static_cast<const T*>(p->GetDataPointer()); + return *res; + } + + } +} + #endif