| The Gaudi Framework v32r1 (f65d50dc)

GaudiHistos.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_GAUDIHISTOS_H
2 #define GAUDIALG_GAUDIHISTOS_H 1
3 // ============================================================================
4 /* @file GaudiHistos.h
5 *
6 * Header file for class : GaudiHistos
7 *
8 * @author Chris Jones Christopher.Rob.Jones@cern.ch
9 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru
10 * @date 2005-08-08
11 */
12 // ============================================================================
13 // Include files#
14 // ============================================================================
15 // STD& STL
16 // ============================================================================
17 #include <boost/algorithm/string/replace.hpp>
18 #include <limits>
19 #include <type_traits>
20 #include <vector>
21 // ============================================================================
22 // GaudiUtils
23 // ============================================================================
24 #include "GaudiUtils/HistoTableFormat.h"
25 // ============================================================================
26 // GaudiAlg
27 // ============================================================================
28 #include "GaudiAlg/GaudiAlgorithm.h"
29 #include "GaudiAlg/GaudiTool.h"
30 #include "GaudiAlg/Maps.h"
31 // ============================================================================
32 // GaudiKernel
33 // ============================================================================
34 #include "GaudiKernel/HistoProperty.h"
35 // ============================================================================
36 // Forward declarations
37 namespace AIDA {
38 class IHistogram1D;
39 class IHistogram2D;
40 class IHistogram3D;
41 class IProfile1D;
42 class IProfile2D;
43 } // namespace AIDA
44 // ============================================================================
54 template <class PBASE>
55 class GAUDI_API GaudiHistos : public PBASE {
56 public:
57 // ==========================================================================
59 typedef GaudiAlg::HistoID HistoID;
60 // ==========================================================================
62 typedef GaudiAlg::Histo1DMapID Histo1DMapID;
64 typedef GaudiAlg::Histo1DMapTitle Histo1DMapTitle;
65 // ==========================================================================
67 typedef GaudiAlg::Histo2DMapID Histo2DMapID;
69 typedef GaudiAlg::Histo2DMapTitle Histo2DMapTitle;
70 // ==========================================================================
72 typedef GaudiAlg::Histo3DMapID Histo3DMapID;
74 typedef GaudiAlg::Histo3DMapTitle Histo3DMapTitle;
75 // ==========================================================================
77 typedef GaudiAlg::Profile1DMapID Profile1DMapID;
79 typedef GaudiAlg::Profile1DMapTitle Profile1DMapTitle;
80 // ==========================================================================
82 typedef GaudiAlg::Profile2DMapID Profile2DMapID;
84 typedef GaudiAlg::Profile2DMapTitle Profile2DMapTitle;
85 // ==========================================================================
87 typedef GaudiAlg::HistoBinEdges HistoBinEdges;
88 // ==========================================================================
89 public:
90 // ==========================================================================
91 // ================================= 1D Histograms ==========================
92 // ================================= Fixed Binning ==========================
93 // ==========================================================================
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;
138 // ==========================================================================
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 );
155 }
156 // ==========================================================================
181 AIDA::IHistogram1D* plot1D( const double value, const Gaudi::Histo1DDef& hdef, const double weight = 1.0 ) const;
182 // ==========================================================================
193 inline AIDA::IHistogram1D* plot( const double value, const Gaudi::Histo1DDef& hdef,
194 const double weight = 1.0 ) const {
195 return plot1D( value, hdef, weight );
196 }
197 // ==========================================================================
262 // ==========================================================================
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;
265 // ==========================================================================
280 inline AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const std::string& title, const double low,
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 );
284 }
285 // ==========================================================================
311 AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const Gaudi::Histo1DDef& hdef,
312 const double weight = 1.0 ) const;
313 // ==========================================================================
325 inline AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const Gaudi::Histo1DDef& hdef,
326 const double weight = 1.0 ) const {
327 return plot1D( value, ID, hdef, weight );
328 }
392 template <class FUNCTION, class OBJECT>
393 inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title,
394 const double low, const double high, const unsigned long bins = 100 ) const {
395 AIDA::IHistogram1D* h = nullptr;
396 if ( produceHistos() ) {
397 // retrieve or book the histogram
398 h = histo1D( title );
399 if ( !h ) { h = book1D( title, low, high, bins ); }
400 // fill histogram
401 while ( first != last && h ) {
402 h = fill( h, func( *first ), 1.0, title );
403 ++first;
404 }
405 }
406 return h;
407 }
408 // ==========================================================================
464 template <class FUNCTION, class OBJECT>
465 inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
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() ) {
470 // retrieve or book the histogram
471 h = histo1D( ID );
472 if ( !h ) { h = book1D( ID, title, low, high, bins ); }
473 // fill histogram
474 while ( first != last && h ) {
475 h = fill( h, func( *first ), 1.0, title );
476 ++first;
477 }
478 }
479 return h;
480 }
481 // ==========================================================================
550 template <class FUNCTION, class OBJECT, class WEIGHT>
551 inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title,
552 const double low, const double high, const unsigned long bins,
553 const WEIGHT& weight ) const {
554 AIDA::IHistogram1D* h = nullptr;
555 if ( produceHistos() ) {
556 // retrieve or book the histogram
557 h = histo1D( title );
558 if ( !h ) { h = book1D( title, low, high, bins ); }
559 // fill histogram
560 while ( first != last && h ) {
561 h = fill( h, func( *first ), weight( *first ), title );
562 ++first;
563 }
564 }
565 return h;
566 }
567 // ==========================================================================
634 template <class FUNCTION, class OBJECT, class WEIGHT>
635 inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
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() ) {
640 // retrieve or book the histogram
641 h = histo1D( ID );
642 if ( !h ) { h = book1D( ID, title, low, high, bins ); }
643 // fill histogram
644 while ( first != last && h ) {
645 h = fill( h, func( *first ), weight( *first ), title );
646 ++first;
647 }
648 }
649 return h;
650 }
651 // ==========================================================================
652 // ================================= 1D Histograms ==========================
653 // =============================== Variable Binning =========================
654 // ==========================================================================
694 AIDA::IHistogram1D* plot1D( const double value, const std::string& title, const HistoBinEdges& edges,
695 const double weight = 1.0 ) const;
696 // ==========================================================================
760 // ==========================================================================
761 AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const std::string& title,
762 const HistoBinEdges& edges, const double weight = 1.0 ) const;
763 // ==========================================================================
764 // ================================= 2D Histograms ==========================
765 // ==========================================================================
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;
819 // ==========================================================================
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;
900 // ==========================================================================
901 // ================================= 2D Histograms ==========================
902 // =============================== Variable Binning =========================
903 // ==========================================================================
949 AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const std::string& title,
950 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
951 const double weight = 1.0 ) const;
952 // ==========================================================================
1028 AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const HistoID& ID, const std::string& title,
1029 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
1030 const double weight = 1.0 ) const;
1031 // ==========================================================================
1032 // ================================= 3D Histograms ==========================
1033 // ==========================================================================
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;
1097 // ==========================================================================
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;
1189 // ==========================================================================
1190 // ================================= 3D Histograms ==========================
1191 // =============================== Variable Binning =========================
1192 // ==========================================================================
1240 AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const std::string& title,
1241 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ,
1242 const double weight = 1.0 ) const;
1243 // ==========================================================================
1244 // ==========================================================================
1329 AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const HistoID& ID,
1330 const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
1331 const HistoBinEdges& edgesZ, const double weight = 1.0 ) const;
1332 // ==========================================================================
1333 // ================================= 1D Profile =============================
1334 // ================================= Fixed binning ==========================
1335 // ==========================================================================
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 = "",
1386 const double lowY = -std::numeric_limits<double>::max(),
1387 const double highY = std::numeric_limits<double>::max(),
1388 const double weight = 1.0 ) const;
1389 // ==========================================================================
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,
1457 const std::string& opt = "", const double lowY = -std::numeric_limits<double>::max(),
1458 const double highY = std::numeric_limits<double>::max(),
1459 const double weight = 1.0 ) const;
1460 // ==========================================================================
1461 // ================================= 1D Profile =============================
1462 // ============================== Variable binning ==========================
1463 // ==========================================================================
1506 AIDA::IProfile1D* profile1D( const double valueX, const double valueY, const std::string& title,
1507 const HistoBinEdges& edges, const double weight = 1.0 ) const;
1508 // ==========================================================================
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;
1572 // ==========================================================================
1573 // ================================= 2D Profile =============================
1574 // ==========================================================================
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;
1629 // ==========================================================================
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;
1701 // ==========================================================================
1702 // ================================= 2D Profile =============================
1703 // ============================== Variable binning ==========================
1704 // ==========================================================================
1750 AIDA::IProfile2D* profile2D( const double valueX, const double valueY, const double valueZ, const std::string& title,
1751 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
1752 const double weight = 1.0 ) const;
1753 // ==========================================================================
1816 AIDA::IProfile2D* profile2D( const double valueX, const double valueY, const double valueZ, const HistoID& ID,
1817 const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
1818 const double weight = 1.0 ) const;
1819 // ==========================================================================
1820
1821 public: // 1D Fixed
1822 // ==========================================================================
1834 AIDA::IHistogram1D* book1D( const std::string& title, const double low = 0, const double high = 100,
1835 const unsigned long bins = 100 ) const;
1836 // ==========================================================================
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 );
1852 }
1853 // ==========================================================================
1862 AIDA::IHistogram1D* book( const Gaudi::Histo1DDef& hdef ) const;
1863 // ==========================================================================
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;
1876 // ==========================================================================
1890 inline AIDA::IHistogram1D* book( const HistoID& ID, const std::string& title, const double low = 0,
1891 const double high = 100, const unsigned long bins = 100 ) const {
1892 return book1D( ID, title, low, high, bins );
1893 }
1894 // ==========================================================================
1902 inline AIDA::IHistogram1D* book( const HistoID& ID, const Gaudi::Histo1DDef& hdef ) const;
1903 // ==========================================================================
1904
1905 public: // 1D Variable
1906 // ==========================================================================
1917 AIDA::IHistogram1D* book1D( const std::string& title, const HistoBinEdges& edges ) const;
1918 // ==========================================================================
1928 AIDA::IHistogram1D* book1D( const HistoID& ID, const std::string& title, const HistoBinEdges& edges ) const;
1929 // ==========================================================================
1930
1931 public: // 2D Fixed
1932 // ==========================================================================
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;
1950 // ==========================================================================
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;
1964 // ==========================================================================
1965
1966 public: // 2D Variable
1967 // ==========================================================================
1979 AIDA::IHistogram2D* book2D( const std::string& title, const HistoBinEdges& edgesX,
1980 const HistoBinEdges& edgesY ) const;
1981 // ==========================================================================
1992 AIDA::IHistogram2D* book2D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX,
1993 const HistoBinEdges& edgesY ) const;
1994 // ==========================================================================
1995
1996 public: // 3D Fixed
1997 // ==========================================================================
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;
2019 // ==========================================================================
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;
2040 // ==========================================================================
2041
2042 public: // 3D Variable
2043 // ==========================================================================
2056 AIDA::IHistogram3D* book3D( const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
2057 const HistoBinEdges& edgesZ ) const;
2058 // ==========================================================================
2070 AIDA::IHistogram3D* book3D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX,
2071 const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ ) const;
2072 // ==========================================================================
2073
2074 public: // 1D Fixed Profiles
2075 // ==========================================================================
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 = "",
2092 const double lowY = -std::numeric_limits<double>::max(),
2093 const double highY = std::numeric_limits<double>::max() ) const;
2094 // ==========================================================================
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 = "",
2112 const double lowY = -std::numeric_limits<double>::max(),
2113 const double highY = std::numeric_limits<double>::max() ) const;
2114 // ==========================================================================
2115
2116 public: // 1D Variable Profiles
2117 // ==========================================================================
2127 AIDA::IProfile1D* bookProfile1D( const std::string& title, const HistoBinEdges& edges ) const;
2128 // ==========================================================================
2138 AIDA::IProfile1D* bookProfile1D( const HistoID& ID, const std::string& title, const HistoBinEdges& edges ) const;
2139 // ==========================================================================
2140
2141 public: // 2D Profiles
2142 // ==========================================================================
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;
2160 // ==========================================================================
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;
2177 // ==========================================================================
2178
2179 public: // 2D Profiles
2180 // ==========================================================================
2191 AIDA::IProfile2D* bookProfile2D( const std::string& title, const HistoBinEdges& edgesX,
2192 const HistoBinEdges& edgesY ) const;
2193 // ==========================================================================
2203 AIDA::IProfile2D* bookProfile2D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX,
2204 const HistoBinEdges& edgesY ) const;
2205 // ==========================================================================
2206
2207 public:
2208 // ==========================================================================
2216 AIDA::IHistogram1D* fill( AIDA::IHistogram1D* histo, const double value, const double weight,
2217 const std::string& title = "" ) const;
2218 // ==========================================================================
2227 AIDA::IHistogram2D* fill( AIDA::IHistogram2D* histo, const double valueX, const double valueY, const double weight,
2228 const std::string& title = "" ) const;
2229 // ==========================================================================
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;
2241 // ==========================================================================
2250 AIDA::IProfile1D* fill( AIDA::IProfile1D* histo, const double valueX, const double valueY, const double weight,
2251 const std::string& title = "" ) const;
2252 // ==========================================================================
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;
2264 // ==========================================================================
2265 public:
2266 // ==========================================================================
2270 inline AIDA::IHistogram1D* histo1D( const std::string& title ) const {
2271 auto found = histo1DMapTitle().find( title );
2272 return found != histo1DMapTitle().end() ? found->second : nullptr;
2273 }
2274 // ==========================================================================
2282 inline AIDA::IHistogram1D* histo( const std::string& title ) const { return histo1D( title ); }
2283 // ==========================================================================
2287 inline AIDA::IHistogram2D* histo2D( const std::string& title ) const {
2288 auto found = histo2DMapTitle().find( title );
2289 return histo2DMapTitle().end() != found ? found->second : nullptr;
2290 }
2291 // ==========================================================================
2295 inline AIDA::IHistogram3D* histo3D( const std::string& title ) const {
2296 auto found = histo3DMapTitle().find( title );
2297 return histo3DMapTitle().end() != found ? found->second : nullptr;
2298 }
2299 // ==========================================================================
2303 inline AIDA::IProfile1D* profile1D( const std::string& title ) const {
2304 auto found = profile1DMapTitle().find( title );
2305 return profile1DMapTitle().end() != found ? found->second : nullptr;
2306 }
2307 // ==========================================================================
2311 inline AIDA::IProfile2D* profile2D( const std::string& title ) const {
2312 auto found = profile2DMapTitle().find( title );
2313 return profile2DMapTitle().end() != found ? found->second : nullptr;
2314 }
2315 // ==========================================================================
2316 public:
2317 // ==========================================================================
2321 AIDA::IHistogram1D* histo1D( const HistoID& ID ) const;
2322 // ==========================================================================
2330 inline AIDA::IHistogram1D* histo( const HistoID& ID ) const { return histo1D( ID ); }
2331 // ==========================================================================
2335 AIDA::IHistogram2D* histo2D( const HistoID& ID ) const;
2336 // ==========================================================================
2340 AIDA::IHistogram3D* histo3D( const HistoID& ID ) const;
2341 // ==========================================================================
2345 AIDA::IProfile1D* profile1D( const HistoID& ID ) const;
2346 // ==========================================================================
2350 AIDA::IProfile2D* profile2D( const HistoID& ID ) const;
2351 // ==========================================================================
2352 public:
2353 // ==========================================================================
2355 inline bool histoExists( const std::string& title ) const {
2356 return ( 0 != histo( title ) || 0 != histo2D( title ) || 0 != histo3D( title ) || 0 != profile1D( title ) ||
2357 0 != profile2D( title ) );
2358 }
2359 // ==========================================================================
2361 inline bool histoExists( const HistoID& ID ) const {
2362 return ( 0 != histo( ID ) || 0 != histo2D( ID ) || 0 != histo3D( ID ) || 0 != profile1D( ID ) ||
2363 0 != profile2D( ID ) );
2364 }
2366 unsigned int totalNumberOfHistos() const;
2367 // ==========================================================================
2368 public: // trivial & non-trivial accessors
2369 // ==========================================================================
2371 inline bool produceHistos() const { return m_produceHistos; }
2373 inline bool fullDetail() const { return m_fullDetail; }
2375 inline bool checkForNaN() const { return m_checkForNaN; }
2377 inline bool splitHistoDir() const { return m_splitHistoDir; }
2379 inline HistoID::NumericID histoOffSet() const { return m_histoOffSet; }
2381 inline const std::string& histoTopDir() const { return m_histoTopDir; }
2383 inline const std::string& histoDir() const { return m_histoDir; }
2385 std::string histoPath() const;
2387 inline bool histosPrint() const { return m_histosPrint; }
2389 inline bool histoCountersPrint() const { return m_histoCountersPrint; }
2391 inline bool useNumericAutoIDs() const { return m_useNumericAutoIDs; }
2392 // ==========================================================================
2397 int printHistos( const MSG::Level level = MSG::ALWAYS ) const;
2398 // ==========================================================================
2424 const Histo1DMapTitle& histo1DMapTitle() const { return m_histo1DMapTitle; }
2425 // ==========================================================================
2448 const Histo1DMapID& histo1DMapID() const { return m_histo1DMapID; }
2449 // ==========================================================================
2475 const Histo2DMapTitle& histo2DMapTitle() const { return m_histo2DMapTitle; }
2476 // ==========================================================================
2498 const Histo2DMapID& histo2DMapID() const { return m_histo2DMapID; }
2499 // ==========================================================================
2525 const Histo3DMapTitle& histo3DMapTitle() const { return m_histo3DMapTitle; }
2526 // ==========================================================================
2548 const Histo3DMapID& histo3DMapID() const { return m_histo3DMapID; }
2549 // ==========================================================================
2577 const Profile1DMapTitle& profile1DMapTitle() const { return m_profile1DMapTitle; }
2578 // ==========================================================================
2600 const Profile1DMapID& profile1DMapID() const { return m_profile1DMapID; }
2601 // ==========================================================================
2627 const Profile2DMapTitle& profile2DMapTitle() const { return m_profile2DMapTitle; }
2628 // ==========================================================================
2650 const Profile2DMapID& profile2DMapID() const { return m_profile2DMapID; }
2651 // ==========================================================================
2652 public: // trivial setters
2653 // ==========================================================================
2655 inline void setProduceHistos( const bool val ) { m_produceHistos = val; }
2657 inline void setFullDetail( const bool val ) { m_fullDetail = val; }
2659 inline void setCheckForNaN( const bool val ) { m_checkForNaN = val; }
2661 inline void setSplitHistoDir( const bool val ) { m_splitHistoDir = val; }
2663 inline void setHistoOffSet( const HistoID::NumericID val ) { m_histoOffSet = val; }
2664 // ==========================================================================
2666 inline void setHistoTopDir( const std::string& val ) { m_histoTopDir = val; }
2667 // ==========================================================================
2669 inline void setHistoDir( const std::string& val ) { m_histoDir = val; }
2670 // ==========================================================================
2671 public:
2672 // FIXME: due to a bug in gcc7, the following two cannot be replaced with
2673 // using PBASE::PBASE...
2674 // ==========================================================================
2677 template <typename U = PBASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, PBASE>, U>>
2678 GaudiHistos( const std::string& name, ISvcLocator* pSvcLocator ) : PBASE( name, pSvcLocator ) {}
2679 // ==========================================================================
2682 template <typename U = PBASE, typename = std::enable_if_t<std::is_base_of_v<GaudiTool, PBASE>, U>>
2683 GaudiHistos( const std::string& type, const std::string& name, const IInterface* parent )
2684 : PBASE( type, name, parent ) {}
2685 // ==========================================================================
2686 protected:
2687 // ==========================================================================
2691 StatusCode initialize() override
2692 #ifdef __ICC
2693 {
2694 return i_ghInitialize();
2695 }
2696 StatusCode i_ghInitialize()
2697 #endif
2698 ;
2699 // ==========================================================================
2703 StatusCode finalize() override
2704 #ifdef __ICC
2705 {
2706 return i_ghFinalize();
2707 }
2708 StatusCode i_ghFinalize()
2709 #endif
2710 ;
2711 // ==========================================================================
2712 private:
2713 // ==========================================================================
2715 bool noHistos() const;
2716 // ===========================================unsigned===============================
2722 void monitorHisto( const AIDA::IBaseHistogram* hist, const HistoID& ID ) const;
2723 // ==========================================================================
2728 void newHistoID( const std::string& title, HistoID& ID ) const;
2729 // ==========================================================================
2730 protected:
2731 // ==========================================================================
2733 std::string convertTitleToID( std::string title ) const;
2734 // ==========================================================================
2735 private:
2736 Gaudi::Property<bool> m_produceHistos{this, "HistoProduce", true, "Switch on/off the production of histograms"};
2737 Gaudi::Property<bool> m_histosPrint{this, "HistoPrint", false,
2738 [this]( const auto& ) {
2739 // no action if not yet initialized
2740 if ( this->FSMState() >= Gaudi::StateMachine::INITIALIZED &&
2741 this->histosPrint() )
2742 this->printHistos( MSG::ALWAYS );
2743 },
2744 "Switch on/off the printout of histograms at finalization"};
2745 Gaudi::Property<bool> m_histoCountersPrint{this, "HistoCountersPrint", true,
2746 "Switch on/off the printout of histogram counters at finalization"};
2747 Gaudi::Property<bool> m_checkForNaN{this, "HistoCheckForNaN", true,
2748 "Switch on/off the checks for NaN and Infinity for histogram fill"};
2749 Gaudi::Property<bool> m_splitHistoDir{this, "HistoSplitDir", false,
2750 "Split long directory names into short pieces (suitable for HBOOK)"};
2751 Gaudi::Property<HistoID::NumericID> m_histoOffSet{
2752 this, "HistoOffSet", 0, "OffSet for automatically assigned histogram numerical identifiers "};
2753 Gaudi::Property<std::string> m_histoTopDir{this, "HistoTopDir", "",
2754 "Top level histogram directory (take care that it ends with '/')"};
2755 Gaudi::Property<std::string> m_histoDir{
2756 this, "HistoDir", boost::algorithm::replace_all_copy( this->name(), ":", "_" ), "Histogram Directory"};
2757 Gaudi::Property<bool> m_fullDetail{this, "FullDetail", false};
2758 Gaudi::Property<bool> m_declareMoniHists{this, "MonitorHistograms", true};
2759 Gaudi::Property<std::string> m_histo1DTableFormat{this, "FormatFor1DHistoTable",
2760 Gaudi::Utils::Histos::Formats::format(),
2761 "Format string for printout of 1D histograms"};
2762 Gaudi::Property<std::string> m_histo1DTableFormatShort{this, "ShortFormatFor1DHistoTable", " | %1$-25.25s %2%",
2763 "Format string for printout of 1D histograms"};
2764 Gaudi::Property<std::string> m_histo1DTableHeader{this, "HeaderFor1DHistoTable",
2765 Gaudi::Utils::Histos::Formats::header(),
2766 "The table header for printout of 1D histograms "};
2767 Gaudi::Property<bool> m_useNumericAutoIDs{
2768 this, "UseSequencialNumericAutoIDs", false,
2769 "Flag to allow users to switch back to the old style of creating numerical automatic IDs"};
2770 Gaudi::Property<std::map<std::string, std::string>> m_idReplaceInfo{
2771 this,
2772 "AutoStringIDPurgeMap",
2773 {{"/", "=SLASH="}},
2774 "Map of strings to search and replace when using the title "
2775 "as the basis of automatically generated literal IDs"};
2776 // ==========================================================================
2778 mutable Histo1DMapTitle m_histo1DMapTitle;
2780 mutable Histo1DMapID m_histo1DMapID;
2781 // ==========================================================================
2783 mutable Histo2DMapTitle m_histo2DMapTitle;
2785 mutable Histo2DMapID m_histo2DMapID;
2786 // ==========================================================================
2788 mutable Histo3DMapTitle m_histo3DMapTitle;
2790 mutable Histo3DMapID m_histo3DMapID;
2791 // ==========================================================================
2793 mutable Profile1DMapTitle m_profile1DMapTitle;
2795 mutable Profile1DMapID m_profile1DMapID;
2796 // ==========================================================================
2798 mutable Profile2DMapTitle m_profile2DMapTitle;
2800 mutable Profile2DMapID m_profile2DMapID;
2801 // ==========================================================================
2802 };
2803 // ============================================================================
2804 // The END
2805 // ============================================================================
2806 #endif // GAUDIALG_GAUDIHISTOS_H
GaudiHistos::setFullDetail
void setFullDetail(const bool val)
set flag to control output level of histograms
Definition: GaudiHistos.h:2657
GaudiHistos::histoTopDir
const std::string & histoTopDir() const
get top-level histogram directory (property "HistoTopDir")
Definition: GaudiHistos.h:2381
GaudiHistos::histo
AIDA::IHistogram1D * histo(const std::string &title) const
access the EXISTING 1D histogram by title
Definition: GaudiHistos.h:2282
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:15
GaudiHistos::Histo3DMapID
GaudiAlg::Histo3DMapID Histo3DMapID
the actual type for (ID)->(3D histogram) mapping
Definition: GaudiHistos.h:72
GaudiHistos::histo2DMapTitle
const Histo2DMapTitle & histo2DMapTitle() const
get access to the map of all 2D histograms indexed via their title
Definition: GaudiHistos.h:2475
GaudiTool.h
Header file for class GaudiAlgorithm.
GaudiHistos::histo3DMapID
const Histo3DMapID & histo3DMapID() const
get access to the map of all 3D histograms index via a ID
Definition: GaudiHistos.h:2548
GaudiHistos::Histo1DMapTitle
GaudiAlg::Histo1DMapTitle Histo1DMapTitle
the actual type for title->(1D histogram) mapping
Definition: GaudiHistos.h:64
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
GaudiHistos::histo3DMapTitle
const Histo3DMapTitle & histo3DMapTitle() const
get access to the map of all 3D histograms indexed via their title
Definition: GaudiHistos.h:2525
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:152
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Histos::book
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:87
GaudiAlg::HistoBinEdges
std::vector< double > HistoBinEdges
Type for bin edges for variable binning histograms.
Definition: HistoID.h:31
GaudiHistos::m_profile1DMapID
Profile1DMapID m_profile1DMapID
the actual storage/access of 1D profile histograms by unique ID
Definition: GaudiHistos.h:2795
GaudiHistos::Profile1DMapTitle
GaudiAlg::Profile1DMapTitle Profile1DMapTitle
the actual type for title->(1D profile histogram) mapping
Definition: GaudiHistos.h:79
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
GaudiHistos::profile2DMapID
const Profile2DMapID & profile2DMapID() const
get access to the map of 2D profile histograms index via a ID
Definition: GaudiHistos.h:2650
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:635
Histos::HistoID
GaudiAlg::ID HistoID
The actual type for histogram identifier.
Definition: HistoID.h:22
GaudiHistos::HistoID
GaudiAlg::HistoID HistoID
the actual type for histogram identifier
Definition: GaudiHistos.h:59
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:2303
GaudiHistos::fullDetail
bool fullDetail() const
get flag to control output level of histograms
Definition: GaudiHistos.h:2373
GaudiAlgorithm.h
Header file for class GaudiAlgorithm.
GaudiHistos::m_histo1DMapID
Histo1DMapID m_histo1DMapID
the actual storage/access of 1D histograms by unique ID
Definition: GaudiHistos.h:2780
GaudiAlg::ID::NumericID
int NumericID
type for internal numeric ID
Definition: GaudiHistoID.h:47
HistoTableFormat.h
GaudiHistos::m_histo3DMapTitle
Histo3DMapTitle m_histo3DMapTitle
the actual storage/access of 3D histograms by unique title
Definition: GaudiHistos.h:2788
HistoProperty.h
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:35
GaudiHistos::histoDir
const std::string & histoDir() const
get histogram directory (property "HistoDir")
Definition: GaudiHistos.h:2383
GaudiHistos::setHistoOffSet
void setHistoOffSet(const HistoID::NumericID val)
set a value for histogram offset (property "HistoOffSet"
Definition: GaudiHistos.h:2663
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:393
GaudiHistos::Histo3DMapTitle
GaudiAlg::Histo3DMapTitle Histo3DMapTitle
the actual type for title->(3D histogram) mapping
Definition: GaudiHistos.h:74
GaudiHistos::Profile2DMapID
GaudiAlg::Profile2DMapID Profile2DMapID
the actual type for (ID)->(2D profile histogram) mapping
Definition: GaudiHistos.h:82
GaudiHistos::Profile1DMapID
GaudiAlg::Profile1DMapID Profile1DMapID
the actual type for (ID)->(1D profile histogram) mapping
Definition: GaudiHistos.h:77
GaudiHistos::HistoBinEdges
GaudiAlg::HistoBinEdges HistoBinEdges
Edges for variable binning.
Definition: GaudiHistos.h:87
GaudiHistos::m_histo2DMapTitle
Histo2DMapTitle m_histo2DMapTitle
the actual storage/access of 2D histograms by unique title
Definition: GaudiHistos.h:2783
Gaudi::Utils::Histos::Formats::header
GAUDI_API std::string header(const int ID=Default)
get the recommended header by enum
Definition: HistoTableFormat.cpp:187
AIDA
GaudiKernel.
Definition: Fill.h:10
GaudiHistos::setProduceHistos
void setProduceHistos(const bool val)
set the flag for histogram production (property "HistoProduce")
Definition: GaudiHistos.h:2655
GaudiHistos::profile1DMapID
const Profile1DMapID & profile1DMapID() const
get access to the map of 1D profile histograms index via a ID
Definition: GaudiHistos.h:2600
GaudiHistos::Profile2DMapTitle
GaudiAlg::Profile2DMapTitle Profile2DMapTitle
the actual type for title->(2D profile histogram) mapping
Definition: GaudiHistos.h:84
std::string
STL class.
GaudiHistos::setCheckForNaN
void setCheckForNaN(const bool val)
set the flag for NaN checks (property "HistoCheckForNan")
Definition: GaudiHistos.h:2659
GaudiHistos::histo
AIDA::IHistogram1D * histo(const HistoID &ID) const
access the EXISTING 1D histogram by ID
Definition: GaudiHistos.h:2330
GaudiHistos::histosPrint
bool histosPrint() const
print histograms at finalization ?
Definition: GaudiHistos.h:2387
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:551
MSG::Level
Level
Definition: IMessageSvc.h:15
GaudiHistos::m_profile1DMapTitle
Profile1DMapTitle m_profile1DMapTitle
the actual storage/access of 1D profile histograms by unique title
Definition: GaudiHistos.h:2793
GaudiHistos::histoExists
bool histoExists(const std::string &title) const
check the existence AND validity of the histogram with given title
Definition: GaudiHistos.h:2355
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:325
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:2270
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:2311
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:211
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
IInterface
Definition of the basic interface.
Definition: IInterface.h:244
gaudirun.type
type
Definition: gaudirun.py:142
Gaudi::Utils::Histos::Formats::format
GAUDI_API std::string format(const int ID=Default)
get the format by enum
Definition: HistoTableFormat.cpp:154
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:280
Gaudi::Histo1DDef
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:31
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:2683
GaudiHistos::histoOffSet
HistoID::NumericID histoOffSet() const
get the value for histogram offset (property "HistoOffSet")
Definition: GaudiHistos.h:2379
GaudiHistos::Histo1DMapID
GaudiAlg::Histo1DMapID Histo1DMapID
the actual type for (ID)->(1D histogram) mapping
Definition: GaudiHistos.h:62
GaudiHistos::histoCountersPrint
bool histoCountersPrint() const
print histogram counters at finalization ?
Definition: GaudiHistos.h:2389
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:2287
GaudiHistos::m_profile2DMapID
Profile2DMapID m_profile2DMapID
the actual storage/access of 2D profile histograms by unique ID
Definition: GaudiHistos.h:2800
GaudiHistos::histoExists
bool histoExists(const HistoID &ID) const
check the existence AND validity of the histogram with given title
Definition: GaudiHistos.h:2361
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:465
GaudiHistos::Histo2DMapTitle
GaudiAlg::Histo2DMapTitle Histo2DMapTitle
the actual type for title->(2D histogram) mapping
Definition: GaudiHistos.h:69
Maps.h
GaudiHistos::setSplitHistoDir
void setSplitHistoDir(const bool val)
set the flag for histogram path split (property "HistoSplitDir")
Definition: GaudiHistos.h:2661
GaudiHistos::checkForNaN
bool checkForNaN() const
get the flag for NaN checks (property "HistoCheckForNan")
Definition: GaudiHistos.h:2375
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:2678
GaudiHistos::profile1DMapTitle
const Profile1DMapTitle & profile1DMapTitle() const
get access to the map of all 1D profile histograms indexed via their title
Definition: GaudiHistos.h:2577
GaudiHistos::m_histo1DMapTitle
Histo1DMapTitle m_histo1DMapTitle
the actual storage/access of 1D histograms by unique title
Definition: GaudiHistos.h:2778
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:2295
GaudiHistos::m_profile2DMapTitle
Profile2DMapTitle m_profile2DMapTitle
the actual storage/access of 2D profile 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:1849
GaudiHistos::setHistoTopDir
void setHistoTopDir(const std::string &val)
set top-level histogram directory (property "HistoTopDir")
Definition: GaudiHistos.h:2666
GaudiHistos::Histo2DMapID
GaudiAlg::Histo2DMapID Histo2DMapID
the actual type for (ID)->(2D histogram) mapping
Definition: GaudiHistos.h:67
GaudiHistos::m_histo3DMapID
Histo3DMapID m_histo3DMapID
the actual storage/access of 3D histograms by unique ID
Definition: GaudiHistos.h:2790
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:193
GaudiHistos::histo1DMapTitle
const Histo1DMapTitle & histo1DMapTitle() const
get access to the map of all 1D histograms indexed via their title
Definition: GaudiHistos.h:2424
GaudiHistos::splitHistoDir
bool splitHistoDir() const
get the flag for histogram path split (property "HistoSplitDir")
Definition: GaudiHistos.h:2377
GaudiUtils::HashMap
Common class providing an architecture-independent hash map.
Definition: HashMap.h:73
gaudirun.level
level
Definition: gaudirun.py:334
GaudiHistos::m_histo2DMapID
Histo2DMapID m_histo2DMapID
the actual storage/access of 2D histograms by unique ID
Definition: GaudiHistos.h:2785
GaudiHistos::histo1DMapID
const Histo1DMapID & histo1DMapID() const
get access to the map of all 1D histograms index via ID
Definition: GaudiHistos.h:2448
GaudiHistos::setHistoDir
void setHistoDir(const std::string &val)
set histogram directory (property "HistoDir")
Definition: GaudiHistos.h:2669
GaudiHistos
Templated base class providing common histogramming methods for GaudiAlgorithm and GaudiTool like cla...
Definition: GaudiHistos.h:55
GaudiHistos::profile2DMapTitle
const Profile2DMapTitle & profile2DMapTitle() const
get access to the map of all 2D profile histograms indexed via their title
Definition: GaudiHistos.h:2627
GaudiHistos::useNumericAutoIDs
bool useNumericAutoIDs() const
Use old style sequencial numerical automatically assigned IDs ?
Definition: GaudiHistos.h:2391
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:1890
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
MSG::ALWAYS
Definition: IMessageSvc.h:15
GaudiAlg::ID
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:43
GaudiHistos::produceHistos
bool produceHistos() const
get the flag for histogram production (property "HistoProduce")
Definition: GaudiHistos.h:2371
GaudiHistos::histo2DMapID
const Histo2DMapID & histo2DMapID() const
get access to the map of 2D histograms index via ID
Definition: GaudiHistos.h:2498
std::numeric_limits