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
22RooHistPdf implements a probablity 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**/
27
28#include "Riostream.h"
29
30#include "RooHistPdf.h"
31#include "RooDataHist.h"
32#include "RooMsgService.h"
33#include "RooRealVar.h"
34#include "RooCategory.h"
35#include "RooWorkspace.h"
36#include "RooGlobalFunc.h"
37#include "RooHelpers.h"
38
39#include "TError.h"
40#include "TBuffer.h"
41
42
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Constructor from a RooDataHist. RooDataHist dimensions
48/// can be either real or discrete. See RooDataHist::RooDataHist for details on the binning.
49/// RooHistPdf neither owns or clone 'dhist' and the user must ensure the input histogram exists
50/// for the entire life span of this PDF.
51
52RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgSet& vars,
53 const RooDataHist& dhist, Int_t intOrder) :
54 RooAbsPdf(name,title),
55 _pdfObsList("pdfObs","List of p.d.f. observables",this),
56 _dataHist((RooDataHist*)&dhist),
57 _codeReg(10),
58 _intOrder(intOrder),
59 _cdfBoundaries(false)
60{
62 _pdfObsList.add(vars) ;
63
64 // Verify that vars and dhist.get() have identical contents
65 const RooArgSet* dvars = dhist.get() ;
66 if (vars.size()!=dvars->size()) {
67 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
68 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
69 assert(0) ;
70 }
71 for (const auto arg : vars) {
72 if (!dvars->find(arg->GetName())) {
73 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
74 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
75 assert(0) ;
76 }
77 }
78
79
80 // Adjust ranges of _histObsList to those of _dataHist
81 for (const auto hobs : _histObsList) {
82 // Guaranteed to succeed, since checked above in ctor
83 RooAbsArg* dhobs = dhist.get()->find(hobs->GetName()) ;
84 RooRealVar* dhreal = dynamic_cast<RooRealVar*>(dhobs) ;
85 if (dhreal){
86 ((RooRealVar*)hobs)->setRange(dhreal->getMin(),dhreal->getMax()) ;
87 }
88 }
89
90}
91
92
93
94
95////////////////////////////////////////////////////////////////////////////////
96/// Constructor from a RooDataHist. The first list of observables are the p.d.f.
97/// observables, which may any RooAbsReal (function or variable). The second list
98/// are the corresponding observables in the RooDataHist which must be of type
99/// RooRealVar or RooCategory This constructor thus allows to apply a coordinate transformation
100/// on the histogram data to be applied.
101
102RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgList& pdfObs,
103 const RooArgList& histObs, const RooDataHist& dhist, Int_t intOrder) :
104 RooAbsPdf(name,title),
105 _pdfObsList("pdfObs","List of p.d.f. observables",this),
106 _dataHist((RooDataHist*)&dhist),
107 _codeReg(10),
108 _intOrder(intOrder),
109 _cdfBoundaries(false)
110{
111 _histObsList.addClone(histObs) ;
112 _pdfObsList.add(pdfObs) ;
113
114 // Verify that vars and dhist.get() have identical contents
115 const RooArgSet* dvars = dhist.get() ;
116 if (histObs.size()!=dvars->size()) {
117 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
118 << ") ERROR histogram variable list and RooDataHist must contain the same variables." << std::endl ;
119 throw(std::string("RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
120 }
121
122 for (const auto arg : histObs) {
123 if (!dvars->find(arg->GetName())) {
124 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
125 << ") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
126 throw(std::string("RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
127 }
128 if (!arg->isFundamental()) {
129 coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
130 << ") ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory." << std::endl ;
131 throw(std::string("RooHistPdf::ctor() ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory.")) ;
132 }
133 }
134
135
136 // Adjust ranges of _histObsList to those of _dataHist
137 for (const auto hobs : _histObsList) {
138 // Guaranteed to succeed, since checked above in ctor
139 RooAbsArg* dhobs = dhist.get()->find(hobs->GetName()) ;
140 RooRealVar* dhreal = dynamic_cast<RooRealVar*>(dhobs) ;
141 if (dhreal){
142 ((RooRealVar*)hobs)->setRange(dhreal->getMin(),dhreal->getMax()) ;
143 }
144 }
145}
146
147
148RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgSet& vars,
149 std::unique_ptr<RooDataHist> dhist, int intOrder)
150 : RooHistPdf{name, title, vars, *dhist, intOrder}
151{
152 _ownedDataHist = std::move(dhist);
153}
154RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgList& pdfObs, const RooArgList& histObs,
155 std::unique_ptr<RooDataHist> dhist, int intOrder)
156 : RooHistPdf{name, title, pdfObs, histObs, *dhist, intOrder}
157{
158 _ownedDataHist = std::move(dhist);
159}
160
161
162////////////////////////////////////////////////////////////////////////////////
163/// Copy constructor
164
165RooHistPdf::RooHistPdf(const RooHistPdf& other, const char* name) :
166 RooAbsPdf(other,name),
167 _pdfObsList("pdfObs",this,other._pdfObsList),
168 _dataHist(other._dataHist),
169 _codeReg(other._codeReg),
170 _intOrder(other._intOrder),
171 _cdfBoundaries(other._cdfBoundaries),
172 _totVolume(other._totVolume),
173 _unitNorm(other._unitNorm)
174{
176
177}
178
179
180
181
182////////////////////////////////////////////////////////////////////////////////
183/// Destructor
184
186{
187
188}
189
191 if (_ownedDataHist) return _ownedDataHist.get();
192 _ownedDataHist.reset(static_cast<RooDataHist*>(_dataHist->Clone(newname)));
194 return _dataHist;
195}
196
197void RooHistPdf::computeBatch(cudaStream_t*, double* output, size_t nEvents, RooFit::Detail::DataMap const& dataMap) const {
198
199 // For interpolation and histograms of higher dimension, use base function
200 if(_pdfObsList.size() > 1) {
201 RooAbsReal::computeBatch(nullptr, output, nEvents, dataMap);
202 return;
203 }
204
205 auto xVals = dataMap.at(_pdfObsList[0]);
207}
208
209
210////////////////////////////////////////////////////////////////////////////////
211/// Return the current value: The value of the bin enclosing the current coordinates
212/// of the observables, normalized by the histograms contents. Interpolation
213/// is applied if the RooHistPdf is configured to do that.
214
216{
217 // Transfer values from
218 for (unsigned int i=0; i < _pdfObsList.size(); ++i) {
219 RooAbsArg* harg = _histObsList[i];
220 RooAbsArg* parg = _pdfObsList[i];
221
222 if (harg != parg) {
223 parg->syncCache() ;
224 harg->copyCache(parg,true) ;
225 if (!harg->inRange(0)) {
226 return 0 ;
227 }
228 }
229 }
230
232
233 return std::max(ret, 0.0);
234}
235
236
237////////////////////////////////////////////////////////////////////////////////
238/// Return the total volume spanned by the observables of the RooHistPdf
239
241{
242 // Return previously calculated value, if any
243 if (_totVolume>0) {
244 return _totVolume ;
245 }
246 _totVolume = 1. ;
247
248 for (const auto arg : _histObsList) {
249 RooRealVar* real = dynamic_cast<RooRealVar*>(arg) ;
250 if (real) {
251 _totVolume *= (real->getMax()-real->getMin()) ;
252 } else {
253 RooCategory* cat = dynamic_cast<RooCategory*>(arg) ;
254 if (cat) {
255 _totVolume *= cat->numTypes() ;
256 }
257 }
258 }
259
260 return _totVolume ;
261}
262
263namespace {
264bool fullRange(const RooAbsArg& x, const RooAbsArg& y ,const char* range)
265{
266 const RooAbsRealLValue *_x = dynamic_cast<const RooAbsRealLValue*>(&x);
267 const RooAbsRealLValue *_y = dynamic_cast<const RooAbsRealLValue*>(&y);
268 if (!_x || !_y) return false;
269 if (!range || !strlen(range) || !_x->hasRange(range) ||
270 _x->getBinningPtr(range)->isParameterized()) {
271 // parameterized ranges may be full range now, but that might change,
272 // so return false
273 if (range && strlen(range) && _x->getBinningPtr(range)->isParameterized())
274 return false;
275 return (_x->getMin() == _y->getMin() && _x->getMax() == _y->getMax());
276 }
277 return (_x->getMin(range) == _y->getMin() && _x->getMax(range) == _y->getMax());
278}
279}
280
281
283 RooArgSet& analVars,
284 const char* rangeName,
285 RooArgSet const& histObsList,
286 RooSetProxy const& pdfObsList,
287 Int_t intOrder) {
288 // First make list of pdf observables to histogram observables
289 // and select only those for which the integral is over the full range
290
291 Int_t code = 0;
292 Int_t frcode = 0;
293 for (unsigned int n=0; n < pdfObsList.size() && n < histObsList.size(); ++n) {
294 const auto pa = pdfObsList[n];
295 const auto ha = histObsList[n];
296
297 if (allVars.find(*pa)) {
298 code |= 2 << n;
299 analVars.add(*pa);
300 if (fullRange(*pa, *ha, rangeName)) {
301 frcode |= 2 << n;
302 }
303 }
304 }
305
306 if (code == frcode) {
307 // integrate over full range of all observables - use bit 0 to indicate
308 // full range integration over all observables
309 code |= 1;
310 }
311
312 // Disable partial analytical integrals if interpolation is used, and we
313 // integrate over sub-ranges, but leave them enabled when we integrate over
314 // the full range of one or several variables
315 if (intOrder > 1 && !(code & 1)) {
316 analVars.removeAll();
317 return 0;
318 }
319 return (code >= 2) ? code : 0;
320}
321
322
324 const char* rangeName,
325 RooArgSet const& histObsList,
326 RooSetProxy const& pdfObsList,
327 RooDataHist& dataHist,
328 bool histFuncMode) {
329 // Simplest scenario, full-range integration over all dependents
330 if (((2 << histObsList.size()) - 1) == code) {
331 return dataHist.sum(histFuncMode);
332 }
333
334 // Partial integration scenario, retrieve set of variables, calculate partial
335 // sum, figure out integration ranges (if needed)
336 RooArgSet intSet;
337 std::map<const RooAbsArg*, std::pair<double, double> > ranges;
338 for (unsigned int n=0; n < pdfObsList.size() && n < histObsList.size(); ++n) {
339 const auto pa = pdfObsList[n];
340 const auto ha = histObsList[n];
341
342 if (code & (2 << n)) {
343 intSet.add(*ha);
344 }
345 if (!(code & 1)) {
346 ranges[ha] = RooHelpers::getRangeOrBinningInterval(pa, rangeName);
347 }
348 // WVE must sync hist slice list values to pdf slice list
349 // Transfer values from
350 if (ha != pa) {
351 pa->syncCache();
352 ha->copyCache(pa,true);
353 }
354 }
355
356 double ret = (code & 1) ? dataHist.sum(intSet,histObsList,true,!histFuncMode) :
357 dataHist.sum(intSet,histObsList,true,!histFuncMode, ranges);
358
359 return ret ;
360}
361
362////////////////////////////////////////////////////////////////////////////////
363/// Determine integration scenario. If no interpolation is used,
364/// RooHistPdf can perform all integrals over its dependents
365/// analytically via partial or complete summation of the input
366/// histogram. If interpolation is used on the integral over
367/// all histogram observables is supported
368
369Int_t RooHistPdf::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName) const
370{
371 return getAnalyticalIntegral(allVars, analVars, rangeName, _histObsList, _pdfObsList, _intOrder);
372}
373
374
375////////////////////////////////////////////////////////////////////////////////
376/// Return integral identified by 'code'. The actual integration
377/// is deferred to RooDataHist::sum() which implements partial
378/// or complete summation over the histograms contents.
379
380double RooHistPdf::analyticalIntegral(Int_t code, const char* rangeName) const
381{
382 return analyticalIntegral(code, rangeName, _histObsList, _pdfObsList, *_dataHist, false);
383}
384
385
386////////////////////////////////////////////////////////////////////////////////
387/// Return sampling hint for making curves of (projections) of this function
388/// as the recursive division strategy of RooCurve cannot deal efficiently
389/// with the vertical lines that occur in a non-interpolated histogram
390
391std::list<double>* RooHistPdf::plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const
392{
394}
395
396
397std::list<double>* RooHistPdf::plotSamplingHint(RooDataHist const& dataHist,
398 RooArgSet const& pdfObsList,
399 RooArgSet const& histObsList,
400 int intOrder,
401 RooAbsRealLValue& obs,
402 double xlo,
403 double xhi)
404{
405 // No hints are required when interpolation is used
406 if (intOrder>0) {
407 return nullptr;
408 }
409
410 // Check that observable is in dataset, if not no hint is generated
411 RooAbsArg* dhObs = nullptr;
412 for (unsigned int i=0; i < pdfObsList.size(); ++i) {
413 RooAbsArg* histObs = histObsList[i];
414 RooAbsArg* pdfObs = pdfObsList[i];
415 if (std::string(obs.GetName())==pdfObs->GetName()) {
416 dhObs = dataHist.get()->find(histObs->GetName()) ;
417 break;
418 }
419 }
420
421 if (!dhObs) {
422 return nullptr;
423 }
424 RooAbsLValue* lval = dynamic_cast<RooAbsLValue*>(dhObs) ;
425 if (!lval) {
426 return nullptr;
427 }
428
429 // Retrieve position of all bin boundaries
430
431 const RooAbsBinning* binning = lval->getBinningPtr(nullptr);
432 std::span<double> boundaries{binning->array(), static_cast<std::size_t>(binning->numBoundaries())};
433
434 auto hint = new std::list<double> ;
435
436 const double delta = (xhi-xlo)*1e-8 ;
437
438 // Sample points right next to the plot limits
439 hint->push_back(xlo + delta);
440 hint->push_back(xhi - delta);
441
442 // Sample points very close to the left and right of the bin boundaries that
443 // are strictly in between the plot limits.
444 for (const double x : boundaries) {
445 if (x - xlo > delta && xhi - x > delta) {
446 hint->push_back(x - delta);
447 hint->push_back(x + delta);
448 }
449 }
450
451 return hint ;
452}
453
454
455////////////////////////////////////////////////////////////////////////////////
456/// Return sampling hint for making curves of (projections) of this function
457/// as the recursive division strategy of RooCurve cannot deal efficiently
458/// with the vertical lines that occur in a non-interpolated histogram
459
460std::list<double>* RooHistPdf::binBoundaries(RooAbsRealLValue& obs, double xlo, double xhi) const
461{
462 // No hints are required when interpolation is used
463 if (_intOrder>0) {
464 return nullptr;
465 }
466
467 // Check that observable is in dataset, if not no hint is generated
468 RooAbsLValue* lvarg = dynamic_cast<RooAbsLValue*>(_dataHist->get()->find(obs.GetName())) ;
469 if (!lvarg) {
470 return 0 ;
471 }
472
473 // Retrieve position of all bin boundaries
474 const RooAbsBinning* binning = lvarg->getBinningPtr(nullptr);
475 double* boundaries = binning->array() ;
476
477 auto hint = new std::list<double> ;
478
479 // Construct array with pairs of points positioned epsilon to the left and
480 // right of the bin boundaries
481 for (Int_t i=0 ; i<binning->numBoundaries() ; i++) {
482 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
483 hint->push_back(boundaries[i]) ;
484 }
485 }
486
487 return hint ;
488}
489
490
491
492
493////////////////////////////////////////////////////////////////////////////////
494/// Only handle case of maximum in all variables
495
497{
498 std::unique_ptr<RooAbsCollection> common{_pdfObsList.selectCommon(vars)};
499 if (common->size()==_pdfObsList.size()) {
500 return 1;
501 }
502 return 0 ;
503}
504
505
506////////////////////////////////////////////////////////////////////////////////
507
508double RooHistPdf::maxVal(Int_t code) const
509{
510 R__ASSERT(code==1) ;
511
512 double max(-1) ;
513 for (Int_t i=0 ; i<_dataHist->numEntries() ; i++) {
514 _dataHist->get(i) ;
515 double wgt = _dataHist->weight() ;
516 if (wgt>max) max=wgt ;
517 }
518
519 return max*1.05 ;
520}
521
522
523
524
525////////////////////////////////////////////////////////////////////////////////
526
528{
529 if (std::abs(dh1.sumEntries()-dh2.sumEntries())>1e-8) return false ;
530 if (dh1.numEntries() != dh2.numEntries()) return false ;
531 for (int i=0 ; i < dh1.numEntries() ; i++) {
532 dh1.get(i) ;
533 dh2.get(i) ;
534 if (std::abs(dh1.weight()-dh2.weight())>1e-8) return false ;
535 }
536 return true ;
537}
538
539
540
541////////////////////////////////////////////////////////////////////////////////
542/// Check if our datahist is already in the workspace
543
545{
546 for(auto const& data : ws.allData()) {
547 // If your dataset is already in this workspace nothing needs to be done
548 if (data == _dataHist) {
549 return false ;
550 }
551 }
552
553 // Check if dataset with given name already exists
554 if (RooAbsData* wsdata = ws.embeddedData(_dataHist->GetName())) {
555
556 // Yes it exists - now check if it is identical to our internal histogram
557 if (wsdata->InheritsFrom(RooDataHist::Class())) {
558
559 // Check if histograms are identical
560 if (areIdentical((RooDataHist&)*wsdata,*_dataHist)) {
561
562 // Exists and is of correct type, and identical -- adjust internal pointer to WS copy
563 _dataHist = (RooDataHist*) wsdata ;
564 } else {
565
566 // not identical, clone rename and import
567 auto uniqueName = std::string(_dataHist->GetName()) + "_" + GetName();
568 bool flag = ws.import(*_dataHist,RooFit::Rename(uniqueName.c_str()),RooFit::Embedded()) ;
569 if (flag) {
570 coutE(ObjectHandling) << " RooHistPdf::importWorkspaceHook(" << GetName() << ") unable to import clone of underlying RooDataHist with unique name " << uniqueName << ", abort" << std::endl ;
571 return true ;
572 }
573 _dataHist = (RooDataHist*) ws.embeddedData(uniqueName.c_str()) ;
574 }
575
576 } else {
577
578 // Exists and is NOT of correct type: clone rename and import
579 auto uniqueName = std::string(_dataHist->GetName()) + "_" + GetName();
580 bool flag = ws.import(*_dataHist,RooFit::Rename(uniqueName.c_str()),RooFit::Embedded()) ;
581 if (flag) {
582 coutE(ObjectHandling) << " RooHistPdf::importWorkspaceHook(" << GetName() << ") unable to import clone of underlying RooDataHist with unique name " << uniqueName << ", abort" << std::endl ;
583 return true ;
584 }
585 _dataHist = static_cast<RooDataHist*>(ws.embeddedData(uniqueName.c_str()));
586
587 }
588 return false ;
589 }
590
591 // We need to import our datahist into the workspace
593
594 // Redirect our internal pointer to the copy in the workspace
596 return false ;
597}
598
599
600////////////////////////////////////////////////////////////////////////////////
601/// Stream an object of class RooHistPdf.
602
604{
605 if (R__b.IsReading()) {
607 // WVE - interim solution - fix proxies here
608 //_proxyList.Clear() ;
609 //registerProxy(_pdfObsList) ;
610 } else {
612 }
613}
614
#define e(i)
Definition RSha256.hxx:103
#define coutE(a)
#define ClassImp(name)
Definition Rtypes.h:377
#define R__ASSERT(e)
Definition TError.h:117
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:110
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:74
virtual void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true)=0
virtual void syncCache(const RooArgSet *nset=nullptr)=0
friend void RooRefArray::Streamer(TBuffer &)
virtual bool inRange(const char *) const
Definition RooAbsArg.h:375
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual bool isParameterized() const
Interface function.
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)
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:59
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.
virtual const RooAbsBinning * getBinningPtr(const char *rangeName) const =0
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
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 computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) 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:55
RooCategory is an 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...
The RooDataHist is a container class to hold N-dimensional binned data.
Definition RooDataHist.h:39
double sum(bool correctForBinSize, bool inverseCorr=false) const
Return the sum of the weights of all bins in the histogram.
static TClass * Class()
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition RooDataHist.h:55
void weights(double *output, RooSpan< double const > xVals, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of RooDataHist::weight() for one dimensional histograms with up to one dimension...
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:76
double sumEntries() const override
Sum the weights of all bins.
RooSpan< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
Definition DataMap.cxx:21
RooHistPdf implements a probablity density function sampled from a multidimensional histogram.
Definition RooHistPdf.h:30
RooArgSet _histObsList
List of observables defining dimensions of histogram.
Definition RooHistPdf.h:108
Int_t _intOrder
Interpolation order.
Definition RooHistPdf.h:113
bool areIdentical(const RooDataHist &dh1, const RooDataHist &dh2)
RooDataHist * _dataHist
Unowned pointer to underlying histogram.
Definition RooHistPdf.h:110
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.
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:109
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...
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const override
Base function for computing multiple values of a RooAbsReal.
RooDataHist & dataHist()
Definition RooHistPdf.h:43
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:111
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Determine integration scenario.
~RooHistPdf() override
Destructor.
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
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:40
void setRange(const char *name, double min, double max)
Set a fit or plotting range.
The RooWorkspace is a 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.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
std::list< RooAbsData * > allData() const
Return list of all dataset in the workspace.
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
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)
Get the lower and upper bound of parameter range if arg can be casted to RooAbsRealLValue.
static void output()