CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ClusterizingHistogram Class Reference

#include <ClusterizingHistogram.h>

List of all members.

Public Member Functions

int bin (float x) const
int bin (double x) const
float bin_pos (int i) const
std::vector< float > clusterize (float resolution)
 ClusterizingHistogram (int nb, float xmi, float xma)
void dump (double x1, float x2) const
void dump (float x1, double x2) const
void dump () const
void dump (int i1, int i2) const
void dump (float x1, float x2) const
void dump (double x1, double x2) const
int entries () const
void fill (float x)
float max_x () const
float min_x () const
int nbins () const
int overflows () const
void reset ()
int underflows () const
 ~ClusterizingHistogram ()

Private Member Functions

 ClusterizingHistogram ()

Private Attributes

int * bin_entries
float * bin_means
float binsiz
int my_entries
int my_nbins
int my_overflows
int my_underflows
float xmax
float xmin

Detailed Description

A very simple 1D equidistant bin histogram that has the ability to clusterize it's contents. The bin entries are averaged in X, giving more accurate indication of where the bin contents are than the center of the bin.

Definition at line 13 of file ClusterizingHistogram.h.


Constructor & Destructor Documentation

ClusterizingHistogram::ClusterizingHistogram ( int  nb,
float  xmi,
float  xma 
)

Definition at line 6 of file ClusterizingHistogram.cc.

References bin_entries, bin_means, binsiz, i, my_nbins, xmax, and xmin.

                                                                         : 
  my_nbins(nb), xmin(xmi), xmax(xma), my_entries(0), my_underflows(0), my_overflows(0) {
    bin_entries = new int[my_nbins];
    bin_means = new float[my_nbins];
    binsiz = (xmax-xmin) / my_nbins;
    for (int i=0; i<my_nbins; i++) {
      bin_entries[i] = 0;
      bin_means[i] = 0.;
    }
}
ClusterizingHistogram::~ClusterizingHistogram ( )

Definition at line 16 of file ClusterizingHistogram.cc.

References bin_entries, and bin_means.

{ delete[] bin_entries; delete [] bin_means;}
ClusterizingHistogram::ClusterizingHistogram ( ) [inline, private]

Definition at line 40 of file ClusterizingHistogram.h.

{}  // Prohibit

Member Function Documentation

int ClusterizingHistogram::bin ( float  x) const

Definition at line 18 of file ClusterizingHistogram.cc.

References binsiz, my_nbins, xmax, and xmin.

Referenced by dump(), and fill().

                                             {
  if      (x < xmin) return -1;
  else if (x > xmax) return my_nbins;
  else return int((x-xmin)/binsiz);
}
int ClusterizingHistogram::bin ( double  x) const

Definition at line 23 of file ClusterizingHistogram.cc.

References binsiz, my_nbins, xmax, and xmin.

                                              {
  if      (x < xmin) return -1;
  else if (x > xmax) return my_nbins;
  else return int((x-xmin)/binsiz);
}
float ClusterizingHistogram::bin_pos ( int  i) const [inline]

Definition at line 25 of file ClusterizingHistogram.h.

References bin_entries, bin_means, and i.

Referenced by dump().

                             {
    return (bin_entries[i]!=0) ? bin_means[i]/bin_entries[i] : 0;}
vector< float > ClusterizingHistogram::clusterize ( float  resolution)

Definition at line 700 of file DAClusterizerInZ.cc.

References gather_cfg::cout, i, gen::k, and position.

Referenced by MagGeoBuilderFromDDD::bRod::bRod(), MagGeoBuilderFromDDD::bSector::bSector(), MagGeoBuilderFromDDD::build(), and MagGeoBuilderFromDDD::eSector::eSector().

{
  if(verbose_) {
    cout << "###################################################" << endl;
    cout << "# DAClusterizerInZ::clusterize   nt="<<tracks.size() << endl;
    cout << "###################################################" << endl;
  }

  vector< vector<reco::TransientTrack> > clusters;
  vector< TransientVertex > pv=vertices(tracks);

  if(verbose_){ cout << "# DAClusterizerInZ::clusterize   pv.size="<<pv.size() << endl;  }
  if (pv.size()==0){ return clusters;}


  // fill into clusters and merge
  vector< reco::TransientTrack>  aCluster=pv.begin()->originalTracks();
  
  for(vector<TransientVertex>::iterator k=pv.begin()+1; k!=pv.end(); k++){
    if ( fabs(k->position().z() - (k-1)->position().z()) > (2*vertexSize_) ){
      // close a cluster
      clusters.push_back(aCluster);
      aCluster.clear();
    }
    for(unsigned int i=0; i<k->originalTracks().size(); i++){ aCluster.push_back( k->originalTracks().at(i)); }
    
  }
  clusters.push_back(aCluster);
  
  
  return clusters;

}
void ClusterizingHistogram::dump ( void  ) const

Definition at line 71 of file ClusterizingHistogram.cc.

