Logo ROOT   6.08/07
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 
22 
23 #ifndef RooStats_PointSetInterval
25 #endif
26 
27 #include "RooRealVar.h"
28 #include "RooDataSet.h"
29 #include "RooDataHist.h"
30 
31 using namespace std;
32 
34 
35 using namespace RooStats;
36 
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Default constructor
40 
41 PointSetInterval::PointSetInterval(const char* name) :
42  ConfInterval(name), fConfidenceLevel(0.95), fParameterPointsInInterval(0)
43 {
44 }
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// Alternate constructor passing the dataset
48 
51 {
52 }
53 
54 
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Destructor
58 
60 {
61 }
62 
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Method to determine if a parameter point is in the interval
66 
67 Bool_t PointSetInterval::IsInInterval(const RooArgSet &parameterPoint) const
68 {
70  RooDataHist* hist = dynamic_cast<RooDataHist*>( fParameterPointsInInterval );
71 
72  if( !this->CheckParameters(parameterPoint) ){
73  // std::cout << "problem with parameters" << std::endl;
74  return false;
75  }
76 
77  if( hist ) {
78  if ( hist->weight( parameterPoint , 0 ) > 0 ) // positive value indicates point is in interval
79  return true;
80  else
81  return false;
82  }
83  else if( tree ){
84  const RooArgSet* thisPoint = 0;
85  // need to check if the parameter point is the same as any point in tree.
86  for(Int_t i = 0; i<tree->numEntries(); ++i){
87  // This method is not complete
88  thisPoint = tree->get(i);
89  bool samePoint = true;
90  TIter it = parameterPoint.createIterator();
91  RooRealVar *myarg;
92  while ( samePoint && (myarg = (RooRealVar *)it.Next())) {
93  if(myarg->getVal() != thisPoint->getRealValue(myarg->GetName()))
94  samePoint = false;
95  }
96  if(samePoint)
97  return true;
98 
99  // delete thisPoint;
100  }
101  return false; // didn't find a good point
102  }
103  else {
104  std::cout << "dataset is not initialized properly" << std::endl;
105  }
106 
107  return true;
108 
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// returns list of parameters
113 
115 {
116  return new RooArgSet(*(fParameterPointsInInterval->get()) );
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 
122 {
123  if (parameterPoint.getSize() != fParameterPointsInInterval->get()->getSize() ) {
124  std::cout << "PointSetInterval: argument size is wrong, parameters don't match: arg=" << parameterPoint
125  << " interval=" << (*fParameterPointsInInterval->get()) << std::endl;
126  return false;
127  }
128  if ( ! parameterPoint.equals( *(fParameterPointsInInterval->get() ) ) ) {
129  std::cout << "PointSetInterval: size is ok, but parameters don't match" << std::endl;
130  return false;
131  }
132  return true;
133 }
134 
135 
136 ////////////////////////////////////////////////////////////////////////////////
137 
139 {
141  Double_t low = 0, high = 0;
142  if( tree ){
143  tree->getRange(param, low, high);
144  return high;
145  }
146  return param.getMax();
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 
152 {
154  Double_t low = 0, high = 0;
155  if( tree ){
156  tree->getRange(param, low, high);
157  return low;
158  }
159  return param.getMin();
160 }
virtual Double_t getMin(const char *name=0) const
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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:37
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:158
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:44
Namespace for the RooStats classes.
Definition: Asimov.h:20
PointSetInterval is a concrete implementation of the ConfInterval interface.
#define ClassImp(name)
Definition: Rtypes.h:279
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
char name[80]
Definition: TGX11.cxx:109
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:269
virtual Bool_t IsInInterval(const RooArgSet &) const
check if parameter is in the interval