Logo ROOT  
Reference Guide
SimpleInterval.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
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 * Project: RooStats
13 * Package: RooFit/RooStats
14 * @(#)root/roofit/roostats:$Id$
15 * Authors:
16 * Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
17 *
18 *****************************************************************************/
19
20/** \class RooStats::SimpleInterval
21 \ingroup Roostats
22
23SimpleInterval is a concrete implementation of the ConfInterval interface.
24It implements simple 1-dimensional intervals in a range [a,b].
25In addition, you can ask it for the upper- or lower-bound.
26*/
27
29#include "RooAbsReal.h"
30#include "RooRealVar.h"
31#include <string>
32
33
34using namespace std;
35
37
38using namespace RooStats;
39
40
41////////////////////////////////////////////////////////////////////////////////
42/// Default constructor
43
44SimpleInterval::SimpleInterval(const char* name) :
45 ConfInterval(name), fLowerLimit(0), fUpperLimit(0), fConfidenceLevel(0)
46{
47}
48
49
50////////////////////////////////////////////////////////////////////////////////
51///fParameters.add( other.fParameters );
52
55 , fParameters(other.fParameters)
56 , fLowerLimit(other.fLowerLimit)
57 , fUpperLimit(other.fUpperLimit)
58 , fConfidenceLevel(other.fConfidenceLevel)
59{
60}
61
62
63////////////////////////////////////////////////////////////////////////////////
64
67{
68 if (&other==this) {
69 return *this ;
70 }
71
73
74 //fParameters = other.fParameters;
80
81 return *this ;
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Alternate constructor
86
87SimpleInterval::SimpleInterval(const char* name, const RooRealVar & var, double lower, double upper, double cl) :
88 ConfInterval(name), fParameters(var), fLowerLimit(lower), fUpperLimit(upper), fConfidenceLevel(cl)
89{
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Destructor
94
96{
97}
98
99////////////////////////////////////////////////////////////////////////////////
100/// Method to determine if a parameter point is in the interval
101
102bool SimpleInterval::IsInInterval(const RooArgSet &parameterPoint) const
103{
104 if( !this->CheckParameters(parameterPoint) )
105 return false;
106
107 if(parameterPoint.getSize() != 1 )
108 return false;
109
110 RooAbsReal* point = dynamic_cast<RooAbsReal*> (parameterPoint.first());
111 if (point == 0)
112 return false;
113
114 if ( point->getVal() > fUpperLimit || point->getVal() < fLowerLimit)
115 return false;
116
117
118 return true;
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// return cloned list of parameters
123
125{
126 return new RooArgSet(fParameters);
127}
128
129////////////////////////////////////////////////////////////////////////////////
130
131bool SimpleInterval::CheckParameters(const RooArgSet &parameterPoint) const
132{
133 if (parameterPoint.getSize() != fParameters.getSize() ) {
134 std::cout << "size is wrong, parameters don't match" << std::endl;
135 return false;
136 }
137 if ( ! parameterPoint.equals( fParameters ) ) {
138 std::cout << "size is ok, but parameters don't match" << std::endl;
139 return false;
140 }
141 return true;
142}
#define ClassImp(name)
Definition: Rtypes.h:375
char name[80]
Definition: TGX11.cxx:110
bool equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically-named contents.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsArg * first() const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:62
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
ConfInterval is an interface class for a generic interval in the RooStats framework.
Definition: ConfInterval.h:35
ConfInterval & operator=(const ConfInterval &other)
operator=
Definition: ConfInterval.h:46
SimpleInterval is a concrete implementation of the ConfInterval interface.
double fUpperLimit
upper interval limit
SimpleInterval(const char *name=nullptr)
default constructor
RooArgSet fParameters
set containing the parameter of interest
bool IsInInterval(const RooArgSet &) const override
check if parameter is in the interval
double fLowerLimit
lower interval limit
~SimpleInterval() override
destructor
RooArgSet * GetParameters() const override
return a cloned list with the parameter of interest
bool CheckParameters(const RooArgSet &) const override
check if parameters are correct (i.e. they are the POI of this interval)
double fConfidenceLevel
confidence level
SimpleInterval & operator=(const SimpleInterval &other)
default constructor
Namespace for the RooStats classes.
Definition: Asimov.h:19