SimpleInterval.cxx

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: SimpleInterval.cxx 31276 2009-11-18 15:06:42Z moneta $
00002 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
00003 /*************************************************************************
00004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 /*****************************************************************************
00012  * Project: RooStats
00013  * Package: RooFit/RooStats  
00014  * @(#)root/roofit/roostats:$Id: SimpleInterval.cxx 31276 2009-11-18 15:06:42Z moneta $
00015  * Authors:                     
00016  *   Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
00017  *
00018  *****************************************************************************/
00019 
00020 
00021 
00022 //_________________________________________________________
00023 //
00024 // BEGIN_HTML
00025 // SimpleInterval is a concrete implementation of the ConfInterval interface.  
00026 // It implements simple 1-dimensional intervals in a range [a,b].
00027 // In addition, you can ask it for the upper- or lower-bound.
00028 // END_HTML
00029 //
00030 //
00031 
00032 #ifndef RooStats_SimpleInterval
00033 #include "RooStats/SimpleInterval.h"
00034 #endif
00035 #include "RooAbsReal.h"
00036 #include "RooRealVar.h"
00037 #include <string>
00038 
00039 
00040 ClassImp(RooStats::SimpleInterval) ;
00041 
00042 using namespace RooStats;
00043 
00044 
00045 //____________________________________________________________________
00046 SimpleInterval::SimpleInterval(const char* name) :
00047    ConfInterval(name),  fLowerLimit(0), fUpperLimit(0), fConfidenceLevel(0)
00048 {
00049    // Default constructor
00050 }
00051 
00052 //____________________________________________________________________
00053 SimpleInterval::SimpleInterval(const char* name, const RooRealVar & var, Double_t lower, Double_t upper, Double_t cl) :
00054    ConfInterval(name), fParameters(var), fLowerLimit(lower), fUpperLimit(upper), fConfidenceLevel(cl)
00055 {
00056    // Alternate constructor
00057 }
00058 
00059 
00060 
00061 //____________________________________________________________________
00062 SimpleInterval::~SimpleInterval()
00063 {
00064    // Destructor
00065 }
00066 
00067 
00068 //____________________________________________________________________
00069 Bool_t SimpleInterval::IsInInterval(const RooArgSet &parameterPoint) const 
00070 {  
00071 
00072    // Method to determine if a parameter point is in the interval
00073    if( !this->CheckParameters(parameterPoint) )
00074       return false; 
00075 
00076    if(parameterPoint.getSize() != 1 )
00077       return false;
00078 
00079    RooAbsReal* point = dynamic_cast<RooAbsReal*> (parameterPoint.first());
00080    if (point == 0)
00081       return false;
00082 
00083    if ( point->getVal() > fUpperLimit || point->getVal() < fUpperLimit)
00084       return false;
00085 
00086 
00087    return true;
00088 }
00089 
00090 //____________________________________________________________________
00091 RooArgSet* SimpleInterval::GetParameters() const
00092 {  
00093    // return cloned list of parameters
00094    return new RooArgSet(fParameters);
00095 }
00096 
00097 //____________________________________________________________________
00098 Bool_t SimpleInterval::CheckParameters(const RooArgSet &parameterPoint) const
00099 {  
00100 
00101    if (parameterPoint.getSize() != fParameters.getSize() ) {
00102       std::cout << "size is wrong, parameters don't match" << std::endl;
00103       return false;
00104    }
00105    if ( ! parameterPoint.equals( fParameters ) ) {
00106       std::cout << "size is ok, but parameters don't match" << std::endl;
00107       return false;
00108    }
00109    return true;
00110 }

Generated on Tue Jul 5 15:14:36 2011 for ROOT_528-00b_version by  doxygen 1.5.1