11 #ifndef GAUDIALG_GAUDIHISTOS_H 12 #define GAUDIALG_GAUDIHISTOS_H 1 27 #include <boost/algorithm/string/replace.hpp> 29 #include <type_traits> 64 template <
class PBASE>
146 AIDA::IHistogram1D* plot1D(
const double value,
const std::string& title,
const double low,
const double high,
147 const unsigned long bins = 100,
const double weight = 1.0 )
const;
162 inline AIDA::IHistogram1D*
plot(
const double value,
const std::string& title,
const double low,
const double high,
163 const unsigned long bins = 100,
const double weight = 1.0 )
const {
164 return plot1D( value, title, low, high, bins, weight );
191 AIDA::IHistogram1D* plot1D(
const double value,
const Gaudi::Histo1DDef& hdef,
const double weight = 1.0 )
const;
204 const double weight = 1.0 )
const {
205 return plot1D( value, hdef, weight );
273 AIDA::IHistogram1D* plot1D(
const double value,
const HistoID& ID,
const std::string& title,
const double low,
274 const double high,
const unsigned long bins = 100,
const double weight = 1.0 )
const;
291 const double high,
const unsigned long bins = 100,
292 const double weight = 1.0 )
const {
293 return plot1D( value, ID, title, low, high, bins, weight );
322 const double weight = 1.0 )
const;
336 const double weight = 1.0 )
const {
337 return plot1D( value, ID, hdef, weight );
402 template <
class FUNCTION,
class OBJECT>
404 const double low,
const double high,
const unsigned long bins = 100 )
const {
405 AIDA::IHistogram1D* h =
nullptr;
406 if ( produceHistos() ) {
408 h = histo1D( title );
409 if ( !h ) { h = book1D( title, low, high, bins ); }
411 while ( first != last && h ) {
412 h =
fill( h,
func( *first ), 1.0, title );
474 template <
class FUNCTION,
class OBJECT>
476 const std::string& title,
const double low,
const double high,
477 const unsigned long bins = 100 )
const {
478 AIDA::IHistogram1D* h( 0 );
479 if ( produceHistos() ) {
482 if ( !h ) { h = book1D( ID, title, low, high, bins ); }
484 while ( first != last && h ) {
485 h =
fill( h,
func( *first ), 1.0, title );
560 template <
class FUNCTION,
class OBJECT,
class WEIGHT>
562 const double low,
const double high,
const unsigned long bins,
563 const WEIGHT& weight )
const {
564 AIDA::IHistogram1D* h =
nullptr;
565 if ( produceHistos() ) {
567 h = histo1D( title );
568 if ( !h ) { h = book1D( title, low, high, bins ); }
570 while ( first != last && h ) {
571 h =
fill( h,
func( *first ), weight( *first ), title );
644 template <
class FUNCTION,
class OBJECT,
class WEIGHT>
646 const std::string& title,
const double low,
const double high,
647 const unsigned long bins,
const WEIGHT& weight )
const {
648 AIDA::IHistogram1D* h =
nullptr;
649 if ( produceHistos() ) {
652 if ( !h ) { h = book1D( ID, title, low, high, bins ); }
654 while ( first != last && h ) {
655 h =
fill( h,
func( *first ), weight( *first ), title );
705 const double weight = 1.0 )
const;
771 AIDA::IHistogram1D* plot1D(
const double value,
const HistoID& ID,
const std::string& title,
772 const HistoBinEdges& edges,
const double weight = 1.0 )
const;
826 AIDA::IHistogram2D* plot2D(
const double valueX,
const double valueY,
const std::string& title,
const double lowX,
827 const double highX,
const double lowY,
const double highY,
const unsigned long binsX = 50,
828 const unsigned long binsY = 50,
const double weight = 1.0 )
const;
906 AIDA::IHistogram2D* plot2D(
const double valueX,
const double valueY,
const HistoID& ID,
const std::string& title,
907 const double lowX,
const double highX,
const double lowY,
const double highY,
908 const unsigned long binsX = 50,
const unsigned long binsY = 50,
909 const double weight = 1.0 )
const;
959 AIDA::IHistogram2D* plot2D(
const double valueX,
const double valueY,
const std::string& title,
961 const double weight = 1.0 )
const;
1038 AIDA::IHistogram2D* plot2D(
const double valueX,
const double valueY,
const HistoID& ID,
const std::string& title,
1040 const double weight = 1.0 )
const;
1102 AIDA::IHistogram3D* plot3D(
const double valueX,
const double valueY,
const double valueZ,
const std::string& title,
1103 const double lowX,
const double highX,
const double lowY,
const double highY,
1104 const double lowZ,
const double highZ,
const unsigned long binsX = 10,
1105 const unsigned long binsY = 10,
const unsigned long binsZ = 10,
1106 const double weight = 1.0 )
const;
1194 AIDA::IHistogram3D* plot3D(
const double valueX,
const double valueY,
const double valueZ,
const HistoID& ID,
1195 const std::string& title,
const double lowX,
const double highX,
const double lowY,
1196 const double highY,
const double lowZ,
const double highZ,
const unsigned long binsX = 10,
1197 const unsigned long binsY = 10,
const unsigned long binsZ = 10,
1198 const double weight = 1.0 )
const;
1250 AIDA::IHistogram3D* plot3D(
const double valueX,
const double valueY,
const double valueZ,
const std::string& title,
1252 const double weight = 1.0 )
const;
1339 AIDA::IHistogram3D* plot3D(
const double valueX,
const double valueY,
const double valueZ,
const HistoID& ID,
1341 const HistoBinEdges& edgesZ,
const double weight = 1.0 )
const;
1394 AIDA::IProfile1D* profile1D(
const double valueX,
const double valueY,
const std::string& title,
const double lowX,
1395 const double highX,
const unsigned long binsX = 100,
const std::string& opt =
"",
1398 const double weight = 1.0 )
const;
1465 AIDA::IProfile1D* profile1D(
const double valueX,
const double valueY,
const HistoID& ID,
const std::string& title,
1466 const double lowX,
const double highX,
const unsigned long binsX = 100,
1469 const double weight = 1.0 )
const;
1516 AIDA::IProfile1D* profile1D(
const double valueX,
const double valueY,
const std::string& title,
1517 const HistoBinEdges& edges,
const double weight = 1.0 )
const;
1580 AIDA::IProfile1D* profile1D(
const double valueX,
const double valueY,
const HistoID& ID,
const std::string& title,
1581 const HistoBinEdges& edges,
const double weight = 1.0 )
const;
1635 AIDA::IProfile2D* profile2D(
const double valueX,
const double valueY,
const double valueZ,
const std::string& title,
1636 const double lowX,
const double highX,
const double lowY,
const double highY,
1637 const unsigned long binsX = 50,
const unsigned long binsY = 50,
1638 const double weight = 1.0 )
const;
1707 AIDA::IProfile2D* profile2D(
const double valueX,
const double valueY,
const double valueZ,
const HistoID& ID,
1708 const std::string& title,
const double lowX,
const double highX,
const double lowY,
1709 const double highY,
const unsigned long binsX = 50,
const unsigned long binsY = 50,
1710 const double weight = 1.0 )
const;
1760 AIDA::IProfile2D* profile2D(
const double valueX,
const double valueY,
const double valueZ,
const std::string& title,
1762 const double weight = 1.0 )
const;
1826 AIDA::IProfile2D* profile2D(
const double valueX,
const double valueY,
const double valueZ,
const HistoID& ID,
1828 const double weight = 1.0 )
const;
1844 AIDA::IHistogram1D* book1D(
const std::string& title,
const double low = 0,
const double high = 100,
1845 const unsigned long bins = 100 )
const;
1859 inline AIDA::IHistogram1D*
book(
const std::string& title,
const double low = 0,
const double high = 100,
1860 const unsigned long bins = 100 )
const {
1861 return book1D( title, low, high, bins );
1884 AIDA::IHistogram1D* book1D(
const HistoID& ID,
const std::string& title,
const double low = 0,
1885 const double high = 100,
const unsigned long bins = 100 )
const;
1901 const double high = 100,
const unsigned long bins = 100 )
const {
1902 return book1D( ID, title, low, high, bins );
1957 AIDA::IHistogram2D* book2D(
const std::string& title,
const double lowX = 0,
const double highX = 100,
1958 const unsigned long binsX = 50,
const double lowY = 0,
const double highY = 100,
1959 const unsigned long binsY = 50 )
const;
1971 AIDA::IHistogram2D* book2D(
const HistoID& ID,
const std::string& title,
const double lowX = 0,
1972 const double highX = 100,
const unsigned long binsX = 50,
const double lowY = 0,
1973 const double highY = 100,
const unsigned long binsY = 50 )
const;
2025 AIDA::IHistogram3D* book3D(
const std::string& title,
const double lowX = 0,
const double highX = 100,
2026 const unsigned long binsX = 10,
const double lowY = 0,
const double highY = 100,
2027 const unsigned long binsY = 10,
const double lowZ = 0,
const double highZ = 100,
2028 const unsigned long binsZ = 10 )
const;
2046 AIDA::IHistogram3D* book3D(
const HistoID& ID,
const std::string& title,
const double lowX = 0,
2047 const double highX = 100,
const unsigned long binsX = 10,
const double lowY = 0,
2048 const double highY = 100,
const unsigned long binsY = 10,
const double lowZ = 0,
2049 const double highZ = 100,
const unsigned long binsZ = 10 )
const;
2100 AIDA::IProfile1D* bookProfile1D(
const std::string& title,
const double low = 0,
const double high = 100,
2101 const unsigned long bins = 100,
const std::string& opt =
"",
2120 AIDA::IProfile1D* bookProfile1D(
const HistoID& ID,
const std::string& title,
const double low = 0,
2121 const double high = 100,
const unsigned long bins = 100,
const std::string& opt =
"",
2167 AIDA::IProfile2D* bookProfile2D(
const std::string& title,
const double lowX = 0,
const double highX = 100,
2168 const unsigned long binsX = 50,
const double lowY = 0,
const double highY = 100,
2169 const unsigned long binsY = 50 )
const;
2184 AIDA::IProfile2D* bookProfile2D(
const HistoID& ID,
const std::string& title,
const double lowX = 0,
2185 const double highX = 100,
const unsigned long binsX = 50,
const double lowY = 0,
2186 const double highY = 100,
const unsigned long binsY = 50 )
const;
2226 AIDA::IHistogram1D*
fill( AIDA::IHistogram1D* histo,
const double value,
const double weight,
2237 AIDA::IHistogram2D*
fill( AIDA::IHistogram2D* histo,
const double valueX,
const double valueY,
const double weight,
2249 AIDA::IHistogram3D*
fill( AIDA::IHistogram3D* histo,
const double valueX,
const double valueY,
const double valueZ,
2250 const double weight,
const std::string& title =
"" )
const;
2260 AIDA::IProfile1D*
fill( AIDA::IProfile1D* histo,
const double valueX,
const double valueY,
const double weight,
2272 AIDA::IProfile2D*
fill( AIDA::IProfile2D* histo,
const double valueX,
const double valueY,
const double valueZ,
2273 const double weight,
const std::string& title =
"" )
const;
2281 auto found = histo1DMapTitle().find( title );
2282 return found != histo1DMapTitle().end() ? found->second :
nullptr;
2292 inline AIDA::IHistogram1D*
histo(
const std::string& title )
const {
return histo1D( title ); }
2298 auto found = histo2DMapTitle().find( title );
2299 return histo2DMapTitle().end() != found ? found->second :
nullptr;
2306 auto found = histo3DMapTitle().find( title );
2307 return histo3DMapTitle().end() != found ? found->second :
nullptr;
2314 auto found = profile1DMapTitle().find( title );
2315 return profile1DMapTitle().end() != found ? found->second :
nullptr;
2322 auto found = profile2DMapTitle().find( title );
2323 return profile2DMapTitle().end() != found ? found->second :
nullptr;
2331 AIDA::IHistogram1D* histo1D(
const HistoID& ID )
const;
2340 inline AIDA::IHistogram1D*
histo(
const HistoID& ID )
const {
return histo1D( ID ); }
2345 AIDA::IHistogram2D* histo2D(
const HistoID& ID )
const;
2350 AIDA::IHistogram3D* histo3D(
const HistoID& ID )
const;
2355 AIDA::IProfile1D* profile1D(
const HistoID& ID )
const;
2360 AIDA::IProfile2D* profile2D(
const HistoID& ID )
const;
2366 return ( 0 != histo( title ) || 0 != histo2D( title ) || 0 != histo3D( title ) || 0 != profile1D( title ) ||
2367 0 != profile2D( title ) );
2372 return ( 0 != histo( ID ) || 0 != histo2D( ID ) || 0 != histo3D( ID ) || 0 != profile1D( ID ) ||
2373 0 != profile2D( ID ) );
2376 unsigned int totalNumberOfHistos()
const;
2687 template <
typename U = PBASE,
typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, PBASE>, U>>
2692 template <
typename U = PBASE,
typename = std::enable_if_t<std::is_base_of_v<GaudiTool, PBASE>, U>>
2704 return i_ghInitialize();
2716 return i_ghFinalize();
2725 bool noHistos()
const;
2732 void monitorHisto(
const AIDA::IBaseHistogram* hist,
const HistoID& ID )
const;
2748 [
this](
const auto& ) {
2751 this->histosPrint() )
2754 "Switch on/off the printout of histograms at finalization"};
2756 "Switch on/off the printout of histogram counters at finalization"};
2758 "Switch on/off the checks for NaN and Infinity for histogram fill"};
2760 "Split long directory names into short pieces (suitable for HBOOK)"};
2762 this,
"HistoOffSet", 0,
"OffSet for automatically assigned histogram numerical identifiers "};
2764 "Top level histogram directory (take care that it ends with '/')"};
2766 this,
"HistoDir", boost::algorithm::replace_all_copy( this->
name(),
":",
"_" ),
"Histogram Directory"};
2771 "Format string for printout of 1D histograms"};
2773 "Format string for printout of 1D histograms"};
2776 "The table header for printout of 1D histograms "};
2778 this,
"UseSequencialNumericAutoIDs",
false,
2779 "Flag to allow users to switch back to the old style of creating numerical automatic IDs"};
2782 "AutoStringIDPurgeMap",
2784 "Map of strings to search and replace when using the title " 2785 "as the basis of automatically generated literal IDs"};
2816 #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.
const Gaudi::Algorithm & parent
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