ROOT  6.06/09
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 /*
14 BEGIN_HTML
15 <p>
16 </p>
17 END_HTML
18 */
19 //
20 
21 #include "RooFit.h"
22 
23 #include "Riostream.h"
24 #include "Riostream.h"
25 #include <math.h>
26 #include "TMath.h"
27 
28 #include "RooAbsReal.h"
29 #include "RooRealVar.h"
30 #include "RooArgList.h"
31 #include "RooMsgService.h"
32 #include "TMath.h"
33 
35 
36 using namespace std;
37 
39 
40 using namespace RooStats;
41 using namespace HistFactory;
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Default constructor
45 
47 {
48  _paramIter = _paramList.createIterator() ;
49  _nominal = 0 ;
50 }
51 
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 
55 LinInterpVar::LinInterpVar(const char* name, const char* title,
56  const RooArgList& paramList,
57  double nominal, vector<double> low, vector<double> high) :
58  RooAbsReal(name, title),
59  _paramList("paramList","List of paramficients",this),
60  _nominal(nominal), _low(low), _high(high)
61 {
63 
64 
65  TIterator* paramIter = paramList.createIterator() ;
66  RooAbsArg* param ;
67  while((param = (RooAbsArg*)paramIter->Next())) {
68  if (!dynamic_cast<RooAbsReal*>(param)) {
69  coutE(InputArguments) << "LinInterpVar::ctor(" << GetName() << ") ERROR: paramficient " << param->GetName()
70  << " is not of type RooAbsReal" << endl ;
71  assert(0) ;
72  }
73  _paramList.add(*param) ;
74  }
75  delete paramIter ;
76 
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Constructor of flat polynomial function
81 
82 LinInterpVar::LinInterpVar(const char* name, const char* title) :
83  RooAbsReal(name, title),
84  _paramList("paramList","List of coefficients",this),
85  _nominal(0)
86 {
88 }
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 
92 LinInterpVar::LinInterpVar(const LinInterpVar& other, const char* name) :
93  RooAbsReal(other, name),
94  _paramList("paramList",this,other._paramList),
95  _nominal(other._nominal), _low(other._low), _high(other._high)
96 
97 {
98  // Copy constructor
100 
101 }
102 
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// Destructor
106 
108 {
109  delete _paramIter ;
110 }
111 
112 
113 
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 /// Calculate and return value of polynomial
117 
119 {
120  Double_t sum(_nominal) ;
121  _paramIter->Reset() ;
122 
123  RooAbsReal* param ;
124  //const RooArgSet* nset = _paramList.nset() ;
125  int i=0;
126 
127  while((param=(RooAbsReal*)_paramIter->Next())) {
128  // param->Print("v");
129 
130  if(param->getVal()>0)
131  sum += param->getVal()*(_high.at(i) - _nominal );
132  else
133  sum += param->getVal()*(_nominal - _low.at(i));
134 
135  ++i;
136  }
137 
138  if(sum<=0) {
139  sum=1E-9;
140  }
141 
142  return sum;
143 }
144 
145 
146 
#define coutE(a)
Definition: RooMsgService.h:35
virtual void Reset()=0
#define assert(cond)
Definition: unittest.h:542
Double_t evaluate() const
do not persist
STL namespace.
Iterator abstract base class.
Definition: TIterator.h:32
ClassImp(RooStats::HistFactory::LinInterpVar) using namespace RooStats
TIterator * createIterator(Bool_t dir=kIterForward) const
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
Double_t E()
Definition: TMath.h:54
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
Namespace for the RooStats classes.
Definition: Asimov.h:20
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
LinInterpVar()
Default constructor.
virtual TObject * Next()=0
virtual ~LinInterpVar()
Destructor.
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66