CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

FastVerticalInterpHistPdf Class Reference

#include <VerticalInterpHistPdf.h>

Inheritance diagram for FastVerticalInterpHistPdf:
FastVerticalInterpHistPdfBase

List of all members.

Public Member Functions

virtual TObject * clone (const char *newname) const
Double_t evaluate () const
 FastVerticalInterpHistPdf ()
 FastVerticalInterpHistPdf (const char *name, const char *title, const RooRealVar &x, const RooArgList &funcList, const RooArgList &coefList, Double_t smoothRegion=1., Int_t smoothAlgo=1)
 FastVerticalInterpHistPdf (const FastVerticalInterpHistPdf &other, const char *name=0)
Bool_t hasCache () const
Bool_t isCacheReady () const
virtual ~FastVerticalInterpHistPdf ()

Protected Member Functions

void setupCaches () const
 not to be serialized
void syncComponent (int which) const
void syncComponents (int dimension) const
void syncNominal () const
void syncTotal () const

Protected Attributes

FastHisto _cache
 Cache of the result.
FastHisto _cacheNominal
 Cache of nominal pdf (additive morphing) and its bin-by-bin logarithm (multiplicative)
FastHisto _cacheNominalLog
 not to be serialized
RooRealProxy _x

Detailed Description

Definition at line 125 of file VerticalInterpHistPdf.h.


Constructor & Destructor Documentation

FastVerticalInterpHistPdf::FastVerticalInterpHistPdf ( ) [inline]

Definition at line 128 of file VerticalInterpHistPdf.h.

Referenced by clone().

FastVerticalInterpHistPdf::FastVerticalInterpHistPdf ( const char *  name,
const char *  title,
const RooRealVar &  x,
const RooArgList &  funcList,
const RooArgList &  coefList,
Double_t  smoothRegion = 1.,
Int_t  smoothAlgo = 1 
) [inline]

Definition at line 129 of file VerticalInterpHistPdf.h.

                                                                                                                                                                                            :
    FastVerticalInterpHistPdfBase(name,title,RooArgSet(x),funcList,coefList,smoothRegion,smoothAlgo),
    _x("x","Independent variable",this,const_cast<RooRealVar&>(x)),
    _cache(), _cacheNominal(), _cacheNominalLog()  {}
FastVerticalInterpHistPdf::FastVerticalInterpHistPdf ( const FastVerticalInterpHistPdf other,
const char *  name = 0 
) [inline]

Definition at line 133 of file VerticalInterpHistPdf.h.

                                                                                        :
    FastVerticalInterpHistPdfBase(other, name),
    _x("x",this,other._x),
#ifdef FastVerticalInterpHistPdf_CopyConstructor
    _cache(other._cache), _cacheNominal(other._cacheNominal), _cacheNominalLog(other._cacheNominalLog)  {}
virtual FastVerticalInterpHistPdf::~FastVerticalInterpHistPdf ( ) [inline, virtual]

Definition at line 142 of file VerticalInterpHistPdf.h.

{}

Member Function Documentation

virtual TObject* FastVerticalInterpHistPdf::clone ( const char *  newname) const [inline, virtual]

Implements FastVerticalInterpHistPdfBase.

Definition at line 141 of file VerticalInterpHistPdf.h.

References FastVerticalInterpHistPdf().

{ return new FastVerticalInterpHistPdf(*this,newname) ; }
Double_t FastVerticalInterpHistPdf::evaluate ( ) const [virtual]
Bool_t FastVerticalInterpHistPdf::hasCache ( ) const [inline]

Definition at line 146 of file VerticalInterpHistPdf.h.

References _cache, and FastTemplate::size().

{ return _cache.size() > 0; }
Bool_t FastVerticalInterpHistPdf::isCacheReady ( ) const [inline]

Definition at line 147 of file VerticalInterpHistPdf.h.

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

{ return _cache.size() > 0 && _init; }
void FastVerticalInterpHistPdf::setupCaches ( ) const [protected]

not to be serialized

Definition at line 489 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().

                                                  {
    TRACEME()
    int ndim = _coefList.getSize();

    _morphs.resize(ndim);
    _morphParams.resize(ndim);
    syncNominal();
    //printf("Nominal template has been set up: \n");  _cacheNominal.Dump();
    _coefIter->Reset();
    for (int i = 0; i < ndim; ++i) {
        _morphParams[i] = dynamic_cast<RooAbsReal *>(_coefIter->Next());
        _morphs[i].sum.Resize(_cacheNominal.size());
        _morphs[i].diff.Resize(_cacheNominal.size());
        syncComponents(i);
    } 
    _cache = FastHisto(_cacheNominal);

    if (_sentry.empty()) _sentry.addVars(_coefList); 
    syncTotal();
}
void FastVerticalInterpHistPdf::syncComponent ( int  which) const [protected]
void FastVerticalInterpHistPdf::syncComponents ( int  dimension) const [protected]

Definition at line 392 of file VerticalInterpHistPdf.cc.

References _cacheNominal, FastVerticalInterpHistPdfBase::_funcList, FastVerticalInterpHistPdfBase::_morphs, _x, FastHisto::Normalize(), FastVerticalInterpHistPdfBase::syncMorph(), TRACEME, and x.

Referenced by setupCaches().

                                                            {
    TRACEME()
    RooAbsPdf *pdfHi = dynamic_cast<RooAbsPdf *>(_funcList.at(2*dim+1));
    RooAbsPdf *pdfLo = dynamic_cast<RooAbsPdf *>(_funcList.at(2*dim+2));
    const RooRealVar &x = dynamic_cast<const RooRealVar &>(_x.arg());
    std::auto_ptr<TH1> histHi(pdfHi->createHistogram("",x)); histHi->SetDirectory(0); 
    std::auto_ptr<TH1> histLo(pdfLo->createHistogram("",x)); histLo->SetDirectory(0);

    FastHisto hi(*histHi), lo(*histLo); 
    //printf("Un-normalized templates for dimension %d: \n", dim);  hi.Dump(); lo.Dump();
    hi.Normalize(); lo.Normalize();
    //printf("Normalized templates for dimension %d: \n", dim);  hi.Dump(); lo.Dump();
    syncMorph(_morphs[dim], _cacheNominal, lo, hi);
}
void FastVerticalInterpHistPdf::syncNominal ( ) const [protected]

Definition at line 346 of file VerticalInterpHistPdf.cc.

References _cacheNominal, _cacheNominalLog, FastVerticalInterpHistPdfBase::_funcList, FastVerticalInterpHistPdfBase::_smoothAlgo, _x, estimatePileup::hist, FastTemplate::Log(), FastHisto::Normalize(), TRACEME, and x.

Referenced by setupCaches().

                                                  {
    TRACEME()
    RooAbsPdf *pdf = dynamic_cast<RooAbsPdf *>(_funcList.at(0));
    const RooRealVar &x = dynamic_cast<const RooRealVar &>(_x.arg());
    std::auto_ptr<TH1> hist(pdf->createHistogram("",x));
    hist->SetDirectory(0); 
    _cacheNominal = FastHisto(*hist);
    _cacheNominal.Normalize();
    if (_smoothAlgo < 0) {
        _cacheNominalLog = _cacheNominal;
        _cacheNominalLog.Log();
    }
}
void FastVerticalInterpHistPdf::syncTotal ( ) const [protected]

Definition at line 471 of file VerticalInterpHistPdf.cc.

References _cache, _cacheNominal, _cacheNominalLog, and FastHisto::Normalize().

Referenced by evaluate(), and setupCaches().

                                                {
    FastVerticalInterpHistPdfBase::syncTotal(_cache, _cacheNominal, _cacheNominalLog);

    // normalize the result
    _cache.Normalize(); 
    //printf("Normalized result\n");  _cache.Dump();
}

Member Data Documentation

Cache of the result.

Definition at line 152 of file VerticalInterpHistPdf.h.

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

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

not to be serialized

Definition at line 154 of file VerticalInterpHistPdf.h.

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

not to be serialized

Definition at line 155 of file VerticalInterpHistPdf.h.

Referenced by syncNominal(), and syncTotal().

RooRealProxy FastVerticalInterpHistPdf::_x [protected]

Reimplemented from FastVerticalInterpHistPdfBase.

Definition at line 149 of file VerticalInterpHistPdf.h.

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