#ifndef HEPROOTHISTPROF_H #define HEPROOTHISTPROF_H // ---------------------------------------------------------------------- // // HepRootHistProf.h - class declaration for Root profile histogram // // HepRootHistProf is the implementation of the Root profile // histogram. It is derived from HepHistProf (the generic interface) and // HepRootHist. It is mainly a C++ wrapper around the Root // histogramming libraries. // // No HepRootHistProf 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); // : // : // HepHistProf* h(m->histProf("Title", 100, 0.0, 23.0, 0.0, 23.0)); // float x, y, weight; // : // [gather data] // : // h->accumulate(x, y, weight); // // History: // 26-Aug-1998 Philippe Canal Initial draft // // // ---------------------------------------------------------------------- #ifndef HEPROOTFILEMANAGER_H #include "HepTuple/HepRootFileManager.h" #endif #ifndef HEPROOTFILEMANAGERHISTPROF_H #include "HepTuple/HepHistProf.h" #endif #ifndef HEPROOTOBJ_H #include "HepTuple/HepRootObj.h" #endif class TProfile; class HepRawHist; ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ class HepRootHistProf : public HepHistProf, public HepRootObj { friend class HepRootFileManager; protected: // create a 1D histogram the given an existing root TH1 HepRootHistProf( HepRootFileManager * manager, TProfile* histo ); // create a profile plot with the given title and binning HepRootHistProf( HepRootFileManager * manager , const std::string& title , const int nBins , const float lowX, const float highX , const float lowY, const float highY , const std::string& chopt , const int id_req = 0 ); HepRootHistProf( HepRootFileManager * manager , const std::string& title , const int nBins , const float lowX, const float highX , const float lowY, const float highY , const int id_req = 0 ); // Used for dummy construction ... // the object is then not valid ... HepRootHistProf( ); // default constructor public: virtual ~HepRootHistProf(); // clone an existing profile histogram HepRootHistProf( HepRootHistProf * original , const std::string& title , const int id_req = 0 ); virtual void accumulate( const float x , const float y , const float weight = 1.0 ); // contents of X-bin virtual float bin( const int binNum ) const; // sum of all weight in X-bin // get sum of weights per bin for all bins virtual void getSumW( float * data ) const; // get sum of weighted Y per bin for all bins virtual void getSumWY( float * data ) const; // get sum of weighted Y^2 per bin for all bins virtual void getSumWY2( float * data ) const; // retrieve error on specified bin virtual float binError( const int binNum ) const; virtual void getStatistics( int & numEntries, float & sumW, float & sumW2, double & sumWX, double & sumWX2 ) const; virtual void getOverflows( float * numOver, float * numUnder ) const; virtual HepRawHist importHistProf( const HepHistProf & 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 addHistProf( const HepRawHist & h ); virtual void subtractHistProf( const HepRawHist & h ); virtual void multiplyHistProf( const HepRawHist & h ); virtual void divideHistProf( const HepRawHist & h ); virtual void removeImportedHistProf( const HepRawHist & h ); virtual void reset(); virtual int entries() const; // number of entries virtual int entries( const int binNumX) const; // number of entries in X-bin virtual float weight() const; // sum of all weight virtual float weight2() const; // sum of all weight^2 virtual float weight( const int binNumX) const; // sum of all weight in X-bin virtual float sumX() const; // retrieve weighted sum of X virtual float sumX2() const; // retrieve weighted sum of X^2 virtual float sumY() const; // retrieve weighted sum of Y virtual float sumY2() const; // retrieve weighted sum of Y^2 virtual float sumY( const int binNumX) const; // retrieve sum of Y in X-bin virtual float sumY2( const int binNumX) const; // retrieve sum of Y^2 in X-bin private: // forbidden operations, hence private: //HepRootHistProf( ); // default constructor HepRootHistProf( const HepRootHistProf & ); // copy constructor HepRootHistProf & operator=( const HepRootHistProf & ); // assignment // get sum of weights for specified bin virtual float getWeight( int numBin ) const; }; // HepRootHistProf ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */ #endif // HEPROOTHISTPROF_H