Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
LinInterpVar.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id: cranmer $
2// Author: Kyle Cranmer, Akira Shibata
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 RooStats::HistFactory::LinInterpVar
14 * \ingroup HistFactory
15 * RooAbsReal that does piecewise-linear interpolations.
16 */
17
18#include <iostream>
19#include <cmath>
20
21#include "RooAbsReal.h"
22#include "RooRealVar.h"
23#include "RooArgList.h"
24#include "RooMsgService.h"
25
27
28using std::vector, std::endl;
29
30
31using namespace RooStats;
32using namespace HistFactory;
33
34////////////////////////////////////////////////////////////////////////////////
35
36LinInterpVar::LinInterpVar(const char* name, const char* title,
37 const RooArgList& paramList,
38 double nominal, vector<double> low, vector<double> high) :
39 RooAbsReal(name, title),
40 _paramList("paramList","List of paramficients",this),
41 _nominal(nominal), _low(low), _high(high)
42{
43
44 for (auto param : paramList) {
45 if (!dynamic_cast<RooAbsReal*>(param)) {
46 coutE(InputArguments) << "LinInterpVar::ctor(" << GetName() << ") ERROR: paramficient " << param->GetName()
47 << " is not of type RooAbsReal" << std::endl ;
48 assert(0) ;
49 }
50 _paramList.add(*param) ;
51 }
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Constructor of flat polynomial function
56
57LinInterpVar::LinInterpVar(const char* name, const char* title) :
58 RooAbsReal(name, title),
59 _paramList("paramList","List of coefficients",this),
60 _nominal(0)
61{
62
63}
64
65////////////////////////////////////////////////////////////////////////////////
66
69 _paramList("paramList",this,other._paramList),
70 _nominal(other._nominal), _low(other._low), _high(other._high)
71
72{
73 // Copy constructor
74
75}
76
77
78////////////////////////////////////////////////////////////////////////////////
79/// Calculate and return value of polynomial
80
82{
83 double sum(_nominal) ;
84
85 int i=0;
86 for(auto const* param: static_range_cast<RooAbsReal *>(_paramList)) {
87 if (param->getVal() > 0) {
88 sum += param->getVal()*(_high.at(i) - _nominal );
89 } else {
90 sum += param->getVal() * (_nominal - _low.at(i));
91 }
92
93 ++i;
94 }
95
96 if(sum<=0) {
97 sum=1E-9;
98 }
99
100 return sum;
101}
102
103
104
#define coutE(a)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:110
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
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...
RooAbsReal that does piecewise-linear interpolations.
double evaluate() const override
Calculate and return value of polynomial.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Namespace for the RooStats classes.
Definition CodegenImpl.h:58
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345