inlib  1.2.0
Public Types | Public Member Functions | Protected Member Functions
inlib::histo::h1< TC, TN, TW, TH > Class Template Reference
Inheritance diagram for inlib::histo::h1< TC, TN, TW, TH >:
Inheritance graph
[legend]
Collaboration diagram for inlib::histo::h1< TC, TN, TW, TH >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef b1< TC, TN, TW, TH >::bn_t bn_t

Public Member Functions

virtual TH bin_error (int aI) const
bool multiply (TW aFactor)
bool scale (TW aFactor)
void copy_from_data (const histo_data< TC, TN, TW > &a_from)
histo_data< TC, TN, TW > get_histo_data () const
bool reset ()
bool fill (TC aX, TW aWeight=1)
bool add (const h1 &a_histo)
bool subtract (const h1 &a_histo)
bool multiply (const h1 &a_histo)
bool divide (const h1 &a_histo)
bool gather_bins (unsigned int a_factor)
 h1 (const std::string &a_title, bn_t aXnumber, TC aXmin, TC aXmax)
 h1 (const std::string &a_title, const std::vector< TC > &aEdges)
virtual ~h1 ()
 h1 (const h1 &a_from)
h1operator= (const h1 &a_from)

Protected Member Functions

virtual TH get_bin_height (int a_offset) const

Detailed Description

template<class TC, class TN, class TW, class TH>
class inlib::histo::h1< TC, TN, TW, TH >

Definition at line 18 of file h1.


Member Typedef Documentation

template<class TC, class TN, class TW, class TH>
typedef b1<TC,TN,TW,TH>::bn_t inlib::histo::h1< TC, TN, TW, TH >::bn_t

Reimplemented from inlib::histo::b1< TC, TN, TW, TH >.

Definition at line 21 of file h1.


Constructor & Destructor Documentation

template<class TC, class TN, class TW, class TH>
inlib::histo::h1< TC, TN, TW, TH >::h1 ( const std::string &  a_title,
bn_t  aXnumber,
TC  aXmin,
TC  aXmax 
) [inline]

Definition at line 162 of file h1.

  : parent(a_title,aXnumber,aXmin,aXmax){}
template<class TC, class TN, class TW, class TH>
inlib::histo::h1< TC, TN, TW, TH >::h1 ( const std::string &  a_title,
const std::vector< TC > &  aEdges 
) [inline]

Definition at line 166 of file h1.

  : parent(a_title,aEdges){}
template<class TC, class TN, class TW, class TH>
virtual inlib::histo::h1< TC, TN, TW, TH >::~h1 ( ) [inline, virtual]

Definition at line 170 of file h1.

{}
template<class TC, class TN, class TW, class TH>
inlib::histo::h1< TC, TN, TW, TH >::h1 ( const h1< TC, TN, TW, TH > &  a_from) [inline]

Definition at line 172 of file h1.

: parent(a_from){}

Member Function Documentation

template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::add ( const h1< TC, TN, TW, TH > &  a_histo) [inline]

Definition at line 74 of file h1.

                             {
    parent::base_add(a_histo);
    this->update_fast_getters();
    return true;
  }
template<class TC, class TN, class TW, class TH>
virtual TH inlib::histo::h1< TC, TN, TW, TH >::bin_error ( int  aI) const [inline, virtual]

Implements inlib::histo::b1< TC, TN, TW, TH >.

Definition at line 27 of file h1.

                                     { //TH should be the same as TW
    if(parent::m_bin_number==0) return 0;
    bn_t offset;
    if(!parent::m_axes[0].in_range_to_absolute_index(aI,offset)) return 0;
    return ::sqrt(parent::m_bin_Sw2[offset]);
  }
template<class TC, class TN, class TW, class TH>
void inlib::histo::h1< TC, TN, TW, TH >::copy_from_data ( const histo_data< TC, TN, TW > &  a_from) [inline]

Definition at line 42 of file h1.

                                                          {
    parent::base_from_data(a_from);
  }
template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::divide ( const h1< TC, TN, TW, TH > &  a_histo) [inline]

Definition at line 91 of file h1.

                                 {
    if(!parent::base_divide(a_histo)) return false;
    this->update_fast_getters();
    return true;
  }
template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::fill ( TC  aX,
TW  aWeight = 1 
) [inline]

Definition at line 55 of file h1.

                                  {
    //m_coords[0] = aX;
    //return fill_bin(m_coords,aWeight);
    if(parent::m_dimension<=0) return false;

    bn_t offset;
    if(!parent::m_axes[0].coord_to_absolute_index(aX,offset)) return false;

    parent::m_bin_entries[offset]++;
    parent::m_bin_Sw[offset] += aWeight;
    parent::m_bin_Sw2[offset] += aWeight * aWeight;
  
    TC xw = aX * aWeight;
    TC x2w = aX * xw;
    parent::m_bin_Sxw[offset][0] += xw;
    parent::m_bin_Sx2w[offset][0] += x2w;
    return true;
  }
template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::gather_bins ( unsigned int  a_factor) [inline]

Definition at line 97 of file h1.

                                          { //for exa 2,3.
    if(!a_factor) return false;

    // actual bin number must be a multiple of a_factor.
    
    const histo::axis<TC>& _axis = this->axis();

    bn_t n = _axis.bins();
    if(!n) return false;

    bn_t new_n = n/a_factor;
    if(a_factor*new_n!=n) return false;

    h1* new_h = 0;
    if(_axis.is_fixed_binning()) {
      new_h = new h1(parent::m_title,
                     new_n,_axis.lower_edge(),_axis.upper_edge());
    } else {
      const std::vector<TC>& _edges = _axis.edges();
      std::vector<TC> new_edges(new_n+1);
      for(bn_t ibin=0;ibin<new_n;ibin++) {
        new_edges[ibin] = _edges[ibin*a_factor];
      }
      new_edges[new_n] = _edges[n]; //upper edge.
      new_h = new h1(parent::m_title,new_edges);
    }
    if(!new_h) return false;

    bn_t offset,new_offset,offac;
    for(bn_t ibin=0;ibin<new_n;ibin++) {
      new_offset = ibin+1;
      offset = a_factor*ibin+1;
      for(unsigned int ifac=0;ifac<a_factor;ifac++) {
        offac = offset+ifac;
        new_h->m_bin_entries[new_offset] += parent::m_bin_entries[offac];
        new_h->m_bin_Sw[new_offset] += parent::m_bin_Sw[offac];
        new_h->m_bin_Sw2[new_offset] += parent::m_bin_Sw2[offac];
        new_h->m_bin_Sxw[new_offset][0] += parent::m_bin_Sxw[offac][0];
        new_h->m_bin_Sx2w[new_offset][0] += parent::m_bin_Sx2w[offac][0];
      }
    }

    //underflow :
    new_offset = 0;
    offac = 0;
    new_h->m_bin_entries[new_offset] = parent::m_bin_entries[offac];
    new_h->m_bin_Sw[new_offset] = parent::m_bin_Sw[offac];
    new_h->m_bin_Sw2[new_offset] = parent::m_bin_Sw2[offac];
    new_h->m_bin_Sxw[new_offset][0] = parent::m_bin_Sxw[offac][0];
    new_h->m_bin_Sx2w[new_offset][0] = parent::m_bin_Sx2w[offac][0];

    //overflow :
    new_offset = new_n+1;
    offac = n+1;
    new_h->m_bin_entries[new_offset] = parent::m_bin_entries[offac];
    new_h->m_bin_Sw[new_offset] = parent::m_bin_Sw[offac];
    new_h->m_bin_Sw2[new_offset] = parent::m_bin_Sw2[offac];
    new_h->m_bin_Sxw[new_offset][0] = parent::m_bin_Sxw[offac][0];
    new_h->m_bin_Sx2w[new_offset][0] = parent::m_bin_Sx2w[offac][0];

    *this = *new_h;
    return true;
  }
template<class TC, class TN, class TW, class TH>
virtual TH inlib::histo::h1< TC, TN, TW, TH >::get_bin_height ( int  a_offset) const [inline, protected, virtual]

Implements inlib::histo::base_histo< TC, TN, TW, TH >.

Definition at line 23 of file h1.

                                                { //TH should be the same as TW
    return parent::m_bin_Sw[a_offset];
  }
template<class TC, class TN, class TW, class TH>
histo_data<TC,TN,TW> inlib::histo::h1< TC, TN, TW, TH >::get_histo_data ( ) const [inline]

Definition at line 45 of file h1.

                                              {
    return parent::base_get_data();
  }
template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::multiply ( TW  aFactor) [inline]

Definition at line 35 of file h1.

                           {
    if(!parent::base_multiply(aFactor)) return false;
    this->update_fast_getters();
    return true;
  }
template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::multiply ( const h1< TC, TN, TW, TH > &  a_histo) [inline]

Definition at line 85 of file h1.

                                   {  
    if(!parent::base_multiply(a_histo)) return false;
    this->update_fast_getters();
    return true;
  }
template<class TC, class TN, class TW, class TH>
h1& inlib::histo::h1< TC, TN, TW, TH >::operator= ( const h1< TC, TN, TW, TH > &  a_from) [inline]

Definition at line 173 of file h1.

                                 {
    parent::operator=(a_from);
    return *this;
  }
template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::reset ( ) [inline]

Definition at line 49 of file h1.

               {
    parent::base_reset();
    this->update_fast_getters();
    return true;
  }
template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::scale ( TW  aFactor) [inline]

Definition at line 40 of file h1.

{return multiply(aFactor);}
template<class TC, class TN, class TW, class TH>
bool inlib::histo::h1< TC, TN, TW, TH >::subtract ( const h1< TC, TN, TW, TH > &  a_histo) [inline]

Definition at line 79 of file h1.

                                  {
    parent::base_subtract(a_histo);
    this->update_fast_getters();
    return true;
  }

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