15#ifndef HGTD_ANALYSIS_ANALYSISALGBASE_H
16#define HGTD_ANALYSIS_ANALYSISALGBASE_H
21#include "GaudiKernel/ITHistSvc.h"
22#include "GaudiKernel/ServiceHandle.h"
25#include "TEfficiency.h"
43 this,
"DirectoryName",
"/HGTD_ANA/",
"The output directory name"};
53 template <
typename T = TH1F,
typename... Ts>
54 void bookSubdir(
const std::string& trk_sel_name,
const std::string& time_wp,
55 const std::string& hist_name,
const std::string& title,
59 const std::string name = trk_sel_name +
"/" + time_wp +
"/" + hist_name;
62 << name <<
", this is not a good idea");
65 auto * ptrT =
new T(hist_name.c_str(), title.c_str(), args...);
73 template <
typename T,
typename... Ts>
74 void book(
const std::string& name,
const std::string& title, Ts... args) {
79 << name <<
", this is not a good idea");
82 auto * ptrT =
new T(name.c_str(), title.c_str(), args...);
90 template <
typename... Ts>
92 const std::string& time_wp,
const std::string& hist_name,
93 const std::string& title, Ts... args) {
96 const std::string name = trk_sel_name +
"/" + time_wp +
"/" + hist_name;
99 << name <<
", this is not a good idea");
102 auto * ptrT =
new TEfficiency(hist_name.c_str(), title.c_str(), args...);
109 template <
typename... Ts>
110 void bookEff(
const std::string& name,
const std::string& title, Ts... args) {
115 << name <<
", this is not a good idea");
118 auto * ptrT =
new TEfficiency(name.c_str(), title.c_str(), args...);
129 template <
typename T,
typename... Ts>
130 void fill(std::string_view name, Ts... args) {
132 if (it ==
m_histos.end() or it->second ==
nullptr) {
134 "[HistogramHandler::fill] ERROR: you are attempting to fill "
135 "a histogram with name "
136 << name <<
" which doesn't exist!");
139 auto * ptrT =
dynamic_cast<T*
>(it->second);
147 template <
typename T,
typename... Ts>
148 void fillSubdir(std::string_view trk_sel_name, std::string_view time_wp,
149 std::string_view hist_name, Ts... args) {
150 const std::string name = std::format(
"{}/{}/{}", trk_sel_name, time_wp, hist_name);
152 if (it ==
m_histos.end() or it->second ==
nullptr) {
154 "[HistogramHandler::fill] ERROR: you are attempting to fill "
155 "a histogram with name "
156 << name <<
" which doesn't exist!");
159 auto * ptrT =
dynamic_cast<T*
>(it->second);
167 template <
typename... Ts>
168 void fillEff(std::string_view name, Ts... args) {
169 const auto it =
m_histos.find(name);
172 "[HistogramHandler::fillEff] ERROR: you are attempting to fill "
173 "a histogram with name "
174 << name <<
" which doesn't exist!");
177 auto * ptrT =
dynamic_cast<TEfficiency*
>(it->second);
185 template <
typename... Ts>
187 std::string_view wp_name, std::string_view hist_name,
189 const std::string name = std::format(
"{}/{}/{}", trk_sel_name, wp_name, hist_name);
191 if (it ==
m_histos.end() or it->second ==
nullptr) {
193 "[HistogramHandler::fill] ERROR: you are attempting to fill "
194 "a histogram with name "
195 << name <<
" which doesn't exist!");
198 auto * ptrT =
dynamic_cast<TEfficiency*
>(it->second);
210 std::map<std::string, TObject*, std::less<>>
m_histos;
#define ATH_MSG_WARNING(x,...)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Property< std::string > m_directory_name
void bookSubdir(const std::string &trk_sel_name, const std::string &time_wp, const std::string &hist_name, const std::string &title, Ts... args)
Templated function for booking histograms The type of the histogram is passed as a template parameter...
void bookEff(const std::string &name, const std::string &title, Ts... args)
virtual ~HGTD_AnalysisAlgBase()
void fill(std::string_view name, Ts... args)
Templated function for filling histograms The type of the histogram is passed as a template parameter...
std::map< std::string, TObject *, std::less<> > m_histos
virtual StatusCode initialize()
HGTD_AnalysisAlgBase(const std::string &name, ISvcLocator *svc_locator)
void bookEffSubdir(const std::string &trk_sel_name, const std::string &time_wp, const std::string &hist_name, const std::string &title, Ts... args)
ServiceHandle< ITHistSvc > m_hist_svc
void fillEff(std::string_view name, Ts... args)
void fillEffSubDir(std::string_view trk_sel_name, std::string_view wp_name, std::string_view hist_name, Ts... args)
void book(const std::string &name, const std::string &title, Ts... args)
void fillSubdir(std::string_view trk_sel_name, std::string_view time_wp, std::string_view hist_name, Ts... args)