CDF II
CDF KITS
source navigation ]
diff markup ]
identifier search ]
freetext search ]
file search ]
 
Architecture: i386 ]
Version: 4.10.4 ] [ 4.10.5 ] [ 4.8.4 ] [ 4.8.4l3s ] [ 4.8.5 ] [ 4.9.0 ] [ 4.9.1 ] [ 4.9.1.hpt3 ] [ 4.9.1hpt3 ] [ 4.9.1top1 ] [ 5.0.0 ] [ 5.1.0 ] [ 5.1.0beamonly ] [ 5.1.1 ] [ 5.2.0 ] [ 5.3.0 ] [ 5.3.1 ] [ 5.3.1dsp ] [ 5.3.3 ] [ 5.3.3_nt ] [ 5.3.4 ] [ 6.1.1 ] [ 6.1.1b ] [ 6.1.2 ] [ 6.1.3 ] [ 6.1.4 ] [ 6.1.4int3 ] [ 6.1.4mc ] [ 6.1.4mc_a ] [ 6.1.6 ] [ development ]

001 #ifndef HEPHIST2D_H
002 #define HEPHIST2D_H
003 
004 
005 // ----------------------------------------------------------------------
006 //
007 // HepHist2D.h - class declaration for generic two-dimensional histogram
008 //
009 // HepHist2D is a generic two-dimensional histogram. It is derived from
010 // HepHist, and its final implementation is defined by a manager class/
011 // histogram subclass. HepHist2D provides methods for filling a
012 // histogram and retreiving information from and about it.
013 //
014 // HepHist2D objects are not directly instantiated. Instead, the manager
015 // creates the object using its own implementation of the histogram.
016 //
017 // Typical usage:
018 //
019 //   HepFileManager* m = new [define the manager];
020 //    :
021 //    :
022 //   HepHist2D* h(m->hist2D("Title", 100, 0.0, 2.0, 100, 0.0, 2.0));
023 //   float x, y, weight;
024 //    :
025 //   [gather data]
026 //    :
027 //   h->accumulate(x, y, weight);
028 //
029 //
030 // Note that the constructor can take an ID number which is used by
031 // some implementations of HepHist2D. If omitted, the ID number is
032 // generated automatically (which is recommended). The ID number is
033 // available through the id() method.
034 //
035 //
036 // History:
037 //   ??-???-19??  Bob Jacobsen   Initial draft, based on ideas in HepTuple
038 //     and the SLT histogram classes of Joe Boudreau
039 //   05-May-1997  Walter Brown   Initial design & draft of Hist class
040 //   22-May-1997  Walter Brown   Merged Hist into HepHistogram
041 //   30-May-1997  Walter Brown   Added cloning functions
042 //   29-May-1997  Jason Luther   Added comments
043 //   04-Jun-1997  Jason Luther   Corrected comments at head of file
044 //   30-Jul-1998  Philippe Canal Added typeId
045 //   04-Aug-1998  Philippe Canal Added weight, entries, sum, etc..
046 //
047 // ----------------------------------------------------------------------
048 
049 
050 #ifdef HEP_SHORT_NAMES      // done early to override HepPlot
051   #define Hist2D HepHist2D
052 #endif
053 
054 
055 #ifndef HEPHIST_H
056   #include "HepTuple/HepHist.h"
057 #endif
058 
059 
060 ZM_BEGIN_NAMESPACE( zmht )      /*  namespace zmht  {  */
061 
062 
063 class HepFileManager;
064 class HepRawHist;
065 
066 
067 class HepHist2D : public HepHist  {
068 
069 protected:
070 
071   // create a 2D histogram with the given title and binning
072   HepHist2D(
073     HepFileManager * manager
074   , const std::string& title
075   , const int nBinsX, const float lowX, const float highX
076   , const int nBinsY, const float lowY, const float highY
077   , const int id_req = 0
078   );
079 
080   // Used for dummy construction ...
081   // the object is then not valid ...
082   HepHist2D( );                           // default constructor
083 
084 public:
085 
086   // type identifier ( is equal to type() for this object )
087   static const char typeId;
088 
089   virtual ~HepHist2D();
090 
091   virtual ZM_COVARIANT_TYPE(HepObj,HepHist2D) & makeClone(
092     const std::string& title
093   , const int  id = 0
094   ) const;
095 
096   virtual ZM_COVARIANT_TYPE(HepObj,HepHist2D) & makeEmpty(
097     const std::string& title
098   , const int  id = 0
099   ) const;
100 
101   virtual ZM_COVARIANT_TYPE(HepObj,HepHist2D) & makeClone(
102     HepFileManager *manager
103   , const std::string& title
104   , const int  id = 0
105   ) const;
106 
107   virtual ZM_COVARIANT_TYPE(HepObj,HepHist2D) & makeEmpty(
108     HepFileManager *manager
109   , const std::string& title
110   , const int  id = 0
111   ) const;
112 
113   virtual void accumulate(
114     const float xValue
115   , const float yValue
116   , const float weight = 1.0
117   );
118 
119   virtual void reset();
120 
121   virtual float bin(
122     const int binNumX
123   , const int binNumY
124   ) const;
125 
126   virtual int nBinsX() const; // retrieve # of in-range X bins
127   virtual int nBinsY() const; // retrieve # of in-range Y bins
128 
129   virtual float minX() const; // retrieve low end of binned X range
130   virtual float minY() const; // retrieve high end of binned X range
131 
132   virtual float maxX() const; // retrieve low end of binned X range
133   virtual float maxY() const; // retrieve high end of binned X range
134 
135   virtual int   entries() const; // Number of entries in all bins
136 
137   virtual float weight() const;         // Retrieve sum of all weights
138   virtual float weight2() const;        // Retrieve sum of all weights^2
139 
140   virtual float sumX() const;           // Retrieve weighted sum of X
141   virtual float sumY() const;           // Retrieve weighted sum of Y 
142   virtual float sumX2() const;          // Retrieve weighted sum of X^2
143   virtual float sumXY() const;          // Retrieve weighted sum of X*Y
144   virtual float sumY2() const;          // Retrieve weighted sum of Y^2
145 
146   // The Sample Average of X can be obtained by: sumX() / weight() 
147   // A biased estimator (Sample covariance) of the X,Y covariance can be
148   // obtained by:
149   //        sumXY()/weight() - sumX()/weight()*sumY()/weight() 
150   // A biased estimator (Sample variance) of X can be obtained by:
151   //        sumX2()/weight() - sumX()/weight()*sumX()/weight()
152 
153   virtual void getContents(      // get contents of all in-range bins
154     float * data
155   ) const;
156 
157   virtual void putContents(      // put contents of all in-range bins
158     float * data
159   ) const;
160 
161   virtual void getErrors(        // get errors of all in-range bins
162     float * data
163   ) const;
164 
165   virtual void putErrors(        // get errors of all in-range bins
166     float * data
167   ) const;
168 
169   virtual float binError(        // retrieve error on specified bin
170     int binNumX
171  ,  int binNumY
172   ) const;
173 
174   virtual void getStatistics( int & numEntries, float & sumW, float & sumW2,
175                               double & sumWX, double & sumWX2 ) const;
176 
177   virtual void getOverflows( float * numXOverYOver,   float * numXOverYUnder,
178                              float * numXUnderYUnder, float * numXUnderYOver,
179                              float * numTop,          float * numRight,
180                              float * numBottom,       float * numLeft ) const;
181 
182   bool compatibleHist2D( const HepHist2D & h );
183 
184   virtual HepRawHist importHist2D( const HepHist2D & h );
185 
186   virtual void setXTitle( const std::string& label );
187   virtual void setYTitle( const std::string& label );
188   virtual void setZTitle( const std::string& label );
189   virtual void setTitle ( const std::string& label );
190 
191   virtual void      addHist2D( const HepRawHist & h );
192   virtual void multiplyHist2D( const HepRawHist & h );
193   virtual void subtractHist2D( const HepRawHist & h );
194   virtual void   divideHist2D( const HepRawHist & h );
195 
196   virtual void removeImportedHist2D( const HepRawHist & h );
197 
198 
199   // Arithmetic operation += on histograms
200   HepHist2D & operator += ( const HepHist2D & );
201 
202   // Arithmetic operation -= on histograms
203   HepHist2D & operator -= ( const HepHist2D & );
204 
205   // Arithmetic operation *= on histograms
206   HepHist2D & operator *= ( const HepHist2D & );
207 
208   // Arithmetic operation /= on histograms
209   HepHist2D & operator /= ( const HepHist2D & );
210 
211 protected:
212 
213   virtual void _accumulate(
214     const float xValue
215   , const float yValue
216   , const float weight = 1.0
217   );
218 
219 
220 private:
221 
222   const int   _nBinsX;                    // # of in-range bins
223   const float _minX;                      // lowest in-range value
224   const float _maxX;                      // highest in-range value
225 
226   const int   _nBinsY;                    // # of in-range bins
227   const float _minY;                      // lowest in-range value
228   const float _maxY;                      // highest in-range value
229 
230   // forbidden operations, hence private (protected for sake of descendents):
231   HepHist2D( const HepHist2D & );         // copy constructor
232   HepHist2D & operator=( const HepHist2D & );  // assignment
233 
234 };  // HepHist2D
235 
236 
237 ZM_END_NAMESPACE( zmht )        /*  }  // namespace zmht  */
238 
239 
240 #endif  // HEPHIST2D_H
241 

source navigation ] diff markup ] identifier search ] freetext search ] file search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!

Send problems or questions to cdfcode@fnal.gov