| The Gaudi Framework v32r1 (f65d50dc)

IHistoTool.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_IHISTOTOOL_H
2 #define GAUDIALG_IHISTOTOOL_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // from STL
7 // ============================================================================
8 #include <string>
9 // ============================================================================
10 // from Gaudi
11 // ============================================================================
12 #include "GaudiAlg/HistoID.h"
13 #include "GaudiKernel/IAlgTool.h"
14 // ============================================================================
15
16 namespace AIDA {
17 class IHistogram1D;
18 class IHistogram2D;
19 class IHistogram3D;
20 } // namespace AIDA
21
30 class GAUDI_API IHistoTool : virtual public IAlgTool {
31 public:
33 DeclareInterfaceID( IHistoTool, 2, 0 );
34
36 typedef Histos::HistoID HistoID;
37
38 public:
39 // ================================= 1D Histograms ========================================
40
69 virtual AIDA::IHistogram1D* plot1D( const double value, const std::string& title, const double low, const double high,
70 const unsigned long bins = 100, const double weight = 1.0 ) const = 0;
71
85 AIDA::IHistogram1D* plot( const double value, const std::string& title, const double low, const double high,
86 const unsigned long bins = 100, const double weight = 1.0 ) const {
87 return plot1D( value, title, low, high, bins, weight );
88 }
89
130 virtual AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const std::string& title, const double low,
131 const double high, const unsigned long bins = 100,
132 const double weight = 1.0 ) const = 0;
133
148 AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const std::string& title, const double low,
149 const double high, const unsigned long bins = 100, const double weight = 1.0 ) const {
150 return plot1D( value, ID, title, low, high, bins, weight );
151 };
152
153 // ================================= 2D Histograms ========================================
154
189 virtual AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const std::string& title,
190 const double lowX, const double highX, const double lowY, const double highY,
191 const unsigned long binsX = 50, const unsigned long binsY = 50,
192 const double weight = 1.0 ) const = 0;
193
240 virtual AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const HistoID& ID,
241 const std::string& title, const double lowX, const double highX,
242 const double lowY, const double highY, const unsigned long binsX = 50,
243 const unsigned long binsY = 50, const double weight = 1.0 ) const = 0;
244
245 // ================================= 3D Histograms ========================================
246
287 virtual AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ,
288 const std::string& title, const double lowX, const double highX,
289 const double lowY, const double highY, const double lowZ, const double highZ,
290 const unsigned long binsX = 10, const unsigned long binsY = 10,
291 const unsigned long binsZ = 10, const double weight = 1.0 ) const = 0;
292
345 virtual AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const HistoID& ID,
346 const std::string& title, const double lowX, const double highX,
347 const double lowY, const double highY, const double lowZ, const double highZ,
348 const unsigned long binsX = 10, const unsigned long binsY = 10,
349 const unsigned long binsZ = 10, const double weight = 1.0 ) const = 0;
350
351 public:
363 virtual AIDA::IHistogram1D* book1D( const std::string& title, const double low = 0, const double high = 100,
364 const unsigned long bins = 100 ) const = 0;
365
378 AIDA::IHistogram1D* book( const std::string& title, const double low = 0, const double high = 100,
379 const unsigned long bins = 100 ) const {
380 return book1D( title, low, high, bins );
381 }
382
397 virtual AIDA::IHistogram2D* book2D( const std::string& title, const double lowX = 0, const double highX = 100,
398 const unsigned long binsX = 50, const double lowY = 0, const double highY = 100,
399 const unsigned long binsY = 50 ) const = 0;
400
418 virtual AIDA::IHistogram3D* book3D( const std::string& title, const double lowX = 0, const double highX = 100,
419 const unsigned long binsX = 10, const double lowY = 0, const double highY = 100,
420 const unsigned long binsY = 10, const double lowZ = 0, const double highZ = 100,
421 const unsigned long binsZ = 10 ) const = 0;
422
433 virtual AIDA::IHistogram1D* book1D( const HistoID& ID, const std::string& title = "", const double low = 0,
434 const double high = 100, const unsigned long bins = 100 ) const = 0;
435
449 AIDA::IHistogram1D* book( const HistoID& ID, const std::string& title = "", const double low = 0,
450 const double high = 100, const unsigned long bins = 100 ) const {
451 return book1D( ID, title, low, high, bins );
452 }
453
464 virtual AIDA::IHistogram2D* book2D( const HistoID& ID, const std::string& title, const double lowX = 0,
465 const double highX = 100, const unsigned long binsX = 100, const double lowY = 0,
466 const double highY = 100, const unsigned long binsY = 100 ) const = 0;
467
484 virtual AIDA::IHistogram3D* book3D( const HistoID& ID, const std::string& title, const double lowX = 0,
485 const double highX = 100, const unsigned long binsX = 10, const double lowY = 0,
486 const double highY = 100, const unsigned long binsY = 10, const double lowZ = 0,
487 const double highZ = 100, const unsigned long binsZ = 10 ) const = 0;
488
496 virtual AIDA::IHistogram1D* fill( AIDA::IHistogram1D* histo, const double value, const double weight,
497 const std::string& title = "" ) const = 0;
498
507 virtual AIDA::IHistogram2D* fill( AIDA::IHistogram2D* histo, const double valueX, const double valueY,
508 const double weight, const std::string& title = "" ) const = 0;
509
519 virtual AIDA::IHistogram3D* fill( AIDA::IHistogram3D* histo, const double valueX, const double valueY,
520 const double valueZ, const double weight, const std::string& title = "" ) const = 0;
521
525 virtual AIDA::IHistogram1D* histo1D( const std::string& title ) const = 0;
526
534 AIDA::IHistogram1D* histo( const std::string& title ) const { return histo1D( title ); };
535
539 virtual AIDA::IHistogram2D* histo2D( const std::string& title ) const = 0;
540
544 virtual AIDA::IHistogram3D* histo3D( const std::string& title ) const = 0;
545
549 virtual AIDA::IHistogram1D* histo1D( const HistoID& ID ) const = 0;
550
558 AIDA::IHistogram1D* histo( const HistoID& ID ) const { return histo1D( ID ); };
559
563 virtual AIDA::IHistogram2D* histo2D( const HistoID& ID ) const = 0;
564
568 virtual AIDA::IHistogram3D* histo3D( const HistoID& ID ) const = 0;
569
571 virtual bool histoExists( const std::string& title ) const = 0;
572
574 virtual bool histoExists( const HistoID& ID ) const = 0;
575
576 public:
626 template <class FUNCTION, class OBJECT>
627 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, const double low,
628 const double high, const unsigned long bins = 100 ) const {
629 // retrieve or book the histogram
630 AIDA::IHistogram1D* h = histo1D( title );
631 if ( !h ) { h = book1D( title, low, high, bins ); }
632 while ( first != last && h ) {
633 h = fill( h, func( *first ), 1.0, title );
634 ++first;
635 }
636 return h;
637 }
638
688 template <class FUNCTION, class OBJECT>
689 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
690 const std::string& title, const double low, const double high,
691 const unsigned long bins = 100 ) const {
692 // retrieve or book the histogram
693 AIDA::IHistogram1D* h = histo1D( ID );
694 if ( !h ) { h = book1D( ID, title, low, high, bins ); }
695 while ( first != last && h ) {
696 h = fill( h, func( *first ), 1.0, title );
697 ++first;
698 }
699 return h;
700 }
701
756 template <class FUNCTION, class OBJECT, class WEIGHT>
757 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, const double low,
758 const double high, const unsigned long bins, const WEIGHT& weight ) const {
759 // retrieve or book the histogram
760 AIDA::IHistogram1D* h = histo1D( title );
761 if ( !h ) { h = book1D( title, low, high, bins ); }
762 while ( first != last && h ) {
763 h = fill( h, func( *first ), weight( *first ), title );
764 ++first;
765 }
766 return h;
767 }
768
828 template <class FUNCTION, class OBJECT, class WEIGHT>
829 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
830 const std::string& title, const double low, const double high, const unsigned long bins,
831 const WEIGHT& weight ) const {
832 // retrieve or book the histogram
833 AIDA::IHistogram1D* h = histo1D( ID );
834 if ( !h ) { h = book1D( ID, title, low, high, bins ); }
835 while ( first != last && h ) {
836 h = fill( h, func( *first ), weight( *first ), title );
837 ++first;
838 }
839 return h;
840 }
841 };
842
843 #endif // GAUDIALG_IHISTOTOOL_H
Histos::HistoID
GaudiAlg::ID HistoID
The actual type for histogram identifier.
Definition: HistoID.h:22
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:689
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
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:148
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:829
IAlgTool::DeclareInterfaceID
DeclareInterfaceID(IAlgTool, 4, 0)
InterfaceID.
AIDA
GaudiKernel.
Definition: Fill.h:10
std::string
STL class.
IHistoTool::histo
AIDA::IHistogram1D * histo(const HistoID &ID) const
access the EXISTING 1D histogram by ID
Definition: IHistoTool.h:558
HistoID.h
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:627
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:211
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:449
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:378
IAlgTool.h
IHistoTool::HistoID
Histos::HistoID HistoID
the actual type for histogram identifier (HBOOK style)
Definition: IHistoTool.h:36
IHistoTool::histo
AIDA::IHistogram1D * histo(const std::string &title) const
access the EXISTING 1D histogram by title
Definition: IHistoTool.h:534
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:757
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
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:85
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
GaudiAlg::ID
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:43
IHistoTool
An abstract interface for "histogramming tool".
Definition: IHistoTool.h:30