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

List of all members.

Public Member Functions

virtual TH bin_error (int aI) const
bool multiply (TW aFactor)
bool scale (TW aFactor)
TV bin_Svw (int aI) const
TV bin_Sv2w (int aI) const
bool reset ()
void copy_from_data (const profile_data< TC, TN, TW, TV > &a_from)
profile_data< TC, TN, TW, TV > get_histo_data () const
bool fill (TC aX, TV aV, TW aWeight=1)
TV bin_rms_value (int aI) const
bool add (const p1 &a_histo)
bool subtract (const p1 &a_histo)
bool gather_bins (unsigned int a_factor)
bool cut_v () const
TV min_v () const
TV max_v () const
 p1 (const std::string &a_title, bn_t aXnumber, TC aXmin, TC aXmax)
 p1 (const std::string &a_title, bn_t aXnumber, TC aXmin, TC aXmax, TV aVmin, TV aVmax)
 p1 (const std::string &a_title, const std::vector< TC > &aEdges)
 p1 (const std::string &a_title, const std::vector< TC > &aEdges, TV aVmin, TV aVmax)
virtual ~p1 ()
 p1 (const p1 &a_from)
p1operator= (const p1 &a_from)
const std::vector< TV > & bins_sum_vw () const
const std::vector< TV > & bins_sum_v2w () const

Protected Member Functions

virtual TH get_bin_height (int a_offset) const

Protected Attributes

bool m_cut_v
TV m_min_v
TV m_max_v
std::vector< TV > m_bin_Svw
std::vector< TV > m_bin_Sv2w

Detailed Description

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

Definition at line 19 of file p1.


Constructor & Destructor Documentation

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

Definition at line 253 of file p1.

  : parent(a_title,aXnumber,aXmin,aXmax)
  ,m_cut_v(false)
  ,m_min_v(0)
  ,m_max_v(0)
  {
    m_bin_Svw.resize(parent::m_bin_number,0);
    m_bin_Sv2w.resize(parent::m_bin_number,0);
  }
template<class TC, class TN, class TW, class TH, class TV>
inlib::histo::p1< TC, TN, TW, TH, TV >::p1 ( const std::string &  a_title,
bn_t  aXnumber,
TC  aXmin,
TC  aXmax,
TV  aVmin,
TV  aVmax 
) [inline]

Definition at line 264 of file p1.

  : parent(a_title,aXnumber,aXmin,aXmax)
  ,m_cut_v(true)
  ,m_min_v(aVmin)
  ,m_max_v(aVmax)
  {
    m_bin_Svw.resize(parent::m_bin_number,0);
    m_bin_Sv2w.resize(parent::m_bin_number,0);
  }
template<class TC, class TN, class TW, class TH, class TV>
inlib::histo::p1< TC, TN, TW, TH, TV >::p1 ( const std::string &  a_title,
const std::vector< TC > &  aEdges 
) [inline]

Definition at line 276 of file p1.

  : parent(a_title,aEdges)
  ,m_cut_v(false)
  ,m_min_v(0)
  ,m_max_v(0)
  {
    m_bin_Svw.resize(parent::m_bin_number,0);
    m_bin_Sv2w.resize(parent::m_bin_number,0);
  }
template<class TC, class TN, class TW, class TH, class TV>
inlib::histo::p1< TC, TN, TW, TH, TV >::p1 ( const std::string &  a_title,
const std::vector< TC > &  aEdges,
TV  aVmin,
TV  aVmax 
) [inline]

Definition at line 287 of file p1.

  : parent(a_title,aEdges) 
  ,m_cut_v(true)
  ,m_min_v(aVmin)
  ,m_max_v(aVmax)
  {
    m_bin_Svw.resize(parent::m_bin_number,0);
    m_bin_Sv2w.resize(parent::m_bin_number,0);
  }
template<class TC, class TN, class TW, class TH, class TV>
virtual inlib::histo::p1< TC, TN, TW, TH, TV >::~p1 ( ) [inline, virtual]

Definition at line 299 of file p1.

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

Definition at line 301 of file p1.

  : parent(a_from)
  ,m_cut_v(a_from.m_cut_v)
  ,m_min_v(a_from.m_min_v)
  ,m_max_v(a_from.m_max_v)
  ,m_bin_Svw(a_from.m_bin_Svw)
  ,m_bin_Sv2w(a_from.m_bin_Sv2w)
  {}

Member Function Documentation

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

Definition at line 153 of file p1.

                             {
    parent::base_add(a_histo);
    for(bn_t ibin=0;ibin<parent::m_bin_number;ibin++) {
      m_bin_Svw[ibin] += a_histo.m_bin_Svw[ibin];      
      m_bin_Sv2w[ibin] += a_histo.m_bin_Sv2w[ibin];      
    }
    this->update_fast_getters();
    return true;
  }
template<class TC, class TN, class TW, class TH, class TV>
virtual TH inlib::histo::p1< TC, TN, TW, TH, TV >::bin_error ( int  aI) const [inline, virtual]

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

