The Gaudi Framework  v38r1p1 (ae26267b)
GaudiHistos.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIALG_GAUDIHISTOS_H
12 #define GAUDIALG_GAUDIHISTOS_H 1
13 // ============================================================================
14 /* @file GaudiHistos.h
15  *
16  * Header file for class : GaudiHistos
17  *
18  * @author Chris Jones Christopher.Rob.Jones@cern.ch
19  * @author Vanya BELYAEV Ivan.Belyaev@itep.ru
20  * @date 2005-08-08
21  */
22 // ============================================================================
23 // Include files#
24 // ============================================================================
25 // STD& STL
26 // ============================================================================
27 #include <boost/algorithm/string/replace.hpp>
28 #include <limits>
29 #include <type_traits>
30 #include <vector>
31 // ============================================================================
32 // GaudiUtils
33 // ============================================================================
35 // ============================================================================
36 // GaudiAlg
37 // ============================================================================
39 #include "GaudiAlg/GaudiTool.h"
40 #include "GaudiAlg/Maps.h"
41 // ============================================================================
42 // GaudiKernel
43 // ============================================================================
45 // ============================================================================
46 // Forward declarations
47 namespace AIDA {
48  class IHistogram1D;
49  class IHistogram2D;
50  class IHistogram3D;
51  class IProfile1D;
52  class IProfile2D;
53 } // namespace AIDA
54 // ============================================================================
64 template <class PBASE>
65 class GAUDI_API GaudiHistos : public PBASE {
66 public:
67  // ==========================================================================
70  // ==========================================================================
75  // ==========================================================================
80  // ==========================================================================
85  // ==========================================================================
90  // ==========================================================================
95  // ==========================================================================
98  // ==========================================================================
99 public:
100  // ==========================================================================
101  // ================================= 1D Histograms ==========================
102  // ================================= Fixed Binning ==========================
103  // ==========================================================================
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;
148  // ==========================================================================
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 );
165  }
166  // ==========================================================================
191  AIDA::IHistogram1D* plot1D( const double value, const Gaudi::Histo1DDef& hdef, const double weight = 1.0 ) const;
192  // ==========================================================================
203  inline AIDA::IHistogram1D* plot( const double value, const Gaudi::Histo1DDef& hdef,
204  const double weight = 1.0 ) const {
205  return plot1D( value, hdef, weight );
206  }
207  // ==========================================================================
272  // ==========================================================================
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;
275  // ==========================================================================
290  inline AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const std::string& title, const double low,
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 );
294  }
295  // ==========================================================================
321  AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const Gaudi::Histo1DDef& hdef,
322  const double weight = 1.0 ) const;
323  // ==========================================================================
335  inline AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const Gaudi::Histo1DDef& hdef,
336  const double weight = 1.0 ) const {
337  return plot1D( value, ID, hdef, weight );
338  }
402  template <class FUNCTION, class OBJECT>
403  inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title,
404  const double low, const double high, const unsigned long bins = 100 ) const {
405  AIDA::IHistogram1D* h = nullptr;
406  if ( produceHistos() ) {
407  // retrieve or book the histogram
408  h = histo1D( title );
409  if ( !h ) { h = book1D( title, low, high, bins ); }
410  // fill histogram
411  while ( first != last && h ) {
412  h = fill( h, func( *first ), 1.0, title );
413  ++first;
414  }
415  }
416  return h;
417  }
418  // ==========================================================================
474  template <class FUNCTION, class OBJECT>
475  inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
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() ) {
480  // retrieve or book the histogram
481  h = histo1D( ID );
482  if ( !h ) { h = book1D( ID, title, low, high, bins ); }
483  // fill histogram
484  while ( first != last && h ) {
485  h = fill( h, func( *first ), 1.0, title );
486  ++first;
487  }
488  }
489  return h;
490  }
491  // ==========================================================================
560  template <class FUNCTION, class OBJECT, class WEIGHT>
561  inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title,
562  const double low, const double high, const unsigned long bins,
563  const WEIGHT& weight ) const {
564  AIDA::IHistogram1D* h = nullptr;
565  if ( produceHistos() ) {
566  // retrieve or book the histogram
567  h = histo1D( title );
568  if ( !h ) { h = book1D( title, low, high, bins ); }
569  // fill histogram
570  while ( first != last && h ) {
571  h = fill( h, func( *first ), weight( *first ), title );
572  ++first;
573  }
574  }
575  return h;
576  }
577  // ==========================================================================
644  template <class FUNCTION, class OBJECT, class WEIGHT>
645  inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
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() ) {
650  // retrieve or book the histogram
651  h = histo1D( ID );
652  if ( !h ) { h = book1D( ID, title, low, high, bins ); }
653  // fill histogram
654  while ( first != last && h ) {
655  h = fill( h, func( *first ), weight( *first ), title );
656  ++first;
657  }
658  }
659  return h;
660  }
661  // ==========================================================================
662  // ================================= 1D Histograms ==========================
663  // =============================== Variable Binning =========================
664  // ==========================================================================
704  AIDA::IHistogram1D* plot1D( const double value, const std::string& title, const HistoBinEdges& edges,
705  const double weight = 1.0 ) const;
706  // ==========================================================================
770  // ==========================================================================
771  AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const std::string& title,
772  const HistoBinEdges& edges, const double weight = 1.0 ) const;
773  // ==========================================================================
774  // ================================= 2D Histograms ==========================
775  // ==========================================================================
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;
829  // ==========================================================================
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;
910  // ==========================================================================
911  // ================================= 2D Histograms ==========================
912  // =============================== Variable Binning =========================
913  // ==========================================================================
959  AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const std::string& title,
960  const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
961  const double weight = 1.0 ) const;
962  // ==========================================================================
1038  AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const HistoID& ID, const std::string& title,
1039  const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
1040  const double weight = 1.0 ) const;
1041  // ==========================================================================
1042  // ================================= 3D Histograms ==========================
1043  // ==========================================================================
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;
1107  // ==========================================================================
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;
1199  // ==========================================================================
1200  // ================================= 3D Histograms ==========================
1201  // =============================== Variable Binning =========================
1202  // ==========================================================================
1250  AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const std::string& title,
1251  const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ,
1252  const double weight = 1.0 ) const;
1253  // ==========================================================================
1254  // ==========================================================================
1339  AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const HistoID& ID,
1340  const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
1341  const HistoBinEdges& edgesZ, const double weight = 1.0 ) const;
1342  // ==========================================================================
1343  // ================================= 1D Profile =============================
1344  // ================================= Fixed binning ==========================
1345  // ==========================================================================
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 = "",
1396  const double lowY = -std::numeric_limits<double>::max(),
1397  const double highY = std::numeric_limits<double>::max(),
1398  const double weight = 1.0 ) const;
1399  // ==========================================================================
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,
1467  const std::string& opt = "", const double lowY = -std::numeric_limits<double>::max(),
1468  const double highY = std::numeric_limits<double>::max(),
1469  const double weight = 1.0 ) const;
1470  // ==========================================================================
1471  // ================================= 1D Profile =============================
1472  // ============================== Variable binning ==========================
1473  // ==========================================================================
1516  AIDA::IProfile1D* profile1D( const double valueX, const double valueY, const std::string& title,
1517  const HistoBinEdges& edges, const double weight = 1.0 ) const;
1518  // ==========================================================================
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;
1582  // ==========================================================================
1583  // ================================= 2D Profile =============================
1584  // ==========================================================================
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;
1639  // ==========================================================================
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;
1711  // ==========================================================================
1712  // ================================= 2D Profile =============================
1713  // ============================== Variable binning ==========================
1714  // ==========================================================================
1760  AIDA::IProfile2D* profile2D( const double valueX, const double valueY, const double valueZ, const std::string& title,
1761  const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
1762  const double weight = 1.0 ) const;
1763  // ==========================================================================
1826  AIDA::IProfile2D* profile2D( const double valueX, const double valueY, const double valueZ, const HistoID& ID,
1827  const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
1828  const double weight = 1.0 ) const;
1829  // ==========================================================================
1830 
1831 public: // 1D Fixed
1832  // ==========================================================================
1844  AIDA::IHistogram1D* book1D( const std::string& title, const double low = 0, const double high = 100,
1845  const unsigned long bins = 100 ) const;
1846  // ==========================================================================
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 );
1862  }
1863  // ==========================================================================
1872  AIDA::IHistogram1D* book( const Gaudi::Histo1DDef& hdef ) const;
1873  // ==========================================================================
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;
1886  // ==========================================================================
1900  inline AIDA::IHistogram1D* book( const HistoID& ID, const std::string& title, const double low = 0,
1901  const double high = 100, const unsigned long bins = 100 ) const {
1902  return book1D( ID, title, low, high, bins );
1903  }
1904  // ==========================================================================
1912  inline AIDA::IHistogram1D* book( const HistoID& ID, const Gaudi::Histo1DDef& hdef ) const;
1913  // ==========================================================================
1914 
1915 public: // 1D Variable
1916  // ==========================================================================
1927  AIDA::IHistogram1D* book1D( const std::string& title, const HistoBinEdges& edges ) const;
1928  // ==========================================================================
1938  AIDA::IHistogram1D* book1D( const HistoID& ID, const std::string& title, const HistoBinEdges& edges ) const;
1939  // ==========================================================================
1940 
1941 public: // 2D Fixed
1942  // ==========================================================================
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;
1960  // ==========================================================================
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;
1974  // ==========================================================================
1975 
1976 public: // 2D Variable
1977  // ==========================================================================
1989  AIDA::IHistogram2D* book2D( const std::string& title, const HistoBinEdges& edgesX,
1990  const HistoBinEdges& edgesY ) const;
1991  // ==========================================================================
2002  AIDA::IHistogram2D* book2D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX,
2003  const HistoBinEdges& edgesY ) const;
2004  // ==========================================================================
2005 
2006 public: // 3D Fixed
2007  // ==========================================================================
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;
2029  // ==========================================================================
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;
2050  // ==========================================================================
2051 
2052 public: // 3D Variable
2053  // ==========================================================================
2066  AIDA::IHistogram3D* book3D( const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
2067  const HistoBinEdges& edgesZ ) const;
2068  // ==========================================================================
2080  AIDA::IHistogram3D* book3D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX,
2081  const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ ) const;
2082  // ==========================================================================
2083 
2084 public: // 1D Fixed Profiles
2085  // ==========================================================================
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 = "",
2102  const double lowY = -std::numeric_limits<double>::max(),
2103  const double highY = std::numeric_limits<double>::max() ) const;
2104  // ==========================================================================
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 = "",
2122  const double lowY = -std::numeric_limits<double>::max(),
2123  const double highY = std::numeric_limits<double>::max() ) const;
2124  // ==========================================================================
2125 
2126 public: // 1D Variable Profiles
2127  // ==========================================================================
2137  AIDA::IProfile1D* bookProfile1D( const std::string& title, const HistoBinEdges& edges ) const;
2138  // ==========================================================================
2148  AIDA::IProfile1D* bookProfile1D( const HistoID& ID, const std::string& title, const HistoBinEdges& edges ) const;
2149  // ==========================================================================
2150 
2151 public: // 2D Profiles
2152  // ==========================================================================
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;
2170  // ==========================================================================
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;
2187  // ==========================================================================
2188 
2189 public: // 2D Profiles
2190  // ==========================================================================
2201  AIDA::IProfile2D* bookProfile2D( const std::string& title, const HistoBinEdges& edgesX,
2202  const HistoBinEdges& edgesY ) const;
2203  // ==========================================================================
2213  AIDA::IProfile2D* bookProfile2D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX,
2214  const HistoBinEdges& edgesY ) const;
2215  // ==========================================================================
2216 
2217 public:
2218  // ==========================================================================
2226  AIDA::IHistogram1D* fill( AIDA::IHistogram1D* histo, const double value, const double weight,
2227  const std::string& title = "" ) const;
2228  // ==========================================================================
2237  AIDA::IHistogram2D* fill( AIDA::IHistogram2D* histo, const double valueX, const double valueY, const double weight,
2238  const std::string& title = "" ) const;
2239  // ==========================================================================
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;
2251  // ==========================================================================
2260  AIDA::IProfile1D* fill( AIDA::IProfile1D* histo, const double valueX, const double valueY, const double weight,
2261  const std::string& title = "" ) const;
2262  // ==========================================================================
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;
2274  // ==========================================================================
2275 public:
2276  // ==========================================================================
2280  inline AIDA::IHistogram1D* histo1D( const std::string& title ) const {
2281  auto found = histo1DMapTitle().find( title );
2282  return found != histo1DMapTitle().end() ? found->second : nullptr;
2283  }
2284  // ==========================================================================
2292  inline AIDA::IHistogram1D* histo( const std::string& title ) const { return histo1D( title ); }
2293  // ==========================================================================
2297  inline AIDA::IHistogram2D* histo2D( const std::string& title ) const {
2298  auto found = histo2DMapTitle().find( title );
2299  return histo2DMapTitle().end() != found ? found->second : nullptr;
2300  }
2301  // ==========================================================================
2305  inline AIDA::IHistogram3D* histo3D( const std::string& title ) const {
2306  auto found = histo3DMapTitle().find( title );
2307  return histo3DMapTitle().end() != found ? found->second : nullptr;
2308  }
2309  // ==========================================================================
2313  inline AIDA::IProfile1D* profile1D( const std::string& title ) const {
2314  auto found = profile1DMapTitle().find( title );
2315  return profile1DMapTitle().end() != found ? found->second : nullptr;
2316  }
2317  // ==========================================================================
2321  inline AIDA::IProfile2D* profile2D( const std::string& title ) const {
2322  auto found = profile2DMapTitle().find( title );
2323  return profile2DMapTitle().end() != found ? found->second : nullptr;
2324  }
2325  // ==========================================================================
2326 public:
2327  // ==========================================================================
2331  AIDA::IHistogram1D* histo1D( const HistoID& ID ) const;
2332  // ==========================================================================
2340  inline AIDA::IHistogram1D* histo( const HistoID& ID ) const { return histo1D( ID ); }
2341  // ==========================================================================
2345  AIDA::IHistogram2D* histo2D( const HistoID& ID ) const;
2346  // ==========================================================================
2350  AIDA::IHistogram3D* histo3D( const HistoID& ID ) const;
2351  // ==========================================================================
2355  AIDA::IProfile1D* profile1D( const HistoID& ID ) const;
2356  // ==========================================================================
2360  AIDA::IProfile2D* profile2D( const HistoID& ID ) const;
2361  // ==========================================================================
2362 public:
2363  // ==========================================================================
2365  inline bool histoExists( const std::string& title ) const {
2366  return ( 0 != histo( title ) || 0 != histo2D( title ) || 0 != histo3D( title ) || 0 != profile1D( title ) ||
2367  0 != profile2D( title ) );
2368  }
2369  // ==========================================================================
2371  inline bool histoExists( const HistoID& ID ) const {
2372  return ( 0 != histo( ID ) || 0 != histo2D( ID ) || 0 != histo3D( ID ) || 0 != profile1D( ID ) ||
2373  0 != profile2D( ID ) );
2374  }
2376  unsigned int totalNumberOfHistos() const;
2377  // ==========================================================================
2378 public: // trivial & non-trivial accessors
2379  // ==========================================================================
2381  inline bool produceHistos() const { return m_produceHistos; }
2383  inline bool fullDetail() const { return m_fullDetail; }
2385  inline bool checkForNaN() const { return m_checkForNaN; }
2387  inline bool splitHistoDir() const { return m_splitHistoDir; }
2389  inline HistoID::NumericID histoOffSet() const { return m_histoOffSet; }
2391  inline const std::string& histoTopDir() const { return m_histoTopDir; }
2393  inline const std::string& histoDir() const { return m_histoDir; }
2395  std::string histoPath() const;
2397  inline bool histosPrint() const { return m_histosPrint; }
2399  inline bool histoCountersPrint() const { return m_histoCountersPrint; }
2401  inline bool useNumericAutoIDs() const { return m_useNumericAutoIDs; }
2402  // ==========================================================================
2407  int printHistos( const MSG::Level level = MSG::ALWAYS ) const;
2408  // ==========================================================================
2434  const Histo1DMapTitle& histo1DMapTitle() const { return m_histo1DMapTitle; }
2435  // ==========================================================================
2458  const Histo1DMapID& histo1DMapID() const { return m_histo1DMapID; }
2459  // ==========================================================================
2485  const Histo2DMapTitle& histo2DMapTitle() const { return m_histo2DMapTitle; }
2486  // ==========================================================================
2508  const Histo2DMapID& histo2DMapID() const { return m_histo2DMapID; }
2509  // ==========================================================================
2535  const Histo3DMapTitle& histo3DMapTitle() const { return m_histo3DMapTitle; }
2536  // ==========================================================================
2558  const Histo3DMapID& histo3DMapID() const { return m_histo3DMapID; }
2559  // ==========================================================================
2587  const Profile1DMapTitle& profile1DMapTitle() const { return m_profile1DMapTitle; }
2588  // ==========================================================================
2610  const Profile1DMapID& profile1DMapID() const { return m_profile1DMapID; }
2611  // ==========================================================================
2637  const Profile2DMapTitle& profile2DMapTitle() const { return m_profile2DMapTitle; }
2638  // ==========================================================================
2660  const Profile2DMapID& profile2DMapID() const { return m_profile2DMapID; }
2661  // ==========================================================================
2662 public: // trivial setters
2663  // ==========================================================================
2665  inline void setProduceHistos( const bool val ) { m_produceHistos = val; }
2667  inline void setFullDetail( const bool val ) { m_fullDetail = val; }
2669  inline void setCheckForNaN( const bool val ) { m_checkForNaN = val; }
2671  inline void setSplitHistoDir( const bool val ) { m_splitHistoDir = val; }
2673  inline void setHistoOffSet( const HistoID::NumericID val ) { m_histoOffSet = val; }
2674  // ==========================================================================
2676  inline void setHistoTopDir( const std::string& val ) { m_histoTopDir = val; }
2677  // ==========================================================================
2679  inline void setHistoDir( const std::string& val ) { m_histoDir = val; }
2680  // ==========================================================================
2681 public:
2682  // FIXME: due to a bug in gcc7, the following two cannot be replaced with
2683  // using PBASE::PBASE...
2684  // ==========================================================================
2687  template <typename U = PBASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, PBASE>, U>>
2688  GaudiHistos( const std::string& name, ISvcLocator* pSvcLocator ) : PBASE( name, pSvcLocator ) {}
2689  // ==========================================================================
2692  template <typename U = PBASE, typename = std::enable_if_t<std::is_base_of_v<GaudiTool, PBASE>, U>>
2693  GaudiHistos( const std::string& type, const std::string& name, const IInterface* parent )
2694  : PBASE( type, name, parent ) {}
2695  // ==========================================================================
2696 protected:
2697  // ==========================================================================
2701  StatusCode initialize() override
2702 #ifdef __ICC
2703  {
2704  return i_ghInitialize();
2705  }
2706  StatusCode i_ghInitialize()
2707 #endif
2708  ;
2709  // ==========================================================================
2713  StatusCode finalize() override
2714 #ifdef __ICC
2715  {
2716  return i_ghFinalize();
2717  }
2718  StatusCode i_ghFinalize()
2719 #endif
2720  ;
2721  // ==========================================================================
2722 private:
2723  // ==========================================================================
2725  bool noHistos() const;
2726  // ===========================================unsigned===============================
2732  void monitorHisto( const AIDA::IBaseHistogram* hist, const HistoID& ID ) const;
2733  // ==========================================================================
2738  void newHistoID( const std::string& title, HistoID& ID ) const;
2739  // ==========================================================================
2740 protected:
2741  // ==========================================================================
2743  std::string convertTitleToID( std::string title ) const;
2744  // ==========================================================================
2745 private:
2746  Gaudi::Property<bool> m_produceHistos{ this, "HistoProduce", true, "Switch on/off the production of histograms" };
2747  Gaudi::Property<bool> m_histosPrint{ this, "HistoPrint", false,
2748  [this]( const auto& ) {
2749  // no action if not yet initialized
2750  if ( this->FSMState() >= Gaudi::StateMachine::INITIALIZED &&
2751  this->histosPrint() )
2752  this->printHistos( MSG::ALWAYS );
2753  },
2754  "Switch on/off the printout of histograms at finalization" };
2755  Gaudi::Property<bool> m_histoCountersPrint{ this, "HistoCountersPrint", true,
2756  "Switch on/off the printout of histogram counters at finalization" };
2757  Gaudi::Property<bool> m_checkForNaN{ this, "HistoCheckForNaN", true,
2758  "Switch on/off the checks for NaN and Infinity for histogram fill" };
2759  Gaudi::Property<bool> m_splitHistoDir{ this, "HistoSplitDir", false,
2760  "Split long directory names into short pieces (suitable for HBOOK)" };
2762  this, "HistoOffSet", 0, "OffSet for automatically assigned histogram numerical identifiers " };
2763  Gaudi::Property<std::string> m_histoTopDir{ this, "HistoTopDir", "",
2764  "Top level histogram directory (take care that it ends with '/')" };
2766  this, "HistoDir", boost::algorithm::replace_all_copy( this->name(), ":", "_" ), "Histogram Directory" };
2767  Gaudi::Property<bool> m_fullDetail{ this, "FullDetail", false };
2768  Gaudi::Property<bool> m_declareMoniHists{ this, "MonitorHistograms", true };
2769  Gaudi::Property<std::string> m_histo1DTableFormat{ this, "FormatFor1DHistoTable",
2771  "Format string for printout of 1D histograms" };
2772  Gaudi::Property<std::string> m_histo1DTableFormatShort{ this, "ShortFormatFor1DHistoTable", " | %1$-25.25s %2%",
2773  "Format string for printout of 1D histograms" };
2774  Gaudi::Property<std::string> m_histo1DTableHeader{ this, "HeaderFor1DHistoTable",
2776  "The table header for printout of 1D histograms " };
2777  Gaudi::Property<bool> m_useNumericAutoIDs{
2778  this, "UseSequencialNumericAutoIDs", false,
2779  "Flag to allow users to switch back to the old style of creating numerical automatic IDs" };
2781  this,
2782  "AutoStringIDPurgeMap",
2783  { { "/", "=SLASH=" } },
2784  "Map of strings to search and replace when using the title "
2785  "as the basis of automatically generated literal IDs" };
2786  // ==========================================================================
2791  // ==========================================================================
2796  // ==========================================================================
2801  // ==========================================================================
2806  // ==========================================================================
2811  // ==========================================================================
2812 };
2813 // ============================================================================
2814 // The END
2815 // ============================================================================
2816 #endif // GAUDIALG_GAUDIHISTOS_H
GaudiHistos::histo1DMapTitle
const Histo1DMapTitle & histo1DMapTitle() const
get access to the map of all 1D histograms indexed via their title
Definition: GaudiHistos.h:2434
GaudiTool.h
AIDA
GaudiKernel.
Definition: Fill.h:20
GaudiHistos::profile1DMapTitle
const Profile1DMapTitle & profile1DMapTitle() const
get access to the map of all 1D profile histograms indexed via their title
Definition: GaudiHistos.h:2587
std::string
STL class.
GaudiHistos::HistoBinEdges
GaudiAlg::HistoBinEdges HistoBinEdges
Edges for variable binning.
Definition: GaudiHistos.h:97
GaudiHistos::plot
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
Definition: GaudiHistos.h:561
GaudiAlg::ID
Definition: GaudiHistoID.h:53
GaudiHistos::histo2D
AIDA::IHistogram2D * histo2D(const std::string &title) const
access the EXISTING 2D histogram by title return the pointer to existing 2D histogram or NULL
Definition: GaudiHistos.h:2297
GaudiHistos::histo3DMapID
const Histo3DMapID & histo3DMapID() const
get access to the map of all 3D histograms index via a ID
Definition: GaudiHistos.h:2558
GaudiHistos::Profile2DMapID
GaudiAlg::Profile2DMapID Profile2DMapID
the actual type for (ID)->(2D profile histogram) mapping
Definition: GaudiHistos.h:92
GaudiHistos
Definition: GaudiHistos.h:65
GaudiHistos::plot
AIDA::IHistogram1D * plot(const double value, const Gaudi::Histo1DDef &hdef, const double weight=1.0) const
fill the 1D histogram (book on demand)
Definition: GaudiHistos.h:203
std::vector< double >
GaudiHistos::GaudiHistos
GaudiHistos(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined ...
Definition: GaudiHistos.h:2688
GaudiHistos::histo3D
AIDA::IHistogram3D * histo3D(const std::string &title) const
access the EXISTING 3D histogram by title return the pointer to existing 3D histogram or NULL
Definition: GaudiHistos.h:2305
ISvcLocator
Definition: ISvcLocator.h:46
GaudiAlg.HistoUtils.book
def book(*args, **kwargs)
Definition: HistoUtils.py:126
GaudiHistos::Histo2DMapID
GaudiAlg::Histo2DMapID Histo2DMapID
the actual type for (ID)->(2D histogram) mapping
Definition: GaudiHistos.h:77
Gaudi::Utils::Histos::Formats::header
GAUDI_API std::string header(const int ID=Default)
get the recommended header by enum
Definition: HistoTableFormat.cpp:186
GaudiHistos::m_profile1DMapTitle
Profile1DMapTitle m_profile1DMapTitle
the actual storage/access of 1D profile histograms by unique title
Definition: GaudiHistos.h:2803
GaudiHistos::m_histo2DMapTitle
Histo2DMapTitle m_histo2DMapTitle
the actual storage/access of 2D histograms by unique title
Definition: GaudiHistos.h:2793
Histos::HistoID
GaudiAlg::ID HistoID
The actual type for histogram identifier.
Definition: HistoID.h:33
GaudiHistos::histoExists
bool histoExists(const std::string &title) const
check the existence AND validity of the histogram with given title
Definition: GaudiHistos.h:2365
GaudiHistos::histo
AIDA::IHistogram1D * histo(const HistoID &ID) const
access the EXISTING 1D histogram by ID
Definition: GaudiHistos.h:2340
GaudiHistos::Histo1DMapTitle
GaudiAlg::Histo1DMapTitle Histo1DMapTitle
the actual type for title->(1D histogram) mapping
Definition: GaudiHistos.h:74
GaudiHistos::m_profile1DMapID
Profile1DMapID m_profile1DMapID
the actual storage/access of 1D profile histograms by unique ID
Definition: GaudiHistos.h:2805
GaudiHistos::setHistoTopDir
void setHistoTopDir(const std::string &val)
set top-level histogram directory (property "HistoTopDir")
Definition: GaudiHistos.h:2676
GaudiHistos::histo1DMapID
const Histo1DMapID & histo1DMapID() const
get access to the map of all 1D histograms index via ID
Definition: GaudiHistos.h:2458
GaudiHistos::produceHistos
bool produceHistos() const
get the flag for histogram production (property "HistoProduce")
Definition: GaudiHistos.h:2381
GaudiHistos::Histo3DMapTitle
GaudiAlg::Histo3DMapTitle Histo3DMapTitle
the actual type for title->(3D histogram) mapping
Definition: GaudiHistos.h:84
GaudiHistos::profile2DMapTitle
const Profile2DMapTitle & profile2DMapTitle() const
get access to the map of all 2D profile histograms indexed via their title
Definition: GaudiHistos.h:2637
GaudiHistos::histo3DMapTitle
const Histo3DMapTitle & histo3DMapTitle() const
get access to the map of all 3D histograms indexed via their title
Definition: GaudiHistos.h:2535
GaudiHistos::histoExists
bool histoExists(const HistoID &ID) const
check the existence AND validity of the histogram with given title
Definition: GaudiHistos.h:2371
GaudiHistos::m_histo3DMapID
Histo3DMapID m_histo3DMapID
the actual storage/access of 3D histograms by unique ID
Definition: GaudiHistos.h:2800
GaudiHistos::Profile1DMapTitle
GaudiAlg::Profile1DMapTitle Profile1DMapTitle
the actual type for title->(1D profile histogram) mapping
Definition: GaudiHistos.h:89
GaudiHistos::fullDetail
bool fullDetail() const
get flag to control output level of histograms
Definition: GaudiHistos.h:2383
GaudiHistos::setProduceHistos
void setProduceHistos(const bool val)
set the flag for histogram production (property "HistoProduce")
Definition: GaudiHistos.h:2665
GaudiHistos::Profile1DMapID
GaudiAlg::Profile1DMapID Profile1DMapID
the actual type for (ID)->(1D profile histogram) mapping
Definition: GaudiHistos.h:87
GaudiHistos::Histo1DMapID
GaudiAlg::Histo1DMapID Histo1DMapID
the actual type for (ID)->(1D histogram) mapping
Definition: GaudiHistos.h:72
GaudiHistos::setHistoOffSet
void setHistoOffSet(const HistoID::NumericID val)
set a value for histogram offset (property "HistoOffSet"
Definition: GaudiHistos.h:2673
GaudiHistos::m_histo1DMapTitle
Histo1DMapTitle m_histo1DMapTitle
the actual storage/access of 1D histograms by unique title
Definition: GaudiHistos.h:2788
Gaudi::Histo1DDef
Definition: HistoDef.h:41
GaudiHistos::Histo3DMapID
GaudiAlg::Histo3DMapID Histo3DMapID
the actual type for (ID)->(3D histogram) mapping
Definition: GaudiHistos.h:82
StatusCode
Definition: StatusCode.h:65
GaudiAlg::HistoBinEdges
std::vector< double > HistoBinEdges
Type for bin edges for variable binning histograms.
Definition: HistoID.h:42
GaudiHistos::setHistoDir
void setHistoDir(const std::string &val)
set histogram directory (property "HistoDir")
Definition: GaudiHistos.h:2679
GaudiHistos::profile1DMapID
const Profile1DMapID & profile1DMapID() const
get access to the map of 1D profile histograms index via a ID
Definition: GaudiHistos.h:2610
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:235
GaudiHistos::histo2DMapID
const Histo2DMapID & histo2DMapID() const
get access to the map of 2D histograms index via ID
Definition: GaudiHistos.h:2508
GaudiHistos::book
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
Definition: GaudiHistos.h:1900
GaudiHistos::setSplitHistoDir
void setSplitHistoDir(const bool val)
set the flag for histogram path split (property "HistoSplitDir")
Definition: GaudiHistos.h:2671
AlgSequencer.h
h
Definition: AlgSequencer.py:31
GaudiHistos::HistoID
GaudiAlg::HistoID HistoID
the actual type for histogram identifier
Definition: GaudiHistos.h:69
GaudiHistos::m_histo3DMapTitle
Histo3DMapTitle m_histo3DMapTitle
the actual storage/access of 3D histograms by unique title
Definition: GaudiHistos.h:2798
GaudiHistos::book
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
Definition: GaudiHistos.h:1859
GaudiHistos::plot
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...
Definition: GaudiHistos.h:645
GaudiHistos::plot
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
Definition: GaudiHistos.h:403
GaudiHistos::histo
AIDA::IHistogram1D * histo(const std::string &title) const
access the EXISTING 1D histogram by title
Definition: GaudiHistos.h:2292
gaudirun.level
level
Definition: gaudirun.py:364
GaudiHistos::histoDir
const std::string & histoDir() const
get histogram directory (property "HistoDir")
Definition: GaudiHistos.h:2393
Gaudi::Utils::Histos::Formats::format
GAUDI_API std::string format(const int ID=Default)
get the format by enum
Definition: HistoTableFormat.cpp:153
GaudiHistos::setCheckForNaN
void setCheckForNaN(const bool val)
set the flag for NaN checks (property "HistoCheckForNan")
Definition: GaudiHistos.h:2669
MSG::Level
Level
Definition: IMessageSvc.h:25
gaudirun.type
type
Definition: gaudirun.py:160
HistoProperty.h
GaudiHistos::histoOffSet
HistoID::NumericID histoOffSet() const
get the value for histogram offset (property "HistoOffSet")
Definition: GaudiHistos.h:2389
GaudiHistos::plot
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)
Definition: GaudiHistos.h:335
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:76
GaudiHistos::m_profile2DMapID
Profile2DMapID m_profile2DMapID
the actual storage/access of 2D profile histograms by unique ID
Definition: GaudiHistos.h:2810
Maps.h
GaudiAlg::ID::NumericID
int NumericID
type for internal numeric ID
Definition: GaudiHistoID.h:57
MSG::ALWAYS
@ ALWAYS
Definition: IMessageSvc.h:25
GaudiAlgorithm.h
GaudiHistos::m_histo1DMapID
Histo1DMapID m_histo1DMapID
the actual storage/access of 1D histograms by unique ID
Definition: GaudiHistos.h:2790
GaudiHistos::plot
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)
Definition: GaudiHistos.h:162
Gaudi::StateMachine::INITIALIZED
@ INITIALIZED
Definition: StateMachine.h:25
GaudiHistos::Histo2DMapTitle
GaudiAlg::Histo2DMapTitle Histo2DMapTitle
the actual type for title->(2D histogram) mapping
Definition: GaudiHistos.h:79
IInterface
Definition: IInterface.h:237
GaudiHistos::GaudiHistos
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...
Definition: GaudiHistos.h:2693
GaudiHistos::splitHistoDir
bool splitHistoDir() const
get the flag for histogram path split (property "HistoSplitDir")
Definition: GaudiHistos.h:2387
GaudiHistos::plot
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
Definition: GaudiHistos.h:475
DataObject
Definition: DataObject.h:40
GaudiHistos::checkForNaN
bool checkForNaN() const
get the flag for NaN checks (property "HistoCheckForNan")
Definition: GaudiHistos.h:2385
GaudiHistos::profile2DMapID
const Profile2DMapID & profile2DMapID() const
get access to the map of 2D profile histograms index via a ID
Definition: GaudiHistos.h:2660
GaudiHistos::histo1D
AIDA::IHistogram1D * histo1D(const std::string &title) const
access the EXISTING 1D histogram by title return the pointer to existing 1D histogram or NULL
Definition: GaudiHistos.h:2280
GaudiHistos::useNumericAutoIDs
bool useNumericAutoIDs() const
Use old style sequencial numerical automatically assigned IDs ?
Definition: GaudiHistos.h:2401
GaudiHistos::Profile2DMapTitle
GaudiAlg::Profile2DMapTitle Profile2DMapTitle
the actual type for title->(2D profile histogram) mapping
Definition: GaudiHistos.h:94
Gaudi::Utils::Histos::fill
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Definition: Fill.cpp:45
GaudiHistos::m_histo2DMapID
Histo2DMapID m_histo2DMapID
the actual storage/access of 2D histograms by unique ID
Definition: GaudiHistos.h:2795
GaudiUtils::HashMap
Definition: HashMap.h:83
GaudiHistos::profile2D
AIDA::IProfile2D * profile2D(const std::string &title) const
access the EXISTING 2D profile histogram by title return the pointer to existing 2D profile histogram...
Definition: GaudiHistos.h:2321
GaudiHistos::histoCountersPrint
bool histoCountersPrint() const
print histogram counters at finalization ?
Definition: GaudiHistos.h:2399
GaudiHistos::histosPrint
bool histosPrint() const
print histograms at finalization ?
Definition: GaudiHistos.h:2397
HistoTableFormat.h
GaudiHistos::profile1D
AIDA::IProfile1D * profile1D(const std::string &title) const
access the EXISTING 1D profile histogram by title return the pointer to existing 1D profile histogram...
Definition: GaudiHistos.h:2313
GaudiHistos::histo2DMapTitle
const Histo2DMapTitle & histo2DMapTitle() const
get access to the map of all 2D histograms indexed via their title
Definition: GaudiHistos.h:2485
std::numeric_limits
GaudiHistos::plot
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)
Definition: GaudiHistos.h:290
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::Property< bool >
GaudiHistos::histoTopDir
const std::string & histoTopDir() const
get top-level histogram directory (property "HistoTopDir")
Definition: GaudiHistos.h:2391
GaudiHistos::m_profile2DMapTitle
Profile2DMapTitle m_profile2DMapTitle
the actual storage/access of 2D profile histograms by unique title
Definition: GaudiHistos.h:2808
GaudiHistos::setFullDetail
void setFullDetail(const bool val)
set flag to control output level of histograms
Definition: GaudiHistos.h:2667