Logo ROOT  
Reference Guide
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 namespace std;
29
31
32using namespace RooStats;
33using namespace HistFactory;
34
35////////////////////////////////////////////////////////////////////////////////
36/// Default constructor
37
38LinInterpVar::LinInterpVar()
39{
40 _nominal = 0 ;
41}
42
43
44////////////////////////////////////////////////////////////////////////////////
45
46LinInterpVar::LinInterpVar(const char* name, const char* title,
47 const RooArgList& paramList,
48 double nominal, vector<double> low, vector<double> high) :
49 RooAbsReal(name, title),
50 _paramList("paramList","List of paramficients",this),
51 _nominal(nominal), _low(low), _high(high)
52{
53
54 for (auto param : paramList) {
55 if (!dynamic_cast<RooAbsReal*>(param)) {
56 coutE(InputArguments) << "LinInterpVar::ctor(" << GetName() << ") ERROR: paramficient " << param->GetName()
57 << " is not of type RooAbsReal" << endl ;
58 assert(0) ;
59 }
60 _paramList.add(*param) ;
61 }
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Constructor of flat polynomial function
66
67LinInterpVar::LinInterpVar(const char* name, const char* title) :
68 RooAbsReal(name, title),
69 _paramList("paramList","List of coefficients",this),
70 _nominal(0)
71{
72
73}
74
75////////////////////////////////////////////////////////////////////////////////
76
77LinInterpVar::LinInterpVar(const LinInterpVar& other, const char* name) :
78 RooAbsReal(other, name),
79 _paramList("paramList",this,other._paramList),
80 _nominal(other._nominal), _low(other._low), _high(other._high)
81
82{
83 // Copy constructor
84
85}
86
87
88////////////////////////////////////////////////////////////////////////////////
89/// Calculate and return value of polynomial
90
92{
93 double sum(_nominal) ;
94
95 int i=0;
96 for(auto const* param: static_range_cast<RooAbsReal *>(_paramList)) {
97 if(param->getVal()>0)
98 sum += param->getVal()*(_high.at(i) - _nominal );
99 else
100 sum += param->getVal()*(_nominal - _low.at(i));
101
102 ++i;
103 }
104
105 if(sum<=0) {
106 sum=1E-9;
107 }
108
109 return sum;
110}
111
112
113
#define coutE(a)
Definition: RooMsgService.h:37
#define ClassImp(name)
Definition: Rtypes.h:375
char name[80]
Definition: TGX11.cxx:110
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:62
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.
Definition: LinInterpVar.h:25
LinInterpVar()
Default constructor.
double evaluate() const override
Calculate and return value of polynomial.
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
@ HistFactory
Definition: RooGlobalFunc.h:63
@ InputArguments
Definition: RooGlobalFunc.h:62
Namespace for the RooStats classes.
Definition: Asimov.h:19
constexpr Double_t E()
Base of natural log: .
Definition: TMath.h:93