1 #ifndef GAUDIALG_GAUDIHISTOS_H 2 #define GAUDIALG_GAUDIHISTOS_H 1 17 #include <boost/algorithm/string/replace.hpp> 19 #include <type_traits> 54 template <
class PBASE>
136 AIDA::IHistogram1D* plot1D(
const double value,
const std::string& title,
const double low,
const double high,
137 const unsigned long bins = 100,
const double weight = 1.0 )
const;
152 inline AIDA::IHistogram1D*
plot(
const double value,
const std::string& title,
const double low,
const double high,
153 const unsigned long bins = 100,
const double weight = 1.0 )
const {
154 return plot1D( value, title, low, high, bins, weight );
181 AIDA::IHistogram1D* plot1D(
const double value,
const Gaudi::Histo1DDef& hdef,
const double weight = 1.0 )
const;
194 const double weight = 1.0 )
const {
195 return plot1D( value, hdef, weight );
263 AIDA::IHistogram1D* plot1D(
const double value,
const HistoID& ID,
const std::string& title,
const double low,
264 const double high,
const unsigned long bins = 100,
const double weight = 1.0 )
const;
281 const double high,
const unsigned long bins = 100,
282 const double weight = 1.0 )
const {
283 return plot1D( value, ID, title, low, high, bins, weight );
312 const double weight = 1.0 )
const;
326 const double weight = 1.0 )
const {
327 return plot1D( value, ID, hdef, weight );
392 template <
class FUNCTION,
class OBJECT>
394 const double low,
const double high,
const unsigned long bins = 100 )
const {
395 AIDA::IHistogram1D* h =
nullptr;
396 if ( produceHistos() ) {
398 h = histo1D( title );
399 if ( !h ) { h = book1D( title, low, high, bins ); }
401 while ( first != last && h ) {
402 h =
fill( h,
func( *first ), 1.0, title );
464 template <
class FUNCTION,
class OBJECT>
466 const std::string& title,
const double low,
const double high,
467 const unsigned long bins = 100 )
const {
468 AIDA::IHistogram1D* h( 0 );
469 if ( produceHistos() ) {
472 if ( !h ) { h = book1D( ID, title, low, high, bins ); }
474 while ( first != last && h ) {
475 h =
fill( h,
func( *first ), 1.0, title );
550 template <
class FUNCTION,
class OBJECT,
class WEIGHT>
552 const double low,
const double high,
const unsigned long bins,
553 const WEIGHT& weight )
const {
554 AIDA::IHistogram1D* h =
nullptr;
555 if ( produceHistos() ) {
557 h = histo1D( title );
558 if ( !h ) { h = book1D( title, low, high, bins ); }
560 while ( first != last && h ) {
561 h =
fill( h,
func( *first ), weight( *first ), title );
634 template <
class FUNCTION,
class OBJECT,
class WEIGHT>
636 const std::string& title,
const double low,
const double high,
637 const unsigned long bins,
const WEIGHT& weight )
const {
638 AIDA::IHistogram1D* h =
nullptr;
639 if ( produceHistos() ) {
642 if ( !h ) { h = book1D( ID, title, low, high, bins ); }
644 while ( first != last && h ) {
645 h =
fill( h,
func( *first ), weight( *first ), title );
695 const double weight = 1.0 )
const;
761 AIDA::IHistogram1D* plot1D(
const double value,
const HistoID& ID,
const std::string& title,
762 const HistoBinEdges& edges,
const double weight = 1.0 )
const;
816 AIDA::IHistogram2D* plot2D(
const double valueX,
const double valueY,
const std::string& title,
const double lowX,
817 const double highX,
const double lowY,
const double highY,
const unsigned long binsX = 50,
818 const unsigned long binsY = 50,
const double weight = 1.0 )
const;
896 AIDA::IHistogram2D* plot2D(
const double valueX,
const double valueY,
const HistoID& ID,
const std::string& title,
897 const double lowX,
const double highX,
const double lowY,
const double highY,
898 const unsigned long binsX = 50,
const unsigned long binsY = 50,
899 const double weight = 1.0 )
const;
949 AIDA::IHistogram2D* plot2D(
const double valueX,
const double valueY,
const std::string& title,
951 const double weight = 1.0 )
const;
1028 AIDA::IHistogram2D* plot2D(
const double valueX,
const double valueY,
const HistoID& ID,
const std::string& title,
1030 const double weight = 1.0 )
const;
1092 AIDA::IHistogram3D* plot3D(
const double valueX,
const double valueY,
const double valueZ,
const std::string& title,
1093 const double lowX,
const double highX,
const double lowY,
const double highY,
1094 const double lowZ,
const double highZ,
const unsigned long binsX = 10,
1095 const unsigned long binsY = 10,
const unsigned long binsZ = 10,
1096 const double weight = 1.0 )
const;
1184 AIDA::IHistogram3D* plot3D(
const double valueX,
const double valueY,
const double valueZ,
const HistoID& ID,
1185 const std::string& title,
const double lowX,
const double highX,
const double lowY,
1186 const double highY,
const double lowZ,
const double highZ,
const unsigned long binsX = 10,
1187 const unsigned long binsY = 10,
const unsigned long binsZ = 10,
1188 const double weight = 1.0 )
const;
1240 AIDA::IHistogram3D* plot3D(
const double valueX,
const double valueY,
const double valueZ,
const std::string& title,
1242 const double weight = 1.0 )
const;
1329 AIDA::IHistogram3D* plot3D(
const double valueX,
const double valueY,
const double valueZ,
const HistoID& ID,
1331 const HistoBinEdges& edgesZ,
const double weight = 1.0 )
const;
1384 AIDA::IProfile1D* profile1D(
const double valueX,
const double valueY,
const std::string& title,
const double lowX,
1385 const double highX,
const unsigned long binsX = 100,
const std::string& opt =
"",
1388 const double weight = 1.0 )
const;
1455 AIDA::IProfile1D* profile1D(
const double valueX,
const double valueY,
const HistoID& ID,
const std::string& title,
1456 const double lowX,
const double highX,
const unsigned long binsX = 100,
1459 const double weight = 1.0 )
const;
1506 AIDA::IProfile1D* profile1D(
const double valueX,
const double valueY,
const std::string& title,
1507 const HistoBinEdges& edges,
const double weight = 1.0 )
const;
1570 AIDA::IProfile1D* profile1D(
const double valueX,
const double valueY,
const HistoID& ID,
const std::string& title,
1571 const HistoBinEdges& edges,
const double weight = 1.0 )
const;
1625 AIDA::IProfile2D* profile2D(
const double valueX,
const double valueY,
const double valueZ,
const std::string& title,
1626 const double lowX,
const double highX,
const double lowY,
const double highY,
1627 const unsigned long binsX = 50,
const unsigned long binsY = 50,
1628 const double weight = 1.0 )
const;
1697 AIDA::IProfile2D* profile2D(
const double valueX,
const double valueY,
const double valueZ,
const HistoID& ID,
1698 const std::string& title,
const double lowX,
const double highX,
const double lowY,
1699 const double highY,
const unsigned long binsX = 50,
const unsigned long binsY = 50,
1700 const double weight = 1.0 )
const;
1750 AIDA::IProfile2D* profile2D(
const double valueX,
const double valueY,
const double valueZ,
const std::string& title,
1752 const double weight = 1.0 )
const;
1816 AIDA::IProfile2D* profile2D(
const double valueX,
const double valueY,
const double valueZ,
const HistoID& ID,
1818 const double weight = 1.0 )
const;
1834 AIDA::IHistogram1D* book1D(
const std::string& title,
const double low = 0,
const double high = 100,
1835 const unsigned long bins = 100 )
const;
1849 inline AIDA::IHistogram1D*
book(
const std::string& title,
const double low = 0,
const double high = 100,
1850 const unsigned long bins = 100 )
const {
1851 return book1D( title, low, high, bins );
1874 AIDA::IHistogram1D* book1D(
const HistoID& ID,
const std::string& title,
const double low = 0,
1875 const double high = 100,
const unsigned long bins = 100 )
const;
1891 const double high = 100,
const unsigned long bins = 100 )
const {
1892 return book1D( ID, title, low, high, bins );
1947 AIDA::IHistogram2D* book2D(
const std::string& title,
const double lowX = 0,
const double highX = 100,
1948 const unsigned long binsX = 50,
const double lowY = 0,
const double highY = 100,
1949 const unsigned long binsY = 50 )
const;
1961 AIDA::IHistogram2D* book2D(
const HistoID& ID,
const std::string& title,
const double lowX = 0,
1962 const double highX = 100,
const unsigned long binsX = 50,
const double lowY = 0,
1963 const double highY = 100,
const unsigned long binsY = 50 )
const;
2015 AIDA::IHistogram3D* book3D(
const std::string& title,
const double lowX = 0,
const double highX = 100,
2016 const unsigned long binsX = 10,
const double lowY = 0,
const double highY = 100,
2017 const unsigned long binsY = 10,
const double lowZ = 0,
const double highZ = 100,
2018 const unsigned long binsZ = 10 )
const;
2036 AIDA::IHistogram3D* book3D(
const HistoID& ID,
const std::string& title,
const double lowX = 0,
2037 const double highX = 100,
const unsigned long binsX = 10,
const double lowY = 0,
2038 const double highY = 100,
const unsigned long binsY = 10,
const double lowZ = 0,
2039 const double highZ = 100,
const unsigned long binsZ = 10 )
const;
2090 AIDA::IProfile1D* bookProfile1D(
const std::string& title,
const double low = 0,
const double high = 100,
2091 const unsigned long bins = 100,
const std::string& opt =
"",
2110 AIDA::IProfile1D* bookProfile1D(
const HistoID& ID,
const std::string& title,
const double low = 0,
2111 const double high = 100,
const unsigned long bins = 100,
const std::string& opt =
"",
2157 AIDA::IProfile2D* bookProfile2D(
const std::string& title,
const double lowX = 0,
const double highX = 100,
2158 const unsigned long binsX = 50,
const double lowY = 0,
const double highY = 100,
2159 const unsigned long binsY = 50 )
const;
2174 AIDA::IProfile2D* bookProfile2D(
const HistoID& ID,
const std::string& title,
const double lowX = 0,
2175 const double highX = 100,
const unsigned long binsX = 50,
const double lowY = 0,
2176 const double highY = 100,
const unsigned long binsY = 50 )
const;
2216 AIDA::IHistogram1D*
fill( AIDA::IHistogram1D* histo,
const double value,
const double weight,
2227 AIDA::IHistogram2D*
fill( AIDA::IHistogram2D* histo,
const double valueX,
const double valueY,
const double weight,
2239 AIDA::IHistogram3D*
fill( AIDA::IHistogram3D* histo,
const double valueX,
const double valueY,
const double valueZ,
2240 const double weight,
const std::string& title =
"" )
const;
2250 AIDA::IProfile1D*
fill( AIDA::IProfile1D* histo,
const double valueX,
const double valueY,
const double weight,
2262 AIDA::IProfile2D*
fill( AIDA::IProfile2D* histo,
const double valueX,
const double valueY,
const double valueZ,
2263 const double weight,
const std::string& title =
"" )
const;
2271 auto found = histo1DMapTitle().find( title );
2272 return found != histo1DMapTitle().end() ? found->second :
nullptr;
2282 inline AIDA::IHistogram1D*
histo(
const std::string& title )
const {
return histo1D( title ); }
2288 auto found = histo2DMapTitle().find( title );
2289 return histo2DMapTitle().end() != found ? found->second :
nullptr;
2296 auto found = histo3DMapTitle().find( title );
2297 return histo3DMapTitle().end() != found ? found->second :
nullptr;
2304 auto found = profile1DMapTitle().find( title );
2305 return profile1DMapTitle().end() != found ? found->second :
nullptr;
2312 auto found = profile2DMapTitle().find( title );
2313 return profile2DMapTitle().end() != found ? found->second :
nullptr;
2321 AIDA::IHistogram1D* histo1D(
const HistoID& ID )
const;
2330 inline AIDA::IHistogram1D*
histo(
const HistoID& ID )
const {
return histo1D( ID ); }
2335 AIDA::IHistogram2D* histo2D(
const HistoID& ID )
const;
2340 AIDA::IHistogram3D* histo3D(
const HistoID& ID )
const;
2345 AIDA::IProfile1D* profile1D(
const HistoID& ID )
const;
2350 AIDA::IProfile2D* profile2D(
const HistoID& ID )
const;
2356 return ( 0 != histo( title ) || 0 != histo2D( title ) || 0 != histo3D( title ) || 0 != profile1D( title ) ||
2357 0 != profile2D( title ) );
2362 return ( 0 != histo( ID ) || 0 != histo2D( ID ) || 0 != histo3D( ID ) || 0 != profile1D( ID ) ||
2363 0 != profile2D( ID ) );
2366 unsigned int totalNumberOfHistos()
const;
2677 template <
typename U = PBASE,
typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, PBASE>, U>>
2682 template <
typename U = PBASE,
typename = std::enable_if_t<std::is_base_of_v<GaudiTool, PBASE>, U>>
2694 return i_ghInitialize();
2706 return i_ghFinalize();
2715 bool noHistos()
const;
2722 void monitorHisto(
const AIDA::IBaseHistogram* hist,
const HistoID& ID )
const;
2738 [
this](
const auto& ) {
2741 this->histosPrint() )
2744 "Switch on/off the printout of histograms at finalization"};
2746 "Switch on/off the printout of histogram counters at finalization"};
2748 "Switch on/off the checks for NaN and Infinity for histogram fill"};
2750 "Split long directory names into short pieces (suitable for HBOOK)"};
2752 this,
"HistoOffSet", 0,
"OffSet for automatically assigned histogram numerical identifiers "};
2754 "Top level histogram directory (take care that it ends with '/')"};
2756 this,
"HistoDir", boost::algorithm::replace_all_copy( this->
name(),
":",
"_" ),
"Histogram Directory"};
2761 "Format string for printout of 1D histograms"};
2763 "Format string for printout of 1D histograms"};
2766 "The table header for printout of 1D histograms "};
2768 this,
"UseSequencialNumericAutoIDs",
false,
2769 "Flag to allow users to switch back to the old style of creating numerical automatic IDs"};
2772 "AutoStringIDPurgeMap",
2774 "Map of strings to search and replace when using the title " 2775 "as the basis of automatically generated literal IDs"};
2806 #endif // GAUDIALG_GAUDIHISTOS_H void setFullDetail(const bool val)
set flag to control output level of histograms
const std::string & histoTopDir() const
get top-level histogram directory (property "HistoTopDir")
AIDA::IHistogram1D * histo(const std::string &title) const
access the EXISTING 1D histogram by title
GaudiAlg::Histo3DMapID Histo3DMapID
the actual type for (ID)->(3D histogram) mapping
const Histo2DMapTitle & histo2DMapTitle() const
get access to the map of all 2D histograms indexed via their title
const Histo3DMapID & histo3DMapID() const
get access to the map of all 3D histograms index via a ID
GaudiAlg::Histo1DMapTitle Histo1DMapTitle
the actual type for title->(1D histogram) mapping
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const Histo3DMapTitle & histo3DMapTitle() const
get access to the map of all 3D histograms indexed via their title
AIDA::IHistogram1D * plot(const double value, const std::string &title, const double low, const double high, const unsigned long bins=100, const double weight=1.0) const
fill the 1D histogram (book on demand)
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
std::vector< double > HistoBinEdges
Type for bin edges for variable binning histograms.
Profile1DMapID m_profile1DMapID
the actual storage/access of 1D profile histograms by unique ID
GaudiAlg::Profile1DMapTitle Profile1DMapTitle
the actual type for title->(1D profile histogram) mapping
Implementation of property with value of concrete type.
const Profile2DMapID & profile2DMapID() const
get access to the map of 2D profile histograms index via a ID
AIDA::IHistogram1D * plot(const FUNCTION &func, OBJECT first, OBJECT last, const HistoID &ID, const std::string &title, const double low, const double high, const unsigned long bins, const WEIGHT &weight) const
book and fill the 1D histogram with forced ID and information from [first,last) sequence with given w...
GaudiAlg::ID HistoID
The actual type for histogram identifier.
GaudiAlg::HistoID HistoID
the actual type for histogram identifier
AIDA::IProfile1D * profile1D(const std::string &title) const
access the EXISTING 1D profile histogram by title return the pointer to existing 1D profile histogram...
bool fullDetail() const
get flag to control output level of histograms
Header file for class GaudiAlgorithm.
Histo1DMapID m_histo1DMapID
the actual storage/access of 1D histograms by unique ID
int NumericID
type for internal numeric ID
Histo3DMapTitle m_histo3DMapTitle
the actual storage/access of 3D histograms by unique title
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
const std::string & histoDir() const
get histogram directory (property "HistoDir")
void setHistoOffSet(const HistoID::NumericID val)
set a value for histogram offset (property "HistoOffSet"
AIDA::IHistogram1D * plot(const FUNCTION &func, OBJECT first, OBJECT last, const std::string &title, const double low, const double high, const unsigned long bins=100) const
fill the 1D histogram with information from [first,last) sequence
GaudiAlg::Histo3DMapTitle Histo3DMapTitle
the actual type for title->(3D histogram) mapping
GaudiAlg::Profile2DMapID Profile2DMapID
the actual type for (ID)->(2D profile histogram) mapping
GaudiAlg::Profile1DMapID Profile1DMapID
the actual type for (ID)->(1D profile histogram) mapping
GaudiAlg::HistoBinEdges HistoBinEdges
Edges for variable binning.
Histo2DMapTitle m_histo2DMapTitle
the actual storage/access of 2D histograms by unique title
void setProduceHistos(const bool val)
set the flag for histogram production (property "HistoProduce")
const Profile1DMapID & profile1DMapID() const
get access to the map of 1D profile histograms index via a ID
GaudiAlg::Profile2DMapTitle Profile2DMapTitle
the actual type for title->(2D profile histogram) mapping
void setCheckForNaN(const bool val)
set the flag for NaN checks (property "HistoCheckForNan")
AIDA::IHistogram1D * histo(const HistoID &ID) const
access the EXISTING 1D histogram by ID
bool histosPrint() const
print histograms at finalization ?
AIDA::IHistogram1D * plot(const FUNCTION &func, OBJECT first, OBJECT last, const std::string &title, const double low, const double high, const unsigned long bins, const WEIGHT &weight) const
book and fill the 1D histogram with information from [first,last) sequence with given weight
Profile1DMapTitle m_profile1DMapTitle
the actual storage/access of 1D profile histograms by unique title
bool histoExists(const std::string &title) const
check the existence AND validity of the histogram with given title
AIDA::IHistogram1D * plot(const double value, const HistoID &ID, const Gaudi::Histo1DDef &hdef, const double weight=1.0) const
fill the 1D histogram (book on demand)
AIDA::IHistogram1D * histo1D(const std::string &title) const
access the EXISTING 1D histogram by title return the pointer to existing 1D histogram or NULL
AIDA::IProfile2D * profile2D(const std::string &title) const
access the EXISTING 2D profile histogram by title return the pointer to existing 2D profile histogram...
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
AIDA::IHistogram1D * plot(const double value, const HistoID &ID, const std::string &title, const double low, const double high, const unsigned long bins=100, const double weight=1.0) const
fill the 1D histogram with forced ID assignment (book on demand)
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
GaudiHistos(const std::string &type, const std::string &name, const IInterface *parent)
Tool constructor - SFINAE-ed to insure this constructor is only defined if PBASE derives from GaudiTo...
HistoID::NumericID histoOffSet() const
get the value for histogram offset (property "HistoOffSet")
GaudiAlg::Histo1DMapID Histo1DMapID
the actual type for (ID)->(1D histogram) mapping
bool histoCountersPrint() const
print histogram counters at finalization ?
AIDA::IHistogram2D * histo2D(const std::string &title) const
access the EXISTING 2D histogram by title return the pointer to existing 2D histogram or NULL
Profile2DMapID m_profile2DMapID
the actual storage/access of 2D profile histograms by unique ID
bool histoExists(const HistoID &ID) const
check the existence AND validity of the histogram with given title
AIDA::IHistogram1D * plot(const FUNCTION &func, OBJECT first, OBJECT last, const HistoID &ID, const std::string &title, const double low, const double high, const unsigned long bins=100) const
fill the 1D histogram with forced ID and information from [first,last) sequence
GaudiAlg::Histo2DMapTitle Histo2DMapTitle
the actual type for title->(2D histogram) mapping
void setSplitHistoDir(const bool val)
set the flag for histogram path split (property "HistoSplitDir")
bool checkForNaN() const
get the flag for NaN checks (property "HistoCheckForNan")
GaudiHistos(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined ...
const Profile1DMapTitle & profile1DMapTitle() const
get access to the map of all 1D profile histograms indexed via their title
Histo1DMapTitle m_histo1DMapTitle
the actual storage/access of 1D histograms by unique title
AIDA::IHistogram3D * histo3D(const std::string &title) const
access the EXISTING 3D histogram by title return the pointer to existing 3D histogram or NULL
Profile2DMapTitle m_profile2DMapTitle
the actual storage/access of 2D profile histograms by unique title
AIDA::IHistogram1D * book(const std::string &title, const double low=0, const double high=100, const unsigned long bins=100) const
book the 1D histogram
void setHistoTopDir(const std::string &val)
set top-level histogram directory (property "HistoTopDir")
GaudiAlg::Histo2DMapID Histo2DMapID
the actual type for (ID)->(2D histogram) mapping
Histo3DMapID m_histo3DMapID
the actual storage/access of 3D histograms by unique ID
AIDA::IHistogram1D * plot(const double value, const Gaudi::Histo1DDef &hdef, const double weight=1.0) const
fill the 1D histogram (book on demand)
const Histo1DMapTitle & histo1DMapTitle() const
get access to the map of all 1D histograms indexed via their title
bool splitHistoDir() const
get the flag for histogram path split (property "HistoSplitDir")
Common class providing an architecture-independent hash map.
Histo2DMapID m_histo2DMapID
the actual storage/access of 2D histograms by unique ID
const Histo1DMapID & histo1DMapID() const
get access to the map of all 1D histograms index via ID
void setHistoDir(const std::string &val)
set histogram directory (property "HistoDir")
Templated base class providing common histogramming methods for GaudiAlgorithm and GaudiTool like cla...
const Profile2DMapTitle & profile2DMapTitle() const
get access to the map of all 2D profile histograms indexed via their title
bool useNumericAutoIDs() const
Use old style sequencial numerical automatically assigned IDs ?
AIDA::IHistogram1D * book(const HistoID &ID, const std::string &title, const double low=0, const double high=100, const unsigned long bins=100) const
book the 1D histogram with forced ID
A DataObject is the base class of any identifiable object on any data store.
ID class for Histogram and Ntuples.
bool produceHistos() const
get the flag for histogram production (property "HistoProduce")
const Histo2DMapID & histo2DMapID() const
get access to the map of 2D histograms index via ID