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 "Riostream.h"
33
34#include "RooCategory.h"
35#include "RooCurve.h"
36#include "RooDataHist.h"
37#include "RooFitImplHelpers.h"
38#include "RooGlobalFunc.h"
39#include "RooHistPdf.h"
40#include "RooMsgService.h"
41#include "RooRealVar.h"
42#include "RooUniformBinning.h"
43#include "RooWorkspace.h"
44
45#include "TError.h"
46#include "TBuffer.h"
47
48#include <algorithm>
49#include <cmath>
50
51////////////////////////////////////////////////////////////////////////////////
52/// Constructor from a RooDataHist. RooDataHist dimensions
53/// can be either real or discrete. See RooDataHist::RooDataHist for details on the binning.
54/// RooHistPdf neither owns or clone 'dhist' and the user must ensure the input histogram exists
55/// for the entire life span of this PDF.
56/// The only exception is a 'dhist' that contains bins with negative content: those are set to
57/// zero in an internally-owned clone that is used instead (see clampNegativeBins()).
58
59RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgSet& vars,
61 RooAbsPdf(name,title),
62 _pdfObsList("pdfObs","List of p.d.f. observables",this),
63 _dataHist(const_cast<RooDataHist*>(&dhist)),
64 _intOrder(intOrder)
65{
67 _pdfObsList.add(vars) ;
68
69 // Verify that vars and dhist.get() have identical contents
70 const RooArgSet* dvars = dhist.get() ;
71 if (vars.size()!=dvars->size()) {
72 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
73 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
74 assert(0) ;
75 }
76 for (const auto arg : vars) {
77 if (!dvars->find(arg->GetName())) {
78 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
79 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
80 assert(0) ;
81 }
82 }
83
84
85 // Adjust ranges of _histObsList to those of _dataHist
86 for (const auto hobs : _histObsList) {
87 // Guaranteed to succeed, since checked above in constructor
88 RooAbsArg* dhobs = dhist.get()->find(hobs->GetName()) ;
89 RooRealVar* dhreal = dynamic_cast<RooRealVar*>(dhobs) ;
90 if (dhreal){
91 (static_cast<RooRealVar*>(hobs))->setRange(dhreal->getMin(),dhreal->getMax()) ;
92 }
93 }
94
96}
97
98
99
100
101////////////////////////////////////////////////////////////////////////////////
102/// Constructor from a RooDataHist. The first list of observables are the p.d.f.
103/// observables, which may any RooAbsReal (function or variable). The second list
104/// are the corresponding observables in the RooDataHist which must be of type
105/// RooRealVar or RooCategory This constructor thus allows to apply a coordinate transformation
106/// on the histogram data to be applied.
107
108RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgList& pdfObs,
110 RooAbsPdf(name,title),
111 _pdfObsList("pdfObs","List of p.d.f. observables",this),
112 _dataHist(const_cast<RooDataHist*>(&dhist)),
113 _intOrder(intOrder)
114{
117
118 // Verify that vars and dhist.get() have identical contents
119 const RooArgSet* dvars = dhist.get() ;
120 if (histObs.size()!=dvars->size()) {
121 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
122 << ") ERROR histogram variable list and RooDataHist must contain the same variables." << std::endl ;
123 throw(std::string("RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
124 }
125
126 for (const auto arg : histObs) {
127 if (!dvars->find(arg->GetName())) {
128 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
129 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
130 throw(std::string("RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
131 }
132 if (!arg->isFundamental()) {
133 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
134 << ") ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory." << std::endl ;
135 throw(std::string("RooHistPdf::ctor() ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory.")) ;
136 }
137 }
138
139
140 // Adjust ranges of _histObsList to those of _dataHist
141 for (const auto hobs : _histObsList) {
142 // Guaranteed to succeed, since checked above in constructor
143 RooAbsArg* dhobs = dhist.get()->find(hobs->GetName()) ;
144 RooRealVar* dhreal = dynamic_cast<RooRealVar*>(dhobs) ;
145 if (dhreal){
146 (static_cast<RooRealVar*>(hobs))->setRange(dhreal->getMin(),dhreal->getMax()) ;
147 }
148 }
149
151}
152
153RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgSet &vars, std::unique_ptr<RooDataHist> dhist,
154 int intOrder)
155 : RooHistPdf{name, title, vars, *dhist, intOrder}
156{
157 initializeOwnedDataHist(std::move(dhist));
158}
159RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgList &pdfObs, const RooArgList &histObs,
160 std::unique_ptr<RooDataHist> dhist, int intOrder)
162{
163 initializeOwnedDataHist(std::move(dhist));
164}
165
166
167////////////////////////////////////////////////////////////////////////////////
168/// Copy constructor
169
172 _pdfObsList("pdfObs",this,other._pdfObsList),
173 _dataHist(other._dataHist),
174 _intOrder(other._intOrder),
175 _cdfBoundaries(other._cdfBoundaries),
176 _totVolume(other._totVolume),
177 _unitNorm(other._unitNorm)
178{
179 _histObsList.addClone(other._histObsList) ;
180}
181
183 if (_ownedDataHist) return _ownedDataHist.get();
184 _ownedDataHist.reset(static_cast<RooDataHist*>(_dataHist->Clone(newname)));
186 return _dataHist;
187}
188
190{
191 const std::size_t nBins = _dataHist->numEntries();
192
193 std::size_t nNegative = 0;
194 double sumNegative = 0.;
195 for (std::size_t i = 0; i < nBins; ++i) {
196 if (_dataHist->weight(i) < 0.) {
197 ++nNegative;
199 }
200 }
201 if (nNegative == 0) {
202 return;
203 }
204
205 coutW(InputArguments) << "RooHistPdf::ctor(" << GetName() << ") WARNING: input histogram \"" << _dataHist->GetName()
206 << "\" contains " << nNegative
207 << " bins with negative content (sum of negative contents: " << sumNegative
208 << "). A p.d.f. cannot be negative, so these bins contents are clipped to zero while "
209 "preserving the error. The input "
210 "histogram is not modified. To avoid this message, remove the negative bin contents "
211 "before constructing the RooHistPdf."
212 << std::endl;
213
215 const bool hasSumW2 = dh->sumW2Array() != nullptr;
216 for (std::size_t i = 0; i < nBins; ++i) {
217 if (dh->weight(i) < 0.) {
218 // Keep the original bin error: clamping the content is a
219 // normalization-consistency measure, not a statement that the bin is
220 // now known exactly. The error still quantifies the statistical
221 // uncertainty of the original bin content estimate (e.g. whether the
222 // negative content is compatible with a fluctuation around zero),
223 // and setting it to zero would introduce undercoverage, which is
224 // always undesired. It would also irreversibly discard information
225 // for anyone retrieving the histogram via dataHist(), including any
226 // future per-bin MC-stat treatment, where a zero error would wrongly
227 // fix the bin at exactly zero.
228 const double wgtErr = hasSumW2 ? std::sqrt(std::max(dh->weightSquared(i), 0.)) : 0.;
229 dh->set(i, 0., wgtErr);
230 }
231 }
232}
233
235{
236 std::span<double> output = ctx.output();
237
238 // For interpolation and histograms of higher dimension, use base function
239 if (_pdfObsList.size() > 1) {
241 return;
242 }
243
244 auto xVals = ctx.at(_pdfObsList[0]);
245 _dataHist->weights(output.data(), xVals, _intOrder, true, _cdfBoundaries);
246 for (auto &ret : output) {
247 ret = std::max(ret, 0.0);
248 }
249}
250
251
252////////////////////////////////////////////////////////////////////////////////
253/// Return the current value: The value of the bin enclosing the current coordinates
254/// of the observables, normalized by the histograms contents. Interpolation
255/// is applied if the RooHistPdf is configured to do that.
256
258{
259 // Transfer values from
260 for (unsigned int i=0; i < _pdfObsList.size(); ++i) {
263
264 if (harg != parg) {
265 parg->syncCache() ;
266 harg->copyCache(parg,true) ;
267 if (!harg->inRange(nullptr)) {
268 return 0 ;
269 }
270 }
271 }
272
274
275 return std::max(ret, 0.0);
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Return the total volume spanned by the observables of the RooHistPdf
280
282{
283 // Return previously calculated value, if any
284 if (_totVolume>0) {
285 return _totVolume ;
286 }
287 _totVolume = 1. ;
288
289 for (const auto arg : _histObsList) {
290 RooRealVar* real = dynamic_cast<RooRealVar*>(arg) ;
291 if (real) {
292 _totVolume *= (real->getMax()-real->getMin()) ;
293 } else {
294 RooCategory* cat = dynamic_cast<RooCategory*>(arg) ;
295 if (cat) {
296 _totVolume *= cat->numTypes() ;
297 }
298 }
299 }
300
301 return _totVolume ;
302}
303
304namespace {
305
306bool fullRange(const RooAbsArg& x, const RooAbsArg& y ,const char* range)
307{
308 const RooAbsRealLValue *_x = dynamic_cast<const RooAbsRealLValue*>(&x);
309 const RooAbsRealLValue *_y = dynamic_cast<const RooAbsRealLValue*>(&y);
310 if (!_x || !_y) return false;
311 if (!range || !strlen(range) || !_x->hasRange(range) ||
312 _x->getBinningPtr(range)->isParameterized()) {
313 // parameterized ranges may be full range now, but that might change,
314 // so return false
315 if (range && strlen(range) && _x->getBinningPtr(range)->isParameterized())
316 return false;
317 return (_x->getMin() == _y->getMin() && _x->getMax() == _y->getMax());
318 }
319 return (_x->getMin(range) == _y->getMin() && _x->getMax(range) == _y->getMax());
320}
321
322bool okayForAnalytical(RooAbsArg const& obs, RooArgSet const& allVars)
323{
324 auto lobs = dynamic_cast<RooAbsRealLValue const*>(&obs);
325 if(lobs == nullptr) return false;
326
327 bool isOkayForAnalyticalInt = false;
328
329 for(RooAbsArg *var : allVars) {
330 if(obs.dependsOn(*var)) {
331 if(!lobs->isJacobianOK(*var)) return false;
333 }
334 }
335
337}
338
339} // namespace
340
341
344 const char* rangeName,
345 RooArgSet const& histObsList,
346 RooArgSet const& pdfObsList,
348{
349 // First make list of pdf observables to histogram observables
350 // and select only those for which the integral is over the full range
351
352 Int_t code = 0;
353 Int_t frcode = 0;
354 bool directSubRange = false;
355 for (unsigned int n=0; n < pdfObsList.size() && n < histObsList.size(); ++n) {
356 const auto pa = pdfObsList[n];
357 const auto ha = histObsList[n];
358
359 if (okayForAnalytical(*pa, allVars)) {
360 code |= 2 << n;
361 analVars.add(*pa);
362 if (fullRange(*pa, *ha, rangeName)) {
363 frcode |= 2 << n;
364 } else if (pa->isFundamental()) {
365 // Sub-range integral over the histogram observable itself (no transform).
366 directSubRange = true;
367 }
368 }
369 }
370
371 if (code == frcode) {
372 // integrate over full range of all observables - use bit 0 to indicate
373 // full range integration over all observables
374 code |= 1;
375 }
376
377 // the full range. For interpolated histograms (intOrder > 0), fall back to
378 // numerical integration over a direct sub-range of the histogram observable.
379 // A derived (non-fundamental) observable, such as a linear transform used to
380 // renormalize the components of a RooMomentMorphFuncND, keeps the analytical
381 // path it relies on.
382 if (intOrder > 0 && directSubRange) {
383 analVars.removeAll();
384 return 0;
385 }
386 return (code >= 2) ? code : 0;
387}
388
389
391 const char* rangeName,
392 RooArgSet const& histObsList,
393 RooArgSet const& pdfObsList,
394 RooDataHist& dataHist,
395 bool histFuncMode) {
396 // Simplest scenario, full-range integration over all dependents
397 if (((2 << histObsList.size()) - 1) == code) {
398 return dataHist.sum(histFuncMode);
399 }
400
401 // Partial integration scenario, retrieve set of variables, calculate partial
402 // sum, figure out integration ranges (if needed)
404 std::map<const RooAbsArg*, std::pair<double, double> > ranges;
405 for (unsigned int n=0; n < pdfObsList.size() && n < histObsList.size(); ++n) {
406 const auto pa = pdfObsList[n];
407 const auto ha = histObsList[n];
408
409 if (code & (2 << n)) {
410 intSet.add(*ha);
411 }
412 if (!(code & 1)) {
414 }
415 // WVE must sync hist slice list values to pdf slice list
416 // Transfer values from
417 if (ha != pa) {
418 pa->syncCache();
419 ha->copyCache(pa,true);
420 }
421 }
422
423 double ret = (code & 1) ? dataHist.sum(intSet,histObsList,true,!histFuncMode) :
425
426 return ret ;
427}
428
429////////////////////////////////////////////////////////////////////////////////
430/// Determine integration scenario. If no interpolation is used,
431/// RooHistPdf can perform all integrals over its dependents
432/// analytically via partial or complete summation of the input
433/// histogram. If interpolation is used on the integral over
434/// all histogram observables is supported
435
440
441
442////////////////////////////////////////////////////////////////////////////////
443/// Return integral identified by 'code'. The actual integration
444/// is deferred to RooDataHist::sum() which implements partial
445/// or complete summation over the histograms contents.
446
447double RooHistPdf::analyticalIntegral(Int_t code, const char* rangeName) const
448{
450}
451
452
454{
455 bool isOkayForAnalyticalInt = false;
456
457 for (RooAbsArg * obs : pdfObsList) {
458 if(obs->dependsOn(dep)) {
459 // If the observable doesn't depend linearly on the integration
460 // variable we will not do analytical integration.
461 auto lvalue = dynamic_cast<RooAbsRealLValue const*>(obs);
462 if(!(lvalue && lvalue->isJacobianOK(dep))) return false;
464 }
465 }
466
468}
469
470
475
476
477////////////////////////////////////////////////////////////////////////////////
478/// Return sampling hint for making curves of (projections) of this function
479/// as the recursive division strategy of RooCurve cannot deal efficiently
480/// with the vertical lines that occur in a non-interpolated histogram
481
482std::list<double>* RooHistPdf::plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const
483{
485}
486
487
488std::list<double>* RooHistPdf::plotSamplingHint(RooDataHist const& dataHist,
489 RooArgSet const& pdfObsList,
490 RooArgSet const& histObsList,
491 int intOrder,
492 RooAbsRealLValue& obs,
493 double xlo,
494 double xhi)
495{
496 // No hints are required when interpolation is used
497 if (intOrder>0) {
498 return nullptr;
499 }
500
501 // Check that observable is in dataset, if not no hint is generated
502 RooAbsArg* dhObs = nullptr;
503 for (unsigned int i=0; i < pdfObsList.size(); ++i) {
506 if (std::string(obs.GetName())==pdfObs->GetName()) {
507 dhObs = dataHist.get()->find(histObs->GetName()) ;
508 break;
509 }
510 }
511
512 if (!dhObs) {
513 return nullptr;
514 }
515 RooAbsLValue* lval = dynamic_cast<RooAbsLValue*>(dhObs) ;
516 if (!lval) {
517 return nullptr;
518 }
519
520 // Retrieve position of all bin boundaries
521
522 const RooAbsBinning* binning = lval->getBinningPtr(nullptr);
523 std::span<const double> boundaries{binning->array(), static_cast<std::size_t>(binning->numBoundaries())};
524
525 // Use the helper function from RooCurve to make sure to get sampling hints
526 // that work with the RooFitPlotting.
527 return RooCurve::plotSamplingHintForBinBoundaries(boundaries, xlo, xhi);
528}
529
530
531////////////////////////////////////////////////////////////////////////////////
532/// Return sampling hint for making curves of (projections) of this function
533/// as the recursive division strategy of RooCurve cannot deal efficiently
534/// with the vertical lines that occur in a non-interpolated histogram
535
536std::list<double>* RooHistPdf::binBoundaries(RooAbsRealLValue& obs, double xlo, double xhi) const
537{
538 // No hints are required when interpolation is used
539 if (_intOrder>0) {
540 return nullptr;
541 }
542
543 // Check that observable is in dataset, if not no hint is generated
544 RooAbsLValue* lvarg = dynamic_cast<RooAbsLValue*>(_dataHist->get()->find(obs.GetName())) ;
545 if (!lvarg) {
546 return nullptr ;
547 }
548
549 // Retrieve position of all bin boundaries
550 const RooAbsBinning* binning = lvarg->getBinningPtr(nullptr);
551 double* boundaries = binning->array() ;
552
553 auto hint = new std::list<double> ;
554
555 // Construct array with pairs of points positioned epsilon to the left and
556 // right of the bin boundaries
557 for (Int_t i=0 ; i<binning->numBoundaries() ; i++) {
558 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
559 hint->push_back(boundaries[i]) ;
560 }
561 }
562
563 return hint ;
564}
565
566
567
568
569////////////////////////////////////////////////////////////////////////////////
570/// Only handle case of maximum in all variables
571
573{
574 std::unique_ptr<RooAbsCollection> common{_pdfObsList.selectCommon(vars)};
575 if (common->size()==_pdfObsList.size()) {
576 return 1;
577 }
578 return 0 ;
579}
580
581
582////////////////////////////////////////////////////////////////////////////////
583
584double RooHistPdf::maxVal(Int_t code) const
585{
586 R__ASSERT(code==1) ;
587
588 double max(-1) ;
589 for (Int_t i=0 ; i<_dataHist->numEntries() ; i++) {
590 double wgt = _dataHist->weight(i) ;
591 if (wgt>max) max=wgt ;
592 }
593
594 return max*1.05 ;
595}
596
597
598
599
600////////////////////////////////////////////////////////////////////////////////
601
603{
604 if (std::abs(dh1.sumEntries()-dh2.sumEntries())>1e-8) return false ;
605 if (dh1.numEntries() != dh2.numEntries()) return false ;
606 for (int i=0 ; i < dh1.numEntries() ; i++) {
607 if (std::abs(dh1.weight(i)-dh2.weight(i))>1e-8) return false ;
608 }
609 return true ;
610}
611
612
613
614////////////////////////////////////////////////////////////////////////////////
615/// Check if our datahist is already in the workspace
616
618{
619 for(auto const& data : ws.allData()) {
620 // If your dataset is already in this workspace nothing needs to be done
621 if (data == _dataHist) {
622 return false ;
623 }
624 }
625
626 // Check if dataset with given name already exists
628
629 // Yes it exists - now check if it is identical to our internal histogram
630 if (wsdata->InheritsFrom(RooDataHist::Class())) {
631
632 // Check if histograms are identical
633 if (areIdentical(static_cast<RooDataHist&>(*wsdata),*_dataHist)) {
634
635 // Exists and is of correct type, and identical -- adjust internal pointer to WS copy
636 _dataHist = static_cast<RooDataHist*>(wsdata) ;
637 } else {
638
639 // not identical, clone rename and import
640 auto uniqueName = std::string(_dataHist->GetName()) + "_" + GetName();
642 if (flag) {
643 coutE(ObjectHandling) << " RooHistPdf::importWorkspaceHook(" << GetName() << ") unable to import clone of underlying RooDataHist with unique name " << uniqueName << ", abort" << std::endl ;
644 return true ;
645 }
646 _dataHist = static_cast<RooDataHist*>(ws.embeddedData(uniqueName)) ;
647 }
648
649 } else {
650
651 // Exists and is NOT of correct type: clone rename and import
652 auto uniqueName = std::string(_dataHist->GetName()) + "_" + GetName();
654 if (flag) {
655 coutE(ObjectHandling) << " RooHistPdf::importWorkspaceHook(" << GetName() << ") unable to import clone of underlying RooDataHist with unique name " << uniqueName << ", abort" << std::endl ;
656 return true ;
657 }
658 _dataHist = static_cast<RooDataHist*>(ws.embeddedData(uniqueName));
659
660 }
661 return false ;
662 }
663
664 // We need to import our datahist into the workspace
666
667 // Redirect our internal pointer to the copy in the workspace
668 _dataHist = static_cast<RooDataHist*>(ws.embeddedData(_dataHist->GetName())) ;
669 return false ;
670}
671
672
673////////////////////////////////////////////////////////////////////////////////
674/// Stream an object of class RooHistPdf.
675
677{
678 if (R__b.IsReading()) {
679 R__b.ReadClassBuffer(RooHistPdf::Class(),this);
680 // WVE - interim solution - fix proxies here
681 //_proxyList.Clear() ;
682 //registerProxy(_pdfObsList) ;
683 } else {
684 R__b.WriteClassBuffer(RooHistPdf::Class(),this);
685 }
686}
#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:125
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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
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:56
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:897
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)