#include <ClusterizingHistogram.h>
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 |
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.
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
int ClusterizingHistogram::bin | ( | float | x | ) | const |
int ClusterizingHistogram::bin | ( | double | x | ) | const |
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 538 of file DAClusterizerInZ.cc.
References gather_cfg::cout, i, gen::k, position, and ExpressReco_HICollisions_FallBack::vertices.
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 ( 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 |
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 |
void ClusterizingHistogram::dump | ( | double | x1, |
double | x2 | ||
) | const |
void ClusterizingHistogram::dump | ( | float | x1, |
double | x2 | ||
) | const |
void ClusterizingHistogram::dump | ( | double | x1, |
float | x2 | ||
) | const |
int ClusterizingHistogram::entries | ( | ) | const [inline] |
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, ExpressReco_HICollisions_FallBack::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] |
float ClusterizingHistogram::min_x | ( | ) | const [inline] |
int ClusterizingHistogram::nbins | ( | ) | const [inline] |
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;}
int* ClusterizingHistogram::bin_entries [private] |
Definition at line 47 of file ClusterizingHistogram.h.
Referenced by bin_pos(), ClusterizingHistogram(), dump(), fill(), reset(), and ~ClusterizingHistogram().
float* ClusterizingHistogram::bin_means [private] |
Definition at line 48 of file ClusterizingHistogram.h.
Referenced by bin_pos(), ClusterizingHistogram(), fill(), reset(), and ~ClusterizingHistogram().
float ClusterizingHistogram::binsiz [private] |
Definition at line 49 of file ClusterizingHistogram.h.
Referenced by bin(), ClusterizingHistogram(), and fill().
int ClusterizingHistogram::my_entries [private] |
int ClusterizingHistogram::my_nbins [private] |
Definition at line 41 of file ClusterizingHistogram.h.
Referenced by bin(), ClusterizingHistogram(), fill(), nbins(), and reset().
int ClusterizingHistogram::my_overflows [private] |
Definition at line 46 of file ClusterizingHistogram.h.
Referenced by dump(), fill(), overflows(), and reset().
int ClusterizingHistogram::my_underflows [private] |
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().