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
41
42using namespace RooStats;
43
44
45////////////////////////////////////////////////////////////////////////////////
46/// Default constructor
47
49 ConfInterval(name), fConfidenceLevel(0.95), fParameterPointsInInterval(nullptr)
50{
51}
52
53////////////////////////////////////////////////////////////////////////////////
54/// Alternate constructor passing the dataset
55
57 ConfInterval(name), fConfidenceLevel(0.95), fParameterPointsInInterval(&data)
58{
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Method to determine if a parameter point is in the interval
63
65{
66 RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
67 RooDataHist* hist = dynamic_cast<RooDataHist*>(fParameterPointsInInterval );
68
69 if( !this->CheckParameters(parameterPoint) ){
70 // std::cout << "problem with parameters" << std::endl;
71 return false;
72 }
73
74 if( hist ) {
75 if (hist->weight(parameterPoint, 0) > 0) { // positive value indicates point is in interval
76 return true;
77 } else {
78 return false;
79 }
80 }
81 else if( tree ){
82 const RooArgSet* thisPoint = nullptr;
83 // need to check if the parameter point is the same as any point in tree.
84 for(Int_t i = 0; i<tree->numEntries(); ++i){
85 // This method is not complete
86 thisPoint = tree->get(i);
87 bool samePoint = true;
89 if(samePoint == false)
90 break;
91 if(myarg->getVal() != thisPoint->getRealValue(myarg->GetName()))
92 samePoint = false;
93 }
94 if(samePoint)
95 return true;
96 }
97 return false; // didn't find a good point
98 }
99 else {
100 std::cout << "dataset is not initialized properly" << std::endl;
101 }
102
103 return true;
104
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// returns list of parameters
109
114
115////////////////////////////////////////////////////////////////////////////////
116
118{
119 if (parameterPoint.size() != fParameterPointsInInterval->get()->size() ) {
120 std::cout << "PointSetInterval: argument size is wrong, parameters don't match: arg=" << parameterPoint
121 << " interval=" << (*fParameterPointsInInterval->get()) << std::endl;
122 return false;
123 }
124 if ( ! parameterPoint.equals( *(fParameterPointsInInterval->get() ) ) ) {
125 std::cout << "PointSetInterval: size is ok, but parameters don't match" << std::endl;
126 return false;
127 }
128 return true;
129}
130
131
132////////////////////////////////////////////////////////////////////////////////
133
135{
136 RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
137 double low = 0;
138 double high = 0;
139 if( tree ){
140 tree->getRange(param, low, high);
141 return high;
142 }
143 return param.getMax();
144}
145
146////////////////////////////////////////////////////////////////////////////////
147
149{
150 RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
151 double low = 0;
152 double high = 0;
153 if( tree ){
154 tree->getRange(param, low, high);
155 return low;
156 }
157 return param.getMin();
158}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
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:34
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.
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 CodegenImpl.h:58