Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
PiecewiseInterpolation.cxx
Go to the documentation of this file.
1/** \class PiecewiseInterpolation
2 * \ingroup HistFactory
3 * The PiecewiseInterpolation is a class that can morph distributions into each other, which
4 * is useful to estimate systematic uncertainties. Given a nominal distribution and one or
5 * more altered or distorted ones, it computes a new shape depending on the value of the nuisance
6 * parameters \f$ \alpha_i \f$:
7 * \f[
8 * A = \sum_i \mathrm{Interpolate}(\mathrm{low}_i, \mathrm{nominal}, \mathrm{high}_i, \alpha_i).
9 * \f]
10 * If an \f$ \alpha_i \f$ is zero, the distribution is identical to the nominal distribution, at
11 * \f$ \pm 1 \f$ it is identical to the up/down distribution for that specific \f$ i \f$.
12 *
13 * The class supports several interpolation methods, which can be selected for each parameter separately
14 * using setInterpCode(). The default interpolation code is 4. This performs
15 * - \f$ |\alpha | > 1 \f$: Linear extrapolation.
16 * - \f$ |\alpha | < 1 \f$: Polynomial interpolation. A sixth-order polynomial is used. Its coefficients
17 * are chosen such that function, first, and second derivative at \f$ \alpha \pm 1 \f$ match the values
18 * that the extrapolation procedure uses.
19 */
20
22
24
25#include "Riostream.h"
26#include "TBuffer.h"
27
28#include "RooAbsReal.h"
29#include "RooAbsPdf.h"
30#include "RooErrorHandler.h"
31#include "RooArgSet.h"
32#include "RooRealVar.h"
33#include "RooMsgService.h"
34#include "RooNumIntConfig.h"
35#include "RooTrace.h"
36
37#include <exception>
38#include <cmath>
39#include <algorithm>
40
41using namespace std;
42
44;
45
47
48////////////////////////////////////////////////////////////////////////////////
49
51{
54}
55
56
57
58////////////////////////////////////////////////////////////////////////////////
59/// Construct a new interpolation. The value of the function will be
60/// \f[
61/// A = \sum_i \mathrm{Interpolate}(\mathrm{low}_i, \mathrm{nominal}, \mathrm{high}_i).
62/// \f]
63/// \param name Name of the object.
64/// \param title Title (for e.g. plotting)
65/// \param nominal Nominal value of the function.
66/// \param lowSet Set of down variations.
67/// \param highSet Set of up variations.
68/// \param paramSet Parameters that control the interpolation.
69/// \param takeOwnership If true, the PiecewiseInterpolation object will take ownership of the arguments in the low, high and parameter sets.
70PiecewiseInterpolation::PiecewiseInterpolation(const char* name, const char* title, const RooAbsReal& nominal,
71 const RooArgList& lowSet,
72 const RooArgList& highSet,
73 const RooArgList& paramSet
74#ifndef ROOFIT_MEMORY_SAFE_INTERFACES
75 , bool takeOwnership
76#endif
77 ) :
78 RooAbsReal(name, title),
79 _normIntMgr(this),
80 _nominal("!nominal","nominal value", this, (RooAbsReal&)nominal),
81 _lowSet("!lowSet","low-side variation",this),
82 _highSet("!highSet","high-side variation",this),
83 _paramSet("!paramSet","high-side variation",this),
84 _positiveDefinite(false)
85
86{
87 // KC: check both sizes
88 if (lowSet.getSize() != highSet.getSize()) {
89 coutE(InputArguments) << "PiecewiseInterpolation::ctor(" << GetName() << ") ERROR: input lists should be of equal length" << endl ;
91 }
92
93 for (auto *comp : lowSet) {
94 if (!dynamic_cast<RooAbsReal*>(comp)) {
95 coutE(InputArguments) << "PiecewiseInterpolation::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
96 << " in first list is not of type RooAbsReal" << endl ;
98 }
99 _lowSet.add(*comp) ;
100#ifndef ROOFIT_MEMORY_SAFE_INTERFACES
101 if (takeOwnership) {
102 _ownedList.addOwned(std::unique_ptr<RooAbsArg>{comp});
103 }
104#endif
105 }
106
107
108 for (auto *comp : highSet) {
109 if (!dynamic_cast<RooAbsReal*>(comp)) {
110 coutE(InputArguments) << "PiecewiseInterpolation::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
111 << " in first list is not of type RooAbsReal" << endl ;
113 }
114 _highSet.add(*comp) ;
115#ifndef ROOFIT_MEMORY_SAFE_INTERFACES
116 if (takeOwnership) {
117 _ownedList.addOwned(std::unique_ptr<RooAbsArg>{comp});
118 }
119#endif
120 }
121
122
123 for (auto *comp : paramSet) {
124 if (!dynamic_cast<RooAbsReal*>(comp)) {
125 coutE(InputArguments) << "PiecewiseInterpolation::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
126 << " in first list is not of type RooAbsReal" << endl ;
128 }
129 _paramSet.add(*comp) ;
130#ifndef ROOFIT_MEMORY_SAFE_INTERFACES
131 if (takeOwnership) {
132 _ownedList.addOwned(std::unique_ptr<RooAbsArg>{comp});
133 }
134#endif
135 _interpCode.push_back(0); // default code: linear interpolation
136 }
137
138
139 // Choose special integrator by default
140 specialIntegratorConfig(true)->method1D().setLabel("RooBinIntegrator") ;
142}
143
144
145
146////////////////////////////////////////////////////////////////////////////////
147/// Copy constructor
148
150 RooAbsReal(other, name),
151 _normIntMgr(other._normIntMgr, this),
152 _nominal("!nominal",this,other._nominal),
153 _lowSet("!lowSet",this,other._lowSet),
154 _highSet("!highSet",this,other._highSet),
155 _paramSet("!paramSet",this,other._paramSet),
156 _positiveDefinite(other._positiveDefinite),
157 _interpCode(other._interpCode)
158{
159 // Member _ownedList is intentionally not copy-constructed -- ownership is not transferred
161}
162
163
164
165////////////////////////////////////////////////////////////////////////////////
166/// Destructor
167
169{
171}
172
173
174
175
176////////////////////////////////////////////////////////////////////////////////
177/// Calculate and return current value of self
178
180{
181 ///////////////////
182 double nominal = _nominal;
183 double sum(nominal) ;
184
185 for (unsigned int i=0; i < _paramSet.size(); ++i) {
186 auto param = static_cast<RooAbsReal*>(_paramSet.at(i));
187 auto low = static_cast<RooAbsReal*>(_lowSet.at(i));
188 auto high = static_cast<RooAbsReal*>(_highSet.at(i));
189 Int_t icode = _interpCode[i] ;
190
191 if(icode < 0 || icode > 5) {
192 coutE(InputArguments) << "PiecewiseInterpolation::evaluate ERROR: " << param->GetName()
193 << " with unknown interpolation code" << icode << endl ;
194 }
195 sum += flexibleInterp(icode, low->getVal(), high->getVal(), 1.0, nominal, param->getVal(), sum);
196 }
197
198 if(_positiveDefinite && (sum<0)){
199 sum = 0;
200 // cout <<"sum < 0 forcing positive definite"<<endl;
201 // int code = 1;
202 // RooArgSet* myset = new RooArgSet();
203 // cout << "integral = " << analyticalIntegralWN(code, myset) << endl;
204 } else if(sum<0){
205 cxcoutD(Tracing) <<"PiecewiseInterpolation::evaluate - sum < 0, not forcing positive definite"<<endl;
206 }
207 return sum;
208
209}
210
212{
213 unsigned int n = _interpCode.size();
214
215 std::string resName = "total_" + ctx.getTmpVarName();
216 ctx.addToCodeBody(this, "double " + resName + " = " + ctx.getResult(_nominal) + ";\n");
217 std::string code = "";
218 for (std::size_t i = 0; i < n; ++i) {
219 if (_interpCode[i] < 0 || _interpCode[i] > 5) {
220 coutE(InputArguments) << "PiecewiseInterpolation::evaluate ERROR: " << _paramSet[i].GetName()
221 << " with unknown interpolation code" << _interpCode[i] << endl;
222 }
223 std::string funcCall;
224 funcCall = ctx.buildCall("RooFit::Detail::EvaluateFuncs::flexibleInterp", _interpCode[i], _lowSet[i],
225 _highSet[i], 1.0, _nominal, _paramSet[i], resName);
226
227 code += resName + " += " + funcCall + ";\n";
228 }
230 code += resName + " = " + resName + " < 0 ? 0 : " + resName + ";\n";
231
232 ctx.addToCodeBody(this, code);
233 ctx.addResult(this, resName);
234}
235
236////////////////////////////////////////////////////////////////////////////////
237/// Interpolate between input distributions for all values of the observable in `evalData`.
238/// \param[in,out] evalData Struct holding spans pointing to input data. The results of this function will be stored here.
239/// \param[in] normSet Arguments to normalise over.
240void PiecewiseInterpolation::computeBatch(double* sum, size_t /*size*/, RooFit::Detail::DataMap const& dataMap) const {
241 auto nominal = dataMap.at(_nominal);
242 for(unsigned int j=0; j < nominal.size(); ++j) {
243 sum[j] = nominal[j];
244 }
245
246 for (unsigned int i=0; i < _paramSet.size(); ++i) {
247 const double param = static_cast<RooAbsReal*>(_paramSet.at(i))->getVal();
248 auto low = dataMap.at(_lowSet.at(i));
249 auto high = dataMap.at(_highSet.at(i));
250 const int icode = _interpCode[i];
251
252 if (icode < 0 || icode > 5) {
253 coutE(InputArguments) << "PiecewiseInterpolation::computeBatch(): " << _paramSet[i].GetName()
254 << " with unknown interpolation code" << icode << std::endl;
255 throw std::invalid_argument("PiecewiseInterpolation::computeBatch() got invalid interpolation code " + std::to_string(icode));
256 }
257
258 for (unsigned int j=0; j < nominal.size(); ++j) {
259 sum[j] += flexibleInterp(icode, low[j], high[j], 1.0, nominal[j], param, sum[j]);
260 }
261 }
262
263 if (_positiveDefinite) {
264 for(unsigned int j=0; j < nominal.size(); ++j) {
265 if (sum[j] < 0.)
266 sum[j] = 0.;
267 }
268 }
269}
270
271////////////////////////////////////////////////////////////////////////////////
272
274{
275 if(allVars.getSize()==1){
276 RooAbsReal* temp = const_cast<PiecewiseInterpolation*>(this);
277 temp->specialIntegratorConfig(true)->method1D().setLabel("RooBinIntegrator") ;
278 int nbins = ((RooRealVar*) allVars.first())->numBins();
279 temp->specialIntegratorConfig(true)->getConfigSection("RooBinIntegrator").setRealValue("numBins",nbins);
280 return true;
281 }else{
282 cout << "Currently BinIntegrator only knows how to deal with 1-d "<<endl;
283 return false;
284 }
285 return false;
286}
287
288////////////////////////////////////////////////////////////////////////////////
289/// Advertise that all integrals can be handled internally.
290
292 const RooArgSet* normSet, const char* /*rangeName*/) const
293{
294 /*
295 cout << "---------------------------\nin PiecewiseInterpolation get analytic integral " <<endl;
296 cout << "all vars = "<<endl;
297 allVars.Print("v");
298 cout << "anal vars = "<<endl;
299 analVars.Print("v");
300 cout << "normset vars = "<<endl;
301 if(normSet2)
302 normSet2->Print("v");
303 */
304
305
306 // Handle trivial no-integration scenario
307 if (allVars.empty()) return 0 ;
308 if (_forceNumInt) return 0 ;
309
310
311 // Force using numeric integration
312 // use special numeric integrator
313 return 0;
314
315
316 // KC: check if interCode=0 for all
317 for (auto it = _paramSet.begin(); it != _paramSet.end(); ++it) {
318 if (!_interpCode.empty() && _interpCode[it - _paramSet.begin()] != 0) {
319 // can't factorize integral
320 cout << "can't factorize integral" << endl;
321 return 0;
322 }
323 }
324
325 // Select subset of allVars that are actual dependents
326 analVars.add(allVars) ;
327
328 // Check if this configuration was created before
329 Int_t sterileIdx(-1) ;
330 CacheElem* cache = (CacheElem*) _normIntMgr.getObj(normSet,&analVars,&sterileIdx) ;
331 if (cache) {
332 return _normIntMgr.lastIndex()+1 ;
333 }
334
335 // Create new cache element
336 cache = new CacheElem ;
337
338 // Make list of function projection and normalization integrals
339 RooAbsReal *func ;
340
341 // do variations
342 for (auto it = _paramSet.begin(); it != _paramSet.end(); ++it)
343 {
344 auto i = it - _paramSet.begin();
345 func = static_cast<RooAbsReal *>(_lowSet.at(i));
346 cache->_lowIntList.addOwned(std::unique_ptr<RooAbsReal>{func->createIntegral(analVars)});
347
348 func = static_cast<RooAbsReal *>(_highSet.at(i));
349 cache->_highIntList.addOwned(std::unique_ptr<RooAbsReal>{func->createIntegral(analVars)});
350 }
351
352 // Store cache element
353 Int_t code = _normIntMgr.setObj(normSet,&analVars,(RooAbsCacheElement*)cache,nullptr) ;
354
355 return code+1 ;
356}
357
358
359
360
361////////////////////////////////////////////////////////////////////////////////
362/// Implement analytical integrations by doing appropriate weighting from component integrals
363/// functions to integrators of components
364
365double PiecewiseInterpolation::analyticalIntegralWN(Int_t code, const RooArgSet* /*normSet2*/,const char* /*rangeName*/) const
366{
367 /*
368 cout <<"Enter analytic Integral"<<endl;
369 printDirty(true);
370 // _nominal.arg().setDirtyInhibit(true) ;
371 _nominal.arg().setShapeDirty() ;
372 RooAbsReal* temp ;
373 RooFIter lowIter(_lowSet.fwdIterator()) ;
374 while((temp=(RooAbsReal*)lowIter.next())) {
375 // temp->setDirtyInhibit(true) ;
376 temp->setShapeDirty() ;
377 }
378 RooFIter highIter(_highSet.fwdIterator()) ;
379 while((temp=(RooAbsReal*)highIter.next())) {
380 // temp->setDirtyInhibit(true) ;
381 temp->setShapeDirty() ;
382 }
383 */
384
385 /*
386 RooAbsArg::setDirtyInhibit(true);
387 printDirty(true);
388 cout <<"done setting dirty inhibit = true"<<endl;
389
390 // old integral, only works for linear and not positive definite
391 CacheElem* cache = (CacheElem*) _normIntMgr.getObjByIndex(code-1) ;
392
393
394 std::unique_ptr<RooArgSet> vars2( getParameters(RooArgSet()) );
395 std::unique_ptr<RooArgSet> iset( _normIntMgr.nameSet2ByIndex(code-1)->select(*vars2) );
396 cout <<"iset = "<<endl;
397 iset->Print("v");
398
399 double sum = 0;
400 RooArgSet* vars = getVariables();
401 vars->remove(_paramSet);
402 _paramSet.Print("v");
403 vars->Print("v");
404 if(vars->getSize()==1){
405 RooRealVar* obs = (RooRealVar*) vars->first();
406 for(int i=0; i<obs->numBins(); ++i){
407 obs->setVal( obs->getMin() + (.5+i)*(obs->getMax()-obs->getMin())/obs->numBins());
408 sum+=evaluate()*(obs->getMax()-obs->getMin())/obs->numBins();
409 cout << "obs = " << obs->getVal() << " sum = " << sum << endl;
410 }
411 } else{
412 cout <<"only know how to deal with 1 observable right now"<<endl;
413 }
414 */
415
416 /*
417 _nominal.arg().setDirtyInhibit(false) ;
418 RooFIter lowIter2(_lowSet.fwdIterator()) ;
419 while((temp=(RooAbsReal*)lowIter2.next())) {
420 temp->setDirtyInhibit(false) ;
421 }
422 RooFIter highIter2(_highSet.fwdIterator()) ;
423 while((temp=(RooAbsReal*)highIter2.next())) {
424 temp->setDirtyInhibit(false) ;
425 }
426 */
427
428 /*
429 RooAbsArg::setDirtyInhibit(false);
430 printDirty(true);
431 cout <<"done"<<endl;
432 cout << "sum = " <<sum<<endl;
433 //return sum;
434 */
435
436 // old integral, only works for linear and not positive definite
437 CacheElem* cache = (CacheElem*) _normIntMgr.getObjByIndex(code-1) ;
438 if( cache==nullptr ) {
439 std::cout << "Error: Cache Element is nullptr" << std::endl;
440 throw std::exception();
441 }
442
443 // old integral, only works for linear and not positive definite
444
445 RooAbsReal *low, *high;
446 double value(0);
447 double nominal(0);
448
449 // get nominal
450 int i=0;
451 for (auto funcInt : static_range_cast<RooAbsReal*>(cache->_funcIntList)) {
452 value += funcInt->getVal() ;
453 nominal = value;
454 i++;
455 }
456 if(i==0 || i>1) { cout << "problem, wrong number of nominal functions"<<endl; }
457
458 // now get low/high variations
459 // KC: old interp code with new iterator
460
461 i = 0;
462 for (auto const *param : static_range_cast<RooAbsReal *>(_paramSet)) {
463 low = static_cast<RooAbsReal *>(cache->_lowIntList.at(i));
464 high = static_cast<RooAbsReal *>(cache->_highIntList.at(i));
465
466 if(param->getVal() > 0) {
467 value += param->getVal()*(high->getVal() - nominal);
468 } else {
469 value += param->getVal()*(nominal - low->getVal());
470 }
471 ++i;
472 }
473
474 /* // MB : old bit of interpolation code
475 while( (param=(RooAbsReal*)_paramIter->Next()) ) {
476 low = (RooAbsReal*)lowIntIter->Next() ;
477 high = (RooAbsReal*)highIntIter->Next() ;
478
479 if(param->getVal()>0) {
480 value += param->getVal()*(high->getVal() - nominal );
481 } else {
482 value += param->getVal()*(nominal - low->getVal());
483 }
484 ++i;
485 }
486 */
487
488 /* KC: the code below is wrong. Can't pull out a constant change to a non-linear shape deformation.
489 while( (param=(RooAbsReal*)paramIter.next()) ) {
490 low = (RooAbsReal*)lowIntIter.next() ;
491 high = (RooAbsReal*)highIntIter.next() ;
492
493 if(_interpCode.empty() || _interpCode.at(i)==0){
494 // piece-wise linear
495 if(param->getVal()>0)
496 value += param->getVal()*(high->getVal() - nominal );
497 else
498 value += param->getVal()*(nominal - low->getVal());
499 } else if(_interpCode.at(i)==1){
500 // piece-wise log
501 if(param->getVal()>=0)
502 value *= pow(high->getVal()/nominal, +param->getVal());
503 else
504 value *= pow(low->getVal()/nominal, -param->getVal());
505 } else if(_interpCode.at(i)==2){
506 // parabolic with linear
507 double a = 0.5*(high->getVal()+low->getVal())-nominal;
508 double b = 0.5*(high->getVal()-low->getVal());
509 double c = 0;
510 if(param->getVal()>1 ){
511 value += (2*a+b)*(param->getVal()-1)+high->getVal()-nominal;
512 } else if(param->getVal()<-1 ) {
513 value += -1*(2*a-b)*(param->getVal()+1)+low->getVal()-nominal;
514 } else {
515 value += a*pow(param->getVal(),2) + b*param->getVal()+c;
516 }
517 } else if(_interpCode.at(i)==3){
518 //parabolic version of log-normal
519 double a = 0.5*(high->getVal()+low->getVal())-nominal;
520 double b = 0.5*(high->getVal()-low->getVal());
521 double c = 0;
522 if(param->getVal()>1 ){
523 value += (2*a+b)*(param->getVal()-1)+high->getVal()-nominal;
524 } else if(param->getVal()<-1 ) {
525 value += -1*(2*a-b)*(param->getVal()+1)+low->getVal()-nominal;
526 } else {
527 value += a*pow(param->getVal(),2) + b*param->getVal()+c;
528 }
529
530 } else {
531 coutE(InputArguments) << "PiecewiseInterpolation::analyticalIntegralWN ERROR: " << param->GetName()
532 << " with unknown interpolation code" << endl ;
533 }
534 ++i;
535 }
536 */
537
538 // cout << "value = " << value <<endl;
539 return value;
540}
541
542
543////////////////////////////////////////////////////////////////////////////////
544
545void PiecewiseInterpolation::setInterpCode(RooAbsReal& param, int code, bool silent){
546 int index = _paramSet.index(&param);
547 if(index<0){
548 coutE(InputArguments) << "PiecewiseInterpolation::setInterpCode ERROR: " << param.GetName()
549 << " is not in list" << endl ;
550 } else {
551 if(!silent){
552 coutW(InputArguments) << "PiecewiseInterpolation::setInterpCode : " << param.GetName()
553 << " is now " << code << endl ;
554 }
555 _interpCode.at(index) = code;
556 }
557}
558
559
560////////////////////////////////////////////////////////////////////////////////
561
563 for(unsigned int i=0; i<_interpCode.size(); ++i){
564 _interpCode.at(i) = code;
565 }
566}
567
568
569////////////////////////////////////////////////////////////////////////////////
570
572 for(unsigned int i=0; i<_interpCode.size(); ++i){
573 coutI(InputArguments) <<"interp code for " << _paramSet.at(i)->GetName() << " = " << _interpCode.at(i) <<endl;
574 }
575}
576
577
578////////////////////////////////////////////////////////////////////////////////
579/// WVE note: assumes nominal and alternates have identical structure, must add explicit check
580
581std::list<double>* PiecewiseInterpolation::binBoundaries(RooAbsRealLValue& obs, double xlo, double xhi) const
582{
583 return _nominal.arg().binBoundaries(obs,xlo,xhi) ;
584}
585
586
587////////////////////////////////////////////////////////////////////////////////
588/// WVE note: assumes nominal and alternates have identical structure, must add explicit check
589
591{
592 return _nominal.arg().isBinnedDistribution(obs) ;
593}
594
595
596
597////////////////////////////////////////////////////////////////////////////////
598
599std::list<double>* PiecewiseInterpolation::plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const
600{
601 return _nominal.arg().plotSamplingHint(obs,xlo,xhi) ;
602}
603
604////////////////////////////////////////////////////////////////////////////////
605/// Stream an object of class PiecewiseInterpolation.
606
608{
609 if (R__b.IsReading()) {
611 specialIntegratorConfig(true)->method1D().setLabel("RooBinIntegrator") ;
612 if (_interpCode.empty()) _interpCode.resize(_paramSet.getSize());
613 } else {
615 }
616}
617
618
619/*
620////////////////////////////////////////////////////////////////////////////////
621/// Customized printing of arguments of a PiecewiseInterpolation to more intuitively reflect the contents of the
622/// product operator construction
623
624void PiecewiseInterpolation::printMetaArgs(ostream& os) const
625{
626 _lowIter->Reset() ;
627 if (_highIter) {
628 _highIter->Reset() ;
629 }
630
631 bool first(true) ;
632
633 RooAbsArg* arg1, *arg2 ;
634 if (_highSet.getSize()!=0) {
635
636 while((arg1=(RooAbsArg*)_lowIter->Next())) {
637 if (!first) {
638 os << " + " ;
639 } else {
640 first = false ;
641 }
642 arg2=(RooAbsArg*)_highIter->Next() ;
643 os << arg1->GetName() << " * " << arg2->GetName() ;
644 }
645
646 } else {
647
648 while((arg1=(RooAbsArg*)_lowIter->Next())) {
649 if (!first) {
650 os << " + " ;
651 } else {
652 first = false ;
653 }
654 os << arg1->GetName() ;
655 }
656
657 }
658
659 os << " " ;
660}
661
662*/
#define coutI(a)
#define cxcoutD(a)
#define coutW(a)
#define coutE(a)
#define TRACE_DESTROY
Definition RooTrace.h:24
#define TRACE_CREATE
Definition RooTrace.h:23
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
The PiecewiseInterpolation is a class that can morph distributions into each other,...
bool _positiveDefinite
protect against negative and 0 bins.
RooListProxy _lowSet
Low-side variation.
RooListProxy _highSet
High-side variation.
bool isBinnedDistribution(const RooArgSet &obs) const override
WVE note: assumes nominal and alternates have identical structure, must add explicit check.
void setInterpCode(RooAbsReal &param, int code, bool silent=false)
static TClass * Class()
~PiecewiseInterpolation() override
Destructor.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
RooObjCacheManager _normIntMgr
! The integration cache manager
bool setBinIntegrator(RooArgSet &allVars)
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Advertise that all integrals can be handled internally.
RooListProxy _paramSet
interpolation parameters
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
WVE note: assumes nominal and alternates have identical structure, must add explicit check.
RooArgList _ownedList
List of owned components.
RooRealProxy _nominal
The nominal value.
double evaluate() const override
Calculate and return current value of self.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Implement analytical integrations by doing appropriate weighting from component integrals functions t...
void computeBatch(double *output, size_t size, RooFit::Detail::DataMap const &) const override
Interpolate between input distributions for all values of the observable in evalData.
friend void RooRefArray::Streamer(TBuffer &)
Abstract base class for objects to be stored in RooAbsCache cache manager objects.
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
const_iterator end() const
Storage_t::size_type size() const
RooAbsArg * first() const
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
bool setRealValue(const char *name, double newVal=0.0, bool verbose=false)
Set value of a RooAbsRealLValue stored in set with given name to newVal No error messages are printed...
const_iterator begin() const
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
virtual std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create an object that represents the integral of the function over one or more observables listed in ...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
bool _forceNumInt
Force numerical integration if flag set.
Definition RooAbsReal.h:546
RooNumIntConfig * specialIntegratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
virtual bool isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition RooAbsReal.h:353
virtual std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
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:55
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
Int_t lastIndex() const
Return index of slot used in last get or set operation.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
bool setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
static void softAbort()
Soft abort function that interrupts macro execution but doesn't kill ROOT.
A class to maintain the context for squashing of RooFit models into code.
std::string buildCall(std::string const &funcname, Args_t const &...args)
Build the code to call the function with name funcname, passing some arguments.
void addResult(RooAbsArg const *key, std::string const &value)
A function to save an expression that includes/depends on the result of the input node.
void addToCodeBody(RooAbsArg const *klass, std::string const &in)
Adds the input string to the squashed code body.
std::string const & getResult(RooAbsArg const &arg)
Gets the result for the given node using the node name.
std::string getTmpVarName()
Get a unique variable name to be used in the generated code.
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
Definition DataMap.cxx:22
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooCategory & method1D()
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:37
const T & arg() const
Return reference to object held in proxy.
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const Int_t n
Definition legend1.C:16
double flexibleInterp(unsigned int code, double low, double high, double boundary, double nominal, double paramVal, double res)
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345