86 std::span<const double> relSigmas,
double minSigma,
92 if (relSigmas.size() != paramSet.
size()) {
93 std::cout <<
"Error: In createGammaConstraints, encountered bad number of relative sigmas" << std::endl;
94 std::cout <<
"Given vector with " << relSigmas.size() <<
" bins,"
95 <<
" but require exactly " << paramSet.
size() << std::endl;
101 for (std::size_t
i = 0;
i < paramSet.
size(); ++
i) {
106 <<
"Creating constraint for: " << gamma.GetName() <<
". Type of constraint: " <<
type << std::endl;
108 const double sigmaRel = relSigmas[
i];
114 <<
"Not creating constraint term for " << gamma.GetName() <<
" because sigma = " << sigmaRel
116 <<
" (bin number = " <<
i <<
")" << std::endl;
121 std::string constrName = std::string(gamma.GetName()) +
"_constraint";
122 std::string nomName = std::string(
"nom_") + gamma.GetName();
129 std::string sigmaName = std::string(gamma.GetName()) +
"_sigma";
130 auto constrSigma = std::make_unique<RooConstVar>(sigmaName.c_str(), sigmaName.c_str(), sigmaRel);
133 auto constrNom = std::make_unique<RooRealVar>(nomName.c_str(), nomName.c_str(), 1.0, 0, 10);
134 constrNom->setConstant(
true);
137 auto term = std::make_unique<RooGaussian>(constrName.c_str(), constrName.c_str(), *constrNom, gamma, *constrSigma);
139 out.globalObservables.push_back(constrNom.get());
141 term->addOwnedComponents(std::move(constrSigma));
142 term->addOwnedComponents(std::move(constrNom));
144 out.constraints.emplace_back(std::move(term));
148 const double tau = 1. / (sigmaRel * sigmaRel);
151 auto constrNom = std::make_unique<RooRealVar>(nomName.c_str(), nomName.c_str(), tau);
152 constrNom->setMin(0);
153 constrNom->setConstant(
true);
156 std::string scalingName = std::string(gamma.GetName()) +
"_tau";
157 auto poissonScaling = std::make_unique<RooConstVar>(scalingName.c_str(), scalingName.c_str(), tau);
160 std::string poisMeanName = std::string(gamma.GetName()) +
"_poisMean";
161 auto constrMean = std::make_unique<RooProduct>(poisMeanName.c_str(), poisMeanName.c_str(), gamma, *poissonScaling);
164 auto term = std::make_unique<RooPoisson>(constrName.c_str(), constrName.c_str(), *constrNom, *constrMean);
165 term->setNoRounding(
true);
167 out.globalObservables.push_back(constrNom.get());
169 term->addOwnedComponents(std::move(poissonScaling));
170 term->addOwnedComponents(std::move(constrMean));
171 term->addOwnedComponents(std::move(constrNom));
173 out.constraints.emplace_back(std::move(term));
176 std::cout <<
"Error: Did not recognize Stat Error constraint term type: " <<
type
177 <<
" for : " << gamma.GetName() << std::endl;