Logo ROOT   master
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 /** \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 
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 
55  , fParameters(other.fParameters)
56  , fLowerLimit(other.fLowerLimit)
57  , fUpperLimit(other.fUpperLimit)
58  , fConfidenceLevel(other.fConfidenceLevel)
59 {
60 }
61 
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 
67 {
68  if (&other==this) {
69  return *this ;
70  }
71 
73 
74  //fParameters = other.fParameters;
77  fLowerLimit = other.fLowerLimit;
78  fUpperLimit = other.fUpperLimit;
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 
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 
125 {
126  return new RooArgSet(fParameters);
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 
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 }
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:88
SimpleInterval(const char *name=0)
Default constructor.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
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 variable that can be changed from the outside.
Definition: RooRealVar.h:35
virtual RooArgSet * GetParameters() const
return cloned list of parameters
Int_t getSize() const
RooAbsArg * first() const
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:90
virtual ~SimpleInterval()
Destructor.
ConfInterval & operator=(const ConfInterval &other)
operator=
Definition: ConfInterval.h:46
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:19
#define ClassImp(name)
Definition: Rtypes.h:361
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:60
virtual Bool_t IsInInterval(const RooArgSet &) const
Method to determine if a parameter 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)
SimpleInterval is a concrete implementation of the ConfInterval interface.
char name[80]
Definition: TGX11.cxx:109