Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAddModel.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17//////////////////////////////////////////////////////////////////////////////
18/// \class RooAddModel
19///
20/// RooAddModel is an efficient implementation of a sum of PDFs of the form
21/// \f[
22/// c_1 \cdot \mathrm{PDF}_1 + c_2 \cdot \mathrm{PDF}_2 + ... + c_n \cdot \mathrm{PDF}_n
23/// \f]
24/// or
25/// \f[
26/// c_1 \cdot \mathrm{PDF}_1 + c_2 \cdot \mathrm{PDF}_2 + ... + \left( 1-\sum_{i=1}^{n-1} c_i \right) \cdot \mathrm{PDF}_n
27/// \f]
28/// The first form is for extended likelihood fits, where the
29/// expected number of events is \f$ \sum_i c_i \f$. The coefficients \f$ c_i \f$
30/// can either be explicitly provided, or, if all components support
31/// extended likelihood fits, they can be calculated from the contribution
32/// of each PDF to the total number of expected events.
33///
34/// In the second form, the sum of the coefficients is enforced to be one,
35/// and the coefficient of the last PDF is calculated from that condition.
36///
37/// RooAddModel relies on each component PDF to be normalized, and will perform
38/// no normalization other than calculating the proper last coefficient \f$ c_n \f$, if requested.
39/// An (enforced) condition for this assumption is that each \f$ \mathrm{PDF}_i \f$ is independent
40/// of each coefficient \f$ i \f$.
41///
42///
43
44#include "RooAddModel.h"
45
46#include "RooAddHelpers.h"
47#include "RooMsgService.h"
48#include "RooDataSet.h"
49#include "RooRealProxy.h"
50#include "RooPlot.h"
51#include "RooRealVar.h"
52#include "RooAddGenContext.h"
53#include "RooNameReg.h"
54#include "RooBatchCompute.h"
55
56using std::endl, std::ostream;
57
58
59
60////////////////////////////////////////////////////////////////////////////////
61
63 : _refCoefNorm("!refCoefNorm", "Reference coefficient normalization set", this, false, false),
64 _projCacheMgr(this, 10),
65 _intCacheMgr(this, 10),
66 _coefErrCount(_errorCount)
67{
68}
69
70
71
72////////////////////////////////////////////////////////////////////////////////
73/// Generic constructor from list of PDFs and list of coefficients.
74/// Each pdf list element (i) is paired with coefficient list element (i).
75/// The number of coefficients must be either equal to the number of PDFs,
76/// in which case extended MLL fitting is enabled, or be one less.
77///
78/// All PDFs must inherit from RooAbsPdf. All coefficients must inherit from RooAbsReal.
79
80RooAddModel::RooAddModel(const char *name, const char *title, const RooArgList& inPdfList, const RooArgList& inCoefList, bool ownPdfList) :
82 _refCoefNorm("!refCoefNorm","Reference coefficient normalization set",this,false,false),
83 _projCacheMgr(this,10),
84 _intCacheMgr(this,10),
85 _pdfList("!pdfs","List of PDFs",this),
86 _coefList("!coefficients","List of coefficients",this)
87{
88 const std::string ownName(GetName() ? GetName() : "");
89 if (inPdfList.size() > inCoefList.size() + 1 || inPdfList.size() < inCoefList.size()) {
90 std::stringstream msgSs;
91 msgSs << "RooAddModel::RooAddModel(" << ownName
92 << ") number of pdfs and coefficients inconsistent, must have Npdf=Ncoef or Npdf=Ncoef+1";
93 const std::string msgStr = msgSs.str();
94 coutE(InputArguments) << msgStr << "\n";
95 throw std::runtime_error(msgStr);
96 }
97
98 // Constructor with N PDFs and N or N-1 coefs
99 std::size_t i = 0;
100 for (auto const &coef : inCoefList) {
101 auto pdf = inPdfList.at(i);
102 if (!pdf) {
103 std::stringstream msgSs;
104 msgSs << "RooAddModel::RooAddModel(" << ownName
105 << ") number of pdfs and coefficients inconsistent, must have Npdf=Ncoef or Npdf=Ncoef+1";
106 const std::string msgStr = msgSs.str();
107 coutE(InputArguments) << msgStr << "\n";
108 throw std::runtime_error(msgStr);
109 }
110 if (!coef) {
111 coutE(InputArguments) << "RooAddModel::RooAddModel(" << ownName
112 << ") encountered and undefined coefficient, ignored\n";
113 continue;
114 }
115 if (!dynamic_cast<RooAbsReal *>(coef)) {
116 auto coefName = coef->GetName();
117 coutE(InputArguments) << "RooAddModel::RooAddModel(" << ownName << ") coefficient "
118 << (coefName != nullptr ? coefName : "") << " is not of type RooAbsReal, ignored\n";
119 continue;
120 }
121 if (!dynamic_cast<RooAbsPdf *>(pdf)) {
122 coutE(InputArguments) << "RooAddModel::RooAddModel(" << ownName << ") pdf "
123 << (pdf->GetName() ? pdf->GetName() : "") << " is not of type RooAbsPdf, ignored\n";
124 continue;
125 }
126 _pdfList.add(*pdf);
127 _coefList.add(*coef);
128 i++;
129 }
130
131 if (i < inPdfList.size()) {
132 auto pdf = inPdfList.at(i);
133 if (!dynamic_cast<RooAbsPdf *>(pdf)) {
134 std::stringstream msgSs;
135 msgSs << "RooAddModel::RooAddModel(" << ownName << ") last pdf " << (pdf->GetName() ? pdf->GetName() : "")
136 << " is not of type RooAbsPdf, fatal error";
137 const std::string msgStr = msgSs.str();
138 coutE(InputArguments) << msgStr << "\n";
139 throw std::runtime_error(msgStr);
140 }
141 _pdfList.add(*pdf);
142 } else {
143 _haveLastCoef = true;
144 }
145
147
148 if (ownPdfList) {
150 }
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// Copy constructor
155
158 _refCoefNorm("!refCoefNorm", this, other._refCoefNorm),
159 _refCoefRangeName((TNamed *)other._refCoefRangeName),
160 _projCacheMgr(other._projCacheMgr, this),
161 _intCacheMgr(other._intCacheMgr, this),
162 _pdfList("!pdfs", this, other._pdfList),
163 _coefList("!coefficients", this, other._coefList),
164 _haveLastCoef(other._haveLastCoef),
165 _allExtendable(other._allExtendable),
166 _coefErrCount(_errorCount)
167{
168}
169
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// By default the interpretation of the fraction coefficients is
174/// performed in the contextual choice of observables. This makes the
175/// shape of the p.d.f explicitly dependent on the choice of
176/// observables. This method instructs RooAddModel to freeze the
177/// interpretation of the coefficients to be done in the given set of
178/// observables. If frozen, fractions are automatically transformed
179/// from the reference normalization set to the contextual normalization
180/// set by ratios of integrals
181
183{
184 if (refCoefNorm.empty()) {
185 return ;
186 }
187
190
192}
193
194
195
196////////////////////////////////////////////////////////////////////////////////
197/// By default the interpretation of the fraction coefficients is
198/// performed in the default range. This make the shape of a RooAddModel
199/// explicitly dependent on the range of the observables. To allow
200/// a range independent definition of the fraction this function
201/// instructs RooAddModel to freeze its interpretation in the given
202/// named range. If the current normalization range is different
203/// from the reference range, the appropriate fraction coefficients
204/// are automatically calculated from the reference fractions using
205/// ratios of integrals.
206
211
212
213
214////////////////////////////////////////////////////////////////////////////////
215/// Instantiate a clone of this resolution model representing a convolution with given
216/// basis function. The owners object name is incorporated in the clones name
217/// to avoid multiple convolution objects with the same name in complex PDF structures.
218///
219/// RooAddModel will clone all the component models to create a composite convolution object
220
222{
223 // Check that primary variable of basis functions is our convolution variable
224 if (inBasis->getParameter(0) != x.absArg()) {
225 coutE(InputArguments) << "RooAddModel::convolution(" << GetName()
226 << ") convolution parameter of basis function and PDF don't match" << std::endl ;
227 ccoutE(InputArguments) << "basis->findServer(0) = " << inBasis->findServer(0) << " " << inBasis->findServer(0)->GetName() << std::endl ;
228 ccoutE(InputArguments) << "x.absArg() = " << x.absArg() << " " << x.absArg()->GetName() << std::endl ;
229 inBasis->Print("v") ;
230 return nullptr ;
231 }
232
234 newName.Append("_conv_") ;
235 newName.Append(inBasis->GetName()) ;
236 newName.Append("_[") ;
237 newName.Append(owner->GetName()) ;
238 newName.Append("]") ;
239
241 newTitle.Append(" convoluted with basis function ") ;
242 newTitle.Append(inBasis->GetName()) ;
243
246 // Create component convolution
247 RooResolutionModel* conv = model->convolution(inBasis,owner) ;
248 modelList.add(*conv) ;
249 }
250
252 for (auto coef : _coefList) {
253 theCoefList.add(*coef) ;
254 }
255
257 for (std::set<std::string>::const_iterator attrIt = _boolAttrib.begin();
258 attrIt != _boolAttrib.end(); ++attrIt) {
259 convSum->setAttribute((*attrIt).c_str()) ;
260 }
261 for (std::map<std::string,std::string>::const_iterator attrIt = _stringAttrib.begin();
262 attrIt != _stringAttrib.end(); ++attrIt) {
263 convSum->setStringAttribute((attrIt->first).c_str(), (attrIt->second).c_str()) ;
264 }
265 convSum->changeBasis(inBasis) ;
266 return convSum ;
267}
268
269
270
271////////////////////////////////////////////////////////////////////////////////
272/// Return code for basis function representing by 'name' string.
273/// The basis code of the first component model will be returned,
274/// if the basis is supported by all components. Otherwise 0
275/// is returned
276
278{
279 bool first(true);
280 bool code(false);
282 Int_t subCode = model->basisCode(name) ;
283 if (first) {
284 code = subCode ;
285 first = false ;
286 } else if (subCode==0) {
287 code = false ;
288 }
289 }
290
291 return code ;
292}
293
294
295
296////////////////////////////////////////////////////////////////////////////////
297/// Retrieve cache element with for calculation of p.d.f value with normalization set nset and integrated over iset
298/// in range 'rangeName'. If cache element does not exist, create and fill it on the fly. The cache contains
299/// suplemental normalization terms (in case not all added p.d.f.s have the same observables), projection
300/// integrals to calculated transformed fraction coefficients when a frozen reference frame is provided
301/// and projection integrals for similar transformations when a frozen reference range is provided.
302
303AddCacheElem* RooAddModel::getProjCache(const RooArgSet* nset, const RooArgSet* iset) const
304{
305 // Check if cache already exists
306 auto cache = static_cast<AddCacheElem*>(_projCacheMgr.getObj(nset,iset,nullptr,normRange()));
307 if (cache) {
308 return cache ;
309 }
310
311 //Create new cache
312 cache = new AddCacheElem{*this, _pdfList, _coefList, nset, iset, _refCoefNorm,
315
317
318 return cache;
319}
320
321
322////////////////////////////////////////////////////////////////////////////////
323/// Update the coefficient values in the given cache element: calculate new remainder
324/// fraction, normalize fractions obtained from extended ML terms to unity, and
325/// multiply the various range and dimensional corrections needed in the
326/// current use context.
327
328void RooAddModel::updateCoefficients(AddCacheElem &cache, const RooArgSet *nset) const
329{
330 _coefCache.resize(_pdfList.size());
331 for (std::size_t i = 0; i < _coefList.size(); ++i) {
332 _coefCache[i] = static_cast<RooAbsReal const &>(_coefList[i]).getVal(nset);
333 }
334 if (_allExtendable) {
335 for (std::size_t i = 0; i < _pdfList.size(); ++i) {
336 auto &pdf = static_cast<RooAbsPdf &>(_pdfList[i]);
337 _coefCache[i] = pdf.expectedEvents(!_refCoefNorm.empty() ? &_refCoefNorm : nset);
338 }
339 }
340
341 RooAddHelpers::updateCoefficients(*this, _pdfList.size(), _coefCache, _haveLastCoef || _allExtendable, cache,
343}
344
345
346////////////////////////////////////////////////////////////////////////////////
347/// Calculate the current value
348
350{
351 const RooArgSet* nset = _normSet ;
352 AddCacheElem* cache = getProjCache(nset) ;
353
354 updateCoefficients(*cache,nset) ;
355
356
357 // Do running sum of coef/pdf pairs, calculate lastCoef.
358 double snormVal ;
359 double value(0) ;
360 Int_t i(0) ;
361 for (auto *pdf : static_range_cast<RooAbsPdf*>(_pdfList)) {
362
363 if (_coefCache[i]!=0.) {
364 snormVal = nset ? cache->suppNormVal(i) : 1.0 ;
365 double pdfVal = pdf->getVal(nset) ;
366 // double pdfNorm = pdf->getNorm(nset) ;
367 if (pdf->isSelectedComp()) {
369 cxcoutD(Eval) << "RooAddModel::evaluate(" << GetName() << ") value += ["
370 << pdf->GetName() << "] " << pdfVal << " * " << _coefCache[i] << " / " << snormVal << std::endl ;
371 }
372 }
373 i++ ;
374 }
375
376 return value ;
377}
378
380{
381 // Like many other functions in this class, the implementation was copy-pasted from the RooAddPdf
382 RooBatchCompute::Config config = ctx.config(this);
383
384 _coefCache.resize(_pdfList.size());
385 for (std::size_t i = 0; i < _coefList.size(); ++i) {
386 auto coefVals = ctx.at(&_coefList[i]);
387 // We don't support per-event coefficients in this function. If the CPU
388 // mode is used, we can just fall back to the RooAbsReal implementation.
389 // With CUDA, we can't do that because the inputs might be on the device.
390 // That's why we throw an exception then.
391 if (coefVals.size() > 1) {
392 if (config.useCuda()) {
393 throw std::runtime_error("The RooAddPdf doesn't support per-event coefficients in CUDA mode yet!");
394 }
396 return;
397 }
398 _coefCache[i] = coefVals[0];
399 }
400
401 std::vector<std::span<const double>> pdfs;
402 std::vector<double> coefs;
403 AddCacheElem *cache = getProjCache(nullptr);
404 updateCoefficients(*cache, nullptr);
405
406 for (unsigned int pdfNo = 0; pdfNo < _pdfList.size(); ++pdfNo) {
407 auto pdf = static_cast<RooAbsPdf *>(&_pdfList[pdfNo]);
408 if (pdf->isSelectedComp()) {
409 pdfs.push_back(ctx.at(pdf));
410 coefs.push_back(_coefCache[pdfNo] / cache->suppNormVal(pdfNo));
411 }
412 }
413 RooBatchCompute::compute(config, RooBatchCompute::AddPdf, ctx.output(), pdfs, coefs);
414}
415
416
417////////////////////////////////////////////////////////////////////////////////
418/// Reset error counter to given value, limiting the number
419/// of future error messages for this pdf to 'resetValue'
420
426
427
428
429////////////////////////////////////////////////////////////////////////////////
430/// Check if PDF is valid for given normalization set.
431/// Coefficient and PDF must be non-overlapping, but pdf-coefficient
432/// pairs may overlap each other
433
435{
436 bool ret(false) ;
437
438 for (unsigned int i = 0; i < _coefList.size(); ++i) {
439 auto pdf = &_pdfList[i];
440 auto coef = &_coefList[i];
441
442 if (pdf->observableOverlaps(nset,*coef)) {
443 coutE(InputArguments) << "RooAddModel::checkObservables(" << GetName() << "): ERROR: coefficient " << coef->GetName()
444 << " and PDF " << pdf->GetName() << " have one or more dependents in common" << std::endl ;
445 ret = true ;
446 }
447 }
448
449 return ret ;
450}
451
452
453
454////////////////////////////////////////////////////////////////////////////////
455
457 const RooArgSet* normSet, const char* rangeName) const
458{
459 if (_forceNumInt) return 0 ;
460
461 // Declare that we can analytically integrate all requested observables
462 analVars.add(allVars) ;
463
464 // Retrieve (or create) the required component integral list
465 Int_t code ;
467 getCompIntList(normSet,&allVars,cilist,code,rangeName) ;
468
469 return code+1 ;
470
471}
472
473
474
475////////////////////////////////////////////////////////////////////////////////
476/// Check if this configuration was created before
477
479{
480 Int_t sterileIdx(-1) ;
481
483 if (cache) {
484 code = _intCacheMgr.lastIndex() ;
485 compIntList = &cache->_intList ;
486
487 return ;
488 }
489
490 // Create containers for partial integral components to be generated
491 cache = new IntCacheElem ;
492
493 // Fill Cache
495
496 cache->_intList.addOwned(std::unique_ptr<RooAbsReal>{model->createIntegral(*iset,nset,nullptr,isetRangeName)});
497 }
498
499 // Store the partial integral list and return the assigned code ;
501
502 // Fill references to be returned
503 compIntList = &cache->_intList ;
504}
505
506
507
508////////////////////////////////////////////////////////////////////////////////
509/// Return analytical integral defined by given scenario code
510
512{
513 // No integration scenario
514 if (code==0) {
515 return getVal(normSet) ;
516 }
517
518 // Partial integration scenarios
519 IntCacheElem* cache = static_cast<IntCacheElem*>(_intCacheMgr.getObjByIndex(code-1)) ;
520
522
523 // If cache has been sterilized, revive this slot
524 if (cache==nullptr) {
525 std::unique_ptr<RooArgSet> vars{getParameters(RooArgSet())} ;
526 RooArgSet nset = _intCacheMgr.selectFromSet1(*vars, code-1) ;
527 RooArgSet iset = _intCacheMgr.selectFromSet2(*vars, code-1) ;
528
529 int code2 = -1 ;
531 } else {
532
533 compIntList = &cache->_intList ;
534
535 }
536
537 // Calculate the current value
538 const RooArgSet* nset = _normSet ;
540
542
543 // Do running sum of coef/pdf pairs, calculate lastCoef.
544 double snormVal ;
545 double value(0) ;
546 Int_t i(0) ;
548 if (_coefCache[i]!=0.) {
549 snormVal = nset ? pcache->suppNormVal(i) : 1.0 ;
550 double intVal = pdfInt->getVal(nset) ;
552 cxcoutD(Eval) << "RooAddModel::evaluate(" << GetName() << ") value += ["
553 << pdfInt->GetName() << "] " << intVal << " * " << _coefCache[i] << " / " << snormVal << std::endl ;
554 }
555 i++ ;
556 }
557
558 return value ;
559
560}
561
562
563
564////////////////////////////////////////////////////////////////////////////////
565/// Return the number of expected events, which is either the sum of all coefficients
566/// or the sum of the components extended terms
567
568double RooAddModel::expectedEvents(const RooArgSet* nset) const
569{
570 double expectedTotal(0.0);
571
572 if (_allExtendable) {
573
574 // Sum of the extended terms
575 for (auto *pdf : static_range_cast<RooAbsPdf*>(_pdfList)) {
576 expectedTotal += pdf->expectedEvents(nset) ;
577 }
578
579 } else {
580
581 // Sum the coefficients
582 for (auto *coef : static_range_cast<RooAbsReal*>(_coefList)) {
583 expectedTotal += coef->getVal() ;
584 }
585 }
586
587 return expectedTotal;
588}
589
590
591
592////////////////////////////////////////////////////////////////////////////////
593/// Interface function used by test statistics to freeze choice of observables
594/// for interpretation of fraction coefficients
595
597{
598 if (!force && !_refCoefNorm.empty()) {
599 return ;
600 }
601
602 if (!depSet) {
604 return ;
605 }
606
610}
611
612
613
614////////////////////////////////////////////////////////////////////////////////
615/// Interface function used by test statistics to freeze choice of range
616/// for interpretation of fraction coefficients
617
619{
620 if (!force && _refCoefRangeName) {
621 return ;
622 }
623
625}
626
627
628
629////////////////////////////////////////////////////////////////////////////////
630/// Return specialized context to efficiently generate toy events from RooAddModels.
631
633 const RooArgSet* auxProto, bool verbose) const
634{
635 return RooAddGenContext::create(*this,vars,prototype,auxProto,verbose).release();
636}
637
638
639
640////////////////////////////////////////////////////////////////////////////////
641/// Direct generation is safe if all components say so
642
644{
645 for (auto *pdf : static_range_cast<RooAbsPdf*>(_pdfList)) {
646
647 if (!pdf->isDirectGenSafe(arg)) {
648 return false ;
649 }
650 }
651 return true ;
652}
653
654
655
656////////////////////////////////////////////////////////////////////////////////
657/// Return pseud-code that indicates if all components can do internal generation (1) or not (0)
658
659Int_t RooAddModel::getGenerator(const RooArgSet& directVars, RooArgSet &/*generateVars*/, bool /*staticInitOK*/) const
660{
661 for (auto *pdf : static_range_cast<RooAbsPdf*>(_pdfList)) {
662
663 RooArgSet tmp ;
664 if (pdf->getGenerator(directVars,tmp)==0) {
665 return 0 ;
666 }
667 }
668 return 1 ;
669}
670
671
672
673
674////////////////////////////////////////////////////////////////////////////////
675/// This function should never be called as RooAddModel implements a custom generator context
676
678{
679 assert(0) ;
680}
681
682
683////////////////////////////////////////////////////////////////////////////////
684/// List all RooAbsArg derived contents in this cache element
685
691
692
693////////////////////////////////////////////////////////////////////////////////
694/// Customized printing of arguments of a RooAddModel to more intuitively reflect the contents of the
695/// product operator construction
696
697void RooAddModel::printMetaArgs(ostream& os) const
698{
699 bool first(true) ;
700
701 os << "(" ;
702 for (unsigned int i=0; i < _coefList.size(); ++i) {
703 auto coef = &_coefList[i];
704 auto pdf = &_pdfList[i];
705 if (!first) {
706 os << " + " ;
707 } else {
708 first = false ;
709 }
710 os << coef->GetName() << " * " << pdf->GetName() ;
711 }
712 if (_pdfList.size() > _coefList.size()) {
713 os << " + [%] * " << _pdfList[_pdfList.size()-1].GetName() ;
714 }
715 os << ") " ;
716}
717
#define ccoutE(a)
#define cxcoutD(a)
#define coutE(a)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:148
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
std::map< std::string, std::string > _stringAttrib
Definition RooAbsArg.h:589
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
std::set< std::string > _boolAttrib
Definition RooAbsArg.h:588
Abstract base class for objects to be stored in RooAbsCache cache manager objects.
const char * GetName() const override
Returns name of object.
Storage_t::size_type size() const
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
Abstract base class for generator contexts of RooAbsPdf objects.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
virtual void resetErrorCounters(Int_t resetValue=10)
Reset error counter to given value, limiting the number of future error messages for this pdf to 'res...
RooArgSet const * _normSet
! Normalization set with for above integral
Definition RooAbsPdf.h:314
Int_t _errorCount
Number of errors remaining to print.
Definition RooAbsPdf.h:328
const char * normRange() const
Definition RooAbsPdf.h:246
static Int_t _verboseEval
Definition RooAbsPdf.h:308
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:107
bool _forceNumInt
Force numerical integration if flag set.
Definition RooAbsReal.h:545
friend class AddCacheElem
Definition RooAbsReal.h:407
virtual void doEval(RooFit::EvalContext &) const
Base function for computing multiple values of a RooAbsReal.
static std::unique_ptr< RooAbsGenContext > create(const Pdf_t &pdf, const RooArgSet &vars, const RooDataSet *prototype, const RooArgSet *auxProto, bool verbose)
Returns a RooAddGenContext if possible, or, if the RooAddGenContext doesn't support this particular R...
RooArgList containedArgs(Action) override
List all RooAbsArg derived contents in this cache element.
RooArgList _intList
List of component integrals.
RooAddModel is an efficient implementation of a sum of PDFs of the form.
Definition RooAddModel.h:26
RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false) const override
Return specialized context to efficiently generate toy events from RooAddModels.
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooAddModel to more intuitively reflect the contents of the pro...
RooObjCacheManager _projCacheMgr
! Manager of cache with coefficient projections and transformations
void getCompIntList(const RooArgSet *nset, const RooArgSet *iset, pRooArgList &compIntList, Int_t &code, const char *isetRangeName) const
Check if this configuration was created before.
void selectNormalization(const RooArgSet *depSet=nullptr, bool force=false) override
Interface function used by test statistics to freeze choice of observables for interpretation of frac...
RooSetProxy _refCoefNorm
! Reference observable set for coefficient interpretation
Definition RooAddModel.h:95
bool _allExtendable
Flag indicating if all PDF components are extendable.
Int_t _coefErrCount
! Coefficient error counter
RooArgSet _ownedComps
! Owned components
RooListProxy _coefList
List of coefficients.
void selectNormalizationRange(const char *rangeName=nullptr, bool force=false) override
Interface function used by test statistics to freeze choice of range for interpretation of fraction c...
Int_t basisCode(const char *name) const override
Return code for basis function representing by 'name' string.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Return analytical integral defined by given scenario code.
RooResolutionModel * convolution(RooFormulaVar *basis, RooAbsArg *owner) const override
Instantiate a clone of this resolution model representing a convolution with given basis function.
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
bool checkObservables(const RooArgSet *nset) const override
Check if PDF is valid for given normalization set.
void generateEvent(Int_t code) override
This function should never be called as RooAddModel implements a custom generator context.
bool _haveLastCoef
Flag indicating if last PDFs coefficient was supplied in the constructor.
double expectedEvents(const RooArgSet *nset) const override
Return expected number of events for extended likelihood calculation, which is the sum of all coeffic...
RooListProxy _pdfList
List of component PDFs.
RooObjCacheManager _intCacheMgr
! Manager of cache with integrals
void resetErrorCounters(Int_t resetValue=10) override
Reset error counter to given value, limiting the number of future error messages for this pdf to 'res...
void fixCoefNormalization(const RooArgSet &refCoefNorm)
By default the interpretation of the fraction coefficients is performed in the contextual choice of o...
void fixCoefRange(const char *rangeName)
By default the interpretation of the fraction coefficients is performed in the default range.
TNamed * _refCoefRangeName
! Reference range name for coefficient interpretation
Definition RooAddModel.h:96
std::vector< double > _coefCache
! Transient cache with transformed values of coefficients
Definition RooAddModel.h:98
double evaluate() const override
Calculate the current value.
void updateCoefficients(AddCacheElem &cache, const RooArgSet *nset) const
Update the coefficient values in the given cache element: calculate new remainder fraction,...
bool isDirectGenSafe(const RooAbsArg &arg) const override
Direct generation is safe if all components say so.
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Return pseud-code that indicates if all components can do internal generation (1) or not (0)
AddCacheElem * getProjCache(const RooArgSet *nset, const RooArgSet *iset=nullptr) const
Retrieve cache element with for calculation of p.d.f value with normalization set nset and integrated...
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooAbsArg * absArg() const
Return pointer to contained argument.
Definition RooArgProxy.h:46
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Minimal configuration struct to steer the evaluation of a single node with the RooBatchCompute librar...
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
RooArgSet selectFromSet1(RooArgSet const &argSet, int index) const
Create RooArgSet containing the objects that are both in the cached set 1 with a given index and an i...
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
RooArgSet selectFromSet2(RooArgSet const &argSet, int index) const
Create RooArgSet containing the objects that are both in the cached set 2 with a given index and an i...
void reset()
Clear the cache.
Int_t lastIndex() const
Return index of slot used in last get or set operation.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Container class to hold unbinned data.
Definition RooDataSet.h:32
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
Definition RooNameReg.h:39
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
virtual RooResolutionModel * convolution(RooFormulaVar *basis, RooAbsArg *owner) const
Instantiate a clone of this resolution model representing a convolution with given basis function.
RooTemplateProxy< RooAbsRealLValue > x
Dependent/convolution variable.
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Basic string class.
Definition TString.h:138
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})