#ifndef HEPROOTHIST2D_H #define HEPROOTHIST2D_H // ---------------------------------------------------------------------- // // HepRootHist2D.h - class declaration for Root two-dimensional histogram // // HepRootHist2D is the implementation of the Root two-dimensional // histogram. It is derived from HepHist2D (the generic interface) and // HepRootHist. It is mainly a C++ wrapper around the Root // histogramming libraries. // // No HepRootHist2D objects are ever directly // instantiated by the programmer. When creating new HepHist* objects, // the manager is in charge of creating the appropriate HepRoot object. // // To use generate Root histograms, HepRootFileManager must be used: // // int lunit = 10; // HepFileManager* m = new HepRootFileManager("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); // // 12-Dec-98 Philippe Canal Creation // // ---------------------------------------------------------------------- #ifndef HEPROOTFILEMANAGER_H #include "HepTuple/HepRootFileManager.h" #endif #ifndef HEPHIST2D_H #include "HepTuple/HepHist2D.h" #endif #ifndef HEPROOTOBJ_H #include "HepTuple/HepRootObj.h" #endif class TH1; class HepRawHist; ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ class HepRootHist2D : public HepHist2D, public HepRootObj { friend class HepRootFileManager; protected: // create a 2D histogram the given an existing root TH1 HepRootHist2D( HepRootFileManager * manager, TH1* histo ); // create a 2D histogram with the given title and binning HepRootHist2D( HepRootFileManager * 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 ... HepRootHist2D( ); // default constructor public: virtual ~HepRootHist2D(); // clone an existing 2D histogram HepRootHist2D( HepRootHist2D * 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 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 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 setTitle ( const std::string& label ); 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 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; // Retrieve sum of all weights virtual float weight2() const; // Retrieve 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: //HepRootHist2D( ); // default constructor HepRootHist2D( const HepRootHist2D & ); // copy constructor HepRootHist2D & operator=( const HepRootHist2D & ); // assignment }; // HepRootHist2D ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */ #endif // HEPROOTHIST2D_H