Referenced by dump().

{ dump(0, my_nbins);}
void ClusterizingHistogram::dump ( int  i1,
int  i2 
) const

Definition at line 73 of file ClusterizingHistogram.cc.

References bin_entries, bin_pos(), gather_cfg::cout, i, max(), min, my_entries, my_overflows, and my_underflows.

                                                     {
  cout << "Dumping ClusterizingHistogram contents:" << endl;
  for (int i=max(i1,0); i<min(i2,my_nbins); i++) {
    cout << i << "  " << bin_entries[i] << "   " << bin_pos(i) << endl;
  }
  cout << "Underflows: " << my_underflows << endl;
  cout << "Overflows:  " << my_overflows << endl;
  cout << "Total number of entries: " << my_entries << endl;
}
void ClusterizingHistogram::dump ( float  x1,
float  x2 
) const

Definition at line 83 of file ClusterizingHistogram.cc.

References bin(), and dump().

{ dump( bin(x1), bin(x2));}
void ClusterizingHistogram::dump ( double  x1,
double  x2 
) const

Definition at line 84 of file ClusterizingHistogram.cc.

References bin(), and dump().

{ dump( bin(x1), bin(x2));}
void ClusterizingHistogram::dump ( float  x1,
double  x2 
) const

Definition at line 85 of file ClusterizingHistogram.cc.

References bin(), and dump().

{ dump( bin(x1), bin(x2));}
void ClusterizingHistogram::dump ( double  x1,
float  x2 
) const

Definition at line 86 of file ClusterizingHistogram.cc.

References bin(), and dump().

{ dump( bin(x1), bin(x2));}
int ClusterizingHistogram::entries ( ) const [inline]

Definition at line 22 of file ClusterizingHistogram.h.

References my_entries.

{return my_entries;}
void ClusterizingHistogram::fill ( float  x)

Definition at line 29 of file ClusterizingHistogram.cc.

References bin(), bin_entries, bin_means, binsiz, my_entries, my_nbins, my_overflows, my_underflows, x, xmax, and xmin.

Referenced by MagGeoBuilderFromDDD::bRod::bRod(), MagGeoBuilderFromDDD::bSector::bSector(), MagGeoBuilderFromDDD::build(), and MagGeoBuilderFromDDD::eSector::eSector().

                                         {
  if      (x < xmin) my_underflows++;
  else if (x > xmax) my_overflows++;
  else {
    int bin = int((x-xmin)/binsiz);
    if ( bin > my_nbins-1) bin = my_nbins-1;
    ++bin_entries[bin];
    bin_means[bin] += x;
    my_entries++;
    // may be problematic for negative x; check!
  }
}
float ClusterizingHistogram::max_x ( ) const [inline]

Definition at line 21 of file ClusterizingHistogram.h.

References xmax.

{return xmax;}
float ClusterizingHistogram::min_x ( ) const [inline]

Definition at line 20 of file ClusterizingHistogram.h.

References xmin.

{return xmin;}
int ClusterizingHistogram::nbins ( ) const [inline]

Definition at line 19 of file ClusterizingHistogram.h.

References my_nbins.

{return my_nbins;}
int ClusterizingHistogram::overflows ( ) const [inline]

Definition at line 24 of file ClusterizingHistogram.h.

References my_overflows.

{return my_overflows;}
void ClusterizingHistogram::reset ( void  )

Definition at line 88 of file ClusterizingHistogram.cc.

References bin_entries, bin_means, i, my_entries, my_nbins, my_overflows, and my_underflows.

                                  {
  my_entries = 0;
  my_underflows = 0;
  my_overflows = 0;
  for (int i=0; i<my_nbins; i++) {
    bin_entries[i] = 0;
    bin_means[i] = 0.;
  }
}
int ClusterizingHistogram::underflows ( ) const [inline]

Definition at line 23 of file ClusterizingHistogram.h.

References my_underflows.

{return my_underflows;}

Member Data Documentation

Definition at line 49 of file ClusterizingHistogram.h.

Referenced by bin(), ClusterizingHistogram(), and fill().

Definition at line 44 of file ClusterizingHistogram.h.

Referenced by dump(), entries(), fill(), and reset().

Definition at line 41 of file ClusterizingHistogram.h.

Referenced by bin(), ClusterizingHistogram(), fill(), nbins(), and reset().

Definition at line 46 of file ClusterizingHistogram.h.

Referenced by dump(), fill(), overflows(), and reset().

Definition at line 45 of file ClusterizingHistogram.h.

Referenced by dump(), fill(), reset(), and underflows().

float ClusterizingHistogram::xmax [private]

Definition at line 43 of file ClusterizingHistogram.h.

Referenced by bin(), ClusterizingHistogram(), fill(), and max_x().

float ClusterizingHistogram::xmin [private]

Definition at line 42 of file ClusterizingHistogram.h.

Referenced by bin(), ClusterizingHistogram(), fill(), and min_x().