Logo ROOT  
Reference Guide
PointSetInterval.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 * Original Author: Kyle Cranmer
16 * Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
17 *
18 *****************************************************************************/
19
20
21/** \class RooStats::PointSetInterval
22 \ingroup Roostats
23
24PointSetInterval is a concrete implementation of the ConfInterval interface.
25It implements simple general purpose interval of arbitrary dimensions and shape.
26It does not assume the interval is connected.
27It uses either a RooDataSet (eg. a list of parameter points in the interval) or
28a RooDataHist (eg. a Histogram-like object for small regions of the parameter space) to
29store the interval.
30
31*/
32
33
35
36#include "RooRealVar.h"
37#include "RooDataSet.h"
38#include "RooDataHist.h"
39
40using namespace std;
41
43
44using namespace RooStats;
45
46
47////////////////////////////////////////////////////////////////////////////////
48/// Default constructor
49
50PointSetInterval::PointSetInterval(const char* name) :
51 ConfInterval(name), fConfidenceLevel(0.95), fParameterPointsInInterval(0)
52{
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// Alternate constructor passing the dataset
57
59 ConfInterval(name), fConfidenceLevel(0.95), fParameterPointsInInterval(&data)
60{
61}
62
63
64
65////////////////////////////////////////////////////////////////////////////////
66/// Destructor
67
69{
70}
71
72
73////////////////////////////////////////////////////////////////////////////////
74/// Method to determine if a parameter point is in the interval
75
76bool PointSetInterval::IsInInterval(const RooArgSet &parameterPoint) const
77{
79 RooDataHist* hist = dynamic_cast<RooDataHist*>( fParameterPointsInInterval );
80
81 if( !this->CheckParameters(parameterPoint) ){
82 // std::cout << "problem with parameters" << std::endl;
83 return false;
84 }
85
86 if( hist ) {
87 if ( hist->weight( parameterPoint , 0 ) > 0 ) // positive value indicates point is in interval
88 return true;
89 else
90 return false;
91 }
92 else if( tree ){
93 const RooArgSet* thisPoint = 0;
94 // need to check if the parameter point is the same as any point in tree.
95 for(Int_t i = 0; i<tree->numEntries(); ++i){
96 // This method is not complete
97 thisPoint = tree->get(i);
98 bool samePoint = true;
99 for (auto const *myarg : static_range_cast<RooRealVar *>(parameterPoint)) {
100 if(samePoint == false)
101 break;
102 if(myarg->getVal() != thisPoint->getRealValue(myarg->GetName()))
103 samePoint = false;
104 }
105 if(samePoint)
106 return true;
107 }
108 return false; // didn't find a good point
109 }
110 else {
111 std::cout << "dataset is not initialized properly" << std::endl;
112 }
113
114 return true;
115
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// returns list of parameters
120
122{
123 return new RooArgSet(*(fParameterPointsInInterval->get()) );
124}
125
126////////////////////////////////////////////////////////////////////////////////
127
128bool PointSetInterval::CheckParameters(const RooArgSet &parameterPoint) const
129{
130 if (parameterPoint.getSize() != fParameterPointsInInterval->get()->getSize() ) {
131 std::cout << "PointSetInterval: argument size is wrong, parameters don't match: arg=" << parameterPoint
132 << " interval=" << (*fParameterPointsInInterval->get()) << std::endl;
133 return false;
134 }
135 if ( ! parameterPoint.equals( *(fParameterPointsInInterval->get() ) ) ) {
136 std::cout << "PointSetInterval: size is ok, but parameters don't match" << std::endl;
137 return false;
138 }
139 return true;
140}
141
142
143////////////////////////////////////////////////////////////////////////////////
144
146{
148 double low = 0, high = 0;
149 if( tree ){
150 tree->getRange(param, low, high);
151 return high;
152 }
153 return param.getMax();
154}
155
156////////////////////////////////////////////////////////////////////////////////
157
159{
161 double low = 0, high = 0;
162 if( tree ){
163 tree->getRange(param, low, high);
164 return low;
165 }
166 return param.getMin();
167}
#define ClassImp(name)
Definition: Rtypes.h:375
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition: TGX11.cxx:110
bool equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically-named contents.
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
Int_t getSize() const
Return the number of elements in the collection.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
virtual const RooArgSet * get() const
Definition: RooAbsData.h:106
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
The RooDataHist is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:39
double weight(std::size_t i) const
Return weight of i-th bin.
Definition: RooDataHist.h:104
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:55
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
PointSetInterval is a concrete implementation of the ConfInterval interface.
double UpperLimit(RooRealVar &param)
return upper limit on a given parameter
bool IsInInterval(const RooArgSet &) const override
check if parameter is in the interval
PointSetInterval(const char *name=nullptr)
default constructors
RooArgSet * GetParameters() const override
return a cloned list with the parameter of interest
~PointSetInterval() override
destructor
bool CheckParameters(const RooArgSet &) const override
return a cloned list with the parameter of interest
RooAbsData * fParameterPointsInInterval
either a histogram (RooDataHist) or a tree (RooDataSet)
double LowerLimit(RooRealVar &param)
return lower limit on a given parameter
Namespace for the RooStats classes.
Definition: Asimov.h:19
Definition: tree.py:1