1 #ifndef BOOK_FOR_ROOT_HISTOGRAMS
2 #define BOOK_FOR_ROOT_HISTOGRAMS
7 #include "TDirectory.h"
13 #include <boost/regex.hpp>
14 #include <boost/iterator/filter_iterator.hpp>
20 typedef std::map<std::string, TH1*>
book_t;
45 if (!hist->GetSumw2N())
51 book_t::const_iterator it =
book_.find(name);
52 return it ==
book_.end() ?
nullptr : it->second;
55 typedef boost::filter_iterator<match_name, book_t::iterator>
iterator;
56 typedef boost::filter_iterator<match_name, book_t::const_iterator>
const_iterator;
59 return boost::make_filter_iterator(
match_name(re),
b,
e);
63 return boost::make_filter_iterator(
match_name(re),
b,
e);
66 book_t::iterator
e(
book_.end());
67 return boost::make_filter_iterator(
match_name(re),
e,
e);
70 book_t::const_iterator
e(
book_.end());
71 return boost::make_filter_iterator(
match_name(re),
e,
e);
81 return std::make_pair(
begin(re),
end(re));
85 book_t::iterator it =
book_.find(name);
86 if (it !=
book_.end()) {
93 book_.erase(it.base());
100 for (
auto const&
name : names) {
101 book_t::const_iterator current =
book_.find(
name);
102 if (current ==
book_.end())
105 current->second->Fill(X, W);
118 for (
auto const&
name : names) {
119 book_t::const_iterator current =
book_.find(
name);
120 if (current ==
book_.end())
123 static_cast<TProfile*
>(current->second)->
Fill(X, Y, W);
136 fill(X, Y,
std::string(name), NbinsX, Xlow, Xup, NbinsY, Ylow, Yup, W);
148 for (
auto const&
name : names) {
149 book_t::const_iterator current =
book_.find(
name);
150 if (current ==
book_.end())
151 static_cast<TH2*>(
book(
name,
new TH2D(
name.c_str(),
"",
NbinsX, Xlow, Xup, NbinsY, Ylow, Yup)))->
Fill(X, Y, W);
153 static_cast<TH2*
>(current->second)->
Fill(X, Y, W);
170 fill(X, Y, Z,
std::string(name), NbinsX, Xlow, Xup, NbinsY, Ylow, Yup, NbinsZ, Zlow, Zup);
186 for (
auto const&
name : names) {
187 book_t::const_iterator current =
book_.find(
name);
188 if (current ==
book_.end())
190 book(
name,
new TH3D(
name.c_str(),
"",
NbinsX, Xlow, Xup, NbinsY, Ylow, Yup, NbinsZ, Zlow, Zup)))
193 static_cast<TH3*
>(current->second)->
Fill(X, Y, Z, W);
const_iterator end(string_t re=".*") const
void fill(double_t X, const poly< std::string > &names, uint_t NbinsX, double_t Xlow, double_t Xup, double_t W=1)
const std::string names[nVars_]
const TH1 * operator[](string_t name) const
void fill(double_t X, double_t Y, double_t Z, const char *name, uint_t NbinsX, double_t Xlow, double_t Xup, uint_t NbinsY, double_t Ylow, double_t Yup, uint_t NbinsZ, double_t Zlow, double_t Zup, double_t W=1)
const std::string string_t
void fill(double_t X, double_t Y, const char *name, uint_t NbinsX, double_t Xlow, double_t Xup, uint_t NbinsY, double_t Ylow, double_t Yup, double_t W=1)
Container::value_type value_type
const_iterator begin(string_t re=".*") const
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void fill(double_t X, double_t Y, const char *name, uint_t NbinsX, double_t Xlow, double_t Xup, double_t W=1)
boost::filter_iterator< match_name, book_t::iterator > iterator
std::map< std::string, TH1 * > book_t
void fill(double_t X, double_t Y, const poly< std::string > &names, uint_t NbinsX, double_t Xlow, double_t Xup, uint_t NbinsY, double_t Ylow, double_t Yup, double_t W=1)
iterator begin(string_t re=".*")
void fill(double_t X, double_t Y, double_t Z, const poly< std::string > &names, uint_t NbinsX, double_t Xlow, double_t Xup, uint_t NbinsY, double_t Ylow, double_t Yup, uint_t NbinsZ, double_t Zlow, double_t Zup, double_t W=1)
TH1 *& operator[](string_t name)
void fill(double_t X, const char *name, uint_t NbinsX, double_t Xlow, double_t Xup, double_t W=1)
std::pair< iterator, iterator > filter_range(string_t re=".*")
void fill(double_t X, double_t Y, const poly< std::string > &names, uint_t NbinsX, double_t Xlow, double_t Xup, double_t W=1)
boost::filter_iterator< match_name, book_t::const_iterator > const_iterator
bool operator()(const book_t::const_iterator::value_type &p)
const unsigned long uint_t
iterator find(string_t name, string_t re=".*")
void erase(string_t name)
std::pair< const_iterator, const_iterator > filter_range(string_t re=".*") const
iterator end(string_t re=".*")
TH1 * book(string_t name, TH1 *const hist)
const_iterator find(string_t name, string_t re=".*") const