Definition at line 28 of file p1.

                                     { //TH should be the same as TV
    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;

    //FIXME Is it correct ?
    // TProfile::GetBinError with kERRORMEAN mode does :
    //  Stat_t cont = fArray[bin];              //Svw (see TProfile::Fill)
    //  Stat_t sum  = parent::m_bin_entries.fArray[bin];  //Sw
    //  Stat_t err2 = fSumw2.fArray[bin];       //Sv2w
    //  if (sum == 0) return 0;
    //  Stat_t eprim;
    //  Stat_t contsum = cont/sum;
    //  Stat_t eprim2  = TMath::Abs(err2/sum - contsum*contsum);
    //  eprim          = TMath::Sqrt(eprim2);
    //  ... ??? 
    //  if (fErrorMode == kERRORMEAN) return eprim/TMath::Sqrt(sum);
  
    TW sw = parent::m_bin_Sw[offset];      //ROOT sum
    if(sw==0) return 0;
    TV svw = m_bin_Svw[offset];    //ROOT cont
    TV sv2w = m_bin_Sv2w[offset];  //ROOT err2
    TV mean = (svw / sw);        //ROOT contsum
    TV rms = ::sqrt(::fabs((sv2w/sw) - mean * mean)); //ROOT eprim
    // rms = get_bin_rms_value.
    return rms/::sqrt(sw); //ROOT kERRORMEAN mode returned value
  }
template<class TC, class TN, class TW, class TH, class TV>
TV inlib::histo::p1< TC, TN, TW, TH, TV >::bin_rms_value ( int  aI) const [inline]

Definition at line 140 of file p1.

                                 {
    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;

    TW sw = parent::m_bin_Sw[offset];
    if(sw==0) return 0;
    TV svw = m_bin_Svw[offset];
    TV sv2w = m_bin_Sv2w[offset];
    TV mean = (svw / sw);
    return ::sqrt(::fabs((sv2w / sw) - mean * mean));
  }
template<class TC, class TN, class TW, class TH, class TV>
TV inlib::histo::p1< TC, TN, TW, TH, TV >::bin_Sv2w ( int  aI) const [inline]

Definition at line 73 of file p1.

                            {
    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 parent::m_bin_Sv2w(offset);
  }
template<class TC, class TN, class TW, class TH, class TV>
TV inlib::histo::p1< TC, TN, TW, TH, TV >::bin_Svw ( int  aI) const [inline]

Definition at line 67 of file p1.

                           {
    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 parent::m_bin_Svw(offset);
  }
template<class TC, class TN, class TW, class TH, class TV>
const std::vector<TV>& inlib::histo::p1< TC, TN, TW, TH, TV >::bins_sum_v2w ( ) const [inline]

Definition at line 320 of file p1.

{return m_bin_Sv2w;}
template<class TC, class TN, class TW, class TH, class TV>
const std::vector<TV>& inlib::histo::p1< TC, TN, TW, TH, TV >::bins_sum_vw ( ) const [inline]

Definition at line 319 of file p1.

{return m_bin_Svw;}
template<class TC, class TN, class TW, class TH, class TV>
void inlib::histo::p1< TC, TN, TW, TH, TV >::copy_from_data ( const profile_data< TC, TN, TW, TV > &  a_from) [inline]

Definition at line 90 of file p1.

                                                               {
    parent::base_from_data(a_from);
    m_bin_Svw = a_from.m_bin_Svw;
    m_bin_Sv2w = a_from.m_bin_Sv2w;
    m_cut_v = a_from.m_cut_v;
    m_min_v = a_from.m_min_v;
    m_max_v = a_from.m_max_v;
  }
template<class TC, class TN, class TW, class TH, class TV>
bool inlib::histo::p1< TC, TN, TW, TH, TV >::cut_v ( ) const [inline]

Definition at line 248 of file p1.

{return m_cut_v;}
template<class TC, class TN, class TW, class TH, class TV>
bool inlib::histo::p1< TC, TN, TW, TH, TV >::fill ( TC  aX,
TV  aV,
TW  aWeight = 1 
) [inline]

Definition at line 109 of file p1.

                                        {
    //m_coords[0] = aX;
    //return fill_bin(m_coords,aV,aWeight);

    if(!parent::m_dimension) return false;
    if(m_cut_v) {
      if( (aV<m_min_v) || (aV>=m_max_v) ) {
        return true;
      }
    }

    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;

    // Profile part :
    TV vw = aV * aWeight;
    m_bin_Svw[offset] += vw;
    m_bin_Sv2w[offset] += aV * vw;

    return true;
  }
template<class TC, class TN, class TW, class TH, class TV>
bool inlib::histo::p1< TC, TN, TW, TH, TV >::gather_bins ( unsigned int  a_factor) [inline]

Definition at line 172 of file p1.

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

    // actual bin number must be a multiple of a_factor.
    typedef typename b1<TC,TN,TW,TH>::bn_t bn_t;
    
    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;

    p1* new_h = 0;
    if(_axis.is_fixed_binning()) {
      new_h = new p1(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 p1(parent::m_title,new_edges);
    }
    if(!new_h) return false;

    new_h->m_cut_v = m_cut_v;
    new_h->m_min_v = m_min_v;
    new_h->m_max_v = m_max_v;

    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];

        new_h->m_bin_Svw[new_offset] += m_bin_Svw[offac];
        new_h->m_bin_Sv2w[new_offset] += m_bin_Sv2w[offac];
      }
    }

    //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];
    new_h->m_bin_Svw[new_offset] = m_bin_Svw[offac];
    new_h->m_bin_Sv2w[new_offset] = m_bin_Sv2w[offac];

    //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];
    new_h->m_bin_Svw[new_offset] = m_bin_Svw[offac];
    new_h->m_bin_Sv2w[new_offset] = m_bin_Sv2w[offac];

    *this = *new_h;
    return true;
  }
template<class TC, class TN, class TW, class TH, class TV>
virtual TH inlib::histo::p1< TC, TN, TW, TH, TV >::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 p1.

                                                {
    return (parent::m_bin_Sw[a_offset] ? (m_bin_Svw[a_offset]/parent::m_bin_Sw[a_offset]):0);
  }
template<class TC, class TN, class TW, class TH, class TV>
profile_data<TC,TN,TW,TV> inlib::histo::p1< TC, TN, TW, TH, TV >::get_histo_data ( ) const [inline]

Definition at line 98 of file p1.

                                                   {
    profile_data<TC,TN,TW,TV> hd(parent::base_get_data());
    hd.m_is_profile = true;
    hd.m_bin_Svw = m_bin_Svw;
    hd.m_bin_Sv2w = m_bin_Sv2w;
    hd.m_cut_v = m_cut_v;
    hd.m_min_v = m_min_v;
    hd.m_max_v = m_max_v;
    return hd;
  }
template<class TC, class TN, class TW, class TH, class TV>
TV inlib::histo::p1< TC, TN, TW, TH, TV >::max_v ( ) const [inline]

Definition at line 250 of file p1.

{return m_max_v;}
template<class TC, class TN, class TW, class TH, class TV>
TV inlib::histo::p1< TC, TN, TW, TH, TV >::min_v ( ) const [inline]

Definition at line 249 of file p1.

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

Definition at line 57 of file p1.

                           {
    if(!parent::base_multiply(aFactor)) return false;
    for(bn_t ibin=0;ibin<parent::m_bin_number;ibin++) {
      m_bin_Svw[ibin] *= aFactor;
    }
    this->update_fast_getters();
    return true;
  }
template<class TC, class TN, class TW, class TH, class TV>
p1& inlib::histo::p1< TC, TN, TW, TH, TV >::operator= ( const p1< TC, TN, TW, TH, TV > &  a_from) [inline]

Definition at line 309 of file p1.

                                 {
    parent::operator=(a_from);
    m_cut_v = a_from.m_cut_v;
    m_min_v = a_from.m_min_v;
    m_max_v = a_from.m_max_v;
    m_bin_Svw = a_from.m_bin_Svw;
    m_bin_Sv2w = a_from.m_bin_Sv2w;
    return *this;
  }
template<class TC, class TN, class TW, class TH, class TV>
bool inlib::histo::p1< TC, TN, TW, TH, TV >::reset ( ) [inline]

Definition at line 80 of file p1.

               {
    parent::base_reset();
    for(bn_t ibin=0;ibin<parent::m_bin_number;ibin++) {
      m_bin_Svw[ibin] = 0;
      m_bin_Sv2w[ibin] = 0;
    }
    this->update_fast_getters();
    return true;
  }
template<class TC, class TN, class TW, class TH, class TV>
bool inlib::histo::p1< TC, TN, TW, TH, TV >::scale ( TW  aFactor) [inline]

Definition at line 65 of file p1.

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

Definition at line 162 of file p1.

                                  {
    parent::base_subtract(a_histo);
    for(bn_t ibin=0;ibin<parent::m_bin_number;ibin++) {
      m_bin_Svw[ibin] -= a_histo.m_bin_Svw[ibin];      
      m_bin_Sv2w[ibin] -= a_histo.m_bin_Sv2w[ibin];      
    }
    this->update_fast_getters();
    return true;
  }

Member Data Documentation

template<class TC, class TN, class TW, class TH, class TV>
std::vector<TV> inlib::histo::p1< TC, TN, TW, TH, TV >::m_bin_Sv2w [protected]

Definition at line 326 of file p1.

template<class TC, class TN, class TW, class TH, class TV>
std::vector<TV> inlib::histo::p1< TC, TN, TW, TH, TV >::m_bin_Svw [protected]

Definition at line 325 of file p1.

template<class TC, class TN, class TW, class TH, class TV>
bool inlib::histo::p1< TC, TN, TW, TH, TV >::m_cut_v [protected]

Definition at line 322 of file p1.

template<class TC, class TN, class TW, class TH, class TV>
TV inlib::histo::p1< TC, TN, TW, TH, TV >::m_max_v [protected]

Definition at line 324 of file p1.

template<class TC, class TN, class TW, class TH, class TV>
TV inlib::histo::p1< TC, TN, TW, TH, TV >::m_min_v [protected]

Definition at line 323 of file p1.


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