Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Histogram.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/analysis/analysis/Histogram.h,v 1.1.1.1 1999/12/20 22:27:04 burnett Exp $
00002 
00003 #ifndef HISTOGRAM_H
00004 #define HISTOGRAM_H
00005 
00006 #include "smplstat.h"
00007 
00008 #include <string>
00009 #include <iostream>
00010 #include <vector>
00011 
00012 
00013 class Histogram : public SampleStatistic
00014 {
00015 public:
00016 
00017     Histogram(std::string title="default", double from=0, double to=1, double step=0.1);
00018     // constructor
00019 
00020     ~Histogram();
00021 
00022     void fill(double x, double w=1.0);
00023     void operator+=(double x){fill(x, 1.0);}
00024     // increment the histogram bin associated with the datum
00025 
00026     virtual void clear();
00027     // clear histogram
00028 
00029     void setRange(double from=0, double to=1, double step=0.1);
00030 
00031     void print(std::ostream& out=std::cout);
00032     // basic print
00033 
00034     float operator[](int n)const{return m_hist[n];}
00035     // access to a bin
00036 
00037     float step()const{return m_step;}
00038     float to()const{return m_to;}
00039     float from()const{return m_from;}
00040     // the histogram parameters
00041 
00042     float total()const{return m_total;}
00043     float under()const{return m_under;}
00044     float over()const {return m_over;}
00045     // statistics
00046 
00047     typedef std::vector<float>::const_iterator const_iterator;
00048     const_iterator begin()const{return m_hist.begin();}
00049     const_iterator end()const{return m_hist.end();}
00050 
00051     Histogram* next() { return m_next;}
00052 
00053     void    setTitle ( std::string& s ) { m_title = s; }
00054 
00055 private:
00056 
00057     std::string m_title;
00058     double m_from, m_to, m_step;
00059     unsigned m_bins;
00060     std::vector <float> m_hist;
00061     double  m_total, m_under, m_over;
00062 
00063     Histogram * m_next;
00064 };
00065 
00066 Histogram* firstHist(); // allow access to start of list
00067 void printAllHists(std::ostream& out =std::cout);
00068 void clearAllHists();
00069   // operation on the list of all defined histograms
00070 #endif

Generated at Wed Nov 21 12:20:52 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000