|
ATLAS Offline Software
|
Go to the documentation of this file.
11 #ifndef ATHENABASECOMPS_ATHHISTOGRAMMING_H
12 #define ATHENABASECOMPS_ATHHISTOGRAMMING_H 1
19 #include "GaudiKernel/ServiceHandle.h"
20 #include "GaudiKernel/ITHistSvc.h"
23 #include "GaudiKernel/MsgStream.h"
29 #include "TEfficiency.h"
70 const std::string&
prefix,
const std::string& rootDir,
71 const std::string& histNamePrefix,
const std::string& histNamePostfix,
72 const std::string& histTitlePrefix,
const std::string& histTitlePostfix );
95 inline StatusCode book( TH1& histRef,
const std::string& tDir=
"",
const std::string&
stream=
"" );
99 TH1*
hist(
const std::string&
histName,
const std::string& tDir=
"",
const std::string&
stream=
"" );
102 inline TH2*
hist2d(
const std::string&
histName,
const std::string& tDir=
"",
const std::string&
stream=
"" );
105 inline TH3*
hist3d(
const std::string&
histName,
const std::string& tDir=
"",
const std::string&
stream=
"" );
116 inline StatusCode book(
const TTree& treeRef,
const std::string& tDir=
"",
const std::string&
stream=
"" );
119 TTree*
tree(
const std::string&
treeName,
const std::string& tDir=
"",
const std::string&
stream=
"" );
133 TGraph*
graph(
const std::string& graphName,
const std::string& tDir=
"",
const std::string&
stream=
"" );
141 inline TEfficiency*
bookGetPointer(
const TEfficiency&
eff,
const std::string& tDir=
"",
const std::string&
stream=
"" );
144 inline TEfficiency*
bookGetPointer( TEfficiency*
eff,
const std::string& tDir=
"",
const std::string&
stream=
"" );
157 inline StatusCode book( TEfficiency& effRef,
const std::string& tDir=
"",
const std::string&
stream=
"" );
161 TEfficiency*
efficiency(
const std::string& effName,
const std::string& tDir=
"",
const std::string&
stream=
"" );
176 bool usePrefixPostfix =
false);
180 const std::string& oldStr,
181 const std::string& newStr);
205 typedef std::map< const hash_t, TEfficiency* >
EffMap_t;
263 TH1* histClone =
dynamic_cast< TH1*
>(
hist.Clone() );
265 m_msg << MSG::ERROR <<
"Couldn't create a TH1 clone in bookGetPointer" <<
endmsg;
275 m_msg << MSG::ERROR <<
"Got a zero pointer to a TH1 in bookGetPointer" <<
endmsg;
284 TEfficiency* histClone =
dynamic_cast< TEfficiency*
>(
hist.Clone() );
286 m_msg << MSG::ERROR <<
"Couldn't create a TEfficiency clone in bookGetPointer" <<
endmsg;
296 m_msg << MSG::ERROR <<
"Got a zero pointer to a TEfficiency in bookGetPointer" <<
endmsg;
306 TH1* histClone =
dynamic_cast< TH1*
>(
hist.Clone() );
308 m_msg << MSG::ERROR <<
"Couldn't create a TH1 clone" <<
endmsg;
309 return StatusCode::FAILURE;
311 return this->
book( *histClone, tDir,
stream );
317 m_msg << MSG::ERROR <<
"Got a zero pointer to a TH1" <<
endmsg;
318 return StatusCode::FAILURE;
328 if ( !histPointer ) {
329 m_msg << MSG::ERROR <<
"Couldn't book a TH1" <<
endmsg;
330 return StatusCode::FAILURE;
332 return StatusCode::SUCCESS;
338 TEfficiency* effClone =
dynamic_cast< TEfficiency*
>(
eff.Clone() );
340 m_msg << MSG::ERROR <<
"Couldn't create a TEfficiency clone" <<
endmsg;
341 return StatusCode::FAILURE;
349 m_msg << MSG::ERROR <<
"Got a zero pointer to a TEfficiency" <<
endmsg;
350 return StatusCode::FAILURE;
361 m_msg << MSG::ERROR <<
"Couldn't book a TEfficiency" <<
endmsg;
362 return StatusCode::FAILURE;
364 return StatusCode::SUCCESS;
372 TH1* th1Pointer = this->
hist(histName, tDir,
stream);
376 <<
"Cannot get a 2-d histogram with name " <<
histName
377 <<
"... will probably seg-fault!" <<
endmsg;
381 return dynamic_cast<TH2*
>( th1Pointer );
389 TH1* th1Pointer = this->
hist(histName, tDir,
stream);
393 <<
"Cannot get a 3-d histogram with name " <<
histName
394 <<
"... will probably seg-fault!" <<
endmsg;
398 return dynamic_cast<TH3*
>( th1Pointer );
409 return StatusCode::SUCCESS;
413 return StatusCode::FAILURE;
435 #endif //> !ATHENABASECOMPS_ATHHISTOGRAMMINGTOOL_H
std::string m_rootDir
Name of the ROOT directory.
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
TH2 * hist2d(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered 2-d histograms.
void myReplace(std::string &str, const std::string &oldStr, const std::string &newStr)
Helper method to replace sub-string.
MsgStream m_msg
Cached Message Stream.
HistMap_t m_histMap
The map of histogram names to their pointers.
std::map< const hash_t, TTree * > TreeMap_t
Typedef for convenience.
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
std::map< const hash_t, TGraph * > GraphMap_t
Typedef for convenience.
TEfficiency * efficiency(const std::string &effName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TEfficiency.
virtual ~AthHistogramming()
Destructor:
TGraph * graph(const std::string &graphName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TGraphs.
std::string m_histNamePostfix
The postfix for the histogram THx name.
TH3 * hist3d(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered 3-d histograms.
::StatusCode StatusCode
StatusCode definition for legacy code.
GraphMap_t m_graphMap
The map of TGraph names to their pointers.
std::string m_streamName
Name of the ROOT output stream (file)
StatusCode configAthHistogramming(const ServiceHandle< ITHistSvc > &histSvc, const std::string &prefix, const std::string &rootDir, const std::string &histNamePrefix, const std::string &histNamePostfix, const std::string &histTitlePrefix, const std::string &histTitlePostfix)
To be called by the derived classes to fill the internal configuration.
uint32_t hash_t
typedef for the internal hash
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.
std::string m_histTitlePostfix
The postfix for the histogram THx title.
hash_t hash(const std::string &histName) const
Method to calculate a 32-bit hash from a string.
StatusCode book(const TGraph &graphRef, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of TGraphs.
std::uint64_t hash64(const void *data, std::size_t size)
Passthrough to XXH3_64bits.
AthHistogramming(const std::string &name)
Constructor with parameters:
EffMap_t m_effMap
The map of histogram names to their pointers.
std::string m_histTitlePrefix
The prefix for the histogram THx title.
TreeMap_t m_treeMap
The map of TTree names to their pointers.
std::string m_histNamePrefix
The prefix for the histogram THx name.
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
ServiceHandle< ITHistSvc > m_histSvc
Pointer to the THistSvc (event store by default)
A crc-64 implementation, using pclmul where possible.
std::string m_name
Instance name.
std::map< const hash_t, TH1 * > HistMap_t
Typedef for convenience.
TTree * tree(const std::string &treeName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TTrees.
std::map< const hash_t, TEfficiency * > EffMap_t
Typedef for convenience.
void buildBookingString(std::string &bookingString, std::string &histName, std::string &tDir, std::string &stream, bool usePrefixPostfix=false)
Method to build individual booking string.
TH1 * bookGetPointer(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.