| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
18 class IHistogram1D;
19 class IHistogram2D;
20 class IHistogram3D;
21 }
22
31 class GAUDI_API IHistoTool : virtual public IAlgTool
32 {
33 public:
35 DeclareInterfaceID( IHistoTool, 2, 0 );
36
38 typedef Histos::HistoID HistoID;
39
40 public:
41 // ================================= 1D Histograms ========================================
42
71 virtual AIDA::IHistogram1D* plot1D( const double value, const std::string& title, const double low, const double high,
72 const unsigned long bins = 100, const double weight = 1.0 ) const = 0;
73
87 AIDA::IHistogram1D* plot( const double value, const std::string& title, const double low, const double high,
88 const unsigned long bins = 100, const double weight = 1.0 ) const
89 {
90 return plot1D( value, title, low, high, bins, weight );
91 }
92
133 virtual AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const std::string& title, const double low,
134 const double high, const unsigned long bins = 100,
135 const double weight = 1.0 ) const = 0;
136
151 AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const std::string& title, const double low,
152 const double high, const unsigned long bins = 100, const double weight = 1.0 ) const
153 {
154 return plot1D( value, ID, title, low, high, bins, weight );
155 };
156
157 // ================================= 2D Histograms ========================================
158
193 virtual AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const std::string& title,
194 const double lowX, const double highX, const double lowY, const double highY,
195 const unsigned long binsX = 50, const unsigned long binsY = 50,
196 const double weight = 1.0 ) const = 0;
197
244 virtual AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const HistoID& ID,
245 const std::string& title, const double lowX, const double highX,
246 const double lowY, const double highY, const unsigned long binsX = 50,
247 const unsigned long binsY = 50, const double weight = 1.0 ) const = 0;
248
249 // ================================= 3D Histograms ========================================
250
291 virtual AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ,
292 const std::string& title, const double lowX, const double highX,
293 const double lowY, const double highY, const double lowZ, const double highZ,
294 const unsigned long binsX = 10, const unsigned long binsY = 10,
295 const unsigned long binsZ = 10, const double weight = 1.0 ) const = 0;
296
349 virtual AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const HistoID& ID,
350 const std::string& title, const double lowX, const double highX,
351 const double lowY, const double highY, const double lowZ, const double highZ,
352 const unsigned long binsX = 10, const unsigned long binsY = 10,
353 const unsigned long binsZ = 10, const double weight = 1.0 ) const = 0;
354
355 public:
367 virtual AIDA::IHistogram1D* book1D( const std::string& title, const double low = 0, const double high = 100,
368 const unsigned long bins = 100 ) const = 0;
369
382 AIDA::IHistogram1D* book( const std::string& title, const double low = 0, const double high = 100,
383 const unsigned long bins = 100 ) const
384 {
385 return book1D( title, low, high, bins );
386 }
387
402 virtual AIDA::IHistogram2D* book2D( const std::string& title, const double lowX = 0, const double highX = 100,
403 const unsigned long binsX = 50, const double lowY = 0, const double highY = 100,
404 const unsigned long binsY = 50 ) const = 0;
405
423 virtual AIDA::IHistogram3D* book3D( const std::string& title, const double lowX = 0, const double highX = 100,
424 const unsigned long binsX = 10, const double lowY = 0, const double highY = 100,
425 const unsigned long binsY = 10, const double lowZ = 0, const double highZ = 100,
426 const unsigned long binsZ = 10 ) const = 0;
427
438 virtual AIDA::IHistogram1D* book1D( const HistoID& ID, const std::string& title = "", const double low = 0,
439 const double high = 100, const unsigned long bins = 100 ) const = 0;
440
454 AIDA::IHistogram1D* book( const HistoID& ID, const std::string& title = "", const double low = 0,
455 const double high = 100, const unsigned long bins = 100 ) const
456 {
457 return book1D( ID, title, low, high, bins );
458 }
459
470 virtual AIDA::IHistogram2D* book2D( const HistoID& ID, const std::string& title, const double lowX = 0,
471 const double highX = 100, const unsigned long binsX = 100, const double lowY = 0,
472 const double highY = 100, const unsigned long binsY = 100 ) const = 0;
473
490 virtual AIDA::IHistogram3D* book3D( const HistoID& ID, const std::string& title, const double lowX = 0,
491 const double highX = 100, const unsigned long binsX = 10, const double lowY = 0,
492 const double highY = 100, const unsigned long binsY = 10, const double lowZ = 0,
493 const double highZ = 100, const unsigned long binsZ = 10 ) const = 0;
494
502 virtual AIDA::IHistogram1D* fill( AIDA::IHistogram1D* histo, const double value, const double weight,
503 const std::string& title = "" ) const = 0;
504
513 virtual AIDA::IHistogram2D* fill( AIDA::IHistogram2D* histo, const double valueX, const double valueY,
514 const double weight, const std::string& title = "" ) const = 0;
515
525 virtual AIDA::IHistogram3D* fill( AIDA::IHistogram3D* histo, const double valueX, const double valueY,
526 const double valueZ, const double weight, const std::string& title = "" ) const = 0;
527
531 virtual AIDA::IHistogram1D* histo1D( const std::string& title ) const = 0;
532
540 AIDA::IHistogram1D* histo( const std::string& title ) const { return histo1D( title ); };
541
545 virtual AIDA::IHistogram2D* histo2D( const std::string& title ) const = 0;
546
550 virtual AIDA::IHistogram3D* histo3D( const std::string& title ) const = 0;
551
555 virtual AIDA::IHistogram1D* histo1D( const HistoID& ID ) const = 0;
556
564 AIDA::IHistogram1D* histo( const HistoID& ID ) const { return histo1D( ID ); };
565
569 virtual AIDA::IHistogram2D* histo2D( const HistoID& ID ) const = 0;
570
574 virtual AIDA::IHistogram3D* histo3D( const HistoID& ID ) const = 0;
575
577 virtual bool histoExists( const std::string& title ) const = 0;
578
580 virtual bool histoExists( const HistoID& ID ) const = 0;
581
582 public:
632 template <class FUNCTION, class OBJECT>
633 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, const double low,
634 const double high, const unsigned long bins = 100 ) const
635 {
636 // retrieve or book the histogram
637 AIDA::IHistogram1D* h = histo1D( title );
638 if ( !h ) {
639 h = book1D( title, low, high, bins );
640 }
641 while ( first != last && h ) {
642 h = fill( h, func( *first ), 1.0, title );
643 ++first;
644 }
645 return h;
646 }
647
697 template <class FUNCTION, class OBJECT>
698 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
699 const std::string& title, const double low, const double high,
700 const unsigned long bins = 100 ) const
701 {
702 // retrieve or book the histogram
703 AIDA::IHistogram1D* h = histo1D( ID );
704 if ( !h ) {
705 h = book1D( ID, title, low, high, bins );
706 }
707 while ( first != last && h ) {
708 h = fill( h, func( *first ), 1.0, title );
709 ++first;
710 }
711 return h;
712 }
713
768 template <class FUNCTION, class OBJECT, class WEIGHT>
769 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, const double low,
770 const double high, const unsigned long bins, const WEIGHT& weight ) const
771 {
772 // retrieve or book the histogram
773 AIDA::IHistogram1D* h = histo1D( title );
774 if ( !h ) {
775 h = book1D( title, low, high, bins );
776 }
777 while ( first != last && h ) {
778 h = fill( h, func( *first ), weight( *first ), title );
779 ++first;
780 }
781 return h;
782 }
783
843 template <class FUNCTION, class OBJECT, class WEIGHT>
844 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID,
845 const std::string& title, const double low, const double high, const unsigned long bins,
846 const WEIGHT& weight ) const
847 {
848 // retrieve or book the histogram
849 AIDA::IHistogram1D* h = histo1D( ID );
850 if ( !h ) {
851 h = book1D( ID, title, low, high, bins );
852 }
853 while ( first != last && h ) {
854 h = fill( h, func( *first ), weight( *first ), title );
855 ++first;
856 }
857 return h;
858 }
859
860 protected:
861 ~IHistoTool() override = default;
862 };
863
864 #endif // GAUDIALG_IHISTOTOOL_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, const WEIGHT &weight) const
book and fill the 1D histogram with information from [first,last) sequence with given weight ...
Definition: IHistoTool.h:769
IHistoTool::histo
AIDA::IHistogram1D * histo(const HistoID &ID) const
access the EXISTING 1D histogram by ID
Definition: IHistoTool.h:564
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:151
IHistoTool::histo
AIDA::IHistogram1D * histo(const std::string &title) const
access the EXISTING 1D histogram by title
Definition: IHistoTool.h:540
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 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:698
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:454
AIDA
GaudiKernel.
Definition: Fill.h:10
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:844
std::string
STL class.
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:382
HistoID.h
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:229
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
DeclareInterfaceID
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:13
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:633
IAlgTool.h
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:87
IHistoTool::HistoID
Histos::HistoID HistoID
the actual type for histogram identifier (HBOOK style)
Definition: IHistoTool.h:38
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
GaudiAlg::ID
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:44
IHistoTool
An abstract interface for "histogramming tool".
Definition: IHistoTool.h:31