The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IHistoTool.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_IHISTOTOOL_H
12 #define GAUDIALG_IHISTOTOOL_H 1
13 // ============================================================================
14 // Include files
15 // ============================================================================
16 // from STL
17 // ============================================================================
18 #include <string>
19 // ============================================================================
20 // from Gaudi
21 // ============================================================================
22 #include "GaudiAlg/HistoID.h"
23 #include "GaudiKernel/IAlgTool.h"
24 // ============================================================================
25 
26 namespace AIDA {
27  class IHistogram1D;
28  class IHistogram2D;
29  class IHistogram3D;
30 } // namespace AIDA
31 
40 class GAUDI_API IHistoTool : virtual public IAlgTool {
41 public:
44 
47 
48 public:
49  // ================================= 1D Histograms ========================================
50 
79  virtual AIDA::IHistogram1D* plot1D( const double value, const std::string& title, const double low, const double high,
80  const unsigned long bins = 100, const double weight = 1.0 ) const = 0;
81 
95  AIDA::IHistogram1D* plot( const double value, const std::string& title, const double low, const double high,
96  const unsigned long bins = 100, const double weight = 1.0 ) const {
97  return plot1D( value, title, low, high, bins, weight );
98  }
99 
140  virtual AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const std::string& title, const double low,
141  const double high, const unsigned long bins = 100,
142  const double weight = 1.0 ) const = 0;
143 
158  AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const std::string& title, const double low,
159  const double high, const unsigned long bins = 100, const double weight = 1.0 ) const {
160  return plot1D( value, ID, title, low, high, bins, weight );
161  };
162 
163  // ================================= 2D Histograms ========================================
164 
199  virtual AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const std::string& title,
200  const double lowX, const double highX, const double lowY, const double highY,
201  const unsigned long binsX = 50, const unsigned long binsY = 50,
202  const double weight = 1.0 ) const = 0;
203 
250  virtual AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const HistoID& ID,
251  const std::string& title, const double lowX, const double highX,
252  const double lowY, const double highY, const unsigned long binsX = 50,
253  const unsigned long binsY = 50, const double weight = 1.0 ) const = 0;
254 
255  // ================================= 3D Histograms ========================================
256 
297  virtual AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ,
298  const std::string& title, const double lowX, const double highX,
299  const double lowY, const double highY, const double lowZ, const double highZ,
300  const unsigned long binsX = 10, const unsigned long binsY = 10,
301  const unsigned long binsZ = 10, const double weight = 1.0 ) const = 0;
302 
355  virtual AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const HistoID& ID,
356  const std::string& title, const double lowX, const double highX,
357  const double lowY, const double highY, const double lowZ, const double highZ,
358  const unsigned long binsX = 10, const unsigned long binsY = 10,
359  const unsigned long binsZ = 10, const double weight = 1.0 ) const = 0;
360 
361 public:
373  virtual AIDA::IHistogram1D* book1D( const std::string& title, const double low = 0, const double high = 100,
374  const unsigned long bins = 100 ) const = 0;
375 
388  AIDA::IHistogram1D* book( const std::string& title, const double low = 0, const double high = 100,
389  const unsigned long bins = 100 ) const {
390  return book1D( title, low, high, bins );
391  }
392 
407  virtual AIDA::IHistogram2D* book2D( const std::string& title, const double lowX = 0, const double highX = 100,
408  const unsigned long binsX = 50, const double lowY = 0, const double highY = 100,
409  const unsigned long binsY = 50 ) const = 0;
410 
428  virtual AIDA::IHistogram3D* book3D( const std::string& title, const double lowX = 0, const double highX = 100,
429  const unsigned long binsX = 10, const double lowY = 0, const double highY = 100,
430  const unsigned long binsY = 10, const double lowZ = 0, const double highZ = 100,
431  const unsigned long binsZ = 10 ) const = 0;
432 
443  virtual AIDA::IHistogram1D* book1D( const HistoID& ID, const std::string& title = "", const double low = 0,
444  const double high = 100, const unsigned long bins = 100 ) const = 0;
445 
459  AIDA::IHistogram1D* book( const HistoID& ID, const std::string& title = "", const double low = 0,
460  const double high = 100, const unsigned long bins = 100 ) const {
461  return book1D( ID, title, low, high, bins );
462  }
463 
474  virtual AIDA::IHistogram2D* book2D( const HistoID& ID, const std::string& title, const double lowX = 0,
475  const double highX = 100, const unsigned long binsX = 100, const double lowY = 0,
476  const double highY = 100, const unsigned long binsY = 100 ) const = 0;
477 
494  virtual AIDA::IHistogram3D* book3D( const HistoID& ID, const std::string& title, const double lowX = 0,
495  const double highX = 100, const unsigned long binsX = 10, const double lowY = 0,
496  const double highY = 100, const unsigned long binsY = 10, const double lowZ = 0,
497  const double highZ = 100, const unsigned long binsZ = 10 ) const = 0;
498 
506  virtual AIDA::IHistogram1D* fill( AIDA::IHistogram1D* histo, const double value, const double weight,
507  const std::string& title = "" ) const = 0;
508 
517  virtual AIDA::IHistogram2D* fill( AIDA::IHistogram2D* histo, const double valueX, const double valueY,
518  const double weight, const std::string& title = "" ) const = 0;
519 
529  virtual AIDA::IHistogram3D* fill( AIDA::IHistogram3D* histo, const double valueX, const double valueY,
530  const double valueZ, const double weight, const std::string& title = "" ) const = 0;
531 
535  virtual AIDA::IHistogram1D* histo1D( const std::string& title ) const = 0;
536 
544  AIDA::IHistogram1D* histo( const std::string& title ) const { return histo1D( title ); };
545 
549  virtual AIDA::IHistogram2D* histo2D( const std::string& title ) const = 0;
550 
554  virtual AIDA::IHistogram3D* histo3D( const std::string& title ) const = 0;
555 
559  virtual AIDA::IHistogram1D* histo1D( const HistoID& ID ) const = 0;
560 
568  AIDA::IHistogram1D* histo( const HistoID& ID ) const { return histo1D( ID ); };
569 
573  virtual AIDA::IHistogram2D* histo2D( const HistoID& ID ) const = 0;
574 
578  virtual AIDA::IHistogram3D* histo3D( const HistoID& ID ) const = 0;
579 
581  virtual bool histoExists( const std::string& title ) const = 0;
582 
584  virtual bool histoExists( const HistoID& ID ) const = 0;
585 
586 public:
636  template <class FUNCTION, class OBJECT>
637  AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, const double low,
638  const double high, const unsigned long bins = 100 ) const {
639  // retrieve or book the histogram
640  AIDA::IHistogram1D* h = histo1D( title );
641  if ( !h ) { h = book1D( title, low, high, bins ); }
642  while ( first != last && h ) {
643  h = fill( h, func( *first ), 1.0, title );
644  ++first;
645  }
646  return h;
647  }
648 
698  template <class FUNCTION, class OBJECT>
699  AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
700  const std::string& title, const double low, const double high,
701  const unsigned long bins = 100 ) const {
702  // retrieve or book the histogram
703  AIDA::IHistogram1D* h = histo1D( ID );
704  if ( !h ) { h = book1D( ID, title, low, high, bins ); }
705  while ( first != last && h ) {
706  h = fill( h, func( *first ), 1.0, title );
707  ++first;
708  }
709  return h;
710  }
711 
766  template <class FUNCTION, class OBJECT, class WEIGHT>
767  AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, const double low,
768  const double high, const unsigned long bins, const WEIGHT& weight ) const {
769  // retrieve or book the histogram
770  AIDA::IHistogram1D* h = histo1D( title );
771  if ( !h ) { h = book1D( title, low, high, bins ); }
772  while ( first != last && h ) {
773  h = fill( h, func( *first ), weight( *first ), title );
774  ++first;
775  }
776  return h;
777  }
778 
838  template <class FUNCTION, class OBJECT, class WEIGHT>
839  AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
840  const std::string& title, const double low, const double high, const unsigned long bins,
841  const WEIGHT& weight ) const {
842  // retrieve or book the histogram
843  AIDA::IHistogram1D* h = histo1D( ID );
844  if ( !h ) { h = book1D( ID, title, low, high, bins ); }
845  while ( first != last && h ) {
846  h = fill( h, func( *first ), weight( *first ), title );
847  ++first;
848  }
849  return h;
850  }
851 };
852 
853 #endif // GAUDIALG_IHISTOTOOL_H
AIDA
GaudiKernel.
Definition: Fill.h:20
IHistoTool::book1D
virtual AIDA::IHistogram1D * book1D(const std::string &title, const double low=0, const double high=100, const unsigned long bins=100) const =0
book the 1D histogram
std::string
STL class.
IAlgTool
Definition: IAlgTool.h:33
GaudiAlg::ID
Definition: GaudiHistoID.h:53
IHistoTool::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: IHistoTool.h:637
IHistoTool::book2D
virtual AIDA::IHistogram2D * book2D(const HistoID &ID, const std::string &title, const double lowX=0, const double highX=100, const unsigned long binsX=100, const double lowY=0, const double highY=100, const unsigned long binsY=100) const =0
book the 2D histogram with forced ID
IHistoTool::plot1D
virtual AIDA::IHistogram1D * plot1D(const double value, const std::string &title, const double low, const double high, const unsigned long bins=100, const double weight=1.0) const =0
fill the 1D histogram (book on demand)
IHistoTool::histo2D
virtual AIDA::IHistogram2D * histo2D(const HistoID &ID) const =0
access the EXISTING 2D histogram by ID return the pointer to existing 2D histogram or NULL
IHistoTool::book3D
virtual AIDA::IHistogram3D * book3D(const std::string &title, const double lowX=0, const double highX=100, const unsigned long binsX=10, const double lowY=0, const double highY=100, const unsigned long binsY=10, const double lowZ=0, const double highZ=100, const unsigned long binsZ=10) const =0
book the 3D histogram
IHistoTool::DeclareInterfaceID
DeclareInterfaceID(IHistoTool, 2, 0)
InterfaceID.
IHistoTool::fill
virtual AIDA::IHistogram3D * fill(AIDA::IHistogram3D *histo, const double valueX, const double valueY, const double valueZ, const double weight, const std::string &title="") const =0
fill the 3D histo with the value and weight
IHistoTool
Definition: IHistoTool.h:40
IHistoTool::histo1D
virtual AIDA::IHistogram1D * histo1D(const HistoID &ID) const =0
access the EXISTING 1D histogram by ID return the pointer to existing 1D histogram or NULL
IHistoTool::histoExists
virtual bool histoExists(const std::string &title) const =0
check the existence AND validity of the histogram with given title
IHistoTool::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: IHistoTool.h:699
IHistoTool::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: IHistoTool.h:459
IHistoTool::HistoID
Histos::HistoID HistoID
the actual type for histogram identifier (HBOOK style)
Definition: IHistoTool.h:46
IHistoTool::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: IHistoTool.h:158
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:235
IAlgTool.h
AlgSequencer.h
h
Definition: AlgSequencer.py:31
IHistoTool::plot2D
virtual AIDA::IHistogram2D * plot2D(const double valueX, const double valueY, const std::string &title, const double lowX, const double highX, const double lowY, const double highY, const unsigned long binsX=50, const unsigned long binsY=50, const double weight=1.0) const =0
fill the 2D histogram (book on demand)
IHistoTool::plot3D
virtual AIDA::IHistogram3D * plot3D(const double valueX, const double valueY, const double valueZ, const HistoID &ID, const std::string &title, const double lowX, const double highX, const double lowY, const double highY, const double lowZ, const double highZ, const unsigned long binsX=10, const unsigned long binsY=10, const unsigned long binsZ=10, const double weight=1.0) const =0
fill the 3D histogram with forced ID assignment (book on demand)
IHistoTool::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: IHistoTool.h:839
IHistoTool::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: IHistoTool.h:388
IHistoTool::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: IHistoTool.h:767
IHistoTool::histo3D
virtual AIDA::IHistogram3D * histo3D(const HistoID &ID) const =0
access the EXISTING 3D histogram by ID return the pointer to existing 3D histogram or NULL
IHistoTool::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: IHistoTool.h:95
IHistoTool::book2D
virtual AIDA::IHistogram2D * book2D(const std::string &title, const double lowX=0, const double highX=100, const unsigned long binsX=50, const double lowY=0, const double highY=100, const unsigned long binsY=50) const =0
book the 2D histogram
IHistoTool::histo2D
virtual AIDA::IHistogram2D * histo2D(const std::string &title) const =0
access the EXISTING 2D histogram by title return the pointer to existing 2D histogram or NULL
IHistoTool::fill
virtual AIDA::IHistogram2D * fill(AIDA::IHistogram2D *histo, const double valueX, const double valueY, const double weight, const std::string &title="") const =0
fill the 2D histo with the value and weight
IHistoTool::book3D
virtual AIDA::IHistogram3D * book3D(const HistoID &ID, const std::string &title, const double lowX=0, const double highX=100, const unsigned long binsX=10, const double lowY=0, const double highY=100, const unsigned long binsY=10, const double lowZ=0, const double highZ=100, const unsigned long binsZ=10) const =0
book the 3D histogram with forced ID
IHistoTool::histo
AIDA::IHistogram1D * histo(const std::string &title) const
access the EXISTING 1D histogram by title
Definition: IHistoTool.h:544
DataObject
Definition: DataObject.h:40
IHistoTool::histo1D
virtual AIDA::IHistogram1D * histo1D(const std::string &title) const =0
access the EXISTING 1D histogram by title return the pointer to existing 1D histogram or NULL
IHistoTool::plot2D
virtual AIDA::IHistogram2D * plot2D(const double valueX, const double valueY, const HistoID &ID, const std::string &title, const double lowX, const double highX, const double lowY, const double highY, const unsigned long binsX=50, const unsigned long binsY=50, const double weight=1.0) const =0
fill the 2D histogram with forced ID assignment (book on demand)
HistoID.h
IHistoTool::histo3D
virtual AIDA::IHistogram3D * histo3D(const std::string &title) const =0
access the EXISTING 3D histogram by title return the pointer to existing 3D histogram or NULL
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
IHistoTool::histo
AIDA::IHistogram1D * histo(const HistoID &ID) const
access the EXISTING 1D histogram by ID
Definition: IHistoTool.h:568
IHistoTool::plot1D
virtual AIDA::IHistogram1D * plot1D(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 =0
fill the 1D histogram with forced ID assignement (book on demand)
IHistoTool::book1D
virtual AIDA::IHistogram1D * book1D(const HistoID &ID, const std::string &title="", const double low=0, const double high=100, const unsigned long bins=100) const =0
book the 1D histogram with forced ID
IHistoTool::histoExists
virtual bool histoExists(const HistoID &ID) const =0
check the existence AND validity of the histogram with given title
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
IHistoTool::plot3D
virtual AIDA::IHistogram3D * plot3D(const double valueX, const double valueY, const double valueZ, const std::string &title, const double lowX, const double highX, const double lowY, const double highY, const double lowZ, const double highZ, const unsigned long binsX=10, const unsigned long binsY=10, const unsigned long binsZ=10, const double weight=1.0) const =0
fill the 3D histogram (book on demand)
IHistoTool::fill
virtual AIDA::IHistogram1D * fill(AIDA::IHistogram1D *histo, const double value, const double weight, const std::string &title="") const =0
fill the 1D histo with the value and weight