CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

cacheutils::CachingPdf Class Reference

#include <CachingNLL.h>

List of all members.

Public Member Functions

 CachingPdf (RooAbsReal *pdf, const RooArgSet *obs)
 CachingPdf (const CachingPdf &other)
const std::vector< Double_t > & eval (const RooAbsData &data)
const RooAbsReal * pdf () const
void setDataDirty ()
 ~CachingPdf ()

Private Member Functions

void realFill_ (const RooAbsData &data, std::vector< Double_t > &values)

Private Attributes

ValuesCache cache_
const RooAbsData * lastData_
const RooArgSet * obs_
RooAbsReal * pdf_
RooAbsReal * pdfOriginal_
RooArgSet pdfPieces_

Detailed Description

Definition at line 54 of file CachingNLL.h.


Constructor & Destructor Documentation

cacheutils::CachingPdf::CachingPdf ( RooAbsReal *  pdf,
const RooArgSet *  obs 
)

Definition at line 173 of file CachingNLL.cc.

cacheutils::CachingPdf::CachingPdf ( const CachingPdf other)

Definition at line 183 of file CachingNLL.cc.

                                                        :
    obs_(other.obs_),
    pdfOriginal_(other.pdfOriginal_),
    pdfPieces_(),
    pdf_(utils::fullCloneFunc(pdfOriginal_, pdfPieces_)),
    lastData_(0),
    cache_(*pdf_,*obs_)
{
}
cacheutils::CachingPdf::~CachingPdf ( )

Definition at line 193 of file CachingNLL.cc.

{
}

Member Function Documentation

const std::vector< Double_t > & cacheutils::CachingPdf::eval ( const RooAbsData &  data)

Definition at line 198 of file CachingNLL.cc.

References Clusterizer1DCommons::add(), and data.

{
#ifdef DEBUG_CACHE
    PerfCounter::add("CachingPdf::eval called");
#endif
    bool newdata = (lastData_ != &data);
    if (newdata) {
        lastData_ = &data;
        pdf_->optimizeCacheMode(*data.get());
        pdf_->attachDataSet(data);
        const_cast<RooAbsData*>(lastData_)->setDirtyProp(false);
        cache_.clear();
    }
    std::pair<std::vector<Double_t> *, bool> hit = cache_.get();
    if (!hit.second) {
        realFill_(data, *hit.first);
    } 
    return *hit.first;
}
const RooAbsReal* cacheutils::CachingPdf::pdf ( ) const [inline]

Definition at line 60 of file CachingNLL.h.

References pdf_.

{ return pdf_; }
void cacheutils::CachingPdf::realFill_ ( const RooAbsData &  data,
std::vector< Double_t > &  values 
) [private]

Definition at line 219 of file CachingNLL.cc.

References Clusterizer1DCommons::add(), i, n, TRACE_NLL, and TRACE_POINT2.

{
#ifdef DEBUG_CACHE
    PerfCounter::add("CachingPdf::realFill_ called");
#endif
    int n = data.numEntries();
    vals.resize(n); // should be a no-op if size is already >= n.
    //std::auto_ptr<RooArgSet> params(pdf_->getObservables(*obs)); // for non-smart handling of pointers
    std::vector<Double_t>::iterator itv = vals.begin();
    for (int i = 0; i < n; ++i, ++itv) {
        data.get(i);
        //*params = *data.get(i); // for non-smart handling of pointers
        *itv = pdf_->getVal(obs_);
        //std::cout << " at i = " << i << " pdf = " << *itv << std::endl;
        TRACE_NLL("PDF value for " << pdf_->GetName() << " is " << *itv << " at this point.") 
        TRACE_POINT2(*obs_,1)
    }
}
void cacheutils::CachingPdf::setDataDirty ( ) [inline]

Definition at line 61 of file CachingNLL.h.

References lastData_.

{ lastData_ = 0; }

Member Data Documentation

Definition at line 68 of file CachingNLL.h.

const RooAbsData* cacheutils::CachingPdf::lastData_ [private]

Definition at line 67 of file CachingNLL.h.

Referenced by setDataDirty().

const RooArgSet* cacheutils::CachingPdf::obs_ [private]

Definition at line 63 of file CachingNLL.h.

RooAbsReal* cacheutils::CachingPdf::pdf_ [private]

Definition at line 66 of file CachingNLL.h.

Referenced by pdf().

RooAbsReal* cacheutils::CachingPdf::pdfOriginal_ [private]

Definition at line 64 of file CachingNLL.h.

Definition at line 65 of file CachingNLL.h.