40 _gamma(
"gamma",
"gamma",this),
51 if (phfSet.
size()==1) {
53 auto phf = dynamic_cast<RooParamHistFunc*>(phfSet.first()) ;
56 coutE(InputArguments) <<
"RooHistConstraint::ctor(" << GetName()
57 <<
") ERROR: input object must be a RooParamHistFunc" << std::endl ;
58 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
62 for (
int i=0 ; i<phf->_dh.numEntries() ; i++) {
63 const double wi = phf->_dh.weight(i) ;
64 if (wi<threshold && wi != 0.) {
65 const char* vname =
Form(
"%s_nominal_bin_%i",
GetName(),i) ;
66 auto var = std::make_unique<RooRealVar>(vname,vname,0,1.E30);
68 var->setConstant(
true);
70 auto gamma =
static_cast<RooRealVar*
>(phf->_p.at(i));
71 if (var->getVal() > 0.0) {
72 gamma->setConstant(
false);
86 std::vector<RooParamHistFunc*> phvec ;
88 std::string bin0_name ;
89 for (
const auto arg : phfSet) {
93 phvec.push_back(phfComp) ;
95 nbins = phfComp->_p.size() ;
96 bin0_name = phfComp->_p.at(0)->GetName() ;
97 gammaSet.
add(phfComp->_p) ;
99 if (
int(phfComp->_p.size())!=nbins) {
100 coutE(InputArguments) <<
"RooHistConstraint::ctor(" << GetName()
101 <<
") ERROR: incongruent input arguments: all input RooParamHistFuncs should have same #bins" << std::endl ;
102 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
104 if (bin0_name != phfComp->_p.at(0)->GetName()) {
105 coutE(InputArguments) <<
"RooHistConstraint::ctor(" << GetName()
106 <<
") ERROR: incongruent input arguments: all input RooParamHistFuncs should have the same bin parameters.\n"
107 <<
"Previously found " << bin0_name <<
", now found " << phfComp->_p.at(0)->GetName() <<
".\n"
108 <<
"Check that the right RooParamHistFuncs have been passed to this RooHistConstraint." << std::endl;
109 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
114 coutW(InputArguments) <<
"RooHistConstraint::ctor(" << GetName()
115 <<
") WARNING: ignoring input argument " << arg->GetName() <<
" which is not of type RooParamHistFunc" << std::endl;
119 _gamma.
add(gammaSet) ;
122 for (
int i=0 ; i<nbins ; i++) {
125 for (
const auto phfunc : phvec) {
126 sumVal += phfunc->getNominal(i);
129 if (sumVal<threshold && sumVal != 0.) {
131 const char* vname =
Form(
"%s_nominal_bin_%i",GetName(),i) ;
132 auto var = std::make_unique<RooRealVar>(vname,vname,0,1000);
135 for(
auto const& elem : phvec) {
136 sumVal2 += elem->getNominal(i) ;
138 var->setVal(sumVal2) ;
139 var->setConstant(
true) ;
141 vname =
Form(
"%s_nominal_error_bin_%i",GetName(),i) ;
151 _nominal.addOwned(std::move(var));
154 (
static_cast<RooRealVar*
>(_gamma.at(i)))->setConstant(
false) ;