MINT2
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
RooEffResModel Class Reference

#include <RooEffResModel.h>

Inheritance diagram for RooEffResModel:
RooAbsEffResModel

Classes

class  CacheElem
 

Public Member Functions

 RooEffResModel ()
 
 RooEffResModel (const char *name, const char *title, RooResolutionModel &model, RooAbsReal &eff)
 
 RooEffResModel (const RooEffResModel &other, const char *name=0)
 
virtual RooEffResModelclone (const char *newname) const
 
virtual ~RooEffResModel ()
 
virtual Int_t basisCode (const char *name) const
 
virtual Int_t getAnalyticalIntegral (RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
 
virtual Double_t analyticalIntegral (Int_t code, const char *rangeName) const
 
virtual Bool_t forceAnalyticalInt (const RooAbsArg &dep) const
 
virtual Int_t getGenerator (const RooArgSet &directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const
 
virtual void initGenerator (Int_t code)
 
virtual void generateEvent (Int_t code)
 
virtual RooAbsGenContext * modelGenContext (const RooAbsAnaConvPdf &convPdf, const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE) const
 
virtual RooAbsReal * efficiency () const
 Return pointer to pdf in product. More...
 
virtual std::vector< RooAbsReal * > efficiencies () const
 Return pointer to pdf in product. More...
 
virtual RooResolutionModel & model () const
 
virtual RooArgSet * observables () const
 Return pointer to pdf in product. More...
 
const RooArgList & getIntegralRanges (const RooArgSet &iset, const char *rangeName=0) const
 
- Public Member Functions inherited from RooAbsEffResModel
virtual ~RooAbsEffResModel ()
 

Protected Member Functions

virtual Double_t evaluate () const
 
virtual RooEffResModelconvolution (RooFormulaVar *inBasis, RooAbsArg *owner) const
 

Private Types

typedef std::map< std::string, RooArgList * > RangeMap
 

Private Member Functions

CacheElemgetCache (const RooArgSet *iset, const TNamed *rangeName=0) const
 

Private Attributes

RooSetProxy _observables
 
RooRealProxy _model
 
RooRealProxy _eff
 
RangeMap _ranges
 
RooObjCacheManager _cacheMgr
 

Friends

class RooMultiEffResModel
 

Detailed Description

Definition at line 29 of file RooEffResModel.h.

Member Typedef Documentation

◆ RangeMap

typedef std::map<std::string, RooArgList*> RooEffResModel::RangeMap
private

Definition at line 108 of file RooEffResModel.h.

Constructor & Destructor Documentation

◆ RooEffResModel() [1/3]

RooEffResModel::RooEffResModel ( )
inline

Definition at line 32 of file RooEffResModel.h.

32 { }

◆ RooEffResModel() [2/3]

RooEffResModel::RooEffResModel ( const char *  name,
const char *  title,
RooResolutionModel &  model,
RooAbsReal &  eff 
)

Definition at line 188 of file RooEffResModel.cpp.

189  :
190  RooResolutionModel(name,title,__model.convVar())
191  , _observables("observables", "observables", this)
192  , _model("!model","Original resolution model",this,__model)
193  , _eff("!efficiency","efficiency of convvar", this,eff)
194  , _cacheMgr(this)
195 {
196  // FIXME: assert that efficiency is a function of convVar, and there are no overlaps...
197  _observables.add(__model.convVar());
198 }
RooRealProxy _model
RooSetProxy _observables
RooRealProxy _eff
RooObjCacheManager _cacheMgr

◆ RooEffResModel() [3/3]

RooEffResModel::RooEffResModel ( const RooEffResModel other,
const char *  name = 0 
)

Definition at line 201 of file RooEffResModel.cpp.

201  :
202  RooResolutionModel(other,name)
203  , _observables("observables", this, other._observables)
204  , _model("!model", this, other._model)
205  , _eff("!efficiency", this, other._eff)
206  , _cacheMgr(other._cacheMgr, this)
207 {
208  // copy constructor
209 }
RooRealProxy _model
RooSetProxy _observables
RooRealProxy _eff
RooObjCacheManager _cacheMgr

◆ ~RooEffResModel()

RooEffResModel::~RooEffResModel ( )
virtual

Definition at line 215 of file RooEffResModel.cpp.

216 {
217  // Destructor
218 }

Member Function Documentation

◆ analyticalIntegral()

Double_t RooEffResModel::analyticalIntegral ( Int_t  code,
const char *  rangeName 
) const
virtual

Definition at line 327 of file RooEffResModel.cpp.

329 {
330  assert(code > 0);
331  CacheElem* cache = static_cast<CacheElem*>(_cacheMgr.getObjByIndex(code - 1));
332  if (!cache) {
333  myunique_ptr<RooArgSet> vars(getParameters(RooArgSet()));
334  myunique_ptr<RooArgSet> iset(
335  _cacheMgr.nameSet1ByIndex(code - 1)->select(*vars));
336  cache = getCache(iset.get(), RooNameReg::ptr(rangeName));
337  assert(cache!=0);
338  }
339  return cache->getVal();
340 }
CacheElem * getCache(const RooArgSet *iset, const TNamed *rangeName=0) const
RooObjCacheManager _cacheMgr

◆ basisCode()

Int_t RooEffResModel::basisCode ( const char *  name) const
virtual

Definition at line 293 of file RooEffResModel.cpp.

294 {
295  return model().basisCode(name);
296 }
virtual RooResolutionModel & model() const

◆ clone()

RooEffResModel * RooEffResModel::clone ( const char *  newname) const
virtual

Definition at line 211 of file RooEffResModel.cpp.

212 { return new RooEffResModel(*this,newname); }

◆ convolution()

RooEffResModel * RooEffResModel::convolution ( RooFormulaVar *  inBasis,
RooAbsArg *  owner 
) const
protectedvirtual

Definition at line 233 of file RooEffResModel.cpp.

235 {
236  // Instantiate a clone of this resolution model representing a convolution with given
237  // basis function. The owners object name is incorporated in the clones name
238  // to avoid multiple convolution objects with the same name in complex PDF structures.
239  //
240  // Note: The 'inBasis' formula expression must be a RooFormulaVar that encodes the formula
241  // in the title of the object and this expression must be an exact match against the
242  // implemented basis function strings (see derived class implementation of method basisCode()
243  // for those strings
244 
245  // Check that primary variable of basis functions is our convolution variable
246  if (inBasis->getParameter(0) != x.absArg()) {
247  coutE(InputArguments) << "RooEffResModel::convolution(" << GetName() << "," << this
248  << ") convolution parameter of basis function and PDF don't match" << endl
249  << "basis->findServer(0) = " << inBasis->findServer(0) << endl
250  << "x.absArg() = " << x.absArg() << endl;
251  return 0;
252  }
253 
254  if (basisCode(inBasis->GetTitle())==0) {
255  coutE(InputArguments) << "RooEffResModel::convolution(" << GetName() << "," << this
256  << ") basis function '" << inBasis->GetTitle() << "' is not supported." << endl;
257  return 0;
258  }
259 
260  std::string newName(GetName());
261  newName += "_conv_";
262  newName += inBasis->GetName();
263  newName += "_[";
264  newName += owner->GetName();
265  newName += "]";
266 
267  RooResolutionModel *conv = model().convolution(inBasis, owner);
268 
269  std::string newTitle(conv->GetTitle());
270  newTitle += " convoluted with basis function ";
271  newTitle += inBasis->GetName();
272  conv->SetTitle(newTitle.c_str());
273 
274  RooAbsReal* eff = efficiency();
275  RooEffResModel *effConv = new RooEffResModel(newName.c_str(), newTitle.c_str(), *conv, *eff);
276  effConv->addOwnedComponents(*conv);
277  effConv->changeBasis(inBasis);
278 
279  const char* cacheParamsStr = getStringAttribute("CACHEPARAMINT");
280  if (cacheParamsStr && strlen(cacheParamsStr)) {
281  //cout << "prior has CACHEPARAMINT : " << cacheParamsStr << endl;
282  //const char* ecCacheParamsStr = effConv->getStringAttribute("CACHEPARAMINT");
283  //if (ecCacheParamsStr && strlen(ecCacheParamsStr)) cout << "bound version has CACHEPARAMINT : " << ecCacheParamsStr << endl;
284  effConv->setStringAttribute("CACHEPARAMINT",cacheParamsStr);
285  //cout << "2nd time: bound version has CACHEPARAMINT : " << effConv->getStringAttribute("CACHEPARAMINT") << endl;
286  //cout << endl << endl << endl;
287  }
288 
289  return effConv;
290 }
virtual RooResolutionModel & model() const
virtual Int_t basisCode(const char *name) const
virtual RooAbsReal * efficiency() const
Return pointer to pdf in product.

◆ efficiencies()

std::vector< RooAbsReal * > RooEffResModel::efficiencies ( ) const
virtual

Return pointer to pdf in product.

Definition at line 226 of file RooEffResModel.cpp.

227 { return std::vector<RooAbsReal*>(1, efficiency()); }
virtual RooAbsReal * efficiency() const
Return pointer to pdf in product.

◆ efficiency()

RooAbsReal * RooEffResModel::efficiency ( ) const
virtual

Return pointer to pdf in product.

Implements RooAbsEffResModel.

Definition at line 223 of file RooEffResModel.cpp.

224 { return static_cast<RooAbsReal*>(_eff.absArg()); }
RooRealProxy _eff

◆ evaluate()

Double_t RooEffResModel::evaluate ( ) const
protectedvirtual

Definition at line 299 of file RooEffResModel.cpp.

300 {
301  Double_t mod = model().getVal();
302  // TODO: replace this by the discretized version, i.e. replace convVar by
303  // customized middle of bin... this in order to ensure evaluate &
304  // analyticalIntegral are consistent (in case eff is not discretized!!!)
305  Double_t eps = efficiency()->getVal();
306  return eps * mod;
307 }
virtual RooResolutionModel & model() const
virtual RooAbsReal * efficiency() const
Return pointer to pdf in product.

◆ forceAnalyticalInt()

Bool_t RooEffResModel::forceAnalyticalInt ( const RooAbsArg &  dep) const
virtual

Definition at line 310 of file RooEffResModel.cpp.

311 {
312  // Force RooRealIntegral to offer all observables for internal integration
313  return kTRUE;
314 }

◆ generateEvent()

void RooEffResModel::generateEvent ( Int_t  code)
virtual

Definition at line 366 of file RooEffResModel.cpp.

367 {
368  // The hit-miss on the efficiency is done at the level of the GenContext.
369  model().generateEvent(code);
370 }
virtual RooResolutionModel & model() const

◆ getAnalyticalIntegral()

Int_t RooEffResModel::getAnalyticalIntegral ( RooArgSet &  allVars,
RooArgSet &  analVars,
const char *  rangeName = 0 
) const
virtual

Definition at line 317 of file RooEffResModel.cpp.

319 {
320  if (_forceNumInt) return 0;
321  analVars.add(allVars);
322  getCache(&analVars, RooNameReg::ptr(rangeName));
323  return 1 + _cacheMgr.lastIndex();
324 }
CacheElem * getCache(const RooArgSet *iset, const TNamed *rangeName=0) const
RooObjCacheManager _cacheMgr

◆ getCache()

RooEffResModel::CacheElem * RooEffResModel::getCache ( const RooArgSet *  iset,
const TNamed *  rangeName = 0 
) const
private

Definition at line 428 of file RooEffResModel.cpp.

430 {
431  Int_t sterileIndex(-1);
432  CacheElem* cache = (CacheElem*) _cacheMgr.getObj(iset, &sterileIndex, rangeName);
433  if (cache) return cache;
434  _cacheMgr.setObj(iset, new CacheElem( *this, *iset, rangeName), rangeName);
435  return getCache(iset, rangeName);
436 }
CacheElem * getCache(const RooArgSet *iset, const TNamed *rangeName=0) const
RooObjCacheManager _cacheMgr

◆ getGenerator()

Int_t RooEffResModel::getGenerator ( const RooArgSet &  directVars,
RooArgSet &  generateVars,
Bool_t  staticInitOK = kTRUE 
) const
virtual

Definition at line 352 of file RooEffResModel.cpp.

355 {
356  return model().getGenerator(directVars, generateVars, staticInitOK);
357 }
virtual RooResolutionModel & model() const

◆ getIntegralRanges()

const RooArgList & RooEffResModel::getIntegralRanges ( const RooArgSet &  iset,
const char *  rangeName = 0 
) const

Definition at line 373 of file RooEffResModel.cpp.

375 {
376  rangeName = rangeName ? rangeName : "default";
377  RangeMap::const_iterator it = _ranges.find(rangeName);
378  if (it != _ranges.end()) return *it->second;
379 
380  RooRealVar& x = static_cast<RooRealVar&>(convVar());
381  const Double_t xmin = x.getMin(rangeName);
382  const Double_t xmax = x.getMax(rangeName);
383 
384  RooArgList* ranges = new RooArgList;
385  myunique_ptr<std::list<Double_t> > bounds(efficiency()->binBoundaries(x, x.getMin(), x.getMax()));
386  if (!bounds.get()) {
387  std::string s;
388  s += "RooEffResModel("; s += GetName(); s += "): specified efficiency ";
389  s += efficiency()->GetName(); s += " does not provide binBoundaries...";
390  std::cout << s << std::endl;
391  throw s;
392  }
393  std::list<Double_t>::const_iterator lo, hi = bounds->begin();
394  std::stringstream strange;
395  for (unsigned int i = 0; i + 1 < bounds->size();++i) {
396  lo = hi++;
397  if (*hi < xmin) continue; // not there yet...
398  if (*lo > xmax) break; // past the requested interval...
399  const Double_t thisxmin = std::max(*lo, xmin);
400  const Double_t thisxmax = std::min(*hi, xmax);
401 
402  // add eff name, as it specifies the boundaries...
403  strange.str("R");
404  strange << i << "_" << x.GetName() << "_" << efficiency()->GetName();
405 
406  // Add original rangeName if there is one
407  if (rangeName) strange << "_" << rangeName;
408  strange << "_I_" << RooNameSet(iset).content();
409  const std::string trange = strange.str();
410  const char* range = trange.c_str();
411 
412  // Create a new name for the range
413  // check if already exists and matches..
414  if (!x.hasRange(range)) {
415  x.setRange(range, thisxmin, thisxmax);
416  }
417  assert(x.getMin(range)==thisxmin);
418  assert(x.getMax(range)==thisxmax);
419  ranges->addOwned(*new RooStringVar(range, range, range));
420  }
421  std::pair<RangeMap::iterator, bool> r = _ranges.insert(
422  std::make_pair(std::string(rangeName), ranges));
423  assert(r.second);
424  return *r.first->second;
425 }
static const double s
virtual RooAbsReal * efficiency() const
Return pointer to pdf in product.

◆ initGenerator()

void RooEffResModel::initGenerator ( Int_t  code)
virtual

Definition at line 360 of file RooEffResModel.cpp.

361 {
362  model().initGenerator(code);
363 }
virtual RooResolutionModel & model() const

◆ model()

RooResolutionModel & RooEffResModel::model ( ) const
virtual

Definition at line 229 of file RooEffResModel.cpp.

230 { return dynamic_cast<RooResolutionModel&>(*_model.absArg()); }
RooRealProxy _model

◆ modelGenContext()

RooAbsGenContext * RooEffResModel::modelGenContext ( const RooAbsAnaConvPdf &  convPdf,
const RooArgSet &  vars,
const RooDataSet *  prototype = 0,
const RooArgSet *  auxProto = 0,
Bool_t  verbose = kFALSE 
) const
virtual

Definition at line 343 of file RooEffResModel.cpp.

347 {
348  return new RooEffConvGenContext(convPdf, vars, prototype, auxProto, verbose);
349 }

◆ observables()

RooArgSet * RooEffResModel::observables ( ) const
virtual

Return pointer to pdf in product.

Implements RooAbsEffResModel.

Definition at line 220 of file RooEffResModel.cpp.

221 { return new RooArgSet(_observables); }
RooSetProxy _observables

Friends And Related Function Documentation

◆ RooMultiEffResModel

friend class RooMultiEffResModel
friend

Definition at line 73 of file RooEffResModel.h.

Member Data Documentation

◆ _cacheMgr

RooObjCacheManager RooEffResModel::_cacheMgr
mutableprivate

Definition at line 111 of file RooEffResModel.h.

◆ _eff

RooRealProxy RooEffResModel::_eff
private

Definition at line 106 of file RooEffResModel.h.

◆ _model

RooRealProxy RooEffResModel::_model
private

Definition at line 105 of file RooEffResModel.h.

◆ _observables

RooSetProxy RooEffResModel::_observables
private

Definition at line 104 of file RooEffResModel.h.

◆ _ranges

RangeMap RooEffResModel::_ranges
mutableprivate

Definition at line 109 of file RooEffResModel.h.


The documentation for this class was generated from the following files: