CMS 3D CMS Logo

Public Member Functions | Private Attributes

FastHisto Class Reference

#include <FastTemplate.h>

Inheritance diagram for FastHisto:
FastTemplate

List of all members.

Public Member Functions

void Dump () const
 FastHisto ()
 FastHisto (const TH1 &hist)
 FastHisto (const FastHisto &other)
T GetAt (const T &x) const
T IntegralWidth () const
void Normalize ()
FastHistooperator= (const FastHisto &other)
FastHistooperator= (const TH1 &other)
void swap (FastHisto &other)
 ~FastHisto ()

Private Attributes

TbinEdges_
TbinWidths_

Detailed Description

Definition at line 64 of file FastTemplate.h.


Constructor & Destructor Documentation

FastHisto::FastHisto ( ) [inline]

Definition at line 66 of file FastTemplate.h.

FastHisto::FastHisto ( const TH1 &  hist)

Definition at line 45 of file FastTemplate.cc.

References binEdges_, binWidths_, i, and FastTemplate::size_.

                                    :
    FastTemplate(hist),
    binEdges_(new T[size_+1]),
    binWidths_(new T[size_])
{
    for (unsigned int i = 0; i < size_; ++i) {
        binEdges_[i] = hist.GetBinLowEdge(i+1);
        binWidths_[i] = hist.GetBinWidth(i+1);
    }
    binEdges_[size_] = hist.GetBinLowEdge(size_+1);
}
FastHisto::FastHisto ( const FastHisto other)

Definition at line 57 of file FastTemplate.cc.

References binEdges_, binWidths_, and FastTemplate::size_.

                                           :
    FastTemplate(other),
    binEdges_(size_ ? new T[size_+1] : 0),
    binWidths_(size_ ? new T[size_] : 0)
{
    if (size_) {
        memcpy(binEdges_,  other.binEdges_, (size_+1)*sizeof(T));
        memcpy(binWidths_, other.binWidths_, size_*sizeof(T));
    }
}
FastHisto::~FastHisto ( ) [inline]

Definition at line 83 of file FastTemplate.h.

References binEdges_, and binWidths_.

{ delete [] binEdges_; delete [] binWidths_; }

Member Function Documentation

void FastHisto::Dump ( void  ) const

Reimplemented from FastTemplate.

Definition at line 80 of file FastTemplate.cc.

References binEdges_, binWidths_, i, FastTemplate::size_, and FastTemplate::values_.

                           {
    printf("--- dumping histo template with %d bins in range %.2f - %.2f (@%p)---\n", size_+1, binEdges_[0], binEdges_[size_], (void*)values_);
    for (unsigned int i = 0; i < size_; ++i) {
        printf(" bin %3d, x = %6.2f: yval = %9.5f, width = %6.3f\n", 
                    i, 0.5*(binEdges_[i]+binEdges_[i+1]), values_[i], binWidths_[i]);
    }
    printf("\n"); 
}
FastHisto::T FastHisto::GetAt ( const T x) const

Definition at line 68 of file FastTemplate.cc.

References binEdges_, match(), FastTemplate::size_, and FastTemplate::values_.

Referenced by FastVerticalInterpHistPdf::evaluate().

                                            {
    T *match = std::lower_bound(binEdges_, binEdges_+size_+1, x);
    if (match == binEdges_ || match == binEdges_+size_+1) return T(0.0);
    return values_[match - binEdges_ - 1];
}
FastHisto::T FastHisto::IntegralWidth ( ) const

Definition at line 74 of file FastTemplate.cc.

References binWidths_, i, FastTemplate::size_, pileupDistInMC::total, and FastTemplate::values_.

Referenced by Normalize().

                                          {
    double total = 0;
    for (unsigned int i = 0; i < size_; ++i) total += values_[i] * binWidths_[i];
    return total;
}
void FastHisto::Normalize ( ) [inline]
FastHisto& FastHisto::operator= ( const TH1 &  other) [inline]

Reimplemented from FastTemplate.

Definition at line 76 of file FastTemplate.h.

References FastTemplate::CopyValues(), FastTemplate::size_, and swap().

                                                { 
            if (size_ != unsigned(other.GetNbinsX())) { 
                FastHisto fh(other);
                swap(fh);
            } else CopyValues(other); 
            CopyValues(other); return *this;  
        }
FastHisto& FastHisto::operator= ( const FastHisto other) [inline]

Definition at line 69 of file FastTemplate.h.

References FastTemplate::CopyValues(), FastTemplate::size_, and swap().

                                                      { 
            if (size_ != other.size_) {
                FastHisto fh(other);
                swap(fh);
            } else CopyValues(other); 
            return *this; 
        }
void FastHisto::swap ( FastHisto other) [inline]

Member Data Documentation

T* FastHisto::binEdges_ [private]

Definition at line 99 of file FastTemplate.h.

Referenced by Dump(), FastHisto(), GetAt(), swap(), and ~FastHisto().

Definition at line 100 of file FastTemplate.h.

Referenced by Dump(), FastHisto(), IntegralWidth(), swap(), and ~FastHisto().