#include <AsciiHisto.h>
Public Member Functions | |
AsciiHisto (std::string title, unsigned int nbins, float min, float max) | |
std::string & | draw () |
void | fill (float x) |
void | fill (float *cont) |
void | fillDeque (std::deque< float > &cont) |
int | maxbin () |
Private Attributes | |
float | binsize_ |
std::vector< float > | cont_ |
std::string | current_ |
unsigned int | nbins_ |
std::string | title_ |
bool | uptodate_ |
float | xmax_ |
float | xmin_ |
float | ymax_ |
float | ymin_ |
Definition at line 14 of file AsciiHisto.h.
evf::AsciiHisto::AsciiHisto | ( | std::string | title, |
unsigned int | nbins, | ||
float | min, | ||
float | max | ||
) | [inline] |
std::string& evf::AsciiHisto::draw | ( | ) | [inline] |
Definition at line 56 of file AsciiHisto.h.
References binsize_, cont_, current_, i, j, maxbin(), nbins_, title_, uptodate_, xmin_, and ymax_.
Referenced by evf::AsciiRollingChart::draw().
{ if(uptodate_) return current_; maxbin(); float yscale = (ymax_*1.2) /20.; std::ostringstream ost; ost << " ^"; ost << std::setw(nbins_-title_.size()) << " "; ost << title_ << std::endl; // std::cout << " ^" << " " << title_ << std::endl; for(int j = 20; j>=0; j--) { // std::cout << "--------------> "<< j << std::endl; if(j%5==0){ ost << std::setw(8) << yscale*j << "-|"; // std::cout << std::setw(8) << yscale*j << "-|"; } else{ ost << " |"; // std::cout << " |"; } for(unsigned int i = 0; i < nbins_+5; i++) { if(j==0) {ost << "-"; /*std::cout << "-";*/} else { if(i<nbins_ && cont_[i] > yscale*j) {ost << "*"; /*std::cout << "*";*/} else {ost << " "; /*std::cout << " ";*/} } } if(j==0){ost << ">"; /*std::cout << ">";*/} ost << std::endl; // std::cout << std::endl; } ost << " "; // std::cout << " "; for(unsigned int i = 0; i < nbins_+5; i++) { if(i%10==0) {ost << "|"; /*std::cout << "|";*/} else {ost << " "; /*std::cout << " ";*/} } ost << std::endl; // std::cout << std::endl; ost << std::setw(10) << xmin_ ; // std::cout << std::setw(10) << xmin_; for(unsigned int i = 0; i < nbins_+5; i++) if((i+3)%10==0){ost << std::setw(10) << xmin_+binsize_*(i+3); // std::cout << std::setw(10) << xmin_+binsize_*(i+3); } ost << std::endl; // std::cout << std::endl; current_ = ost.str(); return current_; }
void evf::AsciiHisto::fill | ( | float * | cont | ) | [inline] |
void evf::AsciiHisto::fill | ( | float | x | ) | [inline] |
void evf::AsciiHisto::fillDeque | ( | std::deque< float > & | cont | ) | [inline] |
int evf::AsciiHisto::maxbin | ( | ) | [inline] |
Definition at line 45 of file AsciiHisto.h.
References cont_, i, nbins_, and ymax_.
Referenced by draw().
{ int retval = -1; ymax_ = -100000.; for(unsigned int i = 0; i < nbins_; i++) if(ymax_ < cont_[i]){ymax_ = cont_[i]; retval = i;} /* std::cout << "max bin " << retval << " has " << ymax_ << std::endl; */ /* std::cout << "nbins " << nbins_ */ /* << " binsize " << binsize_ << std::endl; */ return retval; }
float evf::AsciiHisto::binsize_ [private] |
Definition at line 120 of file AsciiHisto.h.
Referenced by AsciiHisto(), draw(), and fill().
std::vector<float> evf::AsciiHisto::cont_ [private] |
Definition at line 125 of file AsciiHisto.h.
Referenced by draw(), fill(), fillDeque(), and maxbin().
std::string evf::AsciiHisto::current_ [private] |
Definition at line 126 of file AsciiHisto.h.
Referenced by draw().
unsigned int evf::AsciiHisto::nbins_ [private] |
Definition at line 119 of file AsciiHisto.h.
Referenced by AsciiHisto(), draw(), and maxbin().
std::string evf::AsciiHisto::title_ [private] |
Definition at line 127 of file AsciiHisto.h.
Referenced by draw().
bool evf::AsciiHisto::uptodate_ [private] |
Definition at line 118 of file AsciiHisto.h.
Referenced by draw(), fill(), and fillDeque().
float evf::AsciiHisto::xmax_ [private] |
Definition at line 122 of file AsciiHisto.h.
Referenced by AsciiHisto().
float evf::AsciiHisto::xmin_ [private] |
Definition at line 121 of file AsciiHisto.h.
Referenced by AsciiHisto(), draw(), and fill().
float evf::AsciiHisto::ymax_ [private] |
Definition at line 123 of file AsciiHisto.h.
float evf::AsciiHisto::ymin_ [private] |
Definition at line 124 of file AsciiHisto.h.