CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
FastHisto Class Reference

#include <FastTemplate.h>

Inheritance diagram for FastHisto:
FastTemplate

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 ()
 
- Public Member Functions inherited from FastTemplate
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 ()
 

Private Attributes

TbinEdges_
 
TbinWidths_
 

Additional Inherited Members

- Public Types inherited from FastTemplate
typedef double T
 
- Static Public Member Functions inherited from FastTemplate
static void SumDiff (const FastTemplate &h1, const FastTemplate &h2, FastTemplate &sum, FastTemplate &diff)
 assigns sum and diff More...
 
- Protected Attributes inherited from FastTemplate
unsigned int size_
 
Tvalues_
 

Detailed Description

Definition at line 64 of file FastTemplate.h.

Constructor & Destructor Documentation

FastHisto::FastHisto ( )
inline

Definition at line 66 of file FastTemplate.h.

66 : FastTemplate(), binEdges_(0), binWidths_(0) {}
T * binEdges_
Definition: FastTemplate.h:99
T * binWidths_
Definition: FastTemplate.h:100
FastHisto::FastHisto ( const TH1 &  hist)

Definition at line 45 of file FastTemplate.cc.

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

45  :
47  binEdges_(new T[size_+1]),
48  binWidths_(new T[size_])
49 {
50  for (unsigned int i = 0; i < size_; ++i) {
51  binEdges_[i] = hist.GetBinLowEdge(i+1);
52  binWidths_[i] = hist.GetBinWidth(i+1);
53  }
54  binEdges_[size_] = hist.GetBinLowEdge(size_+1);
55 }
T * binEdges_
Definition: FastTemplate.h:99
int i
Definition: DBlmapReader.cc:9
T * binWidths_
Definition: FastTemplate.h:100
unsigned int size_
Definition: FastTemplate.h:61
long double T
FastHisto::FastHisto ( const FastHisto other)

Definition at line 57 of file FastTemplate.cc.

References binEdges_, binWidths_, and FastTemplate::size_.

57  :
58  FastTemplate(other),
59  binEdges_(size_ ? new T[size_+1] : 0),
60  binWidths_(size_ ? new T[size_] : 0)
61 {
62  if (size_) {
63  memcpy(binEdges_, other.binEdges_, (size_+1)*sizeof(T));
64  memcpy(binWidths_, other.binWidths_, size_*sizeof(T));
65  }
66 }
T * binEdges_
Definition: FastTemplate.h:99
T * binWidths_
Definition: FastTemplate.h:100
unsigned int size_
Definition: FastTemplate.h:61
long double T
FastHisto::~FastHisto ( )
inline

Definition at line 83 of file FastTemplate.h.

References binEdges_, and binWidths_.

83 { delete [] binEdges_; delete [] binWidths_; }
T * binEdges_
Definition: FastTemplate.h:99
T * binWidths_
Definition: FastTemplate.h:100

Member Function Documentation

void FastHisto::Dump ( void  ) const

Definition at line 80 of file FastTemplate.cc.

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

80  {
81  printf("--- dumping histo template with %d bins in range %.2f - %.2f (@%p)---\n", size_+1, binEdges_[0], binEdges_[size_], (void*)values_);
82  for (unsigned int i = 0; i < size_; ++i) {
83  printf(" bin %3d, x = %6.2f: yval = %9.5f, width = %6.3f\n",
84  i, 0.5*(binEdges_[i]+binEdges_[i+1]), values_[i], binWidths_[i]);
85  }
86  printf("\n");
87 }
T * binEdges_
Definition: FastTemplate.h:99
int i
Definition: DBlmapReader.cc:9
T * binWidths_
Definition: FastTemplate.h:100
unsigned int size_
Definition: FastTemplate.h:61
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().

68  {
69  T *match = std::lower_bound(binEdges_, binEdges_+size_+1, x);
70  if (match == binEdges_ || match == binEdges_+size_+1) return T(0.0);
71  return values_[match - binEdges_ - 1];
72 }
T * binEdges_
Definition: FastTemplate.h:99
unsigned int size_
Definition: FastTemplate.h:61
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
x
Definition: VDTMath.h:216
long double T
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().

74  {
75  double total = 0;
76  for (unsigned int i = 0; i < size_; ++i) total += values_[i] * binWidths_[i];
77  return total;
78 }
int i
Definition: DBlmapReader.cc:9
T * binWidths_
Definition: FastTemplate.h:100
unsigned int size_
Definition: FastTemplate.h:61
void FastHisto::Normalize ( )
inline

Definition at line 92 of file FastTemplate.h.

References f, IntegralWidth(), and FastTemplate::Scale().

Referenced by FastVerticalInterpHistPdf::syncComponents(), FastVerticalInterpHistPdf::syncNominal(), and FastVerticalInterpHistPdf::syncTotal().

92  {
93  T sum = IntegralWidth();
94  if (sum > 0) Scale(1.0f/sum);
95  }
T IntegralWidth() const
Definition: FastTemplate.cc:74
double f[11][100]
long double T
void Scale(T factor)
Definition: FastTemplate.cc:14
FastHisto& FastHisto::operator= ( const FastHisto other)
inline

Definition at line 69 of file FastTemplate.h.

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

69  {
70  if (size_ != other.size_) {
71  FastHisto fh(other);
72  swap(fh);
73  } else CopyValues(other);
74  return *this;
75  }
void CopyValues(const FastTemplate &other)
Definition: FastTemplate.cc:22
unsigned int size_
Definition: FastTemplate.h:61
void swap(FastHisto &other)
Definition: FastTemplate.h:84
FastHisto& FastHisto::operator= ( const TH1 &  other)
inline

Definition at line 76 of file FastTemplate.h.

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

76  {
77  if (size_ != unsigned(other.GetNbinsX())) {
78  FastHisto fh(other);
79  swap(fh);
80  } else CopyValues(other);
81  CopyValues(other); return *this;
82  }
void CopyValues(const FastTemplate &other)
Definition: FastTemplate.cc:22
unsigned int size_
Definition: FastTemplate.h:61
void swap(FastHisto &other)
Definition: FastTemplate.h:84
void FastHisto::swap ( FastHisto other)
inline

Definition at line 84 of file FastTemplate.h.

References binEdges_, binWidths_, FastTemplate::size_, std::swap(), and FastTemplate::values_.

Referenced by operator=().

84  {
85  std::swap(size_, other.size_);
86  std::swap(values_, other.values_);
89  }
T * binEdges_
Definition: FastTemplate.h:99
T * binWidths_
Definition: FastTemplate.h:100
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
unsigned int size_
Definition: FastTemplate.h:61

Member Data Documentation

T* FastHisto::binEdges_
private

Definition at line 99 of file FastTemplate.h.

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

T* FastHisto::binWidths_
private

Definition at line 100 of file FastTemplate.h.

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