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 Member Functions | Private Attributes
cacheutils::CachingPdf Class Reference

#include <CachingNLL.h>

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.

173  :
174  obs_(obs),
175  pdfOriginal_(pdf),
176  pdfPieces_(),
178  lastData_(0),
179  cache_(*pdf_,*obs_)
180 {
181 }
const RooAbsData * lastData_
Definition: CachingNLL.h:67
const RooAbsReal * pdf() const
Definition: CachingNLL.h:60
RooAbsReal * pdfOriginal_
Definition: CachingNLL.h:64
ValuesCache cache_
Definition: CachingNLL.h:68
RooAbsReal * pdf_
Definition: CachingNLL.h:66
RooAbsReal * fullCloneFunc(const RooAbsReal *pdf, RooArgSet &holder, bool cloneLeafNodes=false)
Definition: utils.cc:226
const RooArgSet * obs_
Definition: CachingNLL.h:63
cacheutils::CachingPdf::CachingPdf ( const CachingPdf other)

Definition at line 183 of file CachingNLL.cc.

183  :
184  obs_(other.obs_),
185  pdfOriginal_(other.pdfOriginal_),
186  pdfPieces_(),
188  lastData_(0),
189  cache_(*pdf_,*obs_)
190 {
191 }
const RooAbsData * lastData_
Definition: CachingNLL.h:67
RooAbsReal * pdfOriginal_
Definition: CachingNLL.h:64
ValuesCache cache_
Definition: CachingNLL.h:68
RooAbsReal * pdf_
Definition: CachingNLL.h:66
RooAbsReal * fullCloneFunc(const RooAbsReal *pdf, RooArgSet &holder, bool cloneLeafNodes=false)
Definition: utils.cc:226
const RooArgSet * obs_
Definition: CachingNLL.h:63
cacheutils::CachingPdf::~CachingPdf ( )

Definition at line 193 of file CachingNLL.cc.

194 {
195 }

Member Function Documentation

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

Definition at line 198 of file CachingNLL.cc.

References PerfCounter::add(), and data.

199 {
200 #ifdef DEBUG_CACHE
201  PerfCounter::add("CachingPdf::eval called");
202 #endif
203  bool newdata = (lastData_ != &data);
204  if (newdata) {
205  lastData_ = &data;
206  pdf_->optimizeCacheMode(*data.get());
207  pdf_->attachDataSet(data);
208  const_cast<RooAbsData*>(lastData_)->setDirtyProp(false);
209  cache_.clear();
210  }
211  std::pair<std::vector<Double_t> *, bool> hit = cache_.get();
212  if (!hit.second) {
213  realFill_(data, *hit.first);
214  }
215  return *hit.first;
216 }
const RooAbsData * lastData_
Definition: CachingNLL.h:67
void add(double increment=1.0)
ValuesCache cache_
Definition: CachingNLL.h:68
std::pair< std::vector< Double_t > *, bool > get()
Definition: CachingNLL.cc:121
RooAbsReal * pdf_
Definition: CachingNLL.h:66
void realFill_(const RooAbsData &data, std::vector< Double_t > &values)
Definition: CachingNLL.cc:219
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const RooAbsReal* cacheutils::CachingPdf::pdf ( ) const
inline

Definition at line 60 of file CachingNLL.h.

References pdf_.

60 { return pdf_; }
RooAbsReal * pdf_
Definition: CachingNLL.h:66
void cacheutils::CachingPdf::realFill_ ( const RooAbsData &  data,
std::vector< Double_t > &  values 
)
private

Definition at line 219 of file CachingNLL.cc.

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

220 {
221 #ifdef DEBUG_CACHE
222  PerfCounter::add("CachingPdf::realFill_ called");
223 #endif
224  int n = data.numEntries();
225  vals.resize(n); // should be a no-op if size is already >= n.
226  //std::auto_ptr<RooArgSet> params(pdf_->getObservables(*obs)); // for non-smart handling of pointers
227  std::vector<Double_t>::iterator itv = vals.begin();
228  for (int i = 0; i < n; ++i, ++itv) {
229  data.get(i);
230  //*params = *data.get(i); // for non-smart handling of pointers
231  *itv = pdf_->getVal(obs_);
232  //std::cout << " at i = " << i << " pdf = " << *itv << std::endl;
233  TRACE_NLL("PDF value for " << pdf_->GetName() << " is " << *itv << " at this point.")
234  TRACE_POINT2(*obs_,1)
235  }
236 }
#define TRACE_NLL(x)
Definition: CachingNLL.cc:59
int i
Definition: DBlmapReader.cc:9
void add(double increment=1.0)
#define TRACE_POINT2(x, i)
Definition: CachingNLL.cc:57
RooAbsReal * pdf_
Definition: CachingNLL.h:66
const RooArgSet * obs_
Definition: CachingNLL.h:63
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void cacheutils::CachingPdf::setDataDirty ( )
inline

Definition at line 61 of file CachingNLL.h.

References lastData_.

61 { lastData_ = 0; }
const RooAbsData * lastData_
Definition: CachingNLL.h:67

Member Data Documentation

ValuesCache cacheutils::CachingPdf::cache_
private

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.

RooArgSet cacheutils::CachingPdf::pdfPieces_
private

Definition at line 65 of file CachingNLL.h.