Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:45

0001 #ifndef _CLUSTERIZINGHISTOGRAM_TT_H_
0002 #define _CLUSTERIZINGHISTOGRAM_TT_H_
0003 
0004 #include <vector>
0005 #include <cmath>
0006 
0007 /** A very simple 1D equidistant bin histogram that has the ability
0008  *  to clusterize it's contents.
0009  *  The bin entries are averaged in X, giving more accurate indication of
0010  *  where the bin contents are than the center of the bin.
0011  */
0012 
0013 class ClusterizingHistogram {
0014 public:
0015   ClusterizingHistogram(int nb, float xmi, float xma);
0016   ~ClusterizingHistogram();
0017 
0018   void fill(float x);
0019   int nbins() const { return my_nbins; }
0020   float min_x() const { return xmin; }
0021   float max_x() const { return xmax; }
0022   int entries() const { return my_entries; }
0023   int underflows() const { return my_underflows; }
0024   int overflows() const { return my_overflows; }
0025   float bin_pos(int i) const { return (bin_entries[i] != 0) ? bin_means[i] / bin_entries[i] : 0; }
0026   void dump() const;
0027   void dump(int i1, int i2) const;
0028   void dump(float x1, float x2) const;
0029   void dump(double x1, double x2) const;
0030   void dump(float x1, double x2) const;
0031   void dump(double x1, float x2) const;
0032   void reset();
0033   int bin(float x) const;
0034   int bin(double x) const;
0035 
0036   std::vector<float> clusterize(float resolution);
0037 
0038 private:
0039   ClusterizingHistogram() {}  // Prohibit
0040   int my_nbins;
0041   float xmin;
0042   float xmax;
0043   int my_entries;
0044   int my_underflows;
0045   int my_overflows;
0046   int *bin_entries;
0047   float *bin_means;
0048   float binsiz;
0049 };
0050 
0051 #endif