Logo ROOT   6.08/07
Reference Guide
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 
21 /**
22  \class SimpleInterval
23  \ingroup Roostats
24 
25  SimpleInterval is a concrete implementation of the ConfInterval interface.
26  It implements simple 1-dimensional intervals in a range [a,b].
27  In addition, you can ask it for the upper- or lower-bound.
28 */
29 
30 
31 #ifndef RooStats_SimpleInterval
33 #endif
34 #include "RooAbsReal.h"
35 #include "RooRealVar.h"
36 #include <string>
37 
38 
39 using namespace std;
40 
42 
43 using namespace RooStats;
44 
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// Default constructor
48 
49 SimpleInterval::SimpleInterval(const char* name) :
50  ConfInterval(name), fLowerLimit(0), fUpperLimit(0), fConfidenceLevel(0)
51 {
52 }
53 
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 ///fParameters.add( other.fParameters );
57 
59  : ConfInterval(name)
60  , fParameters(other.fParameters)
61  , fLowerLimit(other.fLowerLimit)
62  , fUpperLimit(other.fUpperLimit)
64 {
65 }
66 
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 
72 {
73  if (&other==this) {
74  return *this ;
75  }
76 
78 
79  //fParameters = other.fParameters;
82  fLowerLimit = other.fLowerLimit;
83  fUpperLimit = other.fUpperLimit;
85 
86  return *this ;
87 }
88 
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 /// Alternate constructor
92 
93 SimpleInterval::SimpleInterval(const char* name, const RooRealVar & var, Double_t lower, Double_t upper, Double_t cl) :
94  ConfInterval(name), fParameters(var), fLowerLimit(lower), fUpperLimit(upper), fConfidenceLevel(cl)
95 {
96 }
97 
98 
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 /// Destructor
102 
104 {
105 }
106 
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 
110 Bool_t SimpleInterval::IsInInterval(const RooArgSet &parameterPoint) const
111 {
112  // Method to determine if a parameter point is in the interval
113  if( !this->CheckParameters(parameterPoint) )
114  return false;
115 
116  if(parameterPoint.getSize() != 1 )
117  return false;
118 
119  RooAbsReal* point = dynamic_cast<RooAbsReal*> (parameterPoint.first());
120  if (point == 0)
121  return false;
122 
123  if ( point->getVal() > fUpperLimit || point->getVal() < fLowerLimit)
124  return false;
125 
126 
127  return true;
128 }
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// return cloned list of parameters
132 
134 {
135  return new RooArgSet(fParameters);
136 }
137 
138 ////////////////////////////////////////////////////////////////////////////////
139 
141 {
142  if (parameterPoint.getSize() != fParameters.getSize() ) {
143  std::cout << "size is wrong, parameters don't match" << std::endl;
144  return false;
145  }
146  if ( ! parameterPoint.equals( fParameters ) ) {
147  std::cout << "size is ok, but parameters don't match" << std::endl;
148  return false;
149  }
150  return true;
151 }
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:86
SimpleInterval(const char *name=0)
Default constructor.
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
bool Bool_t
Definition: RtypesCore.h:59
Bool_t equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically named contents.
STL namespace.
SimpleInterval & operator=(const SimpleInterval &other)
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
virtual RooArgSet * GetParameters() const
return cloned list of parameters
Int_t getSize() const
RooAbsArg * first() const
virtual ~SimpleInterval()
Destructor.
ConfInterval & operator=(const ConfInterval &other)
operator=
Definition: ConfInterval.h:55
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
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
virtual Bool_t IsInInterval(const RooArgSet &) const
check if given point is in the interval
Bool_t CheckParameters(const RooArgSet &) const
check if parameters are correct (i.e. they are the POI of this interval)
char name[80]
Definition: TGX11.cxx:109