CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes

FastTemplate Class Reference

#include <FastTemplate.h>

Inheritance diagram for FastTemplate:
FastHisto FastHisto2D

List of all members.

Public Types

typedef double T

Public Member Functions

void Clear ()
void CopyValues (const FastTemplate &other)
void CopyValues (const TH1 &other)
void CopyValues (const TH2 &other)
void CropUnderflows (T minimum=1e-9)
 protect from underflows (*this = max(*this, minimum));
void Dump () const
void Exp ()
 *this = exp(*this)
 FastTemplate (const TH1 &other)
 FastTemplate (unsigned int size)
 FastTemplate (const TH2 &other)
 FastTemplate (const FastTemplate &other)
 FastTemplate ()
T Integral () const
void Log ()
 *this = log(*this)
void LogRatio (const FastTemplate &reference)
 *this = log(*this)/(reference)
void Meld (const FastTemplate &diff, const FastTemplate &sum, T x, T y)
 Does this += x * (diff + (sum)*y)
FastTemplateoperator= (const FastTemplate &other)
FastTemplateoperator= (const TH1 &other)
Toperator[] (unsigned int i)
const Toperator[] (unsigned int i) const
void Resize (unsigned int newsize)
void Scale (T factor)
const unsigned int size () const
void Subtract (const FastTemplate &reference)
 *this = *this - reference
 ~FastTemplate ()

Static Public Member Functions

static void SumDiff (const FastTemplate &h1, const FastTemplate &h2, FastTemplate &sum, FastTemplate &diff)
 assigns sum and diff

Protected Attributes

unsigned int size_
Tvalues_

Detailed Description

Definition at line 8 of file FastTemplate.h.


Member Typedef Documentation

typedef double FastTemplate::T

Definition at line 10 of file FastTemplate.h.


Constructor & Destructor Documentation

FastTemplate::FastTemplate ( ) [inline]

Definition at line 11 of file FastTemplate.h.

: size_(0), values_(0) {}
FastTemplate::FastTemplate ( unsigned int  size) [inline]

Definition at line 12 of file FastTemplate.h.

: size_(size), values_(new T[size_]) {}
FastTemplate::FastTemplate ( const FastTemplate other) [inline]

Definition at line 13 of file FastTemplate.h.

References CopyValues(), and size_.

: size_(other.size_), values_(size_ ? new T[size_] :  0) { if (size_) CopyValues(other); }
FastTemplate::FastTemplate ( const TH1 &  other) [inline]

Definition at line 14 of file FastTemplate.h.

References CopyValues().

: size_(other.GetNbinsX()), values_(new T[size_]) { CopyValues(other); }
FastTemplate::FastTemplate ( const TH2 &  other) [inline]

Definition at line 15 of file FastTemplate.h.

References CopyValues().

: size_(other.GetNbinsX()*other.GetNbinsY()), values_(new T[size_]) { CopyValues(other); }
FastTemplate::~FastTemplate ( ) [inline]

Definition at line 28 of file FastTemplate.h.

References values_.

{ delete [] values_; }

Member Function Documentation

void FastTemplate::Clear ( )

Definition at line 18 of file FastTemplate.cc.

References i, size_, and values_.

                         {
    for (unsigned int i = 0; i < size_; ++i) values_[i] = T(0.);
}
void FastTemplate::CopyValues ( const TH1 &  other)

Definition at line 26 of file FastTemplate.cc.

References i, size_, and values_.

                                              {
     for (unsigned int i = 0; i < size_; ++i) values_[i] = other.GetBinContent(i+1);
}
void FastTemplate::CopyValues ( const TH2 &  other)

Definition at line 30 of file FastTemplate.cc.

References i, and values_.

                                              {
    for (unsigned int i = 0, ix = 1, nx = other.GetNbinsX(), ny = other.GetNbinsY(); ix <= nx; ++ix) {
        for (unsigned int iy = 1; iy <= ny; ++iy, ++i) {
            values_[i] = other.GetBinContent(ix,iy);
            //printf("FastTemplate::CopyValues from %s: (ix,iy) = (%d/%d,%d/%d), i = %d/%d, val = %.5f\n", other.GetName(), ix, nx, iy, ny,  i, size_, values_[i]);
        }
    }
}
void FastTemplate::CopyValues ( const FastTemplate other)

Definition at line 22 of file FastTemplate.cc.

References size_, and values_.

Referenced by FastTemplate(), FastHisto::operator=(), FastHisto2D::operator=(), operator=(), and FastVerticalInterpHistPdfBase::syncTotal().

                                                       {
    memcpy(values_, other.values_, size_*sizeof(T));
}
void FastTemplate::CropUnderflows ( T  minimum = 1e-9)

protect from underflows (*this = max(*this, minimum));

Definition at line 220 of file FastTemplate.cc.

References i, size_, and values_.

Referenced by FastVerticalInterpHistPdfBase::syncTotal().

                                           {
    for (unsigned int i = 0; i < size_; ++i) {
        if (values_[i] < minimum) values_[i] = minimum;
    }
}   
void FastTemplate::Dump ( void  ) const

Reimplemented in FastHisto, and FastHisto2D.

Definition at line 39 of file FastTemplate.cc.

References i, size_, and values_.

                              {
    printf("--- dumping template with %d bins (@%p) ---\n", size_+1, (void*)values_);
    for (unsigned int i = 0; i < size_; ++i) printf(" bin %3d: yval = %9.5f\n", i, values_[i]);
    printf("\n"); 
}
void FastTemplate::Exp ( )

*this = exp(*this)

Definition at line 214 of file FastTemplate.cc.

References create_public_lumi_plots::exp, i, size_, and values_.

Referenced by FastVerticalInterpHistPdfBase::syncTotal().

                       {
    for (unsigned int i = 0; i < size_; ++i) {
        values_[i] = std::exp(values_[i]);
    }
}
FastTemplate::T FastTemplate::Integral ( ) const

Definition at line 8 of file FastTemplate.cc.

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

                                           {
    T total = 0;
    for (unsigned int i = 0; i < size_; ++i) total += values_[i];
    return total;
}
void FastTemplate::Log ( )

*this = log(*this)

Definition at line 208 of file FastTemplate.cc.

References i, create_public_lumi_plots::log, size_, and values_.

Referenced by FastVerticalInterpHistPdf::syncNominal(), and FastVerticalInterpHistPdf2D::syncNominal().

                       {
    for (unsigned int i = 0; i < size_; ++i) {
        values_[i] = values_[i] > 0 ? std::log(values_[i]) : T(-999);
    }
}
void FastTemplate::LogRatio ( const FastTemplate reference)

*this = log(*this)/(reference)

Definition at line 196 of file FastTemplate.cc.

References size_, and values_.

Referenced by FastVerticalInterpHistPdfBase::syncMorph().

                                                    {
    logratio(values_, size_, &ref[0]);
}
void FastTemplate::Meld ( const FastTemplate diff,
const FastTemplate sum,
T  x,
T  y 
)

Does this += x * (diff + (sum)*y)

Definition at line 204 of file FastTemplate.cc.

References size_, and values_.

Referenced by FastVerticalInterpHistPdfBase::syncTotal().

                                                                                     {
    meld(values_, size_, &diff[0], &sum[0], x, y);
}
FastTemplate& FastTemplate::operator= ( const TH1 &  other) [inline]

Reimplemented in FastHisto.

Definition at line 22 of file FastTemplate.h.

References CopyValues(), size_, and values_.

                                                   { 
            if (size_ != unsigned(other.GetNbinsX())) { 
                delete [] values_; size_ = other.GetNbinsX(); values_ = new T[size_];
            }
            CopyValues(other); return *this;  
        }
FastTemplate& FastTemplate::operator= ( const FastTemplate other) [inline]

Definition at line 16 of file FastTemplate.h.

References CopyValues(), size_, and values_.

                                                            { 
            if (size_ != other.size_) { 
                delete [] values_; size_ = other.size_; values_ = new T[size_];
            }
            CopyValues(other); return *this; 
        }
const T& FastTemplate::operator[] ( unsigned int  i) const [inline]

Definition at line 41 of file FastTemplate.h.

References i, and values_.

{ return values_[i]; }
T& FastTemplate::operator[] ( unsigned int  i) [inline]

Definition at line 40 of file FastTemplate.h.

References i, and values_.

{ return values_[i]; }
void FastTemplate::Resize ( unsigned int  newsize) [inline]

Definition at line 29 of file FastTemplate.h.

References size_, and values_.

                                          {
            if (newsize != size_) {
                delete [] values_; size_ = newsize; values_ = new T[size_];
            }
        }
void FastTemplate::Scale ( T  factor)

Definition at line 14 of file FastTemplate.cc.

References i, size_, and values_.

Referenced by FastHisto2D::Normalize(), and FastHisto::Normalize().

                                 {
    for (unsigned int i = 0; i < size_; ++i) values_[i] *= factor;
}
const unsigned int FastTemplate::size ( void  ) const [inline]
void FastTemplate::Subtract ( const FastTemplate reference)

*this = *this - reference

Definition at line 193 of file FastTemplate.cc.

References size_, python::rootplot::rootmath::subtract(), and values_.

Referenced by FastVerticalInterpHistPdfBase::syncMorph().

                                                    {
    subtract(values_, size_, &ref[0]);
}
void FastTemplate::SumDiff ( const FastTemplate h1,
const FastTemplate h2,
FastTemplate sum,
FastTemplate diff 
) [static]

assigns sum and diff

Definition at line 199 of file FastTemplate.cc.

References size_.

Referenced by FastVerticalInterpHistPdfBase::syncMorph().

                                                                    {
    sumdiff(&sum[0], &diff[0], h1.size_, &h1[0], &h2[0]);
}

Member Data Documentation

unsigned int FastTemplate::size_ [protected]
T* FastTemplate::values_ [protected]