41 _gamma(
"gamma",
"gamma",this),
52 if (phfSet.
size()==1) {
54 auto phf = dynamic_cast<RooParamHistFunc*>(phfSet.first()) ;
57 coutE(InputArguments) <<
"RooHistConstraint::ctor(" << GetName()
58 <<
") ERROR: input object must be a RooParamHistFunc" << std::endl ;
59 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
63 for (
int i=0 ;
i<phf->_dh.numEntries() ;
i++) {
65 if (phf->_dh.weight()<threshold && phf->_dh.weight() != 0.) {
66 const char* vname =
Form(
"%s_nominal_bin_%i",
GetName(),
i) ;
67 auto var = std::make_unique<RooRealVar>(vname,vname,0,1.E30);
68 var->setVal(phf->_dh.weight()) ;
69 var->setConstant(
true);
71 auto gamma =
static_cast<RooRealVar*
>(phf->_p.at(
i));
72 if (var->getVal() > 0.0) {
73 gamma->setConstant(
false);
87 std::vector<RooParamHistFunc*> phvec ;
89 std::string bin0_name ;
90 for (
const auto arg : phfSet) {
94 phvec.push_back(phfComp) ;
96 nbins = phfComp->_p.size() ;
97 bin0_name = phfComp->_p.at(0)->GetName() ;
98 gammaSet.
add(phfComp->_p) ;
100 if (
int(phfComp->_p.size())!=nbins) {
101 coutE(InputArguments) <<
"RooHistConstraint::ctor(" << GetName()
102 <<
") ERROR: incongruent input arguments: all input RooParamHistFuncs should have same #bins" << std::endl ;
103 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
105 if (bin0_name != phfComp->_p.at(0)->GetName()) {
106 coutE(InputArguments) <<
"RooHistConstraint::ctor(" << GetName()
107 <<
") ERROR: incongruent input arguments: all input RooParamHistFuncs should have the same bin parameters.\n"
108 <<
"Previously found " << bin0_name <<
", now found " << phfComp->_p.at(0)->GetName() <<
".\n"
109 <<
"Check that the right RooParamHistFuncs have been passed to this RooHistConstraint." << std::endl;
110 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
115 coutW(InputArguments) <<
"RooHistConstraint::ctor(" << GetName()
116 <<
") WARNING: ignoring input argument " << arg->GetName() <<
" which is not of type RooParamHistFunc" << std::endl;
120 _gamma.
add(gammaSet) ;
123 for (
int i=0 ;
i<nbins ;
i++) {
126 for (
const auto phfunc : phvec) {
127 sumVal += phfunc->getNominal(
i);
130 if (sumVal<threshold && sumVal != 0.) {
132 const char* vname =
Form(
"%s_nominal_bin_%i",GetName(),
i) ;
133 auto var = std::make_unique<RooRealVar>(vname,vname,0,1000);
136 for(
auto const& elem : phvec) {
137 sumVal2 += elem->getNominal(
i) ;
139 var->setVal(sumVal2) ;
140 var->setConstant(
true) ;
142 vname =
Form(
"%s_nominal_error_bin_%i",GetName(),
i) ;
152 _nominal.addOwned(std::move(var));
155 (
static_cast<RooRealVar*
>(_gamma.at(
i)))->setConstant(
false) ;