CMS 3D CMS Logo

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

#include <VerticalInterpHistPdf.h>

Inheritance diagram for FastVerticalInterpHistPdf2D:
FastVerticalInterpHistPdfBase

Public Member Functions

virtual TObject * clone (const char *newname) const
 
Bool_t conditional () const
 
Double_t evaluate () const
 
 FastVerticalInterpHistPdf2D ()
 
 FastVerticalInterpHistPdf2D (const char *name, const char *title, const RooRealVar &x, const RooRealVar &y, bool conditional, const RooArgList &funcList, const RooArgList &coefList, Double_t smoothRegion=1., Int_t smoothAlgo=1)
 
 FastVerticalInterpHistPdf2D (const FastVerticalInterpHistPdf2D &other, const char *name=0)
 
Bool_t hasCache () const
 
Bool_t isCacheReady () const
 
Bool_t selfNormalized () const
 
virtual ~FastVerticalInterpHistPdf2D ()
 
- Public Member Functions inherited from FastVerticalInterpHistPdfBase
const RooArgList & coefList () const
 
 FastVerticalInterpHistPdfBase ()
 
 FastVerticalInterpHistPdfBase (const char *name, const char *title, const RooArgSet &obs, const RooArgList &funcList, const RooArgList &coefList, Double_t smoothRegion=1., Int_t smoothAlgo=1)
 
 FastVerticalInterpHistPdfBase (const FastVerticalInterpHistPdfBase &other, const char *name=0)
 
const RooArgList & funcList () const
 
Bool_t selfNormalized () const
 
virtual ~FastVerticalInterpHistPdfBase ()
 

Protected Member Functions

void setupCaches () const
 not to be serialized More...
 
void syncComponent (int which) const
 
void syncComponents (int dimension) const
 
void syncNominal () const
 
void syncTotal () const
 
- Protected Member Functions inherited from FastVerticalInterpHistPdfBase
double smoothStepFunc (double x) const
 
void syncMorph (Morph &out, const FastTemplate &nominal, FastTemplate &lo, FastTemplate &hi) const
 not to be serialized More...
 
void syncTotal (FastTemplate &cache, const FastTemplate &cacheNominal, const FastTemplate &cacheNominalLog) const
 

Protected Attributes

FastHisto2D _cache
 Cache of the result. More...
 
FastHisto2D _cacheNominal
 Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative) More...
 
FastHisto2D _cacheNominalLog
 not to be serialized More...
 
bool _conditional
 
RooRealProxy _x
 
RooRealProxy _y
 
- Protected Attributes inherited from FastVerticalInterpHistPdfBase
TIterator * _coefIter
 Iterator over FUNC list. More...
 
RooListProxy _coefList
 
TIterator * _funcIter
 
RooListProxy _funcList
 
bool _init
 Iterator over coefficient list. More...
 
std::vector< RooAbsReal * > _morphParams
 not to be serialized More...
 
std::vector< Morph_morphs
 not to be serialized More...
 
SimpleCacheSentry _sentry
 not to be serialized More...
 
Int_t _smoothAlgo
 
Double_t _smoothRegion
 
RooRealProxy _x
 

Detailed Description

Definition at line 167 of file VerticalInterpHistPdf.h.

Constructor & Destructor Documentation

FastVerticalInterpHistPdf2D::FastVerticalInterpHistPdf2D ( )
inline

Definition at line 170 of file VerticalInterpHistPdf.h.

Referenced by clone().

FastVerticalInterpHistPdf2D::FastVerticalInterpHistPdf2D ( const char *  name,
const char *  title,
const RooRealVar &  x,
const RooRealVar &  y,
bool  conditional,
const RooArgList &  funcList,
const RooArgList &  coefList,
Double_t  smoothRegion = 1.,
Int_t  smoothAlgo = 1 
)
inline

If conditional = false, the pdf is normalized integrating on (x,y). If conditional = true, the pdf is separately normalized integrating on (y) for each specific (x) bin

Definition at line 173 of file VerticalInterpHistPdf.h.

