Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
SimpleInterval.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  * Authors:
16  * Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
17  *
18  *****************************************************************************/
19 
20 /** \class RooStats::SimpleInterval
21  \ingroup Roostats
22 
23 SimpleInterval is a concrete implementation of the ConfInterval interface.
24 It implements simple 1-dimensional intervals in a range [a,b].
25 In addition, you can ask it for the upper- or lower-bound.
26 */
27 
29 #include "RooAbsReal.h"
30 #include "RooRealVar.h"
31 #include <string>
32 
33 
34 using namespace std;
35 
36 ClassImp(RooStats::SimpleInterval); ;
37 
38 using namespace RooStats;
39 
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Default constructor
43 
44 SimpleInterval::SimpleInterval(const char* name) :
45  ConfInterval(name), fLowerLimit(0), fUpperLimit(0), fConfidenceLevel(0)
46 {
47 }
48 
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 ///fParameters.add( other.fParameters );
52 
53 SimpleInterval::SimpleInterval(const SimpleInterval& other, const char* name)
54  : ConfInterval(name)
55  , fParameters(other.fParameters)
56  , fLowerLimit(other.fLowerLimit)
57  , fUpperLimit(other.fUpperLimit)
58  , fConfidenceLevel(other.fConfidenceLevel)
59 {
60 }
61 
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 
65 SimpleInterval&
66 SimpleInterval::operator=(const SimpleInterval& other)
67 {
68  if (&other==this) {
69  return *this ;
70  }
71 
72  ConfInterval::operator = (other);
73 
74  //fParameters = other.fParameters;
75  fParameters.removeAll();
76  fParameters.add(other.fParameters);
77  fLowerLimit = other.fLowerLimit;
78  fUpperLimit = other.fUpperLimit;
79  fConfidenceLevel = other.fConfidenceLevel;
80 
81  return *this ;
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Alternate constructor
86 
87 SimpleInterval::SimpleInterval(const char* name, const RooRealVar & var, Double_t lower, Double_t upper, Double_t cl) :
88  ConfInterval(name), fParameters(var), fLowerLimit(lower), fUpperLimit(upper), fConfidenceLevel(cl)
89 {
90 }
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 /// Destructor
94 
95 SimpleInterval::~SimpleInterval()
96 {
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Method to determine if a parameter point is in the interval
101 
102 Bool_t SimpleInterval::IsInInterval(const RooArgSet &parameterPoint) const
103 {
104  if( !this->CheckParameters(parameterPoint) )
105  return false;
106 
107  if(parameterPoint.getSize() != 1 )
108  return false;
109 
110  RooAbsReal* point = dynamic_cast<RooAbsReal*> (parameterPoint.first());
111  if (point == 0)
112  return false;
113 
114  if ( point->getVal() > fUpperLimit || point->getVal() < fLowerLimit)
115  return false;
116 
117 
118  return true;
119 }
120 
121 ////////////////////////////////////////////////////////////////////////////////
122 /// return cloned list of parameters
123 
124 RooArgSet* SimpleInterval::GetParameters() const
125 {
126  return new RooArgSet(fParameters);
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 
131 Bool_t SimpleInterval::CheckParameters(const RooArgSet &parameterPoint) const
132 {
133  if (parameterPoint.getSize() != fParameters.getSize() ) {
134  std::cout << "size is wrong, parameters don't match" << std::endl;
135  return false;
136  }
137  if ( ! parameterPoint.equals( fParameters ) ) {
138  std::cout << "size is ok, but parameters don't match" << std::endl;
139  return false;
140  }
141  return true;
142 }