Logo ROOT   6.10/09
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 
24 PointSetInterval is a concrete implementation of the ConfInterval interface.
25 It implements simple general purpose interval of arbitrary dimensions and shape.
26 It does not assume the interval is connected.
27 It uses either a RooDataSet (eg. a list of parameter points in the interval) or
28 a RooDataHist (eg. a Histogram-like object for small regions of the parameter space) to
29 store the interval.
30 
31 */
32 
33 
35 
36 #include "RooRealVar.h"
37 #include "RooDataSet.h"
38 #include "RooDataHist.h"
39 
40 using namespace std;
41 
43 
44 using namespace RooStats;
45 
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 /// Default constructor
49 
50 PointSetInterval::PointSetInterval(const char* name) :
51  ConfInterval(name), fConfidenceLevel(0.95), fParameterPointsInInterval(0)
52 {
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Alternate constructor passing the dataset
57 
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 
76 Bool_t 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  TIter it = parameterPoint.createIterator();
100  RooRealVar *myarg;
101  while ( samePoint && (myarg = (RooRealVar *)it.Next())) {
102  if(myarg->getVal() != thisPoint->getRealValue(myarg->GetName()))
103  samePoint = false;
104  }
105  if(samePoint)
106  return true;
107 
108  // delete thisPoint;
109  }
110  return false; // didn't find a good point
111  }
112  else {
113  std::cout << "dataset is not initialized properly" << std::endl;
114  }
115 
116  return true;
117 
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 /// returns list of parameters
122 
124 {
125  return new RooArgSet(*(fParameterPointsInInterval->get()) );
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 
131 {
132  if (parameterPoint.getSize() != fParameterPointsInInterval->get()->getSize() ) {
133  std::cout << "PointSetInterval: argument size is wrong, parameters don't match: arg=" << parameterPoint
134  << " interval=" << (*fParameterPointsInInterval->get()) << std::endl;
135  return false;
136  }
137  if ( ! parameterPoint.equals( *(fParameterPointsInInterval->get() ) ) ) {
138  std::cout << "PointSetInterval: size is ok, but parameters don't match" << std::endl;
139  return false;
140  }
141  return true;
142 }
143 
144 
145 ////////////////////////////////////////////////////////////////////////////////
146 
148 {
150  Double_t low = 0, high = 0;
151  if( tree ){
152  tree->getRange(param, low, high);
153  return high;
154  }
155  return param.getMax();
156 }
157 
158 ////////////////////////////////////////////////////////////////////////////////
159 
161 {
163  Double_t low = 0, high = 0;
164  if( tree ){
165  tree->getRange(param, low, high);
166  return low;
167  }
168  return param.getMin();
169 }
virtual Double_t getMin(const char *name=0) const
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual Double_t getMax(const char *name=0) const
Bool_t CheckParameters(const RooArgSet &) const
return a cloned list with the parameter of interest
virtual const RooArgSet * get() const
Definition: RooAbsData.h:77
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
virtual RooArgSet * GetParameters() const
Method to return lower limit on a given parameter Double_t LowerLimit(RooRealVar& param) ; // could p...
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically named contents.
virtual ~PointSetInterval()
destructor
STL namespace.
Bool_t getRange(RooRealVar &var, Double_t &lowest, Double_t &highest, Double_t marginFrac=0, Bool_t symMode=kFALSE) const
Fill Doubles &#39;lowest&#39; and &#39;highest&#39; with the lowest and highest value of observable &#39;var&#39; in this dat...
RooDataSet is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
virtual Double_t weight() const
Definition: RooDataHist.h:96
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
Double_t LowerLimit(RooRealVar &param)
return lower limit on a given parameter
Int_t getSize() const
RooAbsData * fParameterPointsInInterval
confidence level
TObject * Next()
Definition: TCollection.h:153
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event &#39;index&#39;.
Double_t UpperLimit(RooRealVar &param)
return upper limit on a given parameter
ConfInterval is an interface class for a generic interval in the RooStats framework.
Definition: ConfInterval.h:35
Namespace for the RooStats classes.
Definition: Asimov.h:20
PointSetInterval is a concrete implementation of the ConfInterval interface.
#define ClassImp(name)
Definition: Rtypes.h:336
double Double_t
Definition: RtypesCore.h:55
PointSetInterval(const char *name=0)
default constructors
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
Definition: RooArgSet.cxx:527
Definition: tree.py:1
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:269
virtual Bool_t IsInInterval(const RooArgSet &) const
check if parameter is in the interval