173  :
174  FastVerticalInterpHistPdfBase(name,title,RooArgSet(x,y),funcList,coefList,smoothRegion,smoothAlgo),
175  _x("x","Independent variable",this,const_cast<RooRealVar&>(x)),
176  _y("y","Independent variable",this,const_cast<RooRealVar&>(y)),
FastHisto2D _cacheNominal
Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative) ...
const RooArgList & funcList() const
FastHisto2D _cacheNominalLog
not to be serialized
const RooArgList & coefList() const
x
Definition: VDTMath.h:216
FastHisto2D _cache
Cache of the result.
FastVerticalInterpHistPdf2D::FastVerticalInterpHistPdf2D ( const FastVerticalInterpHistPdf2D other,
const char *  name = 0 
)
inline

Definition at line 179 of file VerticalInterpHistPdf.h.

179  :
181  _x("x",this,other._x), _y("y",this,other._y), _conditional(other._conditional),
182 #ifdef FastVerticalInterpHistPdf_CopyConstructor
FastHisto2D _cacheNominal
Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative) ...
FastHisto2D _cacheNominalLog
not to be serialized
FastHisto2D _cache
Cache of the result.
virtual FastVerticalInterpHistPdf2D::~FastVerticalInterpHistPdf2D ( )
inlinevirtual

Definition at line 188 of file VerticalInterpHistPdf.h.

188 {}

Member Function Documentation

virtual TObject* FastVerticalInterpHistPdf2D::clone ( const char *  newname) const
inlinevirtual

Implements FastVerticalInterpHistPdfBase.

Definition at line 187 of file VerticalInterpHistPdf.h.

References FastVerticalInterpHistPdf2D().

187 { return new FastVerticalInterpHistPdf2D(*this,newname) ; }
Bool_t FastVerticalInterpHistPdf2D::conditional ( ) const
inline

Definition at line 193 of file VerticalInterpHistPdf.h.

References _conditional.

Double_t FastVerticalInterpHistPdf2D::evaluate ( ) const
virtual

Implements FastVerticalInterpHistPdfBase.

Definition at line 334 of file VerticalInterpHistPdf.cc.

References _cache, FastVerticalInterpHistPdfBase::_init, FastVerticalInterpHistPdfBase::_sentry, _x, _y, FastHisto2D::GetAt(), SimpleCacheSentry::good(), setupCaches(), FastTemplate::size(), syncTotal(), and TRACEME.

335 {
336  TRACEME()
337  if (_cache.size() == 0) setupCaches();
338 
339  if (!_sentry.good() || !_init) syncTotal();
340  //return std::max<double>(1e-9, _cache.GetAt(_x, _y));
341  return _cache.GetAt(_x, _y);
342 }
#define TRACEME()
bool _init
Iterator over coefficient list.
void setupCaches() const
not to be serialized
SimpleCacheSentry _sentry
not to be serialized
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
FastHisto2D _cache
Cache of the result.
tuple size
Write out results.
Bool_t FastVerticalInterpHistPdf2D::hasCache ( ) const
inline

Definition at line 195 of file VerticalInterpHistPdf.h.

References _cache, and FastTemplate::size().

195 { return _cache.size() > 0; }
const unsigned int size() const
Definition: FastTemplate.h:42
FastHisto2D _cache
Cache of the result.
Bool_t FastVerticalInterpHistPdf2D::isCacheReady ( ) const
inline

Definition at line 196 of file VerticalInterpHistPdf.h.

References _cache, FastVerticalInterpHistPdfBase::_init, and FastTemplate::size().

196 { return _cache.size() > 0 && _init; }
const unsigned int size() const
Definition: FastTemplate.h:42
bool _init
Iterator over coefficient list.
FastHisto2D _cache
Cache of the result.
Bool_t FastVerticalInterpHistPdf2D::selfNormalized ( ) const
inline

Definition at line 192 of file VerticalInterpHistPdf.h.

192 { return kTRUE; }
void FastVerticalInterpHistPdf2D::setupCaches ( ) const
protected

not to be serialized

Definition at line 510 of file VerticalInterpHistPdf.cc.

