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