Logo ROOT  
Reference Guide
RooHistFunc.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 RooHistFunc.cxx
19 \class RooHistFunc
20 \ingroup Roofitcore
21 
22 RooHistFunc implements a real-valued function sampled from a
23 multidimensional histogram. The histogram can have an arbitrary number of real or
24 discrete dimensions and may have negative values.
25 **/
26 
27 #include "RooHistFunc.h"
28 #include "RooDataHist.h"
29 #include "RooMsgService.h"
30 #include "RooRealVar.h"
31 #include "RooCategory.h"
32 #include "RooWorkspace.h"
33 #include "RooHistPdf.h"
34 #include "RooHelpers.h"
35 #include "RunContext.h"
36 
37 #include "TError.h"
38 #include "TBuffer.h"
39 
40 #include <stdexcept>
41 
42 using namespace std;
43 
45 ;
46 
47 
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// Default constructor
51 
53  _dataHist(0),
54  _intOrder(0),
55  _cdfBoundaries(kFALSE),
56  _totVolume(0),
57  _unitNorm(kFALSE)
58 {
60 }
61 
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// Constructor from a RooDataHist. The variable listed in 'vars' control the dimensionality of the
65 /// function. Any additional dimensions present in 'dhist' will be projected out. RooDataHist dimensions
66 /// can be either real or discrete. See RooDataHist::RooDataHist for details on the binning.
67 /// RooHistFunc neither owns or clone 'dhist' and the user must ensure the input histogram exists
68 /// for the entire life span of this function.
69 
70 RooHistFunc::RooHistFunc(const char *name, const char *title, const RooArgSet& vars,
71  const RooDataHist& dhist, Int_t intOrder) :
72  RooAbsReal(name,title),
73  _depList("depList","List of dependents",this),
74  _dataHist((RooDataHist*)&dhist),
75  _codeReg(10),
76  _intOrder(intOrder),
77  _cdfBoundaries(kFALSE),
78  _totVolume(0),
79  _unitNorm(kFALSE)
80 {
81  _histObsList.addClone(vars) ;
82  _depList.add(vars) ;
83 
84  // Verify that vars and dhist.get() have identical contents
85  const RooArgSet* dvars = dhist.get() ;
86  if (vars.getSize()!=dvars->getSize()) {
87  coutE(InputArguments) << "RooHistFunc::ctor(" << GetName()
88  << ") ERROR variable list and RooDataHist must contain the same variables." << endl ;
89  throw std::invalid_argument("RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
90  }
91 
92  for (const auto arg : vars) {
93  if (!dvars->find(arg->GetName())) {
94  coutE(InputArguments) << "RooHistFunc::ctor(" << GetName()
95  << ") ERROR variable list and RooDataHist must contain the same variables." << endl ;
96  throw std::invalid_argument("RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
97  }
98  }
99 
100  TRACE_CREATE
101 }
102 
103 
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Constructor from a RooDataHist. The variable listed in 'vars' control the dimensionality of the
107 /// function. Any additional dimensions present in 'dhist' will be projected out. RooDataHist dimensions
108 /// can be either real or discrete. See RooDataHist::RooDataHist for details on the binning.
109 /// RooHistFunc neither owns or clone 'dhist' and the user must ensure the input histogram exists
110 /// for the entire life span of this function.
111 
112 RooHistFunc::RooHistFunc(const char *name, const char *title, const RooArgList& funcObs, const RooArgList& histObs,
113  const RooDataHist& dhist, Int_t intOrder) :
114  RooAbsReal(name,title),
115  _depList("depList","List of dependents",this),
116  _dataHist((RooDataHist*)&dhist),
117  _codeReg(10),
118  _intOrder(intOrder),
119  _cdfBoundaries(kFALSE),
120  _totVolume(0),
121  _unitNorm(kFALSE)
122 {
123  _histObsList.addClone(histObs) ;
124  _depList.add(funcObs) ;
125 
126  // Verify that vars and dhist.get() have identical contents
127  const RooArgSet* dvars = dhist.get() ;
128  if (histObs.getSize()!=dvars->getSize()) {
129  coutE(InputArguments) << "RooHistFunc::ctor(" << GetName()
130  << ") ERROR variable list and RooDataHist must contain the same variables." << endl ;
131  throw std::invalid_argument("RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
132  }
133 
134  for (const auto arg : histObs) {
135  if (!dvars->find(arg->GetName())) {
136  coutE(InputArguments) << "RooHistFunc::ctor(" << GetName()
137  << ") ERROR variable list and RooDataHist must contain the same variables." << endl ;
138  throw std::invalid_argument("RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
139  }
140  }
141 
142  TRACE_CREATE
143 }
144 
145 
146 
147 ////////////////////////////////////////////////////////////////////////////////
148 /// Copy constructor
149 
150 RooHistFunc::RooHistFunc(const RooHistFunc& other, const char* name) :
151  RooAbsReal(other,name),
152  _depList("depList",this,other._depList),
153  _dataHist(other._dataHist),
154  _codeReg(other._codeReg),
155  _intOrder(other._intOrder),
156  _cdfBoundaries(other._cdfBoundaries),
157  _totVolume(other._totVolume),
158  _unitNorm(other._unitNorm)
159 {
160  TRACE_CREATE
161 
163 }
164 
165 
166 
167 ////////////////////////////////////////////////////////////////////////////////
168 
170 {
172 }
173 
174 
175 
176 
177 ////////////////////////////////////////////////////////////////////////////////
178 /// Return the current value: The value of the bin enclosing the current coordinates
179 /// of the dependents, normalized by the histograms contents. Interpolation
180 /// is applied if the RooHistFunc is configured to do that
181 
183 {
184  // Transfer values from
185  if (_depList.getSize()>0) {
186  for (auto i = 0u; i < _histObsList.size(); ++i) {
187  const auto harg = _histObsList[i];
188  const auto parg = _depList[i];
189 
190  if (harg != parg) {
191  parg->syncCache() ;
192  harg->copyCache(parg,kTRUE) ;
193  if (!harg->inRange(0)) {
194  return 0 ;
195  }
196  }
197  }
198  }
199 
201  return ret ;
202 }
203 
204 
205 ////////////////////////////////////////////////////////////////////////////////
206 /// Compute value of the HistFunc for every entry in `evalData`.
207 /// \param[in/out] evalData Struct with input data. The computation results will be stored here.
208 /// \param[in] normSet Set of observables to normalise over (ignored).
210  std::vector<RooSpan<const double>> inputValues;
211  std::size_t batchSize = 0;
212  for (const auto& obs : _depList) {
213  auto realObs = dynamic_cast<const RooAbsReal*>(obs);
214  if (realObs) {
215  auto inputs = realObs->getValues(evalData, nullptr);
216  batchSize = std::max(batchSize, inputs.size());
217  inputValues.push_back(std::move(inputs));
218  } else {
219  inputValues.emplace_back();
220  }
221  }
222 
223  auto results = evalData.makeBatch(this, batchSize);
224 
225  for (std::size_t i = 0; i < batchSize; ++i) {
226  bool skip = false;
227 
228  for (auto j = 0u; j < _histObsList.size(); ++j) {
229  const auto histObs = _histObsList[j];
230 
231  if (i < inputValues[j].size()) {
232  histObs->setCachedValue(inputValues[j][i], false);
233  if (!histObs->inRange(nullptr)) {
234  skip = true;
235  break;
236  }
237  }
238  }
239 
240  results[i] = skip ? 0. : _dataHist->weightFast(_histObsList, _intOrder, false, _cdfBoundaries);
241  }
242 
243  return results;
244 }
245 
246 
247 ////////////////////////////////////////////////////////////////////////////////
248 /// Only handle case of maximum in all variables
249 
251 {
252  RooAbsCollection* common = _depList.selectCommon(vars) ;
253  if (common->getSize()==_depList.getSize()) {
254  delete common ;
255  return 1;
256  }
257  delete common ;
258  return 0 ;
259 }
260 
261 ////////////////////////////////////////////////////////////////////////////////
262 
264 {
265  R__ASSERT(code==1) ;
266 
267  Double_t max(-1) ;
268  for (Int_t i=0 ; i<_dataHist->numEntries() ; i++) {
269  _dataHist->get(i) ;
270  Double_t wgt = _dataHist->weight() ;
271  if (wgt>max) max=wgt ;
272  }
273 
274  return max*1.05 ;
275 }
276 
277 ////////////////////////////////////////////////////////////////////////////////
278 /// Return the total volume spanned by the observables of the RooDataHist
279 
281 {
282  // Return previously calculated value, if any
283  if (_totVolume>0) {
284  return _totVolume ;
285  }
286  _totVolume = 1. ;
287  for (const auto arg : _depList) {
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 
302 
303 ////////////////////////////////////////////////////////////////////////////////
304 /// Determine integration scenario. If no interpolation is used,
305 /// RooHistFunc can perform all integrals over its dependents
306 /// analytically via partial or complete summation of the input
307 /// histogram. If interpolation is used, only the integral
308 /// over all RooHistPdf observables is implemented.
309 
310 Int_t RooHistFunc::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName) const
311 {
312  return RooHistPdf::getAnalyticalIntegral(allVars, analVars, rangeName, _histObsList, _depList, _intOrder);
313 }
314 
315 
316 ////////////////////////////////////////////////////////////////////////////////
317 /// Return integral identified by 'code'. The actual integration
318 /// is deferred to RooDataHist::sum() which implements partial
319 /// or complete summation over the histograms contents
320 
321 Double_t RooHistFunc::analyticalIntegral(Int_t code, const char* rangeName) const
322 {
323  return RooHistPdf::analyticalIntegral(code, rangeName, _histObsList, _depList, *_dataHist, true);
324 }
325 
326 
327 ////////////////////////////////////////////////////////////////////////////////
328 /// Return sampling hint for making curves of (projections) of this function
329 /// as the recursive division strategy of RooCurve cannot deal efficiently
330 /// with the vertical lines that occur in a non-interpolated histogram
331 
333 {
334  // No hints are required when interpolation is used
335  if (_intOrder>1) {
336  return 0 ;
337  }
338 
339 
340  // Find histogram observable corresponding to pdf observable
341  RooAbsArg* hobs(0) ;
342  for (auto i = 0u; i < _histObsList.size(); ++i) {
343  const auto harg = _histObsList[i];
344  const auto parg = _depList[i];
345  if (string(parg->GetName())==obs.GetName()) {
346  hobs=harg ;
347  }
348  }
349  if (!hobs) {
350  return 0 ;
351  }
352 
353  // Check that observable is in dataset, if not no hint is generated
354  RooAbsLValue* lvarg = dynamic_cast<RooAbsLValue*>(_dataHist->get()->find(hobs->GetName())) ;
355  if (!lvarg) {
356  return 0 ;
357  }
358 
359  // Retrieve position of all bin boundaries
360  const RooAbsBinning* binning = lvarg->getBinningPtr(0) ;
361  Double_t* boundaries = binning->array() ;
362 
363  list<Double_t>* hint = new list<Double_t> ;
364 
365  // Widen range slighty
366  xlo = xlo - 0.01*(xhi-xlo) ;
367  xhi = xhi + 0.01*(xhi-xlo) ;
368 
369  Double_t delta = (xhi-xlo)*1e-8 ;
370 
371  // Construct array with pairs of points positioned epsilon to the left and
372  // right of the bin boundaries
373  for (Int_t i=0 ; i<binning->numBoundaries() ; i++) {
374  if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
375  hint->push_back(boundaries[i]-delta) ;
376  hint->push_back(boundaries[i]+delta) ;
377  }
378  }
379 
380  return hint ;
381 }
382 
383 
384 ////////////////////////////////////////////////////////////////////////////////
385 /// Return sampling hint for making curves of (projections) of this function
386 /// as the recursive division strategy of RooCurve cannot deal efficiently
387 /// with the vertical lines that occur in a non-interpolated histogram
388 
389 std::list<Double_t>* RooHistFunc::binBoundaries(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const
390 {
391  // No hints are required when interpolation is used
392  if (_intOrder>1) {
393  return 0 ;
394  }
395 
396  // Find histogram observable corresponding to pdf observable
397  RooAbsArg* hobs(0) ;
398  for (auto i = 0u; i < _histObsList.size(); ++i) {
399  const auto harg = _histObsList[i];
400  const auto parg = _depList[i];
401  if (string(parg->GetName())==obs.GetName()) {
402  hobs=harg ;
403  }
404  }
405 
406  // cout << "RooHistFunc::bb(" << GetName() << ") histObs = " << _histObsList << endl ;
407  // cout << "RooHistFunc::bb(" << GetName() << ") pdfObs = " << _depList << endl ;
408 
409  RooAbsRealLValue* transform(0) ;
410  if (!hobs) {
411 
412  // Considering alternate: input observable is histogram observable and pdf observable is transformation in terms of it
413  RooAbsArg* pobs(0) ;
414  for (auto i = 0u; i < _histObsList.size(); ++i) {
415  const auto harg = _histObsList[i];
416  const auto parg = _depList[i];
417  if (string(harg->GetName())==obs.GetName()) {
418  pobs=parg ;
419  hobs=harg ;
420  }
421  }
422 
423  // Not found, or check that matching pdf observable is an l-value dependent on histogram observable fails
424  if (!hobs || !(pobs->dependsOn(obs) && dynamic_cast<RooAbsRealLValue*>(pobs))) {
425  cout << "RooHistFunc::binBoundaries(" << GetName() << ") obs = " << obs.GetName() << " hobs is not found, returning null" << endl ;
426  return 0 ;
427  }
428 
429  // Now we are in business - we are in a situation where the pdf observable LV(x), mapping to a histogram observable x
430  // We can return bin boundaries by mapping the histogram boundaties through the inverse of the LV(x) transformation
431  transform = dynamic_cast<RooAbsRealLValue*>(pobs) ;
432  }
433 
434 
435  // cout << "hobs = " << hobs->GetName() << endl ;
436  // cout << "transform = " << (transform?transform->GetName():"<none>") << endl ;
437 
438  // Check that observable is in dataset, if not no hint is generated
439  RooAbsArg* xtmp = _dataHist->get()->find(hobs->GetName()) ;
440  if (!xtmp) {
441  cout << "RooHistFunc::binBoundaries(" << GetName() << ") hobs = " << hobs->GetName() << " is not found in dataset?" << endl ;
442  _dataHist->get()->Print("v") ;
443  return 0 ;
444  }
445  RooAbsLValue* lvarg = dynamic_cast<RooAbsLValue*>(_dataHist->get()->find(hobs->GetName())) ;
446  if (!lvarg) {
447  cout << "RooHistFunc::binBoundaries(" << GetName() << ") hobs = " << hobs->GetName() << " but is not an LV, returning null" << endl ;
448  return 0 ;
449  }
450 
451  // Retrieve position of all bin boundaries
452  const RooAbsBinning* binning = lvarg->getBinningPtr(0) ;
453  Double_t* boundaries = binning->array() ;
454 
455  list<Double_t>* hint = new list<Double_t> ;
456 
457  Double_t delta = (xhi-xlo)*1e-8 ;
458 
459  // Construct array with pairs of points positioned epsilon to the left and
460  // right of the bin boundaries
461  for (Int_t i=0 ; i<binning->numBoundaries() ; i++) {
462  if (boundaries[i]>xlo-delta && boundaries[i]<xhi+delta) {
463 
464  Double_t boundary = boundaries[i] ;
465  if (transform) {
466  transform->setVal(boundary) ;
467  //cout << "transform bound " << boundary << " using " << transform->GetName() << " result " << obs.getVal() << endl ;
468  hint->push_back(obs.getVal()) ;
469  } else {
470  hint->push_back(boundary) ;
471  }
472  }
473  }
474 
475  return hint ;
476 }
477 
478 
479 
480 ////////////////////////////////////////////////////////////////////////////////
481 /// Check if our datahist is already in the workspace.
482 /// In case of error, return true.
484 {
485  // Check if dataset with given name already exists
486  RooAbsData* wsdata = ws.embeddedData(_dataHist->GetName()) ;
487 
488  if (wsdata) {
489  // If our data is exactly the same, we are done:
490  if (static_cast<RooDataHist*>(wsdata) == _dataHist)
491  return false;
492 
493  // Yes it exists - now check if it is identical to our internal histogram
494  if (wsdata->InheritsFrom(RooDataHist::Class())) {
495 
496  // Check if histograms are identical
497  if (areIdentical((RooDataHist&)*wsdata,*_dataHist)) {
498 
499  // Exists and is of correct type, and identical -- adjust internal pointer to WS copy
500  _dataHist = (RooDataHist*) wsdata ;
501  } else {
502 
503  // not identical, clone rename and import
504  TString uniqueName = Form("%s_%s",_dataHist->GetName(),GetName()) ;
505  Bool_t flag = ws.import(*_dataHist,RooFit::Rename(uniqueName.Data()),RooFit::Embedded()) ;
506  if (flag) {
507  coutE(ObjectHandling) << " RooHistPdf::importWorkspaceHook(" << GetName() << ") unable to import clone of underlying RooDataHist with unique name " << uniqueName << ", abort" << endl ;
508  return kTRUE ;
509  }
510  _dataHist = (RooDataHist*) ws.embeddedData(uniqueName.Data()) ;
511  }
512 
513  } else {
514 
515  // Exists and is NOT of correct type: clone rename and import
516  TString uniqueName = Form("%s_%s",_dataHist->GetName(),GetName()) ;
517  Bool_t flag = ws.import(*_dataHist,RooFit::Rename(uniqueName.Data()),RooFit::Embedded()) ;
518  if (flag) {
519  coutE(ObjectHandling) << " RooHistPdf::importWorkspaceHook(" << GetName() << ") unable to import clone of underlying RooDataHist with unique name " << uniqueName << ", abort" << endl ;
520  return kTRUE ;
521  }
522  _dataHist = (RooDataHist*) ws.embeddedData(uniqueName.Data()) ;
523 
524  }
525  return kFALSE ;
526  }
527 
528  // We need to import our datahist into the workspace
529  ws.import(*_dataHist,RooFit::Embedded()) ;
530 
531  // Redirect our internal pointer to the copy in the workspace
532  _dataHist = (RooDataHist*) ws.embeddedData(_dataHist->GetName()) ;
533  return kFALSE ;
534 }
535 
536 
537 ////////////////////////////////////////////////////////////////////////////////
538 
540 {
541  if (fabs(dh1.sumEntries()-dh2.sumEntries())>1e-8) return kFALSE ;
542  if (dh1.numEntries() != dh2.numEntries()) return kFALSE ;
543  for (int i=0 ; i < dh1.numEntries() ; i++) {
544  dh1.get(i) ;
545  dh2.get(i) ;
546  if (fabs(dh1.weight()-dh2.weight())>1e-8) return kFALSE ;
547  }
549  if (getColonSeparatedNameString(*dh1.get()) != getColonSeparatedNameString(*dh2.get())) return kFALSE ;
550  return kTRUE ;
551 }
552 
553 
554 
555 ////////////////////////////////////////////////////////////////////////////////
556 /// Stream an object of class RooHistFunc.
557 
558 void RooHistFunc::Streamer(TBuffer &R__b)
559 {
560  if (R__b.IsReading()) {
561  R__b.ReadClassBuffer(RooHistFunc::Class(),this);
562  // WVE - interim solution - fix proxies here
563  _proxyList.Clear() ;
565  } else {
567  }
568 }
569 
570 
571 ////////////////////////////////////////////////////////////////////////////////
572 /// Schema evolution: if histObsList wasn't filled from persistence (v1)
573 /// then fill it here. Can't be done in regular schema evolution in LinkDef
574 /// as _depList content is not guaranteed to be initialized there
575 
577 {
578  if (_histObsList.getSize()==0) {
580  }
581 }
582 
583 
584 ////////////////////////////////////////////////////////////////////////////////
585 /// Compute bin number corresponding to current coordinates.
586 /// \return If a bin is not in the current range of the observables, return -1.
588  if (!_depList.empty()) {
589  for (auto i = 0u; i < _histObsList.size(); ++i) {
590  const auto harg = _histObsList[i];
591  const auto parg = _depList[i];
592 
593  if (harg != parg) {
594  parg->syncCache() ;
595  harg->copyCache(parg,kTRUE) ;
596  if (!harg->inRange(nullptr)) {
597  return -1;
598  }
599  }
600  }
601  }
602 
603  return _dataHist->getIndex(_histObsList, true);
604 }
605 
606 
607 ////////////////////////////////////////////////////////////////////////////////
608 /// Compute bin numbers corresponding to all coordinates in `evalData`.
609 /// \return Vector of bin numbers. If a bin is not in the current range of the observables, return -1.
610 std::vector<Int_t> RooHistFunc::getBins(RooBatchCompute::RunContext& evalData) const {
611  std::vector<RooSpan<const double>> depData;
612  for (const auto dep : _depList) {
613  auto real = dynamic_cast<const RooAbsReal*>(dep);
614  if (real) {
615  depData.push_back(real->getValues(evalData, nullptr));
616  } else {
617  depData.emplace_back(nullptr, 0);
618  }
619  }
620 
621  const auto batchSize = std::max_element(depData.begin(), depData.end(),
622  [](const RooSpan<const double>& a, const RooSpan<const double>& b){ return a.size() < b.size(); })->size();
623  std::vector<Int_t> results;
624 
625  for (std::size_t evt = 0; evt < batchSize; ++evt) {
626  if (!_depList.empty()) {
627  for (auto i = 0u; i < _histObsList.size(); ++i) {
628  const auto harg = _histObsList[i];
629 
630  if (evt < depData[i].size())
631  harg->setCachedValue(depData[i][evt], false);
632 
633  if (!harg->inRange(nullptr)) {
634  results.push_back(-1);
635  continue;
636  }
637  }
638  }
639 
640  results.push_back(_dataHist->getIndex(_histObsList, true));
641  }
642 
643  return results;
644 }
RooHistFunc::_totVolume
Double_t _totVolume
Definition: RooHistFunc.h:108
RooHistPdf::analyticalIntegral
static Double_t analyticalIntegral(Int_t code, const char *rangeName, RooArgSet const &histObsList, RooSetProxy const &pdfObsList, RooDataHist &dataHist, bool histFuncMode)
Definition: RooHistPdf.cxx:312
RooHistFunc::areIdentical
Bool_t areIdentical(const RooDataHist &dh1, const RooDataHist &dh2)
Definition: RooHistFunc.cxx:539
RooWorkspace.h
RooHistFunc::getBin
Int_t getBin() const
Compute bin number corresponding to current coordinates.
Definition: RooHistFunc.cxx:587
RooHelpers.h
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
e
#define e(i)
Definition: RSha256.hxx:103
RooBatchCompute::RunContext::makeBatch
RooSpan< double > makeBatch(const RooAbsReal *owner, std::size_t size)
Create a writable batch.
Definition: RunContext.cxx:87
RooMsgService.h
RooAbsData
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:49
RooDataHist::weight
double weight(std::size_t i) const
Return weight of i-th bin.
Definition: RooDataHist.h:102
RooAbsRealLValue::getMax
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
Definition: RooAbsRealLValue.h:89
RooHistFunc.h
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:61
TString::Data
const char * Data() const
Definition: TString.h:369
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
TBuffer::ReadClassBuffer
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooHistFunc::_intOrder
Int_t _intOrder
Auxiliary class keeping tracking of analytical integration code.
Definition: RooHistFunc.h:106
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooDataHist::sumEntries
Double_t sumEntries() const override
Sum the weights of all bins.
Definition: RooDataHist.cxx:1808
RooAbsLValue::getBinningPtr
virtual const RooAbsBinning * getBinningPtr(const char *rangeName) const =0
RooAbsCollection::find
RooAbsArg * find(const char *name) const
Find object with given name in list.
Definition: RooAbsCollection.cxx:810
RooAbsCollection::empty
bool empty() const
Definition: RooAbsCollection.h:218
RooHistFunc::getAnalyticalIntegral
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Determine integration scenario.
Definition: RooHistFunc.cxx:310
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
RooHistFunc::_dataHist
RooDataHist * _dataHist
Definition: RooHistFunc.h:104
TString
Basic string class.
Definition: TString.h:136
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
b
#define b(i)
Definition: RSha256.hxx:100
RooAbsCategory::numTypes
Int_t numTypes(const char *=0) const
Return number of types defined (in range named rangeName if rangeName!=0)
Definition: RooAbsCategory.h:128
bool
RooHistFunc::_histObsList
RooArgSet _histObsList
Definition: RooHistFunc.h:102
RooAbsRealLValue::getMin
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
Definition: RooAbsRealLValue.h:86
RooAbsArg::registerProxy
void registerProxy(RooArgProxy &proxy)
Register an RooArgProxy in the proxy list.
Definition: RooAbsArg.cxx:1205
RooAbsBinning::array
virtual Double_t * array() const =0
RooHistFunc::getBins
std::vector< Int_t > getBins(RooBatchCompute::RunContext &evalData) const
Compute bin numbers corresponding to all coordinates in evalData.
Definition: RooHistFunc.cxx:610
RooHistFunc::evaluateSpan
RooSpan< double > evaluateSpan(RooBatchCompute::RunContext &evalData, const RooArgSet *) const
Compute value of the HistFunc for every entry in evalData.
Definition: RooHistFunc.cxx:209
RooHelpers::getColonSeparatedNameString
std::string getColonSeparatedNameString(RooArgSet const &argSet)
Create a string with all sorted names of RooArgSet elements separated by colons.
Definition: RooHelpers.cxx:271
ROOT::Math::fabs
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Definition: UnaryOperators.h:131
RooFit::Rename
RooCmdArg Rename(const char *suffix)
Definition: RooGlobalFunc.cxx:351
RooDataHist
The RooDataHist is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:37
ws
void ws()
Definition: ws.C:66
RooDataHist::get
const RooArgSet * get() const override
Get bin centre of current bin.
Definition: RooDataHist.h:74
TBuffer.h
TRACE_DESTROY
#define TRACE_DESTROY
Definition: RooTrace.h:24
RooDataHist::weightFast
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...
Definition: RooDataHist.cxx:1083
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
a
auto * a
Definition: textangle.C:12
RooAbsCollection::addClone
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
Definition: RooAbsCollection.cxx:428
TBuffer::WriteClassBuffer
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
RooDataHist.h
RooHistPdf::getAnalyticalIntegral
static Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName, RooArgSet const &histObsList, RooSetProxy const &pdfObsList, Int_t intOrder)
Definition: RooHistPdf.cxx:271
RooAbsBinning
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
Definition: RooAbsBinning.h:26
RooHistFunc::_cdfBoundaries
Bool_t _cdfBoundaries
Definition: RooHistFunc.h:107
RooDataHist::getIndex
Int_t getIndex(const RooAbsCollection &coord, Bool_t fast=false) const
Calculate bin number of the given coordinates.
Definition: RooDataHist.cxx:964
RooHistFunc::RooHistFunc
RooHistFunc()
Default constructor.
Definition: RooHistFunc.cxx:52
RooAbsCollection
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
Definition: RooAbsCollection.h:33
TRACE_CREATE
#define TRACE_CREATE
Definition: RooTrace.h:23
RooFit::Embedded
RooCmdArg Embedded(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:352
RooAbsCollection::size
Storage_t::size_type size() const
Definition: RooAbsCollection.h:214
RooHistFunc::maxVal
virtual Double_t maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
Definition: RooHistFunc.cxx:263
RooCategory.h
RooHistFunc::getMaxVal
virtual Int_t getMaxVal(const RooArgSet &vars) const
Only handle case of maximum in all variables.
Definition: RooHistFunc.cxx:250
RooFit::ObjectHandling
@ ObjectHandling
Definition: RooGlobalFunc.h:61
RooRealVar.h
RooHistFunc::_depList
RooSetProxy _depList
Definition: RooHistFunc.h:103
RooHistFunc
RooHistFunc implements a real-valued function sampled from a multidimensional histogram.
Definition: RooHistFunc.h:30
RooHistFunc::totVolume
Double_t totVolume() const
Get total bin volume spanned by this hist function.
Definition: RooHistFunc.cxx:280
RooAbsCollection::selectCommon
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...
Definition: RooAbsCollection.cxx:702
RooHistFunc::plotSamplingHint
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Return sampling hint for making curves of (projections) of this function as the recursive division st...
Definition: RooHistFunc.cxx:332
RooHistFunc::~RooHistFunc
virtual ~RooHistFunc()
Definition: RooHistFunc.cxx:169
RooHistPdf.h
TObjArray::Clear
virtual void Clear(Option_t *option="")
Remove all objects from the array.
Definition: TObjArray.cxx:321
TBuffer::IsReading
Bool_t IsReading() const
Definition: TBuffer.h:86
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooDataHist::numEntries
Int_t numEntries() const override
Return the number of bins.
Definition: RooDataHist.cxx:1799
RooHistFunc::binBoundaries
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Return sampling hint for making curves of (projections) of this function as the recursive division st...
Definition: RooHistFunc.cxx:389
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsArg::_proxyList
RooRefArray _proxyList
Definition: RooAbsArg.h:612
R__ASSERT
#define R__ASSERT(e)
Definition: TError.h:118
RooCategory
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:27
RooAbsBinning::numBoundaries
virtual Int_t numBoundaries() const =0
name
char name[80]
Definition: TGX11.cxx:110
RooAbsArg::dependsOn
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
Definition: RooAbsArg.cxx:799
RooHistFunc::evaluate
Double_t evaluate() const
Return the current value: The value of the bin enclosing the current coordinates of the dependents,...
Definition: RooHistFunc.cxx:182
RooHistFunc::importWorkspaceHook
Bool_t importWorkspaceHook(RooWorkspace &ws)
Check if our datahist is already in the workspace.
Definition: RooHistFunc.cxx:483
RunContext.h
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooAbsReal::getValues
virtual RooSpan< const double > getValues(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet=nullptr) const
by this change, please consult the release notes for ROOT 6.24 for guidance on how to make this trans...
Definition: RooAbsReal.cxx:312
RooAbsCollection::Print
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
Definition: RooAbsCollection.h:259
RooAbsLValue
Abstract base class for objects that are lvalues, i.e.
Definition: RooAbsLValue.h:26
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Class
void Class()
Definition: Class.C:29
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
RooAbsRealLValue::setVal
virtual void setVal(Double_t value)=0
Set the current value of the object. Needs to be overridden by implementations.
RooHistFunc::ioStreamerPass2
virtual void ioStreamerPass2()
Schema evolution: if histObsList wasn't filled from persistence (v1) then fill it here.
Definition: RooHistFunc.cxx:576
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooBatchCompute::RunContext
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31
RooHistFunc::analyticalIntegral
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Return integral identified by 'code'.
Definition: RooHistFunc.cxx:321
RooAbsCollection::getSize
Int_t getSize() const
Definition: RooAbsCollection.h:231
RooSpan
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
RooSetProxy::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
Definition: RooSetProxy.cxx:165
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
int
TError.h