References _cache, _cacheNominal, FastVerticalInterpHistPdfBase::_coefIter, FastVerticalInterpHistPdfBase::_coefList, FastVerticalInterpHistPdfBase::_morphParams, FastVerticalInterpHistPdfBase::_morphs, FastVerticalInterpHistPdfBase::_sentry, SimpleCacheSentry::addVars(), SimpleCacheSentry::empty(), i, FastTemplate::size(), syncComponents(), syncNominal(), syncTotal(), and TRACEME.

Referenced by evaluate().

510  {
511  TRACEME()
512  int ndim = _coefList.getSize();
513 
514  _morphs.resize(ndim);
515  _morphParams.resize(ndim);
516  syncNominal();
517  //printf("Nominal template has been set up: \n"); _cacheNominal.Dump();
518  _coefIter->Reset();
519  for (int i = 0; i < ndim; ++i) {
520  _morphParams[i] = dynamic_cast<RooAbsReal *>(_coefIter->Next());
521  _morphs[i].sum.Resize(_cacheNominal.size());
522  _morphs[i].diff.Resize(_cacheNominal.size());
523  syncComponents(i);
524  }
526 
528  syncTotal();
529 }
int i
Definition: DBlmapReader.cc:9
const unsigned int size() const
Definition: FastTemplate.h:42
FastHisto2D _cacheNominal
Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative) ...
#define TRACEME()
void syncComponents(int dimension) const
TIterator * _coefIter
Iterator over FUNC list.
std::vector< RooAbsReal * > _morphParams
not to be serialized
std::vector< Morph > _morphs
not to be serialized
void addVars(const RooAbsCollection &vars)
bool empty() const
SimpleCacheSentry _sentry
not to be serialized
void Reset(std::vector< TH2F > &depth)
FastHisto2D _cache
Cache of the result.
void FastVerticalInterpHistPdf2D::syncComponent ( int  which) const
protected
void FastVerticalInterpHistPdf2D::syncComponents ( int  dimension) const
protected

Definition at line 406 of file VerticalInterpHistPdf.cc.

References _cacheNominal, _conditional, FastVerticalInterpHistPdfBase::_funcList, FastVerticalInterpHistPdfBase::_morphs, _x, _y, none, FastHisto2D::Normalize(), FastHisto2D::NormalizeXSlices(), FastVerticalInterpHistPdfBase::syncMorph(), vdt::x, and detailsBasic3DVector::y.

Referenced by setupCaches().

406  {
407  RooAbsPdf *pdfHi = dynamic_cast<RooAbsPdf *>(_funcList.at(2*dim+1));
408  RooAbsPdf *pdfLo = dynamic_cast<RooAbsPdf *>(_funcList.at(2*dim+2));
409  const RooRealVar &x = dynamic_cast<const RooRealVar &>(_x.arg());
410  const RooRealVar &y = dynamic_cast<const RooRealVar &>(_y.arg());
411  const RooCmdArg &cond = _conditional ? RooFit::ConditionalObservables(RooArgSet(x)) : RooCmdArg::none();
412  std::auto_ptr<TH1> histHi(pdfHi->createHistogram("", x, RooFit::YVar(y), cond)); histHi->SetDirectory(0);
413  std::auto_ptr<TH1> histLo(pdfLo->createHistogram("", x, RooFit::YVar(y), cond)); histLo->SetDirectory(0);
414 
415  FastHisto2D hi(dynamic_cast<TH2&>(*histHi), _conditional), lo(dynamic_cast<TH2&>(*histLo), _conditional);
416  //printf("Un-normalized templates for dimension %d: \n", dim); hi.Dump(); lo.Dump();
417  if (_conditional) {
418  hi.NormalizeXSlices(); lo.NormalizeXSlices();
419  } else {
420  hi.Normalize(); lo.Normalize();
421  }
422  //printf("Normalized templates for dimension %d: \n", dim); hi.Dump(); lo.Dump();
423  syncMorph(_morphs[dim], _cacheNominal, lo, hi);
424 }
FastHisto2D _cacheNominal
Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative) ...
std::vector< Morph > _morphs
not to be serialized
x
Definition: VDTMath.h:216
void syncMorph(Morph &out, const FastTemplate &nominal, FastTemplate &lo, FastTemplate &hi) const
not to be serialized
void FastVerticalInterpHistPdf2D::syncNominal ( ) const
protected

Definition at line 360 of file VerticalInterpHistPdf.cc.

References _cacheNominal, _cacheNominalLog, _conditional, FastVerticalInterpHistPdfBase::_funcList, FastVerticalInterpHistPdfBase::_smoothAlgo, _x, _y, estimatePileup::hist, FastTemplate::Log(), none, FastHisto2D::Normalize(), FastHisto2D::NormalizeXSlices(), TRACEME, vdt::x, and detailsBasic3DVector::y.

Referenced by setupCaches().

360  {
361  TRACEME()
362  RooAbsPdf *pdf = dynamic_cast<RooAbsPdf *>(_funcList.at(0));
363  const RooRealVar &x = dynamic_cast<const RooRealVar &>(_x.arg());
364  const RooRealVar &y = dynamic_cast<const RooRealVar &>(_y.arg());
365  const RooCmdArg &cond = _conditional ? RooFit::ConditionalObservables(RooArgSet(x)) : RooCmdArg::none();
366  std::auto_ptr<TH1> hist(pdf->createHistogram("", x, RooFit::YVar(y), cond));
367  hist->SetDirectory(0);
368  _cacheNominal = FastHisto2D(dynamic_cast<TH2F&>(*hist), _conditional);
369  if (_conditional) _cacheNominal.NormalizeXSlices();
370  else _cacheNominal.Normalize();
371 
372  if (_smoothAlgo < 0) {
375  }
376 }
FastHisto2D _cacheNominal
Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative) ...
#define TRACEME()
A arg
Definition: Factorize.h:36
void Log()
*this = log(*this)
string const
Definition: compareJSON.py:14
FastHisto2D _cacheNominalLog
not to be serialized
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
x
Definition: VDTMath.h:216
list at
Definition: asciidump.py:428
void FastVerticalInterpHistPdf2D::syncTotal ( ) const
protected

Definition at line 479 of file VerticalInterpHistPdf.cc.

References _cache, _cacheNominal, _cacheNominalLog, _conditional, FastHisto2D::Normalize(), FastHisto2D::NormalizeXSlices(), and FastVerticalInterpHistPdfBase::syncTotal().

Referenced by evaluate(), and setupCaches().

479  {
481  // normalize the result
483  else _cache.Normalize();
484  //printf("Normalized result\n"); _cache.Dump();
485 }
FastHisto2D _cacheNominal
Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative) ...
void syncTotal(FastTemplate &cache, const FastTemplate &cacheNominal, const FastTemplate &cacheNominalLog) const
void NormalizeXSlices()
For each X, normalize along Y.
void Normalize()
Definition: FastTemplate.h:127
FastHisto2D _cacheNominalLog
not to be serialized
FastHisto2D _cache
Cache of the result.

Member Data Documentation

FastHisto2D FastVerticalInterpHistPdf2D::_cache
mutableprotected

Cache of the result.

Definition at line 202 of file VerticalInterpHistPdf.h.

Referenced by evaluate(), hasCache(), isCacheReady(), setupCaches(), and syncTotal().

FastHisto2D FastVerticalInterpHistPdf2D::_cacheNominal
mutableprotected

Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative)

not to be serialized

Definition at line 204 of file VerticalInterpHistPdf.h.

Referenced by setupCaches(), syncComponents(), syncNominal(), and syncTotal().

FastHisto2D FastVerticalInterpHistPdf2D::_cacheNominalLog
mutableprotected

not to be serialized

Definition at line 205 of file VerticalInterpHistPdf.h.

Referenced by syncNominal(), and syncTotal().

bool FastVerticalInterpHistPdf2D::_conditional
protected

Definition at line 199 of file VerticalInterpHistPdf.h.

Referenced by conditional(), syncComponents(), syncNominal(), and syncTotal().

RooRealProxy FastVerticalInterpHistPdf2D::_x
protected

Definition at line 198 of file VerticalInterpHistPdf.h.

Referenced by evaluate(), syncComponents(), and syncNominal().

RooRealProxy FastVerticalInterpHistPdf2D::_y
protected

Definition at line 198 of file VerticalInterpHistPdf.h.

Referenced by evaluate(), syncComponents(), and syncNominal().