10#include "TProfile2D.h"
20 const std::string& histoPath)
26 SmartIF<IProperty> hs{histSvc.get()};
27 if (hs && hs->hasProperty(
"IncludeName")) {
28 m_deleteOnRemove = false;
31 size_t whereToStart = 0;
33 if (! histoPath.empty() && histoPath[0] ==
'/') {
36 size_t split = histoPath.find(
'/', whereToStart);
41 TClass::GetClass(
"TH1F");
42 TClass::GetClass(
"TH1D");
43 TClass::GetClass(
"TH1C");
44 TClass::GetClass(
"TH1S");
45 TClass::GetClass(
"TH1I");
46 TClass::GetClass(
"TH2F");
47 TClass::GetClass(
"TH2D");
48 TClass::GetClass(
"TH2C");
49 TClass::GetClass(
"TH2S");
50 TClass::GetClass(
"TH2I");
51 TClass::GetClass(
"TProfile");
52 TClass::GetClass(
"TProfile2D");
53 TClass::GetClass(
"TEfficiency");
54 TClass::GetClass(
"TTree");
62 if (def.
type ==
"TH1F") {
64 }
else if (def.
type ==
"TH1D") {
66 }
else if (def.
type ==
"TH1C") {
68 }
else if (def.
type ==
"TH1S") {
70 }
else if (def.
type ==
"TH1I") {
72 }
else if (def.
type ==
"TH2F") {
74 }
else if (def.
type ==
"TH2D") {
76 }
else if (def.
type ==
"TH2C") {
78 }
else if (def.
type ==
"TH2S") {
80 }
else if (def.
type ==
"TH2I") {
82 }
else if (def.
type ==
"TProfile") {
84 }
else if (def.
type ==
"TProfile2D") {
86 }
else if (def.
type ==
"TEfficiency") {
88 }
else if (def.
type ==
"TTree") {
94 "Try one of: TH1[F,D,C,S,I], TH2[F,D,C,S,I], TProfile, TProfile2D, " +
95 "TEfficiency, TTree.");
103 if ( def.
xarray.size()!=0 ) {
112 if (def.
xarray.size()!=0) {
126 }
else if (def.
yarray.size()!=0) {
129 }
else if (def.
xarray.size()!=0) {
143 }
else if (def.
yarray.size()!=0) {
146 }
else if (def.
xarray.size()!=0) {
160 TEfficiency* e =
nullptr;
161 if (
m_histSvc->existsEfficiency(fullName) ) {
162 if ( !
m_histSvc->getEfficiency(fullName,e) ) {
163 throw HistogramException(
"Histogram >"+ fullName +
"< seems to exist but can not be obtained from THistSvc");
173 if (def.
xarray.size()!=0) {
174 e =
new TEfficiency(def.
alias.c_str(), def.
title.c_str(),
177 e =
new TEfficiency(def.
alias.c_str(), def.
title.c_str(),
182 e =
new TEfficiency(def.
alias.c_str(), def.
title.c_str(),
185 e =
new TEfficiency(def.
alias.c_str(), def.
title.c_str(),
189 e =
new TEfficiency(def.
alias.c_str(), def.
title.c_str(),
192 throw HistogramException(
"Histogram >"+ fullName +
"< could not be defined. Check xbins, ybins, and zbins.");
196 if ( !
m_histSvc->regEfficiency(fullName, std::unique_ptr<TEfficiency>(e)) ) {
197 throw HistogramException(
"Histogram >"+ fullName +
"< can not be registered in THistSvc");
207template<
class H,
class HBASE,
typename... Types>
212 HBASE* histo =
nullptr;
214 if ( !
m_histSvc->getHist( fullName, histo ) ) {
215 throw HistogramException(
"Histogram >"+ fullName +
"< seems to exist but can not be obtained from THistSvc");
225 h =
new H(def.
alias.c_str(), def.
title.c_str(), std::forward<Types>(hargs)...);
228 if ( !
m_histSvc->regHist( fullName, std::unique_ptr<TH1>(
h) ) ) {
229 throw HistogramException(
"Histogram >"+ fullName +
"< can not be registered in THistSvc");
232 h->GetYaxis()->SetTitleOffset(1.25);
246 throw HistogramException(
"Tree >"+ fullName +
"< seems to exist but can not be obtained from THistSvc");
255 t =
new TTree(def.
alias.c_str(),def.
title.c_str());
258 if ( !
m_histSvc->regTree(fullName, std::unique_ptr<TTree>(t) ) ) {
267 const unsigned canExtendPolicy = def.
kCanRebin ? TH1::kAllAxes : TH1::kNoAxis;
268 hist->SetCanExtend(canExtendPolicy);
271 hist->Sumw2(def.
Sumw2);
281 if ( !labels.empty() ) {
282 const int nBin = axis->GetNbins();
284 axis->SetBinLabel(
bin+1, labels[
bin].c_str());
290 const static std::set<std::string> onlinePaths( {
"EXPERT",
"SHIFT",
"DEBUG",
"RUNSTAT",
"EXPRESS" } );
296 if ( onlinePaths.count( def.
path)!=0 ) {
298 }
else if ( def.
path==
"DEFAULT" ) {
305 std::string fullName = path +
"/" + def.
alias;
306 fullName.erase(
std::unique( fullName.begin(), fullName.end(),
307 [](
const char a,
const char b) {
308 return a == b and a ==
'/';
309 } ), fullName.end() );
317 TObject* obj =
nullptr;
318 if (def.
type==
"TEfficiency") {
320 m_histSvc->getEfficiency(path, e).ignore();
322 }
else if (def.
type==
"TGraph") {
326 }
else if (def.
type==
"TTree") {
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
static void setLabels(TH1 *hist, const HistogramDef &def)
Set labels for all axes.
std::string getFullName(const HistogramDef &def) const
Invent path name.
TEfficiency * createEfficiency(const HistogramDef &def)
Create and register efficiency graph.
bool m_deleteOnRemove
delete histogram during remove
virtual TNamed * create(const HistogramDef &def)
Book and register ROOT object for given definition.
static std::mutex & globalROOTMutex()
TTree * createTree(const HistogramDef &def)
Create and register tree.
TH2 * create2D(const HistogramDef &def)
Helper for generic 'create' method for 2D histograms.
ServiceHandle< ITHistSvc > m_histSvc
TH1 * create1DProfile(const HistogramDef &def)
Helper for generic 'create' method for 1DProfile histograms.
TH1 * create1D(const HistogramDef &def)
Helper for generic 'create' method for 1D histograms.
std::string m_groupName
defines location of group of histograms
std::string m_streamName
defines the stream for THistSvc
virtual void remove(const HistogramDef &def)
Removes histogram (used to get rid of old LB tagged histograms)
static void setOpts(TH1 *hist, const HistogramDef &def)
Setup various histogram options.
HistogramFactory(const ServiceHandle< ITHistSvc > &histSvc, const std::string &groupName)
Default constructor.
TH2 * create2DProfile(const HistogramDef &def)
Helper for generic 'create' method for 2DProfile histograms.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Generic monitoring tool for athena components.
DataModel_detail::iterator< DVL > unique(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of unique for DataVector/List.
the internal class used to keep parsed Filler properties
bool kCanRebin
allow all axes to be rebinned
int xbins
number of y bins
std::string type
class name
int zbins
number of z bins
std::string tld
top level directory (below THistSvc stream)
int ybins
number of y bins
std::vector< std::string > xlabels
labels for x axis
std::vector< double > xarray
array of x bin edges
std::vector< std::string > zlabels
labels for z axis
std::string path
booking path
std::vector< double > yarray
array of y bin edges
std::string title
title of the histogram
std::vector< std::string > ylabels
labels for y axis
std::string alias
unique alias for THistSvc
bool Sumw2
store sum of squares of weights
Represents error occurred during accessing histograms objects.