Logo ROOT  
Reference Guide
ParamHistFunc.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id: cranmer $
2// Author: Kyle Cranmer, George Lewis
3/*************************************************************************
4 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11////////////////////////////////////////////////////////////////////////////////
12
13/** \class ParamHistFunc
14 * \ingroup HistFactory
15 * A class which maps the current values of a RooRealVar
16 * (or a set of RooRealVars) to one of a number of RooRealVars:
17 *
18 * `ParamHistFunc: {val1, val2, ...} -> {gamma (RooRealVar)}`
19 *
20 * The intended interpretation is that each parameter in the
21 * range represent the height of a bin over the domain
22 * space.
23 *
24 * The 'createParamSet' is an easy way to create these
25 * parameters from a set of observables. They are
26 * stored using the "TH1" ordering convention (as compared
27 * to the RooDataHist convention, which is used internally
28 * and one must map between the two).
29 *
30 * All indices include '0':<br>
31 * \f$ \gamma_{i,j} \f$ = `paramSet[ size(i)*j + i ]`
32 *
33 * ie assuming the dimensions are 5*5:<br>
34 * \f$ \gamma_{2,1} \f$ = `paramSet[ 5*1 + 2 ] = paramSet[7]`
35 */
36
37
39
40#include "RooConstVar.h"
41#include "RooBinning.h"
42#include "RooErrorHandler.h"
43#include "RooArgSet.h"
44#include "RooMsgService.h"
45#include "RooRealVar.h"
46#include "RooArgList.h"
47#include "RooWorkspace.h"
48#include "RunContext.h"
49
50#include "TH1.h"
51
52#include <sstream>
53#include <stdexcept>
54#include <iostream>
55
57
58
59////////////////////////////////////////////////////////////////////////////////
60
62 : _normIntMgr(this), _numBins(0)
63{
64 _dataSet.removeSelfFromDir(); // files must not delete _dataSet.
65}
66
67
68////////////////////////////////////////////////////////////////////////////////
69/// Create a function which returns binewise-values
70/// This class contains N RooRealVar's, one for each
71/// bin from the given RooRealVar.
72///
73/// The value of the function in the ith bin is
74/// given by:
75///
76/// F(i) = gamma_i * nominal(i)
77///
78/// Where the nominal values are simply fixed
79/// numbers (default = 1.0 for all i)
80ParamHistFunc::ParamHistFunc(const char* name, const char* title,
81 const RooArgList& vars, const RooArgList& paramSet) :
82 RooAbsReal(name, title),
83 _normIntMgr(this),
84 _dataVars("!dataVars","data Vars", this),
85 _paramSet("!paramSet","bin parameters", this),
86 _numBins(0),
87 _dataSet( (std::string(name)+"_dataSet").c_str(), "", vars)
88{
89
90 // Create the dataset that stores the binning info:
91
92 // _dataSet = RooDataSet("
93
94 _dataSet.removeSelfFromDir(); // files must not delete _dataSet.
95
96 // Set the binning
97 // //_binning = var.getBinning().clone() ;
98
99 // Create the set of parameters
100 // controlling the height of each bin
101
102 // Get the number of bins
103 _numBins = GetNumBins( vars );
104
105 // Add the parameters (with checking)
106 addVarSet( vars );
107 addParamSet( paramSet );
108}
109
110
111////////////////////////////////////////////////////////////////////////////////
112/// Create a function which returns bin-wise values.
113/// This class allows to multiply bin contents of histograms
114/// with the values of a set of RooRealVars.
115///
116/// The value of the function in the ith bin is
117/// given by:
118/// \f[
119/// F(i) = \gamma_{i} * \mathrm{nominal}(i)
120/// \f]
121///
122/// Where the nominal values are taken from the histogram,
123/// and the \f$ \gamma_{i} \f$ can be set from the outside.
124ParamHistFunc::ParamHistFunc(const char* name, const char* title,
125 const RooArgList& vars, const RooArgList& paramSet,
126 const TH1* Hist ) :
127 RooAbsReal(name, title),
128 _normIntMgr(this),
129 // _dataVar("!dataVar","data Var", this, (RooRealVar&) var),
130 _dataVars("!dataVars","data Vars", this),
131 _paramSet("!paramSet","bin parameters", this),
132 _numBins(0),
133 _dataSet( (std::string(name)+"_dataSet").c_str(), "", vars, Hist)
134{
135
136 _dataSet.removeSelfFromDir(); // files must not delete _dataSet.
137
138 // Get the number of bins
139 _numBins = GetNumBins( vars );
140
141 // Add the parameters (with checking)
142 addVarSet( vars );
143 addParamSet( paramSet );
144}
145
146
148
149 // A helper method to get the number of bins
150
151 if( vars.getSize() == 0 ) return 0;
152
153 Int_t numBins = 1;
154
155 for (auto comp : vars) {
156 if (!dynamic_cast<RooRealVar*>(comp)) {
157 auto errorMsg = std::string("ParamHistFunc::GetNumBins") + vars.GetName() + ") ERROR: component "
158 + comp->GetName() + " in vars list is not of type RooRealVar";
159 oocoutE(static_cast<TObject*>(nullptr), InputArguments) << errorMsg << std::endl;
160 throw std::runtime_error(errorMsg);
161 }
162 auto var = static_cast<RooRealVar*>(comp);
163
164 Int_t varNumBins = var->numBins();
165 numBins *= varNumBins;
166 }
167
168 return numBins;
169}
170
171
172////////////////////////////////////////////////////////////////////////////////
173
175 RooAbsReal(other, name),
176 _normIntMgr(other._normIntMgr, this),
177 _dataVars("!dataVars", this, other._dataVars ),
178 _paramSet("!paramSet", this, other._paramSet),
179 _numBins( other._numBins ),
180 _dataSet( other._dataSet )
181{
182 _dataSet.removeSelfFromDir(); // files must not delete _dataSet.
183
184 // Copy constructor
185 // Member _ownedList is intentionally not copy-constructed -- ownership is not transferred
186}
187
188
189////////////////////////////////////////////////////////////////////////////////
190
192{
193 ;
194}
195
196
197////////////////////////////////////////////////////////////////////////////////
198/// Get the parameter associated with the index.
199/// The index follows RooDataHist indexing conventions.
200/// It uses the binMap to convert the RooDataSet style index
201/// into the TH1 style index (which is how they are stored
202/// internally in the '_paramSet' vector).
204
205 auto const& n = _numBinsPerDim;
206
207 // check if _numBins needs to be filled
208 if(n.x == 0) {
210 }
211
212 int i = index / n.yz ;
213 int j = (index % n.y) / n.z;
214 int k = index % (n.yz);
215
216 return static_cast<RooRealVar&>(_paramSet[i + j * n.x + k * n.xy]);
217}
218
219
220////////////////////////////////////////////////////////////////////////////////
221
223 Int_t index = getCurrentBin();
224 return getParameter( index );
225}
226
227
229 RooRealVar& var = getParameter( index );
230 var.setConstant( varConst );
231}
232
233
234void ParamHistFunc::setConstant( bool constant ) {
235 for( int i=0; i < numBins(); ++i) {
236 setParamConst(i, constant);
237 }
238}
239
240
241////////////////////////////////////////////////////////////////////////////////
242
244 int num_hist_bins = shape->GetNbinsX()*shape->GetNbinsY()*shape->GetNbinsZ();
245
246 if( num_hist_bins != numBins() ) {
247 std::cout << "Error - ParamHistFunc: cannot set Shape of ParamHistFunc: " << GetName()
248 << " using histogram: " << shape->GetName()
249 << ". Bins don't match" << std::endl;
250 throw std::runtime_error("setShape");
251 }
252
253
254 Int_t TH1BinNumber = 0;
255 for( Int_t i = 0; i < numBins(); ++i) {
256
257 TH1BinNumber++;
258
259 while( shape->IsBinUnderflow(TH1BinNumber) || shape->IsBinOverflow(TH1BinNumber) ){
260 TH1BinNumber++;
261 }
262
263 static_cast<RooRealVar&>(_paramSet[i]).setVal( shape->GetBinContent(TH1BinNumber) );
264 }
265
266}
267
268
269////////////////////////////////////////////////////////////////////////////////
270/// Create the list of RooRealVar
271/// parameters which represent the
272/// height of the histogram bins.
273/// The list 'vars' represents the
274/// observables (corresponding to histogram bins)
275/// that these newly created parameters will
276/// be mapped to. (ie, we create one parameter
277/// per observable in vars and per bin in each observable)
278
279/// Store them in a list using:
280/// _paramSet.add( createParamSet() );
281/// This list is stored in the "TH1" index order
283 const RooArgList& vars) {
284
285
286 // Get the number of bins
287 // in the nominal histogram
288
289 RooArgList paramSet;
290
291 Int_t numVars = vars.getSize();
292 Int_t numBins = GetNumBins( vars );
293
294 if( numVars == 0 ) {
295 std::cout << "Warning - ParamHistFunc::createParamSet() :"
296 << " No Variables provided. Not making constraint terms."
297 << std::endl;
298 return paramSet;
299 }
300
301 else if( numVars == 1 ) {
302
303 // For each bin, create a RooRealVar
304 for( Int_t i = 0; i < numBins; ++i) {
305
306 std::stringstream VarNameStream;
307 VarNameStream << Prefix << "_bin_" << i;
308 std::string VarName = VarNameStream.str();
309
310 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
311 // "Hard-Code" a minimum of 0.0
312 gamma.setMin( 0.0 );
313 gamma.setConstant( false );
314
316 RooRealVar* gamma_wspace = (RooRealVar*) w.var( VarName.c_str() );
317
318 paramSet.add( *gamma_wspace );
319
320 }
321 }
322
323 else if( numVars == 2 ) {
324
325 // Create a vector of indices
326 // all starting at 0
327 std::vector< Int_t > Indices(numVars, 0);
328
329 RooRealVar* varx = (RooRealVar*) vars.at(0);
330 RooRealVar* vary = (RooRealVar*) vars.at(1);
331
332 // For each bin, create a RooRealVar
333 for( Int_t j = 0; j < vary->numBins(); ++j) {
334 for( Int_t i = 0; i < varx->numBins(); ++i) {
335
336 // Ordering is important:
337 // To match TH1, list goes over x bins
338 // first, then y
339
340 std::stringstream VarNameStream;
341 VarNameStream << Prefix << "_bin_" << i << "_" << j;
342 std::string VarName = VarNameStream.str();
343
344 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
345 // "Hard-Code" a minimum of 0.0
346 gamma.setMin( 0.0 );
347 gamma.setConstant( false );
348
350 RooRealVar* gamma_wspace = (RooRealVar*) w.var( VarName.c_str() );
351
352 paramSet.add( *gamma_wspace );
353
354 }
355 }
356 }
357
358 else if( numVars == 3 ) {
359
360 // Create a vector of indices
361 // all starting at 0
362 std::vector< Int_t > Indices(numVars, 0);
363
364 RooRealVar* varx = (RooRealVar*) vars.at(0);
365 RooRealVar* vary = (RooRealVar*) vars.at(1);
366 RooRealVar* varz = (RooRealVar*) vars.at(2);
367
368 // For each bin, create a RooRealVar
369 for( Int_t k = 0; k < varz->numBins(); ++k) {
370 for( Int_t j = 0; j < vary->numBins(); ++j) {
371 for( Int_t i = 0; i < varx->numBins(); ++i) {
372
373 // Ordering is important:
374 // To match TH1, list goes over x bins
375 // first, then y, then z
376
377 std::stringstream VarNameStream;
378 VarNameStream << Prefix << "_bin_" << i << "_" << j << "_" << k;
379 std::string VarName = VarNameStream.str();
380
381 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
382 // "Hard-Code" a minimum of 0.0
383 gamma.setMin( 0.0 );
384 gamma.setConstant( false );
385
387 RooRealVar* gamma_wspace = (RooRealVar*) w.var( VarName.c_str() );
388
389 paramSet.add( *gamma_wspace );
390
391 }
392 }
393 }
394 }
395
396 else {
397 std::cout << " Error: ParamHistFunc doesn't support dimensions > 3D " << std::endl;
398 }
399
400 return paramSet;
401
402}
403
404
405////////////////////////////////////////////////////////////////////////////////
406/// Create the list of RooRealVar parameters which scale the
407/// height of histogram bins.
408/// The list `vars` represents the observables (corresponding to histogram bins)
409/// that these newly created parameters will
410/// be mapped to. *I.e.*, we create one parameter
411/// per observable in `vars` and per bin in each observable.
412///
413/// The new parameters are initialised to 1 with an uncertainty of +/- 1.,
414/// their range is set to the function arguments.
415///
416/// Store the parameters in a list using:
417/// ```
418/// _paramSet.add( createParamSet() );
419/// ```
420/// This list is stored in the "TH1" index order.
422 const RooArgList& vars,
423 Double_t gamma_min, Double_t gamma_max) {
424
425
426
428
429 for (auto comp : params) {
430 auto var = static_cast<RooRealVar*>(comp);
431
432 var->setMin( gamma_min );
433 var->setMax( gamma_max );
434 }
435
436 return params;
437
438}
439
440
441////////////////////////////////////////////////////////////////////////////////
442/// Create the list of RooRealVar
443/// parameters which represent the
444/// height of the histogram bins.
445/// Store them in a list
447 Double_t gamma_min, Double_t gamma_max) {
448
449 // Get the number of bins
450 // in the nominal histogram
451
452 RooArgList paramSet;
453
454 if( gamma_max <= gamma_min ) {
455
456 std::cout << "Warning: gamma_min <= gamma_max: Using default values (0, 10)" << std::endl;
457
458 gamma_min = 0.0;
459 gamma_max = 10.0;
460
461 }
462
463 Double_t gamma_nominal = 1.0;
464
465 if( gamma_nominal < gamma_min ) {
466 gamma_nominal = gamma_min;
467 }
468
469 if( gamma_nominal > gamma_max ) {
470 gamma_nominal = gamma_max;
471 }
472
473 // For each bin, create a RooRealVar
474 for( Int_t i = 0; i < numBins; ++i) {
475
476 std::stringstream VarNameStream;
477 VarNameStream << Prefix << "_bin_" << i;
478 std::string VarName = VarNameStream.str();
479
480 RooRealVar* gamma = new RooRealVar( VarName.c_str(), VarName.c_str(),
481 gamma_nominal, gamma_min, gamma_max );
482 gamma->setConstant( false );
483 paramSet.add( *gamma );
484
485 }
486
487 return paramSet;
488
489}
490
491
493 int numVars = vars.size();
494
495 if (numVars > 3 || numVars < 1) {
496 std::cout << "ParamHistFunc() - Only works for 1-3 variables (1d-3d)" << std::endl;
497 throw -1;
498 }
499
500 int numBinsX = numVars >= 1 ? static_cast<RooRealVar const&>(*vars[0]).numBins() : 1;
501 int numBinsY = numVars >= 2 ? static_cast<RooRealVar const&>(*vars[1]).numBins() : 1;
502 int numBinsZ = numVars >= 3 ? static_cast<RooRealVar const&>(*vars[2]).numBins() : 1;
503
504 return {numBinsX, numBinsY, numBinsZ};
505}
506
507
508////////////////////////////////////////////////////////////////////////////////
509/// Get the index of the gamma parameter associated with the current bin.
510/// e.g. `RooRealVar& currentParam = getParameter( getCurrentBin() );`
512 // We promise that our coordinates and the data hist coordinates have same layout.
513 return _dataSet.getIndex(_dataVars, /*fast=*/true);
514}
515
516
517////////////////////////////////////////////////////////////////////////////////
518/// return 0 for success
519/// return 1 for failure
520/// Check that the elements
521/// are actually RooRealVar's
522/// If so, add them to the
523/// list of vars
525 for(auto const& comp : vars) {
526 if (!dynamic_cast<RooRealVar*>(comp)) {
527 auto errorMsg = std::string("ParamHistFunc::(") + GetName() + ") ERROR: component "
528 + comp->GetName() + " in variables list is not of type RooRealVar";
529 coutE(InputArguments) << errorMsg << std::endl;
530 throw std::runtime_error(errorMsg);
531 }
532 _dataVars.add( *comp );
533 }
534 return 0;
535}
536
537
538////////////////////////////////////////////////////////////////////////////////
539
541 // return 0 for success
542 // return 1 for failure
543
544 // Check that the supplied list has
545 // the right number of arguments:
546
547 Int_t numVarBins = GetNumBins(_dataVars);
548 Int_t numElements = params.getSize();
549
550 if( numVarBins != numElements ) {
551 std::cout << "ParamHistFunc::addParamSet - ERROR - "
552 << "Supplied list of parameters " << params.GetName()
553 << " has " << numElements << " elements but the ParamHistFunc"
554 << GetName() << " has " << numVarBins << " bins."
555 << std::endl;
556 return 1;
557
558 }
559
560 // Check that the elements
561 // are actually RooRealVar's
562 // If so, add them to the
563 // list of params
564
565 for (const auto comp : params) {
566 if (!dynamic_cast<const RooRealVar*>(comp)) {
567 auto errorMsg = std::string("ParamHistFunc::(") + GetName() + ") ERROR: component "
568 + comp->GetName() + " in parameter list is not of type RooRealVar.";
569 coutE(InputArguments) << errorMsg << std::endl;
570 throw std::runtime_error(errorMsg);
571 }
572
573 _paramSet.add( *comp );
574 }
575
576 return 0;
577}
578
579
580////////////////////////////////////////////////////////////////////////////////
581/// Find the bin corresponding to the current value of the observable, and evaluate
582/// the associated parameter.
584{
585 return getParameter().getVal();
586}
587
588
589////////////////////////////////////////////////////////////////////////////////
590/// Find all bins corresponding to the values of the observables in `evalData`, and evaluate
591/// the associated parameters.
592/// \param[in/out] evalData Input/output data for evaluating the ParamHistFunc.
593/// \param[in] normSet Normalisation set passed on to objects that are serving values to us.
595 std::vector<double> oldValues;
596 std::vector<RooSpan<const double>> data;
597 std::size_t batchSize = 0;
598
599 // Retrieve data for all variables
600 for (auto arg : _dataVars) {
601 const auto* var = static_cast<RooRealVar*>(arg);
602 oldValues.push_back(var->getVal());
603 data.push_back(var->getValues(evalData, normSet));
604 batchSize = std::max(batchSize, data.back().size());
605 }
606
607 // Run computation for each entry in the dataset
608 RooSpan<double> output = evalData.makeBatch(this, batchSize);
609
610 for (std::size_t i = 0; i < batchSize; ++i) {
611 for (unsigned int j = 0; j < _dataVars.size(); ++j) {
612 assert(i < data[j].size());
613 auto& var = static_cast<RooRealVar&>(_dataVars[j]);
614 var.setCachedValue(data[j][i], /*notifyClients=*/false);
615 }
616
617 const auto index = _dataSet.getIndex(_dataVars, /*fast=*/true);
618 const RooRealVar& param = getParameter(index);
619 output[i] = param.getVal();
620 }
621
622 // Restore old values
623 for (unsigned int j = 0; j < _dataVars.size(); ++j) {
624 auto& var = static_cast<RooRealVar&>(_dataVars[j]);
625 var.setCachedValue(oldValues[j], /*notifyClients=*/false);
626 }
627
628 return output;
629}
630
631////////////////////////////////////////////////////////////////////////////////
632/// Advertise that all integrals can be handled internally.
633
635 const RooArgSet* normSet,
636 const char* /*rangeName*/) const
637{
638 // Handle trivial no-integration scenario
639 if (allVars.getSize()==0) return 0 ;
640 if (_forceNumInt) return 0 ;
641
642
643 // Select subset of allVars that are actual dependents
644 analVars.add(allVars) ;
645
646 // Check if this configuration was created before
647 Int_t sterileIdx(-1) ;
648 CacheElem* cache = (CacheElem*) _normIntMgr.getObj(normSet,&analVars,&sterileIdx,(const char*)0) ;
649 if (cache) {
650 return _normIntMgr.lastIndex()+1 ;
651 }
652
653 // Create new cache element
654 cache = new CacheElem ;
655
656 // Store cache element
657 Int_t code = _normIntMgr.setObj(normSet,&analVars,(RooAbsCacheElement*)cache,0) ;
658
659 return code+1 ;
660
661}
662
663
664////////////////////////////////////////////////////////////////////////////////
665/// Implement analytical integrations by doing appropriate weighting from component integrals
666/// functions to integrators of components
667
669 const char* /*rangeName*/) const
670{
671 Double_t value(0) ;
672
673 // Simply loop over bins,
674 // get the height, and
675 // multiply by the bind width
676 auto binVolumes = _dataSet.binVolumes(0, _dataSet.numEntries());
677
678 for (unsigned int i=0; i < _paramSet.size(); ++i) {
679 const auto& param = static_cast<const RooRealVar&>(_paramSet[i]);
680 assert(static_cast<Int_t>(i) == _dataSet.getIndex(param)); // We assume that each parameter i belongs to bin i
681
682 // Get the gamma's value
683 const double paramVal = param.getVal();
684
685 // Finally, get the subtotal
686 value += paramVal * binVolumes[i];
687 }
688
689 return value;
690
691}
692
693
694
695////////////////////////////////////////////////////////////////////////////////
696/// Return sampling hint for making curves of (projections) of this function
697/// as the recursive division strategy of RooCurve cannot deal efficiently
698/// with the vertical lines that occur in a non-interpolated histogram
699
701 Double_t xhi) const
702{
703 // copied and edited from RooHistFunc
704 RooAbsLValue* lvarg = &obs;
705
706 // Retrieve position of all bin boundaries
707 const RooAbsBinning* binning = lvarg->getBinningPtr(0) ;
708 Double_t* boundaries = binning->array() ;
709
710 std::list<Double_t>* hint = new std::list<Double_t> ;
711
712 // Widen range slighty
713 xlo = xlo - 0.01*(xhi-xlo) ;
714 xhi = xhi + 0.01*(xhi-xlo) ;
715
716 Double_t delta = (xhi-xlo)*1e-8 ;
717
718 // Construct array with pairs of points positioned epsilon to the left and
719 // right of the bin boundaries
720 for (Int_t i=0 ; i<binning->numBoundaries() ; i++) {
721 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
722 hint->push_back(boundaries[i]-delta) ;
723 hint->push_back(boundaries[i]+delta) ;
724 }
725 }
726 return hint ;
727}
728
729
730////////////////////////////////////////////////////////////////////////////////
731/// Return sampling hint for making curves of (projections) of this function
732/// as the recursive division strategy of RooCurve cannot deal efficiently
733/// with the vertical lines that occur in a non-interpolated histogram
734
736 Double_t xhi) const
737{
738 // copied and edited from RooHistFunc
739 RooAbsLValue* lvarg = &obs;
740
741 // Retrieve position of all bin boundaries
742 const RooAbsBinning* binning = lvarg->getBinningPtr(0) ;
743 Double_t* boundaries = binning->array() ;
744
745 std::list<Double_t>* hint = new std::list<Double_t> ;
746
747 // Construct array with pairs of points positioned epsilon to the left and
748 // right of the bin boundaries
749 for (Int_t i=0 ; i<binning->numBoundaries() ; i++) {
750 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
751 hint->push_back(boundaries[i]) ;
752 }
753 }
754
755 return hint ;
756}
#define e(i)
Definition: RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define oocoutE(o, a)
Definition: RooMsgService.h:48
#define coutE(a)
Definition: RooMsgService.h:33
int Int_t
Definition: RtypesCore.h:45
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
#define ClassImp(name)
Definition: Rtypes.h:364
char name[80]
Definition: TGX11.cxx:110
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
Definition: ParamHistFunc.h:24
static NumBins getNumBinsPerDim(RooArgSet const &vars)
virtual ~ParamHistFunc()
void setParamConst(Int_t, Bool_t=kTRUE)
RooRealVar & getParameter() const
RooDataHist _dataSet
static Int_t GetNumBins(const RooArgSet &vars)
void setConstant(bool constant)
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
Int_t getCurrentBin() const
Get the index of the gamma parameter associated with the current bin.
RooObjCacheManager _normIntMgr
Definition: ParamHistFunc.h:83
Int_t numBins() const
Definition: ParamHistFunc.h:37
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const override
Advertise that all integrals can be handled internally.
RooSpan< double > evaluateSpan(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet) const override
Find all bins corresponding to the values of the observables in evalData, and evaluate the associated...
Int_t addVarSet(const RooArgList &vars)
return 0 for success return 1 for failure Check that the elements are actually RooRealVar's If so,...
Int_t addParamSet(const RooArgList &params)
NumBins _numBinsPerDim
double evaluate() const override
Find the bin corresponding to the current value of the observable, and evaluate the associated parame...
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const override
Implement analytical integrations by doing appropriate weighting from component integrals functions t...
static RooArgList createParamSet(RooWorkspace &w, const std::string &, const RooArgList &Vars)
Create the list of RooRealVar parameters which represent the height of the histogram bins.
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
RooListProxy _paramSet
Definition: ParamHistFunc.h:86
void setShape(TH1 *shape)
RooListProxy _dataVars
The integration cache manager.
Definition: ParamHistFunc.h:85
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
Definition: RooAbsBinning.h:26
virtual Double_t * array() const =0
virtual Int_t numBoundaries() const =0
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
Int_t getSize() const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Storage_t::size_type size() const
const char * GetName() const
Returns name of object.
Abstract base class for objects that are lvalues, i.e.
Definition: RooAbsLValue.h:26
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 Int_t numBins(const char *rangeName=0) const
void setConstant(Bool_t value=kTRUE)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
Bool_t _forceNumInt
Definition: RooAbsReal.h:480
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
void setCachedValue(double value, bool notifyClients=true) final
Overwrite the value stored in this object's cache.
Definition: RooAbsReal.h:601
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition: RooArgList.h:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:35
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
Int_t lastIndex() const
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
Int_t getIndex(const RooAbsCollection &coord, Bool_t fast=false) const
Calculate bin number of the given coordinates.
RooSpan< const double > binVolumes(std::size_t first, std::size_t len) const
Retrieve all bin volumes. Bins are indexed according to getIndex().
Definition: RooDataHist.h:97
void removeSelfFromDir()
Definition: RooDataHist.h:164
Int_t numEntries() const override
Return the number of bins.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::add()
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
void setMin(const char *name, Double_t value)
Set minimum of name range to given value.
Definition: RooRealVar.cxx:461
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
Bool_t 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.
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
virtual Int_t GetNbinsY() const
Definition: TH1.h:297
virtual Int_t GetNbinsZ() const
Definition: TH1.h:298
virtual Int_t GetNbinsX() const
Definition: TH1.h:296
Bool_t IsBinUnderflow(Int_t bin, Int_t axis=0) const
Return true if the bin is underflow.
Definition: TH1.cxx:5147
Bool_t IsBinOverflow(Int_t bin, Int_t axis=0) const
Return true if the bin is overflow.
Definition: TH1.cxx:5115
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4994
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
RooCmdArg RecycleConflictNodes(Bool_t flag=kTRUE)
const Int_t n
Definition: legend1.C:16
double gamma(double x)
@ InputArguments
Definition: RooGlobalFunc.h:61
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31
RooSpan< double > makeBatch(const RooAbsReal *owner, std::size_t size)
Create a writable batch.
Definition: RunContext.cxx:87
static int Prefix[TSIZE]
Definition: gifdecode.c:12
static void output(int code)
Definition: gifencode.c:226