| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# IHistoTool.h

Go to the documentation of this file.

    00001 // $Id: IHistoTool.h,v 1.3 2005/01/18 15:51:53 mato Exp $
    00002 // ============================================================================
    00003 #ifndef GAUDIALG_IHISTOTOOL_H
    00004 #define GAUDIALG_IHISTOTOOL_H 1
    00005 // ============================================================================
    00006 // Include files
    00007 // ============================================================================
    00008 // from STL
    00009 // ============================================================================
    00010 #include <string>
    00011 // ============================================================================
    00012 // from Gaudi
    00013 // ============================================================================
    00014 #include "GaudiKernel/IAlgTool.h"
    00015 #include "GaudiAlg/HistoID.h"
    00016 // ============================================================================
    00017
    00018 namespace AIDA
    00019 {
    00020   class IHistogram1D;
    00021   class IHistogram2D;
    00022   class IHistogram3D;
    00023 }
    00024
    00033 class GAUDI_API IHistoTool: virtual public IAlgTool
    00034 {
    00035 public:
    00037   DeclareInterfaceID(IHistoTool,2,0);
    00038
    00040   typedef Histos::HistoID       HistoID       ;
    00041
    00042 public:
    00043
    00044   // ================================= 1D Histograms ========================================
    00045
    00074   virtual AIDA::IHistogram1D*  plot1D
    00075   ( const double        value        ,
    00076     const std::string&  title        ,
    00077     const double        low          ,
    00078     const double        high         ,
    00079     const unsigned long bins   = 100 ,
    00080     const double        weight = 1.0 ) const  = 0 ;
    00081
    00095   AIDA::IHistogram1D*  plot
    00096   ( const double        value        ,
    00097     const std::string&  title        ,
    00098     const double        low          ,
    00099     const double        high         ,
    00100     const unsigned long bins   = 100 ,
    00101     const double        weight = 1.0 ) const
    00102   {
    00103     return plot1D ( value, title, low, high, bins, weight );
    00104   }
    00105
    00146   virtual AIDA::IHistogram1D*  plot1D
    00147   ( const double        value        ,
    00148     const HistoID&      ID           ,
    00149     const std::string&  title        ,
    00150     const double        low          ,
    00151     const double        high         ,
    00152     const unsigned long bins   = 100 ,
    00153     const double        weight = 1.0 ) const = 0 ;
    00154
    00169   AIDA::IHistogram1D*  plot
    00170   ( const double        value        ,
    00171     const HistoID&      ID           ,
    00172     const std::string&  title        ,
    00173     const double        low          ,
    00174     const double        high         ,
    00175     const unsigned long bins   = 100 ,
    00176     const double        weight = 1.0 ) const
    00177   {
    00178     return plot1D ( value, ID, title, low, high, bins, weight );
    00179   };
    00180
    00181   // ================================= 2D Histograms ========================================
    00182
    00217   virtual AIDA::IHistogram2D*  plot2D
    00218   ( const double        valueX       ,
    00219     const double        valueY       ,
    00220     const std::string&  title        ,
    00221     const double        lowX         ,
    00222     const double        highX        ,
    00223     const double        lowY         ,
    00224     const double        highY        ,
    00225     const unsigned long binsX  = 50  ,
    00226     const unsigned long binsY  = 50  ,
    00227     const double        weight = 1.0 ) const = 0;
    00228
    00275   virtual AIDA::IHistogram2D*  plot2D
    00276   ( const double        valueX       ,
    00277     const double        valueY       ,
    00278     const HistoID&      ID           ,
    00279     const std::string&  title        ,
    00280     const double        lowX         ,
    00281     const double        highX        ,
    00282     const double        lowY         ,
    00283     const double        highY        ,
    00284     const unsigned long binsX  = 50  ,
    00285     const unsigned long binsY  = 50  ,
    00286     const double        weight = 1.0 ) const = 0;
    00287
    00288   // ================================= 3D Histograms ========================================
    00289
    00330   virtual AIDA::IHistogram3D*  plot3D
    00331   ( const double        valueX       ,
    00332     const double        valueY       ,
    00333     const double        valueZ       ,
    00334     const std::string&  title        ,
    00335     const double        lowX         ,
    00336     const double        highX        ,
    00337     const double        lowY         ,
    00338     const double        highY        ,
    00339     const double        lowZ         ,
    00340     const double        highZ        ,
    00341     const unsigned long binsX  = 10  ,
    00342     const unsigned long binsY  = 10  ,
    00343     const unsigned long binsZ  = 10  ,
    00344     const double        weight = 1.0 ) const = 0;
    00345
    00398   virtual AIDA::IHistogram3D*  plot3D
    00399   ( const double        valueX       ,
    00400     const double        valueY       ,
    00401     const double        valueZ       ,
    00402     const HistoID&      ID           ,
    00403     const std::string&  title        ,
    00404     const double        lowX         ,
    00405     const double        highX        ,
    00406     const double        lowY         ,
    00407     const double        highY        ,
    00408     const double        lowZ         ,
    00409     const double        highZ        ,
    00410     const unsigned long binsX  = 10  ,
    00411     const unsigned long binsY  = 10  ,
    00412     const unsigned long binsZ  = 10  ,
    00413     const double        weight = 1.0 ) const = 0;
    00414
    00415 public:
    00416
    00428   virtual AIDA::IHistogram1D*  book1D
    00429   ( const std::string&  title        ,
    00430     const double        low    =   0 ,
    00431     const double        high   = 100 ,
    00432     const unsigned long bins   = 100 ) const = 0 ;
    00433
    00446   AIDA::IHistogram1D*  book
    00447   ( const std::string&  title        ,
    00448     const double        low    =   0 ,
    00449     const double        high   = 100 ,
    00450     const unsigned long bins   = 100 ) const
    00451   {
    00452     return book1D( title, low, high, bins );
    00453   }
    00454
    00469   virtual AIDA::IHistogram2D*  book2D
    00470   ( const std::string&  title         ,
    00471     const double        lowX    =   0 ,
    00472     const double        highX   = 100 ,
    00473     const unsigned long binsX   =  50 ,
    00474     const double        lowY    =   0 ,
    00475     const double        highY   = 100 ,
    00476     const unsigned long binsY   =  50 ) const = 0;
    00477
    00495   virtual AIDA::IHistogram3D*  book3D
    00496   ( const std::string&  title         ,
    00497     const double        lowX    =   0 ,
    00498     const double        highX   = 100 ,
    00499     const unsigned long binsX   =  10 ,
    00500     const double        lowY    =   0 ,
    00501     const double        highY   = 100 ,
    00502     const unsigned long binsY   =  10 ,
    00503     const double        lowZ    =   0 ,
    00504     const double        highZ   = 100 ,
    00505     const unsigned long binsZ   =  10 ) const = 0;
    00506
    00517   virtual AIDA::IHistogram1D*  book1D
    00518   ( const HistoID&      ID           ,
    00519     const std::string&  title  = ""  ,
    00520     const double        low    =   0 ,
    00521     const double        high   = 100 ,
    00522     const unsigned long bins   = 100 ) const = 0 ;
    00523
    00537   AIDA::IHistogram1D*  book
    00538   ( const HistoID&      ID           ,
    00539     const std::string&  title  = ""  ,
    00540     const double        low    =   0 ,
    00541     const double        high   = 100 ,
    00542     const unsigned long bins   = 100 ) const
    00543   {
    00544     return book1D( ID, title, low, high, bins );
    00545   }
    00546
    00557   virtual AIDA::IHistogram2D*  book2D
    00558   ( const HistoID&      ID            ,
    00559     const std::string&  title         ,
    00560     const double        lowX    =   0 ,
    00561     const double        highX   = 100 ,
    00562     const unsigned long binsX   = 100 ,
    00563     const double        lowY    =   0 ,
    00564     const double        highY   = 100 ,
    00565     const unsigned long binsY   = 100 ) const = 0;
    00566
    00583   virtual AIDA::IHistogram3D*  book3D
    00584   ( const HistoID&      ID            ,
    00585     const std::string&  title         ,
    00586     const double        lowX    =   0 ,
    00587     const double        highX   = 100 ,
    00588     const unsigned long binsX   =  10 ,
    00589     const double        lowY    =   0 ,
    00590     const double        highY   = 100 ,
    00591     const unsigned long binsY   =  10 ,
    00592     const double        lowZ    =   0 ,
    00593     const double        highZ   = 100 ,
    00594     const unsigned long binsZ   =  10 ) const = 0;
    00595
    00603   virtual AIDA::IHistogram1D* fill
    00604   ( AIDA::IHistogram1D* histo  ,
    00605     const double        value  ,
    00606     const double        weight ,
    00607     const std::string&  title  = "") const = 0 ;
    00608
    00617   virtual AIDA::IHistogram2D* fill
    00618   ( AIDA::IHistogram2D* histo  ,
    00619     const double        valueX ,
    00620     const double        valueY ,
    00621     const double        weight ,
    00622     const std::string&  title  = "" ) const = 0 ;
    00623
    00633   virtual AIDA::IHistogram3D* fill
    00634   ( AIDA::IHistogram3D* histo  ,
    00635     const double        valueX ,
    00636     const double        valueY ,
    00637     const double        valueZ ,
    00638     const double        weight ,
    00639     const std::string&  title  = "" ) const = 0 ;
    00640
    00644   virtual AIDA::IHistogram1D*  histo1D ( const std::string& title  )  const = 0 ;
    00645
    00653   AIDA::IHistogram1D* histo ( const std::string& title  )  const
    00654   {
    00655     return histo1D( title );
    00656   };
    00657
    00661   virtual AIDA::IHistogram2D* histo2D ( const std::string& title  )  const = 0;
    00662
    00663
    00667   virtual AIDA::IHistogram3D* histo3D ( const std::string& title  )  const = 0;
    00668
    00672   virtual AIDA::IHistogram1D*  histo1D ( const HistoID&     ID     )  const = 0 ;
    00673
    00681   AIDA::IHistogram1D* histo ( const HistoID&     ID     )  const
    00682   {
    00683     return histo1D( ID );
    00684   };
    00685
    00689   virtual AIDA::IHistogram2D* histo2D ( const HistoID&     ID     )  const = 0;
    00690
    00694   virtual AIDA::IHistogram3D* histo3D ( const HistoID&     ID     )  const = 0;
    00695
    00697   virtual bool histoExists ( const std::string& title  )  const = 0 ;
    00698
    00700   virtual bool histoExists ( const HistoID&     ID     )  const = 0 ;
    00701
    00702 public:  // non-virtual methods
    00703
    00753   template <class FUNCTION,class OBJECT>
    00754   AIDA::IHistogram1D*  plot
    00755   ( const FUNCTION&     func         ,
    00756     OBJECT              first        ,
    00757     OBJECT              last         ,
    00758     const std::string&  title        ,
    00759     const double        low          ,
    00760     const double        high         ,
    00761     const unsigned long bins  = 100  ) const
    00762   {
    00763     // retrieve or book the histogram
    00764     AIDA::IHistogram1D* h = histo1D ( title ) ;
    00765     if ( 0 == h )     { h = book1D  ( title , low , high , bins ); }
    00766     while ( first != last && 0 != h  )
    00767     { h = fill ( h , func( *first ) , 1.0 , title  ) ; ++first ; }
    00768     return h ;
    00769   }
    00770
    00820   template <class FUNCTION,class OBJECT>
    00821   AIDA::IHistogram1D*  plot
    00822   ( const FUNCTION&     func         ,
    00823     OBJECT              first        ,
    00824     OBJECT              last         ,
    00825     const HistoID&      ID           ,
    00826     const std::string&  title        ,
    00827     const double        low          ,
    00828     const double        high         ,
    00829     const unsigned long bins  = 100  ) const
    00830   {
    00831     // retrieve or book the histogram
    00832     AIDA::IHistogram1D* h = histo1D ( ID ) ;
    00833     if ( 0 == h )     { h = book1D  ( ID , title , low , high , bins ); }
    00834     while ( first != last && 0 != h )
    00835     { h = fill( h , func( *first ) , 1.0 , title  ) ; ++first ; }
    00836     return h ;
    00837   }
    00838
    00893   template <class FUNCTION,class OBJECT,class WEIGHT>
    00894   AIDA::IHistogram1D*  plot
    00895   ( const FUNCTION&     func         ,
    00896     OBJECT              first        ,
    00897     OBJECT              last         ,
    00898     const std::string&  title        ,
    00899     const double        low          ,
    00900     const double        high         ,
    00901     const unsigned long bins         ,
    00902     const WEIGHT&       weight       ) const
    00903   {
    00904     // retrieve or book the histogram
    00905     AIDA::IHistogram1D* h = histo1D ( title ) ;
    00906     if ( 0 == h     ) { h = book1D  ( title , low , high , bins ); }
    00907     while( first != last && 0 != h )
    00908     { h = fill ( h                 ,
    00909                  func   ( *first ) ,
    00910                  weight ( *first ) , title  ) ; ++first ; }
    00911     return h ;
    00912   }
    00913
    00973   template <class FUNCTION,class OBJECT,class WEIGHT>
    00974   AIDA::IHistogram1D*  plot
    00975   ( const FUNCTION&     func         ,
    00976     OBJECT              first        ,
    00977     OBJECT              last         ,
    00978     const HistoID&      ID           ,
    00979     const std::string&  title        ,
    00980     const double        low          ,
    00981     const double        high         ,
    00982     const unsigned long bins         ,
    00983     const WEIGHT&       weight       ) const
    00984   {
    00985     // retrieve or book the histogram
    00986     AIDA::IHistogram1D* h = histo1D ( ID ) ;
    00987     if ( 0 == h     ) { h = book1D  ( ID , title , low , high , bins ); }
    00988     while( first != last && 0 != h )
    00989     { h  = fill ( h                 ,
    00990                   func   ( *first ) ,
    00991                   weight ( *first ) , title  ) ; ++first ; }
    00992     return h ;
    00993   }
    00994
    00995 protected:
    00996
    00997   virtual ~IHistoTool() ;
    00998
    00999 };
    01000
    01001 #endif // GAUDIALG_IHISTOTOOL_H