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

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