#ifndef HEPHISTPROF_H #define HEPHISTPROF_H // ---------------------------------------------------------------------- // // HepHistProf.h - class declaration for generic profile histogram // // HepHistProf is a generic profile histogram. It is derived from // HepHist, and its final implementation is defined by a manager class/ // histogram subclass. HepHistProf provides methods for filling a // histogram and retreiving information from and about it. // // HepHistProf objects are not directly instantiated. Instead, the manager // creates the object using its own implementation of the histogram. // // Typical usage: // // HepFileManager* m = new [define the manager]; // : // : // HepHistProf* h(m->histProf("Title", 100, 0.0, 2.0, 0.0, 2.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 // some implementations of HepHistProf. If omitted, the ID number is // generated automatically (which is recommended). The ID number is // available through the id() method. // // // History: // ??-???-19?? Bob Jacobsen Initial draft, based on ideas in HepTuple // and the SLT histogram classes of Joe Boudreau // 05-May-1997 Walter Brown Initial design & draft of Hist class // 22-May-1997 Walter Brown Merged Hist into HepHistogram // 30-May-1997 Walter Brown Added cloning functions // 29-May-1997 Jason Luther Added comments // 04-Jun-1997 Jason Luther Fixed comments // 30-Jul-1998 Philippe Canal Added typeId // 04-Aug-1998 Philippe Canal Added weight, entries, sum, etc.. // // ---------------------------------------------------------------------- #ifdef HEP_SHORT_NAMES // done early to override HepPlot #define HistProf HepHistProf #endif #ifndef HEPHIST_H #include "HepTuple/HepHist.h" #endif ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ class HepFileManager; class HepRawHist; class HepHistProf : public HepHist { protected: // create a profile histogram with the given title and binning HepHistProf( HepFileManager * manager , const std::string& title , const int nBinsX, const float lowX, const float highX , const float lowY, const float highY , const std::string& chopt , const int id_req = 0 ); HepHistProf( HepFileManager * manager , const std::string& title , const int nBinsX, float lowX, float highX , const float lowY, float highY , const int id_req = 0 ); // Used for dummy construction ... // the object is then not valid ... HepHistProf( ); // default constructor public: // type identifier ( is equal to type() for this object ) static const char typeId; virtual ~HepHistProf(); virtual ZM_COVARIANT_TYPE(HepObj,HepHistProf) & makeClone( const std::string& title , const int id = 0 ) const; virtual ZM_COVARIANT_TYPE(HepObj,HepHistProf) & makeEmpty( const std::string& title , const int id = 0 ) const; virtual ZM_COVARIANT_TYPE(HepObj,HepHistProf) & makeClone( HepFileManager *manager , const std::string& title , const int id = 0 ) const; virtual ZM_COVARIANT_TYPE(HepObj,HepHistProf) & makeEmpty( HepFileManager *manager , const std::string& title , const int id = 0 ) const; virtual void accumulate( const float xValue , const float yValue , const float weight = 1.0 ); // Reset all bins virtual void reset(); // contents of X-bin virtual float bin( const int binNum ) const; // sum of all weight in X-bin // get sum of weights for all bins virtual void getSumW( // get sum of weights of all bins float * data ) const; // get sum of weighted Y for all bins virtual void getSumWY( // get sum of weighted Y of all bins float * data ) const; // get sum of weighted Y^2 for all bins virtual void getSumWY2( // get sum of weighted Y^2 of all bins float * data ) const; // retrieve error on specified bin virtual float binError( // retrieve error on specified bin const int binNum ) const; // retrieve # of in-range X bins virtual int nBinsX() const; // retrieve # of in-range X bins // retrieve low end of binned X range virtual float minX() const; // retrieve low end of binned X range // retrieve low end of binned Y range virtual float minY() const; // retrieve low end of binned Y range // retrieve high end of binned X range virtual float maxX() const; // retrieve high end of binned X range // retrieve high end of binned Y range virtual float maxY() const; // retrieve high end of binned Y range // number of entries virtual int entries() const; // number of entries // number of entries in X-bin virtual int entries( const int binNumX) const; // number of entries in X-bin // sum of all weight virtual float weight() const; // sum of all weight virtual float weight2() const; // sum of all weight^2 // sum of all weight in X-bin virtual float weight( const int binNumX) const; // sum of all weight in X-bin // retrieve weighted sum of X virtual float sumX() const; // retrieve weighted sum of X // retrieve weighted sum of Y virtual float sumY() const; // retrieve weighted sum of Y // retrieve weighted sum of X^2 virtual float sumX2() const; // retrieve weighted sum of X^2 // retrieve weighted sum of Y^2 virtual float sumY2() const; // retrieve weighted sum of Y^2 // retrieve sum of Y in X-bin virtual float sumY( const int binNumX) const; // retrieve sum of Y in X-bin // retrieve sum of Y^2 in X-bin virtual float sumY2( const int binNumX) const; // retrieve sum of Y^2 in X-bin virtual void getStatistics( int & numEntries, float & sumW, float & sumW2, double & sumWX, double & sumWX2 ) const; virtual void getOverflows( float * numOver, float * numUnder ) const; bool compatibleHistProf( const HepHistProf & h ); 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 ); // Arithmetic operation += on histograms HepHistProf & operator += ( const HepHistProf & ); // Arithmetic operation -= on histograms HepHistProf & operator -= ( const HepHistProf & ); // Arithmetic operation *= on histograms HepHistProf & operator *= ( const HepHistProf & ); // Arithmetic operation /= on histograms HepHistProf & operator /= ( const HepHistProf & ); protected: virtual void _accumulate( const float xValue , const float yValue , const float weight = 1.0 ); private: const int _nBinsX; // # of in-range bins const float _minX; // lowest in-range value const float _maxX; // highest in-range value const float _minY; // lowest in-range value const float _maxY; // highest in-range value // forbidden operations, hence private (protected for sake of descendents): HepHistProf( const HepHistProf & ); // copy constructor HepHistProf & operator=( const HepHistProf & ); // assignment }; // HepHistProf ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */ #endif // HEPHISTPROF_H