CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
evf::AsciiHisto Class Reference

#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_
 

Detailed Description

Definition at line 14 of file AsciiHisto.h.

Constructor & Destructor Documentation

evf::AsciiHisto::AsciiHisto ( std::string  title,
unsigned int  nbins,
float  min,
float  max 
)
inline

Definition at line 17 of file AsciiHisto.h.

References binsize_, nbins_, xmax_, and xmin_.

17  :
18  uptodate_(false),
19  nbins_(nbins), xmin_(min), xmax_(max), ymax_(-100000.), cont_(nbins_,0), title_(title)
20  {
21  float span = xmax_-xmin_;
22  binsize_ = span/nbins_;
23  }
#define min(a, b)
Definition: mlp_lapack.h:161
const T & max(const T &a, const T &b)
std::vector< float > cont_
Definition: AsciiHisto.h:125
unsigned int nbins_
Definition: AsciiHisto.h:119
std::string title_
Definition: AsciiHisto.h:127

Member Function Documentation

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(), and Vispa.Gui.PortConnection.PointToPointConnection::paintEvent().

57  {
58  if(uptodate_) return current_;
59  maxbin();
60  float yscale = (ymax_*1.2) /20.;
61  std::ostringstream ost;
62  ost << " ^";
63  ost << std::setw(nbins_-title_.size()) << " ";
64  ost << title_ << std::endl;
65  // std::cout << " ^" << " " << title_ << std::endl;
66  for(int j = 20; j>=0; j--)
67  {
68  // std::cout << "--------------> "<< j << std::endl;
69  if(j%5==0){
70  ost << std::setw(8) << yscale*j << "-|";
71  // std::cout << std::setw(8) << yscale*j << "-|";
72  }
73  else{
74  ost << " |";
75  // std::cout << " |";
76  }
77  for(unsigned int i = 0; i < nbins_+5; i++)
78  {
79  if(j==0) {ost << "-"; /*std::cout << "-";*/}
80  else
81  {
82  if(i<nbins_ && cont_[i] > yscale*j)
83  {ost << "*"; /*std::cout << "*";*/}
84  else
85  {ost << " "; /*std::cout << " ";*/}
86  }
87  }
88  if(j==0){ost << ">"; /*std::cout << ">";*/}
89  ost << std::endl;
90  // std::cout << std::endl;
91  }
92  ost << " ";
93  // std::cout << " ";
94 
95  for(unsigned int i = 0; i < nbins_+5; i++)
96  {
97  if(i%10==0)
98  {ost << "|"; /*std::cout << "|";*/}
99  else
100  {ost << " "; /*std::cout << " ";*/}
101  }
102  ost << std::endl;
103  // std::cout << std::endl;
104  ost << std::setw(10) << xmin_ ;
105  // std::cout << std::setw(10) << xmin_;
106  for(unsigned int i = 0; i < nbins_+5; i++)
107  if((i+3)%10==0){ost << std::setw(10) << xmin_+binsize_*(i+3);
108  // std::cout << std::setw(10) << xmin_+binsize_*(i+3);
109  }
110  ost << std::endl;
111  // std::cout << std::endl;
112 
113  current_ = ost.str();
114  return current_;
115  }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
std::vector< float > cont_
Definition: AsciiHisto.h:125
unsigned int nbins_
Definition: AsciiHisto.h:119
std::string title_
Definition: AsciiHisto.h:127
std::string current_
Definition: AsciiHisto.h:126
void evf::AsciiHisto::fill ( float  x)
inline

Definition at line 25 of file AsciiHisto.h.

References newFWLiteAna::bin, binsize_, cont_, uptodate_, and xmin_.

26  {
27  uptodate_ = false;
28  int bin = (x-xmin_)/binsize_;
29  cont_[bin]++;
30  }
std::vector< float > cont_
Definition: AsciiHisto.h:125
x
Definition: VDTMath.h:216
void evf::AsciiHisto::fill ( float *  cont)
inline

Definition at line 31 of file AsciiHisto.h.

References cont_, i, and uptodate_.

32  {
33  uptodate_ = false;
34  for(unsigned int i = 0; i < cont_.size(); i++)
35  cont_[i] = cont[i];
36  }
int i
Definition: DBlmapReader.cc:9
std::vector< float > cont_
Definition: AsciiHisto.h:125
int cont
void evf::AsciiHisto::fillDeque ( std::deque< float > &  cont)
inline

Definition at line 38 of file AsciiHisto.h.

References cont_, i, and uptodate_.

Referenced by evf::AsciiRollingChart::flip().

39  {
40  uptodate_ = false;
41  for(unsigned int i = 0; i < cont_.size(); i++)
42  cont_[i] = cont.at(i);
43  }
int i
Definition: DBlmapReader.cc:9
std::vector< float > cont_
Definition: AsciiHisto.h:125
int cont
int evf::AsciiHisto::maxbin ( )
inline

Definition at line 45 of file AsciiHisto.h.

References cont_, i, nbins_, and ymax_.

Referenced by draw().

46  {
47  int retval = -1;
48  ymax_ = -100000.;
49  for(unsigned int i = 0; i < nbins_; i++)
50  if(ymax_ < cont_[i]){ymax_ = cont_[i]; retval = i;}
51 /* std::cout << "max bin " << retval << " has " << ymax_ << std::endl; */
52 /* std::cout << "nbins " << nbins_ */
53 /* << " binsize " << binsize_ << std::endl; */
54  return retval;
55  }
int i
Definition: DBlmapReader.cc:9
std::vector< float > cont_
Definition: AsciiHisto.h:125
unsigned int nbins_
Definition: AsciiHisto.h:119

Member Data Documentation

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.

Referenced by draw(), and maxbin().

float evf::AsciiHisto::ymin_
private

Definition at line 124 of file AsciiHisto.h.