CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
FastTemplate Class Reference

#include <FastTemplate.h>

Inheritance diagram for FastTemplate:
FastHisto FastHisto2D

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)); More...
 
void Dump () const
 
void Exp ()
 *this = exp(*this) More...
 
 FastTemplate ()
 
 FastTemplate (unsigned int size)
 
 FastTemplate (const FastTemplate &other)
 
 FastTemplate (const TH1 &other)
 
 FastTemplate (const TH2 &other)
 
T Integral () const
 
void Log ()
 *this = log(*this) More...
 
void LogRatio (const FastTemplate &reference)
 *this = log(*this)/(reference) More...
 
void Meld (const FastTemplate &diff, const FastTemplate &sum, T x, T y)
 Does this += x * (diff + (sum)*y) More...
 
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 More...
 
 ~FastTemplate ()
 

Static Public Member Functions

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

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.

11 : size_(0), values_(0) {}
unsigned int size_
Definition: FastTemplate.h:61
FastTemplate::FastTemplate ( unsigned int  size)
inline

Definition at line 12 of file FastTemplate.h.

12 : size_(size), values_(new T[size_]) {}
const unsigned int size() const
Definition: FastTemplate.h:42
unsigned int size_
Definition: FastTemplate.h:61
long double T
FastTemplate::FastTemplate ( const FastTemplate other)
inline

Definition at line 13 of file FastTemplate.h.

References CopyValues(), and size_.

13 : size_(other.size_), values_(size_ ? new T[size_] : 0) { if (size_) CopyValues(other); }
void CopyValues(const FastTemplate &other)
Definition: FastTemplate.cc:22
unsigned int size_
Definition: FastTemplate.h:61
long double T
FastTemplate::FastTemplate ( const TH1 &  other)
inline

Definition at line 14 of file FastTemplate.h.

References CopyValues().

14 : size_(other.GetNbinsX()), values_(new T[size_]) { CopyValues(other); }
void CopyValues(const FastTemplate &other)
Definition: FastTemplate.cc:22
unsigned int size_
Definition: FastTemplate.h:61
long double T
FastTemplate::FastTemplate ( const TH2 &  other)
inline

Definition at line 15 of file FastTemplate.h.

References CopyValues().

15 : size_(other.GetNbinsX()*other.GetNbinsY()), values_(new T[size_]) { CopyValues(other); }
void CopyValues(const FastTemplate &other)
Definition: FastTemplate.cc:22
unsigned int size_
Definition: FastTemplate.h:61
long double T
FastTemplate::~FastTemplate ( )
inline

Definition at line 28 of file FastTemplate.h.

References values_.

28 { delete [] values_; }

Member Function Documentation

void FastTemplate::Clear ( )

Definition at line 18 of file FastTemplate.cc.

References i, size_, and values_.

18  {
19  for (unsigned int i = 0; i < size_; ++i) values_[i] = T(0.);
20 }
int i
Definition: DBlmapReader.cc:9
unsigned int size_
Definition: FastTemplate.h:61
void FastTemplate::CopyValues ( const FastTemplate other)

Definition at line 22 of file FastTemplate.cc.

References size_, and values_.

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

22  {
23  memcpy(values_, other.values_, size_*sizeof(T));
24 }
unsigned int size_
Definition: FastTemplate.h:61
long double T
void FastTemplate::CopyValues ( const TH1 &  other)

Definition at line 26 of file FastTemplate.cc.

References i, size_, and values_.

26  {
27  for (unsigned int i = 0; i < size_; ++i) values_[i] = other.GetBinContent(i+1);
28 }
int i
Definition: DBlmapReader.cc:9
unsigned int size_
Definition: FastTemplate.h:61
void FastTemplate::CopyValues ( const TH2 &  other)

Definition at line 30 of file FastTemplate.cc.

References i, and values_.

30  {
31  for (unsigned int i = 0, ix = 1, nx = other.GetNbinsX(), ny = other.GetNbinsY(); ix <= nx; ++ix) {
32  for (unsigned int iy = 1; iy <= ny; ++iy, ++i) {
33  values_[i] = other.GetBinContent(ix,iy);
34  //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]);
35  }
36  }
37 }
int i
Definition: DBlmapReader.cc:9
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().

220  {
221  for (unsigned int i = 0; i < size_; ++i) {
222  if (values_[i] < minimum) values_[i] = minimum;
223  }
224 }
int i
Definition: DBlmapReader.cc:9
unsigned int size_
Definition: FastTemplate.h:61
void FastTemplate::Dump ( void  ) const

Definition at line 39 of file FastTemplate.cc.

References i, size_, and values_.

39  {
40  printf("--- dumping template with %d bins (@%p) ---\n", size_+1, (void*)values_);
41  for (unsigned int i = 0; i < size_; ++i) printf(" bin %3d: yval = %9.5f\n", i, values_[i]);
42  printf("\n");
43 }
int i
Definition: DBlmapReader.cc:9
unsigned int size_
Definition: FastTemplate.h:61
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().

214  {
215  for (unsigned int i = 0; i < size_; ++i) {
216  values_[i] = std::exp(values_[i]);
217  }
218 }
int i
Definition: DBlmapReader.cc:9
unsigned int size_
Definition: FastTemplate.h:61
FastTemplate::T FastTemplate::Integral ( ) const

Definition at line 8 of file FastTemplate.cc.

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

8  {
9  T total = 0;
10  for (unsigned int i = 0; i < size_; ++i) total += values_[i];
11  return total;
12 }
int i
Definition: DBlmapReader.cc:9
unsigned int size_
Definition: FastTemplate.h:61
long double T
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().

208  {
209  for (unsigned int i = 0; i < size_; ++i) {
210  values_[i] = values_[i] > 0 ? std::log(values_[i]) : T(-999);
211  }
212 }
int i
Definition: DBlmapReader.cc:9
unsigned int size_
Definition: FastTemplate.h:61
long double T
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().

196  {
197  logratio(values_, size_, &ref[0]);
198 }
unsigned int size_
Definition: FastTemplate.h:61
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().

204  {
205  meld(values_, size_, &diff[0], &sum[0], x, y);
206 }
unsigned int size_
Definition: FastTemplate.h:61
Definition: DDAxes.h:10
FastTemplate& FastTemplate::operator= ( const FastTemplate other)
inline

Definition at line 16 of file FastTemplate.h.

References CopyValues(), size_, and values_.

16  {
17  if (size_ != other.size_) {
18  delete [] values_; size_ = other.size_; values_ = new T[size_];
19  }
20  CopyValues(other); return *this;
21  }
void CopyValues(const FastTemplate &other)
Definition: FastTemplate.cc:22
unsigned int size_
Definition: FastTemplate.h:61
long double T
FastTemplate& FastTemplate::operator= ( const TH1 &  other)
inline

Definition at line 22 of file FastTemplate.h.

References CopyValues(), size_, and values_.

22  {
23  if (size_ != unsigned(other.GetNbinsX())) {
24  delete [] values_; size_ = other.GetNbinsX(); values_ = new T[size_];
25  }
26  CopyValues(other); return *this;
27  }
void CopyValues(const FastTemplate &other)
Definition: FastTemplate.cc:22
unsigned int size_
Definition: FastTemplate.h:61
long double T
T& FastTemplate::operator[] ( unsigned int  i)
inline

Definition at line 40 of file FastTemplate.h.

References i, and values_.

40 { return values_[i]; }
int i
Definition: DBlmapReader.cc:9
const T& FastTemplate::operator[] ( unsigned int  i) const
inline

Definition at line 41 of file FastTemplate.h.

References i, and values_.

41 { return values_[i]; }
int i
Definition: DBlmapReader.cc:9
void FastTemplate::Resize ( unsigned int  newsize)
inline

Definition at line 29 of file FastTemplate.h.

References size_, and values_.

29  {
30  if (newsize != size_) {
31  delete [] values_; size_ = newsize; values_ = new T[size_];
32  }
33  }
unsigned int size_
Definition: FastTemplate.h:61
long double T
void FastTemplate::Scale ( T  factor)

Definition at line 14 of file FastTemplate.cc.

References i, size_, and values_.

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

14  {
15  for (unsigned int i = 0; i < size_; ++i) values_[i] *= factor;
16 }
int i
Definition: DBlmapReader.cc:9
unsigned int size_
Definition: FastTemplate.h:61
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().

193  {
194  subtract(values_, size_, &ref[0]);
195 }
unsigned int size_
Definition: FastTemplate.h:61
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().

200  {
201  sumdiff(&sum[0], &diff[0], h1.size_, &h1[0], &h2[0]);
202 }
unsigned int size_
Definition: FastTemplate.h:61

Member Data Documentation

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