#include "RooRealVar.h"
#include "RooStats/HistFactory/HistFactoryException.h"
#include "RooStats/HistFactory/Asimov.h"
void RooStats::HistFactory::Asimov::ConfigureWorkspace(RooWorkspace* wspace) {
for( std::map< std::string, double >::iterator itr = fParamValsToSet.begin();
itr != fParamValsToSet.end(); ++itr) {
std::string param = itr->first;
double val = itr->second;
RooRealVar* var = wspace->var(param.c_str());
if( !var ) {
std::cout << "Error: Trying to set variable: " << var
<< " to a specific value in creation of asimov dataset: " << fName
<< " but this variable doesn't appear to exist in the workspace"
<< std::endl;
throw hf_exc();
}
double inRange = var->inRange(val, NULL);
if( !inRange ) {
std::cout << "Error: Attempting to set variable: " << var
<< " to value: " << val << ", however it appears"
<< " that this is not withn the variable's range: "
<< "[" << var->getMin() << ", " << var->getMax() << "]"
<< std::endl;
throw hf_exc();
}
std::cout << "Configuring Asimov Dataset: Setting " << param
<< " = " << val << std::endl;
var->setVal( val );
}
for( std::map< std::string, bool >::iterator itr = fParamsToFix.begin();
itr != fParamsToFix.end(); ++itr) {
std::string param = itr->first;
bool isConstant = itr->second;
RooRealVar* var = wspace->var(param.c_str());
if( !var ) {
std::cout << "Error: Trying to set variable: " << var
<< " constant in creation of asimov dataset: " << fName
<< " but this variable doesn't appear to exist in the workspace"
<< std::endl;
throw hf_exc();
}
std::cout << "Configuring Asimov Dataset: Setting " << param
<< " to constant " << std::endl;
var->setConstant( isConstant );
}
return;
}