#ifndef HEPHBOOKHIST2D_H #define HEPHBOOKHIST2D_H // ---------------------------------------------------------------------- // // HepHBookHist2D.h - class declaration for HBook two-dimensional histogram // // HepHBookHist2D is the implementation of the HBook two-dimensional // histogram. It is derived from HepHist2D (the generic interface) and // HepHBookHist. It is mainly a C++ wrapper around the CERNlib HBook // Fortran histogramming libraries. // // No HepHBookHist2D objects are ever directly // instantiated by the programmer. When creating new HepHist* objects, // the manager is in charge of creating the appropriate HepHBook object. // // To use generate HBook histograms, HepHBookFileManager must be used: // // int lunit = 10; // HepFileManager* m = new HepHBookFileManager("filename.rz", lunit); // : // : // HepHist2D* h(m->hist2D("Title", 100, 0.0, 23.0, 100, 0.0, 23.0)); // float x, y, weight; // : // [gather data] // : // h->accumulate(x, y, weight); // // // Note that the constructor can take an ID number which is used by // the HBook implementation of HepHist2D. If omitted, the ID number is // generated automatically (which is recommended). The ID number is // available through the id() method. // // // Created by Bob Jacobsen to go with HepHist // 30-May-1997 Walter Brown Added cloning functions // 29-May-1997 Jason Luther Added comments // 04-Jun-1997 Jason Luther Rewrote comments // 09-Jun-1997 Jason Luther Added cloning constructor // 04-Aug-1998 Philippe Canal Added weight, entries, sum, etc.. // 21-Feb-2000 Walter Brown Improved C++ standard compliance // // ---------------------------------------------------------------------- #ifdef HEP_SHORT_NAMES // done early to override HepPlot #define Hist2D HepHBookHist2D #endif #ifndef HEPHBOOKFILEMANAGER_H #include "HepTuple/HepHBookFileManager.h" #endif #ifndef HEPHIST2D_H #include "HepTuple/HepHist2D.h" #endif ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ class HepHBookHist2D : public HepHist2D { friend class HepHBookFileManager; protected: // create a 2D histogram with the given title and binning HepHBookHist2D( HepHBookFileManager * manager , const std::string& title , const int nBinsX, const float lowX, const float highX , const int nBinsY, const float lowY, const float highY , const int id_req = 0 ); // Used for dummy construction ... // the object is then not valid ... HepHBookHist2D( ); // default constructor // Silence g++ complaints about various functions never being called void silenceCompiler(); public: virtual ~HepHBookHist2D(); virtual void accumulate( const float x , const float y , const float weight = 1.0 ); virtual float bin( const int binNumX , const int binNumY ) const; virtual void getStatistics( int & numEntries, float & sumW, float & sumW2, double & sumWX, double & sumWX2 ) const; virtual void getOverflows( float * numXOverYOver, float * numXOverYUnder, float * numXUnderYUnder, float * numXUnderYOver, float * numTop, float * numRight, float * numBottom, float * numLeft ) const; virtual HepRawHist importHist2D( const HepHist2D & h ); virtual void setXTitle( const std::string& label ); virtual void setYTitle( const std::string& label ); virtual void setZTitle( const std::string& label ); virtual void addHist2D( const HepRawHist & h ); virtual void multiplyHist2D( const HepRawHist & h ); virtual void subtractHist2D( const HepRawHist & h ); virtual void divideHist2D( const HepRawHist & h ); virtual void removeImportedHist2D( const HepRawHist & h ); virtual void reset(); virtual int entries() const; // Number of entries in bins virtual float weight() const; // Sum of all weights virtual float weight2() const; // Sum of all weights^2 virtual float sumX() const; // retrieve weighted sum of X virtual float sumY() const; // retrieve weighted sum of Y virtual float sumX2() const; // retrieve weighted sum of X^2 virtual float sumXY() const; // retrieve weighted sum of X*Y virtual float sumY2() const; // retrieve weighted sum of Y^2 virtual void getContents( // get contents of all in-range bins float * data ) const; virtual void putContents( // set contents of all in-range bins float * data ) const; virtual void getErrors( // get errors of all in-range bins float * data ) const; virtual void putErrors( // set errors of all in-range bins float * data ) const; virtual float binError( // retrieve error on specified bin const int binNumX , const int binNumY ) const; private: // forbidden operations, hence private: //HepHBookHist2D( ); // default constructor HepHBookHist2D( const HepHBookHist2D & ); // copy constructor HepHBookHist2D & operator=( const HepHBookHist2D & ); // assignment }; // HepHBookHist2D ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */ #endif // HEPHBOOKHIST2D_H