#ifndef HEPHISTOHIST2D_H #define HEPHISTOHIST2D_H // ---------------------------------------------------------------------- // // HepHistoHist2D.h - class declaration for Histo two-dimensional histogram // // HepHistoHist2D is the implementation of the Histo two-dimensional // histogram. It is derived from HepHist2D (the generic interface) and // HepHistoHist. It is mainly a C++ wrapper around the CERNlib Histo // Fortran histogramming libraries. // // No HepHistoHist2D objects are ever directly // instantiated by the programmer. When creating new HepHist* objects, // the manager is in charge of creating the appropriate HepHisto object. // // To use generate Histo histograms, HepHistoFileManager must be used: // // int lunit = 10; // HepFileManager* m = new HepHistoFileManager("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 Histo 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.. // // ---------------------------------------------------------------------- #ifdef HEP_SHORT_NAMES // done early to override HepPlot #define Hist2D HepHistoHist2D #endif #ifndef HEPHISTOFILEMANAGER_H #include "HepTuple/HepHistoFileManager.h" #endif #ifndef HEPHIST2D_H #include "HepTuple/HepHist2D.h" #endif ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ class HepHistoHist2D : public HepHist2D { friend class HepHistoFileManager; protected: // create a 2D histogram with the given title and binning HepHistoHist2D( HepHistoFileManager * 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 ); // create a 2D histogram with the given title and binning HepHistoHist2D( HepHistoFileManager * 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 , const int histo_id ); // Used for dummy construction ... // the object is then not valid ... HepHistoHist2D( ); // default constructor public: virtual ~HepHistoHist2D(); // clone an existing 2D histogram HepHistoHist2D( HepHist2D * original , const std::string& title , const int id_req = 0 ); 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 float binError( // retrieve error for specified bin const int binNumX , const int binNumY ) const; virtual void getContents( // get contents of all bins float * data ) const; virtual void getErrors( // get errors of all bins float * data ) 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 void setXTitle( const std::string& label ); virtual void setYTitle( const std::string& label ); virtual void setZTitle( const std::string& label ); virtual HepRawHist importHist2D( const HepHist2D & h ); 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 private: // forbidden operations, hence private: //HepHistoHist2D( ); // default constructor HepHistoHist2D( const HepHistoHist2D & ); // copy constructor HepHistoHist2D & operator=( const HepHistoHist2D & ); // assignment // remember the Histoscope id for quick reference int histo_id_; float *values_; // array of dimensions binNumX*binNumY to copy the data // for quick ref }; // HepHistoHist2D ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */ #endif // HEPHISTOHIST2D_H