Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooHistPdf.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofit:$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\file RooHistPdf.cxx
19\class RooHistPdf
20\ingroup Roofitcore
21
22A probability density function sampled from a
23multidimensional histogram. The histogram distribution is explicitly
24normalized by RooHistPdf and can have an arbitrary number of real or
25discrete dimensions.
26
27A p.d.f. cannot be negative. If the input histogram contains bins with
28negative content, the bin contents are clipped to zero and the bin errors are kept the same.
29The input histogram is not modified.
30**/
31
32#include "RooCategory.h"
33#include "RooCurve.h"
34#include "RooDataHist.h"
35#include "RooFitImplHelpers.h"
36#include "RooGlobalFunc.h"
37#include "RooHistPdf.h"
38#include "RooMsgService.h"
39#include "RooRealVar.h"
40#include "RooWorkspace.h"
41
42#include "TError.h"
43#include "TBuffer.h"
44
45#include <algorithm>
46#include <cmath>
47#include <ostream>
48
49////////////////////////////////////////////////////////////////////////////////
50/// Constructor from a RooDataHist. RooDataHist dimensions
51/// can be either real or discrete. See RooDataHist::RooDataHist for details on the binning.
52/// RooHistPdf neither owns or clone 'dhist' and the user must ensure the input histogram exists
53/// for the entire life span of this PDF.
54/// The only exception is a 'dhist' that contains bins with negative content: those are set to
55/// zero in an internally-owned clone that is used instead (see clampNegativeBins()).
56
57RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgSet& vars,
59 RooAbsPdf(name,title),
60 _pdfObsList("pdfObs","List of p.d.f. observables",this),
61 _dataHist(const_cast<RooDataHist*>(&dhist)),
62 _intOrder(intOrder)
63{
65 _pdfObsList.add(vars) ;
66
67 // Verify that vars and dhist.get() have identical contents
68 const RooArgSet* dvars = dhist.get() ;
69 if (vars.size()!=dvars->size()) {
70 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
71 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
72 assert(0) ;
73 }
74 for (const auto arg : vars) {
75 if (!dvars->find(arg->GetName())) {
76 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
77 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
78 assert(0) ;
79 }
80 }
81
82
83 // Adjust ranges of _histObsList to those of _dataHist
84 for (const auto hobs : _histObsList) {
85 // Guaranteed to succeed, since checked above in constructor
86 RooAbsArg* dhobs = dhist.get()->find(hobs->GetName()) ;
87 RooRealVar* dhreal = dynamic_cast<RooRealVar*>(dhobs) ;
88 if (dhreal){
89 (static_cast<RooRealVar*>(hobs))->setRange(dhreal->getMin(),dhreal->getMax()) ;
90 }
91 }
92
94}
95
96
97
98
99////////////////////////////////////////////////////////////////////////////////
100/// Constructor from a RooDataHist. The first list of observables are the p.d.f.
101/// observables, which may any RooAbsReal (function or variable). The second list
102/// are the corresponding observables in the RooDataHist which must be of type
103/// RooRealVar or RooCategory This constructor thus allows to apply a coordinate transformation
104/// on the histogram data to be applied.
105
106RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgList& pdfObs,
108 RooAbsPdf(name,title),
109 _pdfObsList("pdfObs","List of p.d.f. observables",this),
110 _dataHist(const_cast<RooDataHist*>(&dhist)),
111 _intOrder(intOrder)
112{
115
116 // Verify that vars and dhist.get() have identical contents
117 const RooArgSet* dvars = dhist.get() ;
118 if (histObs.size()!=dvars->size()) {
119 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
120 << ") ERROR histogram variable list and RooDataHist must contain the same variables." << std::endl ;
121 throw(std::string("RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
122 }
123
124 for (const auto arg : histObs) {
125 if (!dvars->find(arg->GetName())) {
126 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
127 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
128 throw(std::string("RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
129 }
130 if (!arg->isFundamental()) {
131 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
132 << ") ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory." << std::endl ;
133 throw(std::string("RooHistPdf::ctor() ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory.")) ;
134 }
135 }
136
137
138 // Adjust ranges of _histObsList to those of _dataHist
139 for (const auto hobs : _histObsList) {
140 // Guaranteed to succeed, since checked above in constructor
141 RooAbsArg* dhobs = dhist.get()->find(hobs->GetName()) ;
142 RooRealVar* dhreal = dynamic_cast<RooRealVar*>(dhobs) ;
143 if (dhreal){
144 (static_cast<RooRealVar*>(hobs))->setRange(dhreal->getMin(),dhreal->getMax()) ;
145 }
146 }
147
149}
150
151RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgSet &vars, std::unique_ptr<RooDataHist> dhist,
152 int intOrder)
153 : RooHistPdf{name, title, vars, *dhist, intOrder}
154{
155 initializeOwnedDataHist(std::move(dhist));
156}
157RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgList &pdfObs, const RooArgList &histObs,
158 std::unique_ptr<RooDataHist> dhist, int intOrder)
160{
161 initializeOwnedDataHist(std::move(dhist));
162}
163
164
165////////////////////////////////////////////////////////////////////////////////
166/// Copy constructor
167
170 _pdfObsList("pdfObs",this,other._pdfObsList),
171 _dataHist(other._dataHist),
172 _intOrder(other._intOrder),
173 _cdfBoundaries(other._cdfBoundaries),
174 _totVolume(other._totVolume),
175 _unitNorm(other._unitNorm)
176{
177 _histObsList.addClone(other._histObsList) ;
178}
179
181 if (_ownedDataHist) return _ownedDataHist.get();
182 _ownedDataHist.reset(static_cast<RooDataHist*>(_dataHist->Clone(newname)));
184 return _dataHist;
185}
186
188{
189 const std::size_t nBins = _dataHist->numEntries();
190
191 std::size_t nNegative = 0;
192 double sumNegative = 0.;
193 for (std::size_t i = 0; i < nBins; ++i) {
194 if (_dataHist->weight(i) < 0.) {
195 ++nNegative;
197 }
198 }
199 if (nNegative == 0) {
200 return;
201 }
202
203 coutW(InputArguments) << "RooHistPdf::ctor(" << GetName() << ") WARNING: input histogram \"" << _dataHist->GetName()
204 << "\" contains " << nNegative
205 << " bins with negative content (sum of negative contents: " << sumNegative
206 << "). A p.d.f. cannot be negative, so these bins contents are clipped to zero while "
207 "preserving the error. The input "
208 "histogram is not modified. To avoid this message, remove the negative bin contents "
209 "before constructing the RooHistPdf."
210 << std::endl;
211
213 const bool hasSumW2 = dh->sumW2Array() != nullptr;
214 for (std::size_t i = 0; i < nBins; ++i) {
215 if (dh->weight(i) < 0.) {
216 // Keep the original bin error: clamping the content is a
217 // normalization-consistency measure, not a statement that the bin is
218 // now known exactly. The error still quantifies the statistical
219 // uncertainty of the original bin content estimate (e.g. whether the
220 // negative content is compatible with a fluctuation around zero),
221 // and setting it to zero would introduce undercoverage, which is
222 // always undesired. It would also irreversibly discard information
223 // for anyone retrieving the histogram via dataHist(), including any
224 // future per-bin MC-stat treatment, where a zero error would wrongly
225 // fix the bin at exactly zero.
226 const double wgtErr = hasSumW2 ? std::sqrt(std::max(dh->weightSquared(i), 0.)) : 0.;
227 dh->set(i, 0., wgtErr);
228 }
229 }
230}
231
233{
234 std::span<double> output = ctx.output();
235
236 // For interpolation and histograms of higher dimension, use base function
237 if (_pdfObsList.size() > 1) {
239 return;
240 }
241
242 auto xVals = ctx.at(_pdfObsList[0]);
243 _dataHist->weights(output.data(), xVals, _intOrder, true, _cdfBoundaries);
244 for (auto &ret : output) {
245 ret = std::max(ret, 0.0);
246 }
247}
248
249
250////////////////////////////////////////////////////////////////////////////////
251/// Return the current value: The value of the bin enclosing the current coordinates
252/// of the observables, normalized by the histograms contents. Interpolation
253/// is applied if the RooHistPdf is configured to do that.
254
256{
257 // Transfer values from
258 for (unsigned int i=0; i < _pdfObsList.size(); ++i) {
261
262 if (harg != parg) {
263 parg->syncCache() ;
264 harg->copyCache(parg,true) ;
265 if (!harg->inRange(nullptr)) {
266 return 0 ;
267 }
268 }
269 }
270
272
273 return std::max(ret, 0.0);
274}
275
276////////////////////////////////////////////////////////////////////////////////
277/// Return the total volume spanned by the observables of the RooHistPdf
278
280{
281 // Return previously calculated value, if any
282 if (_totVolume>0) {
283 return _totVolume ;
284 }
285 _totVolume = 1. ;
286
287 for (const auto arg : _histObsList) {
288 RooRealVar* real = dynamic_cast<RooRealVar*>(arg) ;
289 if (real) {
290 _totVolume *= (real->getMax()-real->getMin()) ;
291 } else {
292 RooCategory* cat = dynamic_cast<RooCategory*>(arg) ;
293 if (cat) {
294 _totVolume *= cat->numTypes() ;
295 }
296 }
297 }
298
299 return _totVolume ;
300}
301
302namespace {
303
304bool fullRange(const RooAbsArg& x, const RooAbsArg& y ,const char* range)
305{
306 const RooAbsRealLValue *_x = dynamic_cast<const RooAbsRealLValue*>(&x);
307 const RooAbsRealLValue *_y = dynamic_cast<const RooAbsRealLValue*>(&y);
308 if (!_x || !_y) return false;
309 if (!range || !strlen(range) || !_x->hasRange(range) ||
310 _x->getBinningPtr(range)->isParameterized()) {
311 // parameterized ranges may be full range now, but that might change,
312 // so return false
313 if (range && strlen(range) && _x->getBinningPtr(range)->isParameterized())
314 return false;
315 return (_x->getMin() == _y->getMin() && _x->getMax() == _y->getMax());
316 }
317 return (_x->getMin(range) == _y->getMin() && _x->getMax(range) == _y->getMax());
318}
319
320bool okayForAnalytical(RooAbsArg const& obs, RooArgSet const& allVars)
321{
322 auto lobs = dynamic_cast<RooAbsRealLValue const*>(&obs);
323 if(lobs == nullptr) return false;
324
325 bool isOkayForAnalyticalInt = false;
326
327 for(RooAbsArg *var : allVars) {
328 if(obs.dependsOn(*var)) {
329 if(!lobs->isJacobianOK(*var)) return false;
331 }
332 }
333
335}
336
337} // namespace
338
339
342 const char* rangeName,
343 RooArgSet const& histObsList,
344 RooArgSet const& pdfObsList,
346{
347 // First make list of pdf observables to histogram observables
348 // and select only those for which the integral is over the full range
349
350 Int_t code = 0;
351 Int_t frcode = 0;
352 bool directSubRange = false;
353 for (unsigned int n=0; n < pdfObsList.size() && n < histObsList.size(); ++n) {
354 const auto pa = pdfObsList[n];
355 const auto ha = histObsList[n];
356
357 if (okayForAnalytical(*pa, allVars)) {
358 code |= 2 << n;
359 analVars.add(*pa);
360 if (fullRange(*pa, *ha, rangeName)) {
361 frcode |= 2 << n;
362 } else if (pa->isFundamental()) {
363 // Sub-range integral over the histogram observable itself (no transform).
364 directSubRange = true;
365 }
366 }
367 }
368
369 if (code == frcode) {
370 // integrate over full range of all observables - use bit 0 to indicate
371 // full range integration over all observables
372 code |= 1;
373 }
374
375 // the full range. For interpolated histograms (intOrder > 0), fall back to
376 // numerical integration over a direct sub-range of the histogram observable.
377 // A derived (non-fundamental) observable, such as a linear transform used to
378 // renormalize the components of a RooMomentMorphFuncND, keeps the analytical
379 // path it relies on.
380 if (intOrder > 0 && directSubRange) {
381 analVars.removeAll();
382 return 0;
383 }
384 return (code >= 2) ? code : 0;
385}
386
387
389 const char* rangeName,
390 RooArgSet const& histObsList,
391 RooArgSet const& pdfObsList,
392 RooDataHist& dataHist,
393 bool histFuncMode) {
394 // Simplest scenario, full-range integration over all dependents
395 if (((2 << histObsList.size()) - 1) == code) {
396 return dataHist.sum(histFuncMode);
397 }
398
399 // Partial integration scenario, retrieve set of variables, calculate partial
400 // sum, figure out integration ranges (if needed)
402 std::map<const RooAbsArg*, std::pair<double, double> > ranges;
403 for (unsigned int n=0; n < pdfObsList.size() && n < histObsList.size(); ++n) {
404 const auto pa = pdfObsList[n];
405 const auto ha = histObsList[n];
406
407 if (code & (2 << n)) {
408 intSet.add(*ha);
409 }
410 if (!(code & 1)) {
412 }
413 // WVE must sync hist slice list values to pdf slice list
414 // Transfer values from
415 if (ha != pa) {
416 pa->syncCache();
417 ha->copyCache(pa,true);
418 }
419 }
420
421 double ret = (code & 1) ? dataHist.sum(intSet,histObsList,true,!histFuncMode) :
423
424 return ret ;
425}
426
427////////////////////////////////////////////////////////////////////////////////
428/// Determine integration scenario. If no interpolation is used,
429/// RooHistPdf can perform all integrals over its dependents
430/// analytically via partial or complete summation of the input
431/// histogram. If interpolation is used on the integral over
432/// all histogram observables is supported
433
438
439
440////////////////////////////////////////////////////////////////////////////////
441/// Return integral identified by 'code'. The actual integration
442/// is deferred to RooDataHist::sum() which implements partial
443/// or complete summation over the histograms contents.
444
445double RooHistPdf::analyticalIntegral(Int_t code, const char* rangeName) const
446{
448}
449
450
452{
453 bool isOkayForAnalyticalInt = false;
454
455 for (RooAbsArg * obs : pdfObsList) {
456 if(obs->dependsOn(dep)) {
457 // If the observable doesn't depend linearly on the integration
458 // variable we will not do analytical integration.
459 auto lvalue = dynamic_cast<RooAbsRealLValue const*>(obs);
460 if(!(lvalue && lvalue->isJacobianOK(dep))) return false;
462 }
463 }
464
466}
467
468
473
474
475////////////////////////////////////////////////////////////////////////////////
476/// Return sampling hint for making curves of (projections) of this function
477/// as the recursive division strategy of RooCurve cannot deal efficiently
478/// with the vertical lines that occur in a non-interpolated histogram
479
480std::list<double>* RooHistPdf::plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const
481{
483}
484
485
486std::list<double>* RooHistPdf::plotSamplingHint(RooDataHist const& dataHist,
487 RooArgSet const& pdfObsList,
488 RooArgSet const& histObsList,
489 int intOrder,
490 RooAbsRealLValue& obs,
491 double xlo,
492 double xhi)
493{
494 // No hints are required when interpolation is used
495 if (intOrder>0) {
496 return nullptr;
497 }
498
499 // Check that observable is in dataset, if not no hint is generated
500 RooAbsArg* dhObs = nullptr;
501 for (unsigned int i=0; i < pdfObsList.size(); ++i) {
504 if (std::string(obs.GetName())==pdfObs->GetName()) {
505 dhObs = dataHist.get()->find(histObs->GetName()) ;
506 break;
507 }
508 }
509
510 if (!dhObs) {
511 return nullptr;
512 }
513 RooAbsLValue* lval = dynamic_cast<RooAbsLValue*>(dhObs) ;
514 if (!lval) {
515 return nullptr;
516 }
517
518 // Retrieve position of all bin boundaries
519
520 const RooAbsBinning* binning = lval->getBinningPtr(nullptr);
521 std::span<const double> boundaries{binning->array(), static_cast<std::size_t>(binning->numBoundaries())};
522
523 // Use the helper function from RooCurve to make sure to get sampling hints
524 // that work with the RooFitPlotting.
525 return RooCurve::plotSamplingHintForBinBoundaries(boundaries, xlo, xhi);
526}
527
528
529////////////////////////////////////////////////////////////////////////////////
530/// Return sampling hint for making curves of (projections) of this function
531/// as the recursive division strategy of RooCurve cannot deal efficiently
532/// with the vertical lines that occur in a non-interpolated histogram
533
534std::list<double>* RooHistPdf::binBoundaries(RooAbsRealLValue& obs, double xlo, double xhi) const
535{
536 // No hints are required when interpolation is used
537 if (_intOrder>0) {
538 return nullptr;
539 }
540
541 // Check that observable is in dataset, if not no hint is generated
542 RooAbsLValue* lvarg = dynamic_cast<RooAbsLValue*>(_dataHist->get()->find(obs.GetName())) ;
543 if (!lvarg) {
544 return nullptr ;
545 }
546
547 // Retrieve position of all bin boundaries
548 const RooAbsBinning* binning = lvarg->getBinningPtr(nullptr);
549 double* boundaries = binning->array() ;
550
551 auto hint = new std::list<double> ;
552
553 // Construct array with pairs of points positioned epsilon to the left and
554 // right of the bin boundaries
555 for (Int_t i=0 ; i<binning->numBoundaries() ; i++) {
556 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
557 hint->push_back(boundaries[i]) ;
558 }
559 }
560
561 return hint ;
562}
563
564
565
566
567////////////////////////////////////////////////////////////////////////////////
568/// Only handle case of maximum in all variables
569
571{
572 std::unique_ptr<RooAbsCollection> common{_pdfObsList.selectCommon(vars)};
573 if (common->size()==_pdfObsList.size()) {
574 return 1;
575 }
576 return 0 ;
577}
578
579
580////////////////////////////////////////////////////////////////////////////////
581
582double RooHistPdf::maxVal(Int_t code) const
583{
584 R__ASSERT(code==1) ;
585
586 double max(-1) ;
587 for (Int_t i=0 ; i<_dataHist->numEntries() ; i++) {
588 double wgt = _dataHist->weight(i) ;
589 if (wgt>max) max=wgt ;
590 }
591
592 return max*1.05 ;
593}
594
595
596
597
598////////////////////////////////////////////////////////////////////////////////
599
601{
602 if (std::abs(dh1.sumEntries()-dh2.sumEntries())>1e-8) return false ;
603 if (dh1.numEntries() != dh2.numEntries()) return false ;
604 for (int i=0 ; i < dh1.numEntries() ; i++) {
605 if (std::abs(dh1.weight(i)-dh2.weight(i))>1e-8) return false ;
606 }
607 return true ;
608}
609
610
611
612////////////////////////////////////////////////////////////////////////////////
613/// Check if our datahist is already in the workspace
614
616{
617 for(auto const& data : ws.allData()) {
618 // If your dataset is already in this workspace nothing needs to be done
619 if (data == _dataHist) {
620 return false ;
621 }
622 }
623
624 // Check if dataset with given name already exists
626
627 // Yes it exists - now check if it is identical to our internal histogram
628 if (wsdata->InheritsFrom(RooDataHist::Class())) {
629
630 // Check if histograms are identical
631 if (areIdentical(static_cast<RooDataHist&>(*wsdata),*_dataHist)) {
632
633 // Exists and is of correct type, and identical -- adjust internal pointer to WS copy
634 _dataHist = static_cast<RooDataHist*>(wsdata) ;
635 } else {
636
637 // not identical, clone rename and import
638 auto uniqueName = std::string(_dataHist->GetName()) + "_" + GetName();
640 if (flag) {
641 coutE(ObjectHandling) << " RooHistPdf::importWorkspaceHook(" << GetName() << ") unable to import clone of underlying RooDataHist with unique name " << uniqueName << ", abort" << std::endl ;
642 return true ;
643 }
644 _dataHist = static_cast<RooDataHist*>(ws.embeddedData(uniqueName)) ;
645 }
646
647 } else {
648
649 // Exists and is NOT of correct type: clone rename and import
650 auto uniqueName = std::string(_dataHist->GetName()) + "_" + GetName();
652 if (flag) {
653 coutE(ObjectHandling) << " RooHistPdf::importWorkspaceHook(" << GetName() << ") unable to import clone of underlying RooDataHist with unique name " << uniqueName << ", abort" << std::endl ;
654 return true ;
655 }
656 _dataHist = static_cast<RooDataHist*>(ws.embeddedData(uniqueName));
657
658 }
659 return false ;
660 }
661
662 // We need to import our datahist into the workspace
664
665 // Redirect our internal pointer to the copy in the workspace
666 _dataHist = static_cast<RooDataHist*>(ws.embeddedData(_dataHist->GetName())) ;
667 return false ;
668}
669
670
671////////////////////////////////////////////////////////////////////////////////
672/// Stream an object of class RooHistPdf.
673
675{
676 if (R__b.IsReading()) {
677 R__b.ReadClassBuffer(RooHistPdf::Class(),this);
678 // WVE - interim solution - fix proxies here
679 //_proxyList.Clear() ;
680 //registerProxy(_pdfObsList) ;
681 } else {
682 R__b.WriteClassBuffer(RooHistPdf::Class(),this);
683 }
684}
#define e(i)
Definition RSha256.hxx:103
#define coutW(a)
#define coutE(a)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:130
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:142
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
friend void RooRefArray::Streamer(TBuffer &)
Abstract base class for RooRealVar binning definitions.
virtual Int_t numBoundaries() const =0
virtual double * array() const =0
Int_t numTypes(const char *=nullptr) const
Return number of types defined (in range named rangeName if rangeName!=nullptr)
Storage_t::size_type size() const
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:55
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract base class for objects that are lvalues, i.e.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
const RooAbsBinning * getBinningPtr(const char *rangeName) const override
bool hasRange(const char *name) const override
Check if variable has a binning with given name.
virtual void doEval(RooFit::EvalContext &) const
Base function for computing multiple values of a RooAbsReal.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
Definition RooArgSet.h:154
Object to represent discrete states.
Definition RooCategory.h:28
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...
static std::list< double > * plotSamplingHintForBinBoundaries(std::span< const double > boundaries, double xlo, double xhi)
Returns sampling hints for a histogram with given boundaries.
Definition RooCurve.cxx:901
Container class to hold N-dimensional binned data.
Definition RooDataHist.h:40
double sum(bool correctForBinSize, bool inverseCorr=false) const
Return the sum of the weights of all bins in the histogram.
void weights(double *output, std::span< double const > xVals, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of RooDataHist::weight() for one dimensional histograms with up to one dimension...
static TClass * Class()
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition RooDataHist.h:61
double weight(std::size_t i) const
Return weight of i-th bin.
double weightFast(const RooArgSet &bin, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A faster version of RooDataHist::weight that assumes the passed arguments are aligned with the histog...
const RooArgSet * get() const override
Get bin centre of current bin.
Definition RooDataHist.h:82
A probability density function sampled from a multidimensional histogram.
Definition RooHistPdf.h:29
RooArgSet _histObsList
List of observables defining dimensions of histogram.
Definition RooHistPdf.h:109
Int_t _intOrder
Interpolation order.
Definition RooHistPdf.h:113
bool forceAnalyticalInt(const RooAbsArg &dep) const override
bool areIdentical(const RooDataHist &dh1, const RooDataHist &dh2)
RooDataHist * _dataHist
Unowned pointer to underlying histogram.
Definition RooHistPdf.h:111
bool _cdfBoundaries
Use boundary conditions for CDFs.
Definition RooHistPdf.h:114
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
double totVolume() const
Return the total volume spanned by the observables of the RooHistPdf.
void initializeOwnedDataHist(std::unique_ptr< RooDataHist > &&dataHist)
Definition RooHistPdf.h:146
bool importWorkspaceHook(RooWorkspace &ws) override
Check if our datahist is already in the workspace.
static TClass * Class()
RooSetProxy _pdfObsList
List of observables mapped onto histogram observables.
Definition RooHistPdf.h:110
void clampNegativeBins()
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Return integral identified by 'code'.
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
RooDataHist & dataHist()
Definition RooHistPdf.h:41
Int_t getMaxVal(const RooArgSet &vars) const override
Only handle case of maximum in all variables.
double _totVolume
! Total volume of space (product of ranges of observables)
Definition RooHistPdf.h:115
RooDataHist * cloneAndOwnDataHist(const char *newname="")
Replaces underlying RooDataHist with a clone, which is now owned, and returns the clone.
std::unique_ptr< RooDataHist > _ownedDataHist
! Owned pointer to underlying histogram
Definition RooHistPdf.h:112
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Determine integration scenario.
double evaluate() const override
Return the current value: The value of the bin enclosing the current coordinates of the observables,...
bool _unitNorm
Assume contents is unit normalized (for use as pdf cache)
Definition RooHistPdf.h:116
Variable that can be changed from the outside.
Definition RooRealVar.h:37
void setRange(const char *name, double min, double max, bool shared=true)
Set a fit or plotting range.
Persistable container for RooFit projects.
RooAbsData * embeddedData(RooStringView name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
std::list< RooAbsData * > allData() const
Return list of all dataset in the workspace.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
Buffer base class used for serializing objects.
Definition TBuffer.h:43
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
RooCmdArg Rename(const char *suffix)
RooCmdArg Embedded(bool flag=true)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
std::pair< double, double > getRangeOrBinningInterval(RooAbsArg const *arg, const char *rangeName)