// PointSetInterval is a concrete implementation of the ConfInterval interface.
// It implements simple general purpose interval of arbitrary dimensions and shape.
// It does not assume the interval is connected.
// It uses either a RooDataSet (eg. a list of parameter points in the interval) or
// a RooDataHist (eg. a Histogram-like object for small regions of the parameter space) to
// store the interval.
// END_HTML
#ifndef RooStats_PointSetInterval
#include "RooStats/PointSetInterval.h"
#endif
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooDataHist.h"
ClassImp(RooStats::PointSetInterval) ;
using namespace RooStats;
PointSetInterval::PointSetInterval(const char* name) :
ConfInterval(name), fParameterPointsInInterval(0)
{
}
PointSetInterval::PointSetInterval(const char* name, RooAbsData& data) :
ConfInterval(name), fParameterPointsInInterval(&data)
{
}
PointSetInterval::~PointSetInterval()
{
}
Bool_t PointSetInterval::IsInInterval(const RooArgSet ¶meterPoint) const
{
RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
RooDataHist* hist = dynamic_cast<RooDataHist*>( fParameterPointsInInterval );
if( !this->CheckParameters(parameterPoint) ){
return false;
}
if( hist ) {
if ( hist->weight( parameterPoint , 0 ) > 0 )
return true;
else
return false;
}
else if( tree ){
const RooArgSet* thisPoint = 0;
for(Int_t i = 0; i<tree->numEntries(); ++i){
thisPoint = tree->get(i);
bool samePoint = true;
TIter it = parameterPoint.createIterator();
RooRealVar *myarg;
while ( samePoint && (myarg = (RooRealVar *)it.Next())) {
if(!myarg) continue;
if(myarg->getVal() != thisPoint->getRealValue(myarg->GetName()))
samePoint = false;
}
if(samePoint)
return true;
}
return false;
}
else {
std::cout << "dataset is not initialized properly" << std::endl;
}
return true;
}
RooArgSet* PointSetInterval::GetParameters() const
{
return new RooArgSet(*(fParameterPointsInInterval->get()) );
}
Bool_t PointSetInterval::CheckParameters(const RooArgSet ¶meterPoint) const
{
if (parameterPoint.getSize() != fParameterPointsInInterval->get()->getSize() ) {
std::cout << "PointSetInterval: argument size is wrong, parameters don't match: arg=" << parameterPoint
<< " interval=" << (*fParameterPointsInInterval->get()) << std::endl;
return false;
}
if ( ! parameterPoint.equals( *(fParameterPointsInInterval->get() ) ) ) {
std::cout << "PointSetInterval: size is ok, but parameters don't match" << std::endl;
return false;
}
return true;
}
Double_t PointSetInterval::UpperLimit(RooRealVar& param )
{
RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
Double_t low, high;
if( tree ){
tree->getRange(param, low, high);
return high;
}
return param.getMax();
}
Double_t PointSetInterval::LowerLimit(RooRealVar& param )
{
RooDataSet* tree = dynamic_cast<RooDataSet*>( fParameterPointsInInterval );
Double_t low, high;
if( tree ){
tree->getRange(param, low, high);
return low;
}
return param.getMin();
}