inlib  1.2.0
Public Member Functions | Protected Member Functions | Protected Attributes
inlib::histo::c1d Class Reference
Inheritance diagram for inlib::histo::c1d:
Inheritance graph
[legend]
Collaboration diagram for inlib::histo::c1d:
Collaboration graph
[legend]

List of all members.

Public Member Functions

bool set_title (const std::string &a_title)
unsigned int dimension () const
bool reset ()
unsigned int entries () const
double sum_of_weights () const
bool convert_to_histogram ()
bool is_converted () const
bool scale (double a_scale)
bool fill (double aX, double aW=1)
double lower_edge () const
double upper_edge () const
double value (unsigned int aIndex) const
double weight (unsigned int aIndex) const
double mean () const
double rms () const
bool convert (unsigned int aBins, double aLowerEdge, double aUpperEdge)
bool convert (const std::vector< double > &aEdges)
const histo::h1dhistogram () const
bool fill_histogram (histo::h1d &a_histo) const
bool set_conversion_parameters (unsigned int aCnvXnumber, double aCnvXmin, double aCnvXmax)
 c1d ()
 c1d (const std::string &a_title, int aLimit=-1)
virtual ~c1d ()
 c1d (const c1d &a_from)
c1doperator= (const c1d &a_from)

Protected Member Functions

void clear ()

Protected Attributes

std::vector< double > m_xs
double m_lower_x
double m_upper_x
double m_Sxw
double m_Sx2w
unsigned int m_cnv_x_num
double m_cnv_x_min
double m_cnv_x_max
histo::h1dm_histo

Detailed Description

Definition at line 16 of file c1d.


Constructor & Destructor Documentation

inlib::histo::c1d::c1d ( ) [inline]

Definition at line 153 of file c1d.

inlib::histo::c1d::c1d ( const std::string &  a_title,
int  aLimit = -1 
) [inline]

Definition at line 160 of file c1d.

  :base_cloud(aLimit)
  ,m_lower_x(0),m_upper_x(0)
  ,m_Sxw(0),m_Sx2w(0)
  ,m_cnv_x_num(0),m_cnv_x_min(0),m_cnv_x_max(0),m_histo(0)
  {
    set_title(a_title);
  }
virtual inlib::histo::c1d::~c1d ( ) [inline, virtual]

Definition at line 169 of file c1d.

{delete m_histo;}
inlib::histo::c1d::c1d ( const c1d a_from) [inline]

Definition at line 171 of file c1d.

  :base_cloud(a_from)
  ,m_xs(a_from.m_xs)
  ,m_lower_x(a_from.m_lower_x)
  ,m_upper_x(a_from.m_upper_x)
  ,m_Sxw(a_from.m_Sxw)
  ,m_Sx2w(a_from.m_Sx2w)
  ,m_cnv_x_num(a_from.m_cnv_x_num)
  ,m_cnv_x_min(a_from.m_cnv_x_min)
  ,m_cnv_x_max(a_from.m_cnv_x_max)
  ,m_histo(0)
  {
    if(a_from.m_histo) {
      m_histo = new histo::h1d(*a_from.m_histo);
    }
  }

Member Function Documentation

void inlib::histo::c1d::clear ( ) [inline, protected]

Definition at line 207 of file c1d.

              {
    m_lower_x = 0;
    m_upper_x = 0;
    m_Sw = 0;
    m_Sxw = 0;
    m_Sx2w = 0;
    m_xs.clear();
    m_ws.clear();
  }
bool inlib::histo::c1d::convert ( unsigned int  aBins,
double  aLowerEdge,
double  aUpperEdge 
) [inline]

Definition at line 115 of file c1d.

                                                                      {
    if(m_histo) return true;
    m_histo = new histo::h1d(this->title(),aBins,aLowerEdge,aUpperEdge);
    if(!m_histo) return false;
    bool status = fill_histogram(*m_histo);
    clear();
    return status;
  }
bool inlib::histo::c1d::convert ( const std::vector< double > &  aEdges) [inline]

Definition at line 124 of file c1d.

                                                {
    if(m_histo) return true;
    m_histo = new histo::h1d(this->title(),aEdges);
    if(!m_histo) return false;
    bool status = fill_histogram(*m_histo);
    clear();
    return status;
  }
bool inlib::histo::c1d::convert_to_histogram ( ) [inline]

Definition at line 39 of file c1d.

                             {
    if( (m_cnv_x_num<=0) || (m_cnv_x_max<=m_cnv_x_min) ) {
      // Cloud min, max should be included in the histo.
      double dx = 0.01 * (upper_edge() - lower_edge())/BINS();
      return convert(BINS(),lower_edge(),upper_edge() + dx);
    } else {
      return convert(m_cnv_x_num,m_cnv_x_min,m_cnv_x_max);
    }
  }
unsigned int inlib::histo::c1d::dimension ( ) const [inline]

Definition at line 24 of file c1d.

{return 1;}
unsigned int inlib::histo::c1d::entries ( ) const [inline]

Definition at line 31 of file c1d.

                               { 
    return m_histo ? m_histo->all_entries() : m_ws.size();
  }
bool inlib::histo::c1d::fill ( double  aX,
double  aW = 1 
) [inline]

Definition at line 64 of file c1d.

                                    {
    if(!m_histo && (m_limit!=UNLIMITED()) && 
       ((int)m_xs.size()>=m_limit)){
      convert_to_histogram();
    }
  
    if(m_histo) {
      return m_histo->fill(aX,aW);
    } else {
      if(m_xs.size()) {
        m_lower_x = inlib::mn<double>(aX,m_lower_x);
        m_upper_x = inlib::mx<double>(aX,m_upper_x);
      } else {
        m_lower_x = aX;
        m_upper_x = aX;
      }
      m_xs.push_back(aX);
      m_ws.push_back(aW);
      m_Sw += aW;
      double xw = aX * aW;
      m_Sxw += xw;
      m_Sx2w += aX * xw;
      return true;
    }
  }
bool inlib::histo::c1d::fill_histogram ( histo::h1d a_histo) const [inline]

Definition at line 137 of file c1d.

                                               {
    unsigned int number = m_xs.size();
    for(unsigned int index=0;index<number;index++) {
      if(!a_histo.fill(m_xs[index],m_ws[index])) return false;
    }
    return true;
  }
const histo::h1d& inlib::histo::c1d::histogram ( ) const [inline]

Definition at line 133 of file c1d.

                                    {
    if(!m_histo) const_cast<c1d&>(*this).convert_to_histogram();
    return *m_histo;
  }
bool inlib::histo::c1d::is_converted ( ) const [inline]

Definition at line 49 of file c1d.

{return m_histo ? true : false;}
double inlib::histo::c1d::lower_edge ( ) const [inline]

Definition at line 90 of file c1d.

                            { 
    return (m_histo ? m_histo->axis().lower_edge() : m_lower_x);
  }
double inlib::histo::c1d::mean ( ) const [inline]

Definition at line 98 of file c1d.

                      {
    return (m_histo ? m_histo->mean() : (m_Sw?m_Sxw/m_Sw:0));
  }
c1d& inlib::histo::c1d::operator= ( const c1d a_from) [inline]

Definition at line 188 of file c1d.

                                   {
    base_cloud::operator=(a_from);
    m_xs = a_from.m_xs;
    m_lower_x = a_from.m_lower_x;
    m_upper_x = a_from.m_upper_x;
    m_Sxw = a_from.m_Sxw;
    m_Sx2w = a_from.m_Sx2w;
    m_cnv_x_num = a_from.m_cnv_x_num;
    m_cnv_x_min = a_from.m_cnv_x_min;
    m_cnv_x_max = a_from.m_cnv_x_max;
    delete m_histo;
    m_histo = 0;
    if(a_from.m_histo) {
      m_histo = new histo::h1d(*a_from.m_histo);
    }
    return *this;
  }
bool inlib::histo::c1d::reset ( ) [inline]

Definition at line 25 of file c1d.

               { 
    clear();
    delete m_histo;
    m_histo = 0;
    return true;
  }
double inlib::histo::c1d::rms ( ) const [inline]

Definition at line 101 of file c1d.

                     {
    double rms = 0; //FIXME nan.
    if(m_histo) {
      rms = m_histo->rms();
    } else {
      if(m_Sw==0) {
      } else {
        double mean = m_Sxw / m_Sw;
        rms = ::sqrt(::fabs( (m_Sx2w / m_Sw) - mean * mean));
      }
    }
    return rms;
  }
bool inlib::histo::c1d::scale ( double  a_scale) [inline]

Definition at line 50 of file c1d.

                             {
    if(m_histo) {
      return m_histo->scale(a_scale);
    } else {
      unsigned int number = m_ws.size();
      for(unsigned int index=0;index<number;index++) m_ws[index] *= a_scale;
      m_Sw *= a_scale;
      m_Sxw *= a_scale;
      m_Sx2w *= a_scale;
      return true;
    }
  }
bool inlib::histo::c1d::set_conversion_parameters ( unsigned int  aCnvXnumber,
double  aCnvXmin,
double  aCnvXmax 
) [inline]

Definition at line 144 of file c1d.

                                                                 {
    m_cnv_x_num = aCnvXnumber;
    m_cnv_x_min = aCnvXmin;
    m_cnv_x_max = aCnvXmax;
    return true;
  }
bool inlib::histo::c1d::set_title ( const std::string &  a_title) [inline]

Definition at line 18 of file c1d.

                                          {
    m_title = a_title;
    if(m_histo) m_histo->set_title(a_title);
    return true;
  }
double inlib::histo::c1d::sum_of_weights ( ) const [inline]

Definition at line 35 of file c1d.

                                { 
    return (m_histo ? m_histo->sum_bin_heights() : m_Sw);
  }
double inlib::histo::c1d::upper_edge ( ) const [inline]

Definition at line 93 of file c1d.

                            { 
    return (m_histo ? m_histo->axis().upper_edge() : m_upper_x);
  }
double inlib::histo::c1d::value ( unsigned int  aIndex) const [inline]

Definition at line 96 of file c1d.

{return (m_histo ?0:m_xs[aIndex]);}
double inlib::histo::c1d::weight ( unsigned int  aIndex) const [inline]

Definition at line 97 of file c1d.

{return (m_histo ?0:m_ws[aIndex]);}

Member Data Documentation

double inlib::histo::c1d::m_cnv_x_max [protected]

Definition at line 226 of file c1d.

double inlib::histo::c1d::m_cnv_x_min [protected]

Definition at line 225 of file c1d.

unsigned int inlib::histo::c1d::m_cnv_x_num [protected]

Definition at line 224 of file c1d.

Definition at line 227 of file c1d.

double inlib::histo::c1d::m_lower_x [protected]

Definition at line 219 of file c1d.

double inlib::histo::c1d::m_Sx2w [protected]

Definition at line 222 of file c1d.

double inlib::histo::c1d::m_Sxw [protected]

Definition at line 221 of file c1d.

double inlib::histo::c1d::m_upper_x [protected]

Definition at line 220 of file c1d.

std::vector<double> inlib::histo::c1d::m_xs [protected]

Definition at line 218 of file c1d.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines