Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
40
42
43using namespace RooStats;
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Default constructor
48
50 ConfInterval(name), fConfidenceLevel(0.95), fParameterPointsInInterval(nullptr)
51{
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Alternate constructor passing the dataset
56
58 ConfInterval(name), fConfidenceLevel(0.95), fParameterPointsInInterval(&data)
59{
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Method to determine if a parameter point is in the interval
64
65bool PointSetInterval::IsInInterval(const RooArgSet &parameterPoint) const
66{
67 RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
68 RooDataHist* hist = dynamic_cast<RooDataHist*>(fParameterPointsInInterval );
69
70 if( !this->CheckParameters(parameterPoint) ){
71 // std::cout << "problem with parameters" << std::endl;
72 return false;
73 }
74
75 if( hist ) {
76 if (hist->weight(parameterPoint, 0) > 0) { // positive value indicates point is in interval
77 return true;
78 } else {
79 return false;
80 }
81 }
82 else if( tree ){
83 const RooArgSet* thisPoint = nullptr;
84 // need to check if the parameter point is the same as any point in tree.
85 for(Int_t i = 0; i<tree->numEntries(); ++i){
86 // This method is not complete
87 thisPoint = tree->get(i);
88 bool samePoint = true;
89 for (auto const *myarg : static_range_cast<RooRealVar *>(parameterPoint)) {
90 if(samePoint == false)
91 break;
92 if(myarg->getVal() != thisPoint->getRealValue(myarg->GetName()))
93 samePoint = false;
94 }
95 if(samePoint)
96 return true;
97 }
98 return false; // didn't find a good point
99 }
100 else {
101 std::cout << "dataset is not initialized properly" << std::endl;
102 }
103
104 return true;
105
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// returns list of parameters
110
112{
113 return new RooArgSet(*(fParameterPointsInInterval->get()) );
114}
115
116////////////////////////////////////////////////////////////////////////////////
117
118bool PointSetInterval::CheckParameters(const RooArgSet &parameterPoint) const
119{
120 if (parameterPoint.size() != fParameterPointsInInterval->get()->size() ) {
121 std::cout << "PointSetInterval: argument size is wrong, parameters don't match: arg=" << parameterPoint
122 << " interval=" << (*fParameterPointsInInterval->get()) << std::endl;
123 return false;
124 }
125 if ( ! parameterPoint.equals( *(fParameterPointsInInterval->get() ) ) ) {
126 std::cout << "PointSetInterval: size is ok, but parameters don't match" << std::endl;
127 return false;
128 }
129 return true;
130}
131
132
133////////////////////////////////////////////////////////////////////////////////
134
136{
137 RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
138 double low = 0;
139 double high = 0;
140 if( tree ){
141 tree->getRange(param, low, high);
142 return high;
143 }
144 return param.getMax();
145}
146
147////////////////////////////////////////////////////////////////////////////////
148
150{
151 RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
152 double low = 0;
153 double high = 0;
154 if( tree ){
155 tree->getRange(param, low, high);
156 return low;
157 }
158 return param.getMin();
159}
#define ClassImp(name)
Definition Rtypes.h:382
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.
Storage_t::size_type size() const
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
virtual const RooArgSet * get() const
Definition RooAbsData.h:101
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:24
Container class to hold N-dimensional binned data.
Definition RooDataHist.h:40
double weight(std::size_t i) const
Return weight of i-th bin.
Container class to hold unbinned data.
Definition RooDataSet.h:33
Variable that can be changed from the outside.
Definition RooRealVar.h:37
ConfInterval is an interface class for a generic interval in the RooStats framework.
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
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