69double round_prec(
double d,
int nSig)
73 int ndigits = std::floor(std::log10(std::abs(
d))) + 1 - nSig;
74 double sf = std::pow(10, ndigits);
75 if (std::abs(
d / sf) < 2)
77 return sf * std::round(
d / sf);
80std::string interpolationString(
const Interpolation &interpolation)
83 ss << R
"({"type":")" << toString(interpolation.type) << R"(","in":")" << toString(interpolation.in) << R"(","out":)";
84 if (interpolation.
out) {
93const char *interpolationClassName(InterpolationClass interpolationClass)
95 return interpolationClass == InterpolationClass::Piecewise ?
"PiecewiseInterpolation" :
"FlexibleInterpVar";
101 return *interpolation;
104 std::to_string(code));
108 const std::string &context)
114 interpolationClassName(interpolationClass));
118std::vector<Interpolation>
119toInterpolations(std::vector<int>
const &codes, InterpolationClass interpolationClass, std::string
const &context)
121 std::vector<Interpolation> out;
122 out.reserve(codes.size());
123 for (std::size_t i = 0; i < codes.size(); ++i) {
125 interpolationFromCode(codes[i], interpolationClass, context +
" at parameter index " + std::to_string(i)));
130std::vector<int> toCodes(std::vector<Interpolation>
const &interpolations, InterpolationClass interpolationClass,
131 std::string
const &context)
133 std::vector<int> out;
134 out.reserve(interpolations.size());
135 for (std::size_t i = 0; i < interpolations.size(); ++i) {
137 context +
" component 'interpolations' at index " + std::to_string(i)));
145 for (
auto &diagnostic : diagnostics) {
146 diagnostic.path =
name + (diagnostic.path.empty() ?
"" :
"." + diagnostic.path);
151int interpolationCode(std::optional<Interpolation>
const &interpolation,
152 std::optional<Interpolation>
const &defaultInterpolation, InterpolationClass interpolationClass,
153 std::string
const &context)
159 if (!defaultInterpolation) {
165void erasePrefix(std::string &str, std::string_view prefix)
168 str.erase(0, prefix.size());
172bool eraseSuffix(std::string &str, std::string_view suffix)
175 str.erase(str.size() - suffix.size());
183void sortByName(Coll &coll)
185 std::sort(coll.begin(), coll.end(), [](
auto &
l,
auto &
r) { return l.name < r.name; });
191 for (
const auto &client :
gamma->clients()) {
192 if (
auto casted =
dynamic_cast<T *
>(client)) {
195 T *
c = findClient<T>(client);
204T *findAmong(
RooAbsArg *
g, std::vector<RooAbsPdf *>
const &pdfs)
207 if (
auto casted =
dynamic_cast<T *
>(pdf); casted && casted->dependsOn(*
g)) {
221 if (
auto *constraint = findAmong<RooPoisson>(
g, channelConstraints))
223 if (
auto *constraint = findAmong<RooGaussian>(
g, channelConstraints))
225 if (
auto *constraint = findAmong<RooLognormal>(
g, channelConstraints))
227 if (
auto *constraint = findClient<RooPoisson>(
g))
229 if (
auto *constraint = findClient<RooGaussian>(
g))
231 return findClient<RooLognormal>(
g);
234inline std::string defaultGammaName(std::string
const &sysname, std::size_t i)
236 return "gamma_" + sysname +
"_bin_" + std::to_string(i);
239RooRealVar &createNominal(
RooWorkspace &ws, std::string
const &parname,
double val,
double min,
double max)
241 RooRealVar &nom = getOrCreate<RooRealVar>(ws,
"nom_" + parname, val, min, max);
248std::string constraintName(std::string
const ¶mName)
250 return paramName +
"Constraint";
256 std::vector<RooAbsPdf *> matches;
258 if (pdf->dependsOn(param)) {
259 matches.push_back(pdf);
262 if (matches.size() == 1) {
263 return *matches.front();
265 const std::string
what =
"the array distribution '" + std::string(array.
GetName()) +
266 "' named as the constraint of '" + param.
GetName() +
"' (" + context +
") has ";
267 if (matches.empty()) {
271 " components that depend on this parameter, but a parameter can only be constrained "
280 std::string
const &context)
286 auto const *array =
dynamic_cast<RooProdPdf const *
>(constraint);
290 return &arrayComponentFor(*array, param, context);
296 double max, std::string
const &
modifier)
301 return getOrCreate<RooRealVar>(ws,
name, val, min, max);
307 "' is neither a variable nor a constant");
310void setErrorIfVariable(
RooAbsReal ¶m,
double error)
312 if (
auto *var =
dynamic_cast<RooRealVar *
>(¶m)) {
313 var->setError(error);
320 const char *modifierType, std::string
const &
modifier, std::string
const &sample,
327 if (
type != HS3::ConstraintType::Gauss) {
330 "' is a known constraint type, but it cannot be resolved in this "
334 setErrorIfVariable(param, 1.0);
335 const std::string
name = constraintName(param.
GetName());
340 RooAbsPdf *pdf = findNamedConstraint(tool, constraintPdf.pdf.name, param,
341 std::string(
"the ") + modifierType +
" modifier '" +
modifier +
342 "' of sample '" + sample +
"'");
345 constraintPdf.pdf.name +
"' for modifier '" +
modifier +
"'");
347 if (
auto gauss =
dynamic_cast<RooGaussian *
>(pdf)) {
348 setErrorIfVariable(param, gauss->getSigma().getVal());
350 constraints.
add(*pdf);
360 const char *modifierType, std::string
const &
modifier, std::string
const &sample,
363 auto const *pdf = std::get_if<HS3::ConstraintPdf>(&constraint);
364 if (pdf && pdf->legacyName) {
367 addConstraint(tool, constraint, param, 0.0, modifierType,
modifier, sample, constraints);
384 if (
auto const *tau =
dynamic_cast<RooConstVar const *
>(arg)) {
390 if (
auto const *real =
dynamic_cast<RooAbsReal const *
>(arg)) {
391 if (real->isConstant() ||
endsWith(std::string(real->GetName()),
"_tau")) {
392 return real->getVal();
404std::optional<double> gammaRelUncertainty(
RooAbsPdf const &constraint,
RooAbsArg const &gamma)
406 if (
auto gauss =
dynamic_cast<RooGaussian const *
>(&constraint)) {
407 return gauss->getSigma().getVal();
409 if (
auto poisson =
dynamic_cast<RooPoisson const *
>(&constraint)) {
410 if (
auto tau = findPoissonTau(*poisson, gamma)) {
411 return 1. / std::sqrt(*tau);
422void configureGammasWithConstraints(
RooArgList const &gammas, std::vector<double>
const &relSigmas,
423 std::vector<RooAbsPdf *>
const &constraintPdfs,
double minSigma)
426 std::vector<double> constrainedSigmas;
427 for (std::size_t i = 0; i < gammas.
size(); ++i) {
429 if (!constraintPdfs[i] || !gamma) {
432 std::optional<double> relSigma = !relSigmas.empty() && relSigmas[i] > 0.
433 ? std::make_optional(relSigmas[i])
434 : gammaRelUncertainty(*constraintPdfs[i], *
gamma);
439 if (relSigmas.empty()) {
440 gamma->setError(*relSigma);
442 constrainedGammas.
add(*gamma);
443 constrainedSigmas.push_back(*relSigma);
452 std::vector<HS3::ParameterRef>
const &parnames, std::vector<double>
const &vals,
454 double gammaMax,
double minSigma, std::size_t nBins, std::string
const &context)
460 for (std::size_t i = 0; i < nBins; ++i) {
461 const std::string
name = parnames.empty() ? defaultGammaName(sysname, i) : parnames[i].
name;
463 gammas.
add(*existing);
477 bool same = existingPHF && existingPHF->
paramList().
size() == gammasInTH1Order.
size();
478 for (std::size_t i = 0; same && i < gammasInTH1Order.
size(); ++i) {
479 same = &existingPHF->paramList()[i] == &gammasInTH1Order[i];
483 "of this name in the channel");
491 constraints.
add(*ws.
pdf(term->GetName()));
495 if (
auto const *pdfs = std::get_if<HS3::GammaConstraintPdfs>(&constraint)) {
498 std::vector<RooAbsPdf *> constraintPdfs;
499 for (std::size_t i = 0; i < pdfs->pdfs.size(); ++i) {
500 auto const &pdfName = pdfs->pdfs[i];
503 pdf = findNamedConstraint(tool, pdfName->name, gammas[i], context);
506 "' for modifier '" + sysname +
"'");
508 constraints.
add(*pdf);
510 constraintPdfs.push_back(pdf);
512 configureGammasWithConstraints(gammas, vals, constraintPdfs, minSigma);
526 if (
auto *var =
dynamic_cast<RooRealVar *
>(gamma)) {
527 var->setConstant(
true);
535 case HS3::ConstraintType::LogNormal:
537 "' for the gamma parameters of '" + sysname +
538 "', supported are \"Poisson\" and \"Gauss\"");
551 if (
auto relSigma = gammaRelUncertainty(constraint, gamma)) {
556 "': only RooGaussian and RooPoisson with mean gamma * tau are supported for the "
557 "relative uncertainties of gammas");
558 return std::numeric_limits<double>::quiet_NaN();
561struct ChannelContext {
573struct SampleElements {
578 std::vector<double> overallLow;
579 std::vector<double> overallHigh;
580 std::vector<int> overallInterp;
585 std::vector<int> histoInterp;
593 std::string
const &sampleName = sample.
name;
594 std::string prefixedName = ctx.fprefix +
"_" + sampleName;
597 auto newName = [&](std::string
name) {
600 ctx.channelName +
"' has the name of an existing object");
608 SampleElements elems;
611 const bool hasStatError = std::any_of(sample.
modifiers.begin(), sample.
modifiers.end(),
612 [](
auto const &
m) { return std::holds_alternative<HS3::StatError>(m); });
614 elems.shapeElems.
add(*ctx.mcStatObject);
617 auto context = [&](
const char *
type, std::string
const &
name) {
618 return std::string(
"interpolation for ") +
type +
" modifier '" +
name +
"' in sample '" + sampleName +
619 "' of channel '" + ctx.channelName +
"'";
629 RooAbsReal ¶m = getOrCreateParameter(tool, mod.parameter.name, 1., -3, 5, mod.name);
635 elems.normElems.
add(param);
637 addConstraint(tool, mod.constraint, param, 1.0,
"normfactor", mod.name, sampleName, ctx.constraints);
640 RooAbsReal ¶m = getOrCreateParameter(tool, mod.parameter.name, 0., -5, 5, mod.name);
641 elems.overallNps.
add(param);
643 InterpolationClass::Flexible, context(
"normsys", mod.name));
645 double high = mod.hi;
651 if (interp == 4 && low <= 0)
652 low = std::numeric_limits<double>::epsilon();
653 if (interp == 4 && high <= 0)
654 high = std::numeric_limits<double>::epsilon();
656 elems.overallLow.push_back(low);
657 elems.overallHigh.push_back(high);
658 elems.overallInterp.push_back(interp);
660 addSysConstraint(tool, mod.constraint, param,
"normsys", mod.name, sampleName, ctx.constraints);
663 RooAbsReal ¶m = getOrCreateParameter(tool, mod.parameter.name, 0., -5, 5, mod.name);
664 elems.histNps.
add(param);
666 const std::string
name = newName(mod.name + suffix + prefixedName);
670 variation.errors ? &*variation.errors : nullptr)));
672 addVariation(elems.histoLo, mod.lo,
"Low_");
673 addVariation(elems.histoHi, mod.hi,
"High_");
675 InterpolationClass::Piecewise,
676 context(
"histosys", mod.name)));
677 addSysConstraint(tool, mod.constraint, param,
"histosys", mod.name, sampleName, ctx.constraints);
680 const bool constrained = std::visit(
684 return std::any_of(constraints.pdfs.
begin(), constraints.pdfs.
end(),
685 [](
auto const &pdf) { return pdf.has_value(); });
690 const std::string funcName =
691 ctx.channelName +
"_" + mod.name + (constrained ?
"_ShapeSys" :
"_shapeFactor");
692 elems.shapeElems.
add(
693 createPHF(tool, funcName, mod.name, mod.parameters, mod.vals, mod.constraint, ctx.constraints,
695 "the shapesys modifier '" + mod.name +
"' of sample '" + sampleName +
"'"));
701 elems.shapeElems.
add(*obj);
703 elems.normElems.
add(*obj);
710 if (!elems.overallNps.
empty()) {
711 std::string interpName = newName(sampleName +
"_" + ctx.channelName +
"_epsilon");
713 interpName, elems.overallNps, 1., elems.overallLow, elems.overallHigh, elems.overallInterp));
715 if (!elems.histNps.
empty()) {
717 elems.histoHi, elems.histNps, elems.histoInterp);
719 elems.shapeElems.
add(
v);
721 elems.shapeElems.
add(hf);
725 if (!elems.normElems.
empty()) {
728 ws.
factory(
"RooConstVar::" + newName(prefixedName +
"_scaleFactors") +
"(1.)");
738 for (
auto const &sample :
dist.samples) {
739 for (
auto const &
modifier : sample.modifiers) {
740 auto const *statError = std::get_if<HS3::StatError>(&
modifier);
744 if (std::holds_alternative<HS3::GammaConstraintPdfs>(statError->constraint)) {
745 return statError->constraint;
747 if (!modifierConstraint && !std::holds_alternative<HS3::Unconstrained>(statError->constraint)) {
748 modifierConstraint = &statError->constraint;
752 return modifierConstraint ? *modifierConstraint :
dist.statError.constraint;
758 for (
auto const &sample :
dist.samples) {
759 for (
auto const &
modifier : sample.modifiers) {
760 auto const *statError = std::get_if<HS3::StatError>(&
modifier);
761 auto const *
type = statError ? std::get_if<HS3::ConstraintType>(&statError->constraint) : nullptr;
762 if (
type && *
type == HS3::ConstraintType::LogNormal) {
764 "' of the staterror modifier in channel '" +
name +
765 "', supported are \"Poisson\" and \"Gauss\"");
783 std::string
const &key()
const override
785 static const std::string keystring =
"interpolation0d";
791 const std::string context =
"FlexibleInterpVar '" + std::string{fip->GetName()} +
"'";
792 const std::size_t nParameters = fip->variables().size();
793 if (fip->low().size() != nParameters || fip->high().size() != nParameters ||
794 fip->interpolationCodes().size() != nParameters) {
802 out.
high = fip->high();
803 out.
low = fip->low();
804 out.
interpolations = toInterpolations(fip->interpolationCodes(), InterpolationClass::Flexible, context);
812 std::string
const &key()
const override
814 static const std::string keystring =
"interpolation";
820 const std::string context =
"PiecewiseInterpolation '" + std::string{pip->
GetName()} +
"'";
828 for (std::size_t i = 0; i < nParameters; ++i) {
849 auto request = [&](std::vector<HS3::NameOrNumber>
const &refs) {
851 for (
auto const &ref : refs) {
852 auto const *
value = std::get_if<double>(&ref);
862 toCodes(in.
interpolations, InterpolationClass::Piecewise,
"PiecewiseInterpolation '" +
name +
"'"));
878 for (std::string
const &var : in.parameters) {
883 toCodes(in.
interpolations, InterpolationClass::Flexible,
"FlexibleInterpVar '" +
name +
"'"));
888std::string stripOuterParens(
const std::string &s)
891 size_t end = s.size();
893 while (start < end && s[start] ==
'(' && s[end - 1] ==
')') {
895 bool balanced =
true;
896 for (
size_t i = start; i < end - 1; ++i) {
899 }
else if (s[i] ==
')') {
902 if (depth == 0 && i < end - 1) {
914 return s.substr(start, end - start);
919bool isBinaryOperator(
const std::string &expr, std::size_t i)
922 while (j > 0 && std::isspace(
static_cast<unsigned char>(expr[j - 1]))) {
928 const char prev = expr[j - 1];
929 if (prev ==
'e' || prev ==
'E') {
931 std::size_t k = j - 1;
932 while (k > 0 && (std::isdigit(
static_cast<unsigned char>(expr[k - 1])) || expr[k - 1] ==
'.')) {
935 const bool startsName = k > 0 && (std::isalpha(
static_cast<unsigned char>(expr[k - 1])) || expr[k - 1] ==
'_');
936 if (k < j - 1 && !startsName && i == j) {
940 return std::isalnum(
static_cast<unsigned char>(prev)) || prev ==
'_' || prev ==
'.' || prev ==
')' || prev ==
']';
943std::vector<std::string> splitTopLevelProduct(
const std::string &expr)
945 std::vector<std::string> parts;
948 bool foundTopLevelStar =
false;
950 for (
size_t i = 0; i < expr.size(); ++i) {
954 }
else if (
c ==
')') {
956 }
else if ((
c ==
'+' ||
c ==
'-') && depth == 0 && isBinaryOperator(expr, i)) {
958 }
else if (
c ==
'*' && depth == 0) {
959 foundTopLevelStar =
true;
960 std::string sub = expr.substr(start, i - start);
961 parts.push_back(stripOuterParens(sub));
966 if (!foundTopLevelStar) {
970 std::string sub = expr.substr(start);
971 parts.push_back(stripOuterParens(sub));
977void collectConstraintTerms(
RooAbsPdf *pdf, std::vector<RooAbsPdf *> &terms)
979 if (
auto prod =
dynamic_cast<RooProdPdf *
>(pdf)) {
981 collectConstraintTerms(factor, terms);
984 terms.push_back(pdf);
989struct FormulaNormSys {
992 double variation = 0.0;
995FormulaNormSys parseOverallModifierFormula(
const std::string &s,
RooFormulaVar *formula,
996 std::vector<RooAbsPdf *>
const &channelConstraints)
998 static const std::regex pattern(
999 R
"(^\s*1(?:\.0)?\s*([\+\-])\s*([a-zA-Z_][a-zA-Z0-9_]*|[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*\*\s*([a-zA-Z_][a-zA-Z0-9_]*|[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*$)");
1003 if (std::regex_match(s, match, pattern)) {
1004 const double sign = match[1].str() ==
"-" ? -1.0 : 1.0;
1006 std::string token2 = match[2].str();
1007 std::string token3 = match[4].str();
1014 auto *constr2 = findConstraint(
v2, channelConstraints);
1015 auto *constr3 = findConstraint(
v3, channelConstraints);
1017 if (constr2 && !p3) {
1019 sys.variation = sign *
toDouble(token3);
1020 }
else if (!p2 && constr3) {
1022 sys.variation = sign *
toDouble(token2);
1023 }
else if (constr2 && p3 && !constr3) {
1025 sys.variation = sign * p3->
getVal();
1026 }
else if (p2 && !constr2 && constr3) {
1028 sys.variation = sign * p2->
getVal();
1032 sys.constraint = constr2 ? constr2 : constr3;
1039 if (
auto prod =
dynamic_cast<RooProduct *
>(arg)) {
1040 for (
const auto &
e : prod->components()) {
1041 collectElements(elems,
e);
1050 for (
auto *var : list) {
1063 ": functions are not supported as parameters of this modifier");
1067std::vector<double> contents(
RooDataHist const &dataHist)
1073struct ExportedChannel {
1077 std::unique_ptr<RooArgSet> observables;
1078 std::size_t nBins = 0;
1080 std::map<std::string, RooAbsPdf const *> constraints;
1081 std::vector<RooAbsReal *> customModifiers;
1083 std::vector<std::unique_ptr<RooAbsReal>> temporaries;
1085 std::map<int, double> totYield;
1086 std::map<int, double> totYield2;
1087 std::map<int, double> relErrors;
1089 std::set<RooAbsArg const *> legacyBinWidthFactors;
1098 std::vector<double> out;
1100 auto *hf =
dynamic_cast<RooHistFunc const *
>(node);
1101 if (!hf || hf->dataHist().numEntries() == 0) {
1104 out.push_back(hf->dataHist().binVolume(0));
1105 double average = 1.;
1107 if (
auto *real =
dynamic_cast<RooRealVar const *
>(obs)) {
1108 average *= (real->getMax() - real->getMin()) / real->numBins();
1111 out.push_back(average);
1124 std::vector<double>
const &volumes,
RooWorkspace const *ws)
1129 auto const *var =
dynamic_cast<RooRealVar const *
>(&factor);
1130 if (!
dynamic_cast<RooConstVar const *
>(&factor) && !(var && var->isConstant())) {
1135 auto const *inSnapshot =
dynamic_cast<RooRealVar const *
>(snapshot->find(*var));
1136 if (inSnapshot && !inSnapshot->isConstant()) {
1144 auto isOriginalOfChannelNode = [&](
RooAbsArg const &client) {
1145 const std::string attribute = std::string{
"ORIGNAME:"} + client.
GetName();
1147 std::any_of(channelNodes.
begin(), channelNodes.
end(),
1148 [&](
RooAbsArg const *node) {
return node->getAttribute(attribute.c_str()); });
1150 for (
RooAbsArg const *client : factor.clients()) {
1151 const bool isChannelProduct =
dynamic_cast<RooProduct const *
>(client) && channelNodes.
find(*client) == client;
1152 if (client == &sumpdf || isChannelProduct || isOriginalOfChannelNode(*client)) {
1157 if (ws && ws->
arg(client->GetName()) != client) {
1163 const double value =
static_cast<RooAbsReal const &
>(factor).getVal();
1164 return std::any_of(volumes.begin(), volumes.end(),
1165 [&](
double volume) { return volume > 0. && std::abs(value * volume - 1.) < 1e-6; });
1171bool isShapeModifierFunction(
ParamHistFunc const &phf, ExportedChannel
const &channel)
1173 if (!channel.observables || phf.
paramList().
size() != channel.nBins ||
1174 static_cast<std::size_t
>(phf.
numBins()) != channel.nBins ||
1175 phf.
dataVars().
size() != channel.observables->size()) {
1178 for (
RooAbsArg const *obs : phf.dataVars()) {
1179 if (!channel.observables->find(obs->GetName())) {
1187 std::vector<RooAbsPdf *>
const &channelConstraints)
1189 ExportedChannel channel;
1193 channel.name = pdfname;
1194 erasePrefix(channel.name,
"model_");
1195 eraseSuffix(channel.name,
"_model");
1199 const std::vector<double> volumes = binVolumes(*sumpdf);
1205 channel.constraints.emplace(pdf->
GetName(), pdf);
1208 auto gammaConstraint = [&](
RooAbsPdf const *pdf) -> std::optional<HS3::DistributionRef> {
1210 return std::nullopt;
1212 channel.constraints.emplace(pdf->
GetName(), pdf);
1216 for (
size_t sampleidx = 0; sampleidx < sumpdf->
funcList().
size(); ++sampleidx) {
1218 std::vector<ParamHistFunc *> phfs;
1220 const auto func = sumpdf->
funcList().
at(sampleidx);
1223 erasePrefix(sample.
name,
"L_x_");
1224 eraseSuffix(sample.
name,
"_shapes");
1225 eraseSuffix(sample.
name,
"_" + channel.name);
1226 erasePrefix(sample.
name, pdfname +
"_");
1229 std::vector<HS3::NormFactor> normFactors;
1230 std::vector<HS3::NormSys> normSys;
1231 std::vector<HS3::HistoSys> histoSys;
1232 std::vector<HS3::ShapeSys> shapeSys;
1233 std::vector<HS3::CustomModifier> custom;
1234 std::vector<HS3::CustomModifier> temporaries;
1235 std::optional<HS3::StatError> statError;
1239 checkModifierParameter(param, pdf);
1240 std::string sysname(param.
GetName());
1241 erasePrefix(sysname,
"alpha_");
1242 normSys.push_back({sysname, {param.
GetName()},
hi, lo, constraint(pdf), interpolation});
1245 auto updateObservables = [&](
RooHistFunc const &histFunc) {
1246 RooDataHist const &dataHist = histFunc.dataHist();
1251 if (channel.observables ==
nullptr) {
1252 channel.observables = std::move(varsPtr);
1258 bool sameOrder = vars.
size() == channel.observables->size();
1259 for (std::size_t i = 0; sameOrder && i < vars.
size(); ++i) {
1260 sameOrder = std::string(vars[i]->
GetName()) == (*channel.observables)[i]->
GetName();
1264 "' don't have their observables in the same order, so their bin "
1265 "contents can't be written along the same axes");
1269 sample.
contents = contents(dataHist);
1272 auto processElements = [&](
const auto &elements,
auto &&self) ->
void {
1276 }
else if (isLegacyBinWidthFactor(*
e, *sumpdf, channelNodes, volumes, ws)) {
1278 channel.legacyBinWidthFactors.insert(
e);
1280 oocoutW(
nullptr, ObjectHandling)
1281 <<
"RooFitHS3: the constant factor '" <<
e->GetName() <<
"' of sample '" << sample.
name
1282 <<
"' in channel '" << channel.name
1283 <<
"' is used like the inverse bin width of HistFactory before ROOT 6.26 (its value is the "
1284 "inverse bin volume), so it is not written: histfactory_dist implies it. Set "
1285 "RooJSONFactoryWSTool::config().identifyLegacyBinWidthFactors = false to write such factors "
1289 }
else if (
auto constVar =
dynamic_cast<RooConstVar *
>(
e)) {
1290 if (constVar->getVal() != 1.) {
1291 normFactors.push_back({constVar->GetName(), {constVar->GetName()},
HS3::Unconstrained{}});
1293 }
else if (
auto par =
dynamic_cast<RooRealVar *
>(
e)) {
1296 normFactors.push_back(
1297 {par->GetName(), {par->GetName()}, constraint(findConstraint(par, channelConstraints))});
1298 }
else if (
auto hf =
dynamic_cast<const RooHistFunc *
>(
e)) {
1299 updateObservables(*hf);
1301 phfs.push_back(phf);
1305 for (
size_t i = 0; i < fip->variables().size(); ++i) {
1307 std::string sysname(var->
GetName());
1308 erasePrefix(sysname,
"alpha_");
1309 const std::string context =
"normsys modifier '" + sysname +
"' in sample '" + sample.
name +
1310 "' of channel '" + channel.name +
"'";
1312 addNormSys(*var, fip->high()[i], fip->low()[i],
1314 findConstraint(var, channelConstraints));
1324 expression.ReplaceAll((
"x[" + std::to_string(i) +
"]").c_str(),
p->
GetName());
1325 expression.ReplaceAll((
"@" + std::to_string(i)).c_str(),
p->
GetName());
1327 auto components = splitTopLevelProduct(expression.Data());
1328 if (components.empty()) {
1330 custom.push_back({formula->
GetName()});
1331 channel.customModifiers.push_back(formula);
1334 std::vector<RooAbsArg *> realComponents;
1336 for (
auto &comp : components) {
1340 realComponents.push_back(part);
1344 FormulaNormSys sys = parseOverallModifierFormula(comp, formula, channelConstraints);
1347 addNormSys(*sys.param, 1.0 + sys.variation, 1.0 - sys.variation,
1348 multiplicativePiecewiseExponential, sys.constraint);
1353 std::string
name = std::string(formula->
GetName()) +
"_part" + std::to_string(idx);
1355 temporaries.push_back({
name});
1356 channel.temporaries.push_back(std::make_unique<RooFormulaVar>(
1359 self(realComponents, self);
1361 }
else if (
auto real =
dynamic_cast<RooAbsReal *
>(
e)) {
1362 custom.push_back({real->GetName()});
1363 channel.customModifiers.push_back(real);
1369 collectElements(elems, func);
1370 collectElements(elems, sumpdf->
coefList().
at(sampleidx));
1371 processElements(elems, processElements);
1376 updateObservables(*nh);
1383 std::string sysname(var->
GetName());
1384 erasePrefix(sysname,
"alpha_");
1388 const auto *pdf = findConstraint(var, channelConstraints);
1389 checkModifierParameter(*var, pdf);
1390 const std::string context =
"histosys modifier '" + sysname +
"' in sample '" + sample.
name +
1391 "' of channel '" + channel.name +
"'";
1395 {contents(
hi->dataHist()), std::nullopt},
1396 {contents(lo->dataHist()), std::nullopt},
1406 statError.emplace();
1407 statError->name =
"staterror";
1412 statError->parameters.push_back({
g->GetName()});
1414 RooAbsPdf *pdf = findConstraint(
g, channelConstraints);
1415 pdfs.
pdfs.push_back(gammaConstraint(pdf));
1416 channel.totYield[idx] += sample.
contents[idx - 1];
1417 channel.totYield2[idx] += (sample.
contents[idx - 1] * sample.
contents[idx - 1]);
1419 channel.relErrors[idx] = constraintRelError(*pdf, *
g);
1422 statError->constraint = std::move(pdfs);
1428 if (!isShapeModifierFunction(*phf, channel)) {
1429 if (channel.observables && phf->
dataVars().
overlaps(*channel.observables)) {
1431 "': it has another binning of the observables of channel '" +
1432 channel.name +
"'");
1434 custom.push_back({phf->
GetName()});
1435 channel.customModifiers.push_back(phf);
1440 erasePrefix(sys.name, channel.name +
"_");
1441 for (std::string_view suffix : {
"_ShapeSys",
"_shapeSys",
"_ShapeFactor",
"_shapeFactor"}) {
1442 if (eraseSuffix(sys.name, suffix))
1450 sys.parameters.push_back({
g->GetName()});
1451 RooAbsPdf *pdf = findConstraint(
g, channelConstraints);
1453 pdf = ws->
pdf(constraintName(
g->GetName()));
1454 pdfs.
pdfs.push_back(gammaConstraint(pdf));
1456 sys.constraint = std::move(pdfs);
1460 sortByName(normFactors);
1461 sortByName(normSys);
1462 sortByName(histoSys);
1463 sortByName(shapeSys);
1464 auto append = [&](
auto &modifiers) {
1465 sample.
modifiers.insert(sample.
modifiers.end(), std::make_move_iterator(modifiers.begin()),
1466 std::make_move_iterator(modifiers.end()));
1468 append(normFactors);
1473 append(temporaries);
1475 sample.
modifiers.push_back(std::move(*statError));
1478 channel.dist.
samples.push_back(std::move(sample));
1481 sortByName(channel.dist.
samples);
1487void configureStatError(ExportedChannel &channel)
1491 [](
auto const &
m) { return std::holds_alternative<HS3::StatError>(m); })) {
1494 std::vector<double> errors(sample.
contents.size());
1495 for (
auto const &bin : channel.relErrors) {
1496 const int i = bin.first;
1500 round_prec(bin.second * channel.totYield[i] / std::sqrt(channel.totYield2[i]) * sample.
contents[i - 1], 7);
1502 sample.
errors = std::move(errors);
1508bool isHistFactoryChannelProduct(
RooAbsArg const &pdf)
1510 auto const *prod =
dynamic_cast<RooProdPdf const *
>(&pdf);
1515 for (
RooAbsArg const *factor : prod->pdfList()) {
1530 for (
TObject const *obj : tool.workspace()->allGenericObjects()) {
1532 if (mc && mc->GetExternalConstraints() && mc->GetExternalConstraints()->find(constraint.
GetName())) {
1536 for (
RooAbsArg const *client : constraint.clients()) {
1537 if (tool.
workspace()->
arg(client->GetName()) != client) {
1540 if (!client->getAttribute(
arrayDistTag) && !isHistFactoryChannelProduct(*client)) {
1555 std::string arrayName;
1556 for (
RooAbsArg const *client : constraint.clients()) {
1558 arrayName = client->GetName();
1562 if (arrayName.empty()) {
1576std::vector<std::string> exportNamedConstraints(
RooJSONFactoryWSTool &tool, ExportedChannel &channel)
1578 std::map<std::string, std::string> writtenAs;
1579 std::vector<std::string> terms;
1581 auto rename = [&](std::string &
name, std::string
const ¶mName) {
1582 auto found = writtenAs.find(
name);
1583 if (found == writtenAs.end()) {
1584 RooAbsPdf const &constraint = *channel.constraints.at(
name);
1589 if (
auto const *gauss =
dynamic_cast<RooGaussian const *
>(&constraint); gauss && param) {
1590 RooAbsReal const &observable = gauss->getX().
dependsOn(*param) ? gauss->getMean() : gauss->getX();
1595 found = writtenAs.emplace(
name, exportConstraint(tool, constraint)).first;
1596 if (std::find(terms.begin(), terms.end(), found->second) == terms.end()) {
1597 terms.push_back(found->second);
1600 name = found->second;
1603 if (
auto *pdf = std::get_if<HS3::ConstraintPdf>(&constraint)) {
1604 rename(pdf->pdf.name, param.name);
1607 auto renameGammas = [&](
HS3::GammaConstraint &constraint, std::vector<HS3::ParameterRef>
const ¶ms) {
1608 if (
auto *pdfs = std::get_if<HS3::GammaConstraintPdfs>(&constraint)) {
1609 for (std::size_t i = 0; i < pdfs->
pdfs.size(); ++i) {
1610 if (
auto &pdf = pdfs->
pdfs[i]) {
1611 rename(pdf->name, i < params.size() ? params[i].name : std::string{});
1619 [&](
HS3::NormSys &
m) { renameConstraint(
m.constraint,
m.parameter); },
1632std::set<RooAbsPdf const *>
1633nameChannelConstraints(ExportedChannel &channel, std::vector<RooAbsPdf *>
const &constraints)
1635 std::set<RooAbsPdf const *> named;
1636 auto isNamed = [&](std::string
const &
name) {
1638 if (std::find(constraints.begin(), constraints.end(), pdf) == constraints.end()) {
1645 auto const *pdf = std::get_if<HS3::ConstraintPdf>(&constraint);
1646 if (pdf && !isNamed(pdf->pdf.name)) {
1651 auto *pdfs = std::get_if<HS3::GammaConstraintPdfs>(&constraint);
1656 for (
auto &pdf : pdfs->pdfs) {
1657 if (pdf && !isNamed(pdf->name)) {
1681 std::vector<RooAbsPdf *> constraints)
1688 for (
RooAbsArg *sample : sumpdf->funcList()) {
1694 ExportedChannel channel = readChannel(tool, pdfname, sumpdf, constraints);
1698 if (
dist.samples.empty())
1700 for (
auto &sample :
dist.samples) {
1709 configureStatError(channel);
1716 std::set<RooAbsPdf const *> namedConstraints = nameChannelConstraints(channel, constraints);
1722 for (
auto &
modifier : channel.temporaries) {
1728 sumpdf->
getParameters(channel.observables.get(), parameters);
1731 if (!
startsWith(std::string{param->
GetName()},
"nom_") && !channel.legacyBinWidthFactors.count(param)) {
1737 std::vector<HS3::DistributionRef> channelConstraintNames;
1738 for (
RooAbsPdf const *pdf : constraints) {
1739 if (!namedConstraints.count(pdf)) {
1741 channelConstraintNames.push_back({pdf->
GetName()});
1751 bool autoExportDependants()
const override {
return false; }
1754 std::vector<RooAbsPdf *> constraints;
1766 collectConstraintTerms(pdf, constraints);
1772 return tryExportHistFactory(tool, prodpdf->
GetName(), sumpdf, constraints);
1774 std::string
const &key()
const override
1776 static const std::string keystring =
"histfactory_dist";
1781 return tryExport(tool,
static_cast<const RooProdPdf *
>(
p));
1787 bool autoExportDependants()
const override {
return false; }
1790 std::vector<RooAbsPdf *> constraints;
1791 return tryExportHistFactory(tool, sumpdf->
GetName(), sumpdf, constraints);
1793 std::string
const &key()
const override
1795 static const std::string keystring =
"histfactory_dist";
1807 registerImporter<HistFactoryImporter>(
"histfactory_dist",
true);
1808 registerImporter<PiecewiseInterpolationFactory>(
"interpolation",
true);
1809 registerImporter<FlexibleInterpVarFactory>(
"interpolation0d",
true);
1819 std::vector<DistributionRef>
const *channelConstraints)
1821 checkStatErrorConstraints(dist,
name);
1825 std::vector<std::unique_ptr<RooDataHist>>
data;
1826 data.reserve(dist.samples.size());
1827 std::vector<double> sumW;
1828 std::vector<double> sumW2;
1829 std::vector<ParameterRef> gammaParnames;
1830 for (
auto const &sample : dist.samples) {
1836 [](
auto const &
m) { return std::holds_alternative<StatError>(m); });
1840 sumW2.resize(nbins);
1843 const bool hasErrors = sample.
errors || dist.statError.impliedPoissonErrors;
1844 for (std::size_t i = 0; i < nbins; ++i) {
1845 sumW[i] += dh->
weight(i);
1848 if (gammaParnames.empty()) {
1849 gammaParnames = std::get<StatError>(*found).parameters;
1852 data.emplace_back(std::move(dh));
1858 std::size_t nBins = 1;
1859 for (
auto const &axis : dist.axes) {
1867 if (!sumW.empty()) {
1868 std::vector<double> errs(sumW.size());
1869 for (std::size_t i = 0; i < sumW.size(); ++i) {
1870 if (sumW[i] == 0.) {
1874 errs[i] = std::sqrt(sumW2[i]) / sumW[i];
1876 errs[i] = std::max(errs[i], 0.);
1881 dist.statError.relThreshold, nBins,
"the staterror modifier of channel '" +
name +
"'");
1884 ChannelContext ctx{tool, dist, observables,
name,
channelName, nBins, mcStatObject, constraints};
1888 for (std::size_t i = 0; i < dist.samples.size(); ++i) {
1890 buildSample(ctx, sample, *
data[i]);
1895 if (channelConstraints) {
1896 for (
auto const &ref : *channelConstraints) {
1901 constraints.
add(*pdf);
1909 sum.setAttribute(
"BinnedLikelihood");
1910 sum.setAttribute(
"GenerateBinned");
1912 if (constraints.
empty()) {
1915 std::string sumName =
name +
"_model";
1916 erasePrefix(sumName,
"model_");
1926 return dynamic_cast<HistFactoryImporter
const *
>(&importer) !=
nullptr;
1931 std::vector<DistributionRef>
const *channelConstraints)
1934 if (!
p.has_child(
"samples")) {
1937 std::stringstream ss;
std::optional< ArrayComponentInfo > arrayComponentInfo(RooAbsPdf const &pdf, std::string const *observable)
std::vector< RooAbsReal * > paramHistFuncParamsInBinOrder(ParamHistFunc const &func)
RooArgList toParamHistFuncOrder(RooArgList const ¶msInBinOrder, RooAbsCollection const &vars)
bool startsWith(std::string_view str, std::string_view prefix)
bool endsWith(std::string_view str, std::string_view suffix)
bool isLiteralConstVar(RooAbsArg const &arg)
std::string removeSuffix(std::string_view str, std::string_view suffix)
std::unique_ptr< RooArgSet > histogramVariablesNamedAfterObservables(RooDataHist const &dh, RooArgSet const &histObs, RooArgSet const &funcObs)
void checkParamHistFuncOrderIsDefined(std::string const &hs3Version, RooAbsCollection const &vars, std::string const &context)
constexpr const char * arrayDistTag
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
double toDouble(const char *s)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void funcs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t modifier
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
const RooArgList & paramList() const
const RooArgList & dataVars() const
The PiecewiseInterpolation is a class that can morph distributions into each other,...
const RooArgList & highList() const
const RooAbsReal * nominalHist() const
Return pointer to the nominal hist function.
bool positiveDefinite() const
const RooArgList & lowList() const
void setPositiveDefinite(bool flag=true)
const RooArgList & paramList() const
const std::vector< int > & interpolationCodes() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
bool isConstant() const
Check if the "Constant" attribute is set.
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
void treeNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=nullptr, bool doBranch=true, bool doLeaf=true, bool valueOnly=false, bool recurseNonDerived=false) const
Fill supplied list with nodes of the arg tree, following all server links, starting with ourself as t...
Abstract container object that can hold multiple RooAbsArg objects.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
bool overlaps(Iterator_t otherCollBegin, Iterator_t otherCollEnd) const
const_iterator end() const
Storage_t::size_type size() const
const_iterator begin() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract interface for all probability density functions.
void setConstant(bool value=true)
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Returns the bin width (or volume) given a RooHistFunc.
bool divideByBinWidth() const
Represents a constant real-valued object.
Container class to hold N-dimensional binned data.
double const * weightArray() const
double weight(std::size_t i) const
Return weight of i-th bin.
double weightSquared(std::size_t i) const
Return squared weight sum of i-th bin.
static std::unique_ptr< JSONTree > create()
A real-valued function sampled from a multidimensional histogram.
RooAbsReal const & getMean() const
Get the mean parameter.
Efficient implementation of a product of PDFs of the form.
Represents the product of a given set of RooAbsReal objects.
Implements a PDF constructed from a sum of functions:
const RooArgList & funcList() const
const RooArgList & coefList() const
Variable that can be changed from the outside.
bool hasError(bool allowZero=true) const
< A class that holds configuration information for a model using a workspace as a store
Persistable container for RooFit projects.
TObject * obj(RooStringView name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooAbsArg * arg(RooStringView name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
RooFactoryWSTool & factory()
Return instance to factory tool.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
RooCmdArg RecycleConflictNodes(bool flag=true)
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, bool depsAreCond=false)
RooConstVar & RooConst(double val)
RooCmdArg Silence(bool flag=true)
CoordSystem::Scalar get(DisplacementVector2D< CoordSystem, Tag > const &p)
double dist(Rotation3D const &r1, Rotation3D const &r2)
Types that represent an HS3 document.
HistFactoryDist parseHistFactoryDist(Detail::JSONNode const &distribution, Diagnostics &diagnostics)
Reads a HistFactory distribution that doesn't come with a document.
void validateHistFactoryDist(HistFactoryDist const &dist, std::string const &name, Diagnostics &diagnostics)
Same as validate(), but for a single HistFactory distribution that doesn't come with a document.
void buildHistFactoryDist(RooJSONFactoryWSTool &tool, std::string const &name, HistFactoryDist const &dist, std::vector< DistributionRef > const *channelConstraints=nullptr)
Create the RooFit objects of a HistFactory distribution in the workspace of the tool.
void writeInterpolatedFunction(Detail::JSONNode &node, InterpolatedFunction const &function)
Writes the functions "interpolation" and "interpolation0d", with a single interpolation if they are a...
std::variant< NormFactor, NormSys, HistoSys, ShapeSys, StatError, CustomModifier > Modifier
InterpolationClass
The RooFit classes that implement the interpolations, which encode them with integer codes.
constexpr Interpolation multiplicativePolynomialExponential
constexpr Interpolation additivePolynomialLinear
void mergeDuplicateModifiers(HistFactoryDist &dist, std::string const &channel, Diagnostics &diagnostics)
Combines the modifiers of a sample that have the same type and name, which HistFactory models can hav...
ConstraintType
The constraint types that older documents named, for which RooFit creates the constraint terms.
std::optional< Interpolation > interpolationFromCode(int code, InterpolationClass interpolationClass)
The interpolation for an integer code, or nothing if the class doesn't support the code.
void factorOutDefaultInterpolation(HistFactoryDist &dist)
Makes the most common interpolation of the modifiers the "default_interpolation", which they then don...
void setExportedObject(RooJSONFactoryWSTool &tool, HistFactoryDist dist, std::vector< DistributionRef > channelConstraints)
Called by the exporter of a HistFactory distribution, which is then written by the tool.
char const * toString(InterpolationType type)
InterpolatedNumber parseInterpolatedNumber(Detail::JSONNode const &node, Diagnostics &diagnostics)
void upgradeHistFactoryDist(Detail::JSONNode &distribution, Version const &version, Diagnostics &diagnostics)
Same as upgradeDocument(), but for a single HistFactory distribution that doesn't come with a documen...
InterpolatedFunction parseInterpolatedFunction(Detail::JSONNode const &node, Diagnostics &diagnostics)
Reads the functions "interpolation" and "interpolation0d", which don't come with a document.
RooArgSet createObservables(std::vector< BinnedAxis > const &axes)
Create the variables for the axes of binned data.
std::optional< int > codeFromInterpolation(Interpolation const &interpolation, InterpolationClass interpolationClass)
The integer code of an interpolation, or nothing if the class can't represent the interpolation.
void importHistFactoryNode(RooJSONFactoryWSTool &tool, Detail::JSONNode const &node, std::vector< DistributionRef > const *channelConstraints)
What the built-in importer does with a HistFactory distribution, plus the constraint terms of the cha...
bool hasErrors(Diagnostics const &diagnostics)
Whether there is a diagnostic with error severity.
void writeInterpolatedNumber(Detail::JSONNode &node, InterpolatedNumber const &function)
constexpr Interpolation multiplicativePiecewiseExponential
std::vector< Diagnostic > Diagnostics
void report(Diagnostics const &diagnostics)
Forward the warnings to the message service, and throw if there are errors.
NameOrNumber toNameOrNumber(RooAbsArg const &arg)
The name of an object, or the value of a literal constant.
std::variant< Unconstrained, ConstraintType, ConstantGammas, GammaConstraintPdfs > GammaConstraint
bool parseVersion(std::string const &version, Version &out)
Reads the leading "MAJOR.MINOR" and the optional ".PATCH" of an HS3 version string.
BinnedAxis toBinnedAxis(RooRealVar const &var)
The axis of binned data for a variable.
std::unique_ptr< RooDataHist > createDataHist(std::string const &name, RooArgSet const &vars, std::vector< double > const &contents, std::vector< double > const *errors)
Create a RooDataHist with the contents and errors. If there are no errors, it doesn't store squared w...
std::variant< Unconstrained, ConstraintType, ConstraintPdf > Constraint
bool isBuiltinHistFactoryImporter(JSONIO::Importer const &importer)
Whether this is the importer that RooFit registers for HistFactory distributions, as opposed to the o...
constexpr double defaultShapeSysGammaMax
constexpr double minShapeUncertainty
constexpr double defaultStatErrorGammaMax
constexpr double defaultGammaMin
void configureConstrainedGammas(RooArgList const &gammas, std::span< const double > relSigmas, double minSigma)
Configure constrained gamma parameters for fitting.
CreateGammaConstraintsOutput createGammaConstraints(RooArgList const ¶mList, std::span< const double > relSigmas, double minSigma, Constraint::Type type)
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
std::string GetName(TCppScope_t)
#define STATIC_EXECUTE(MY_FUNC)
The gamma parameters are constant, which is a RooFit extension.
The constraint term is a distribution of the document, named in "constraints".
Multiplies the sample with a function of the document.
Every gamma parameter has its own constraint term, or none, as named in "constraints".
std::vector< std::optional< DistributionRef > > pdfs
std::optional< Interpolation > defaultInterpolation
std::vector< Sample > samples
The function "interpolation" of RooFit, implemented by PiecewiseInterpolation: a nominal function plu...
std::vector< Interpolation > interpolations
One per parameter.
std::vector< NameOrNumber > parameters
std::vector< NameOrNumber > low
std::vector< NameOrNumber > high
The function "interpolation0d" of RooFit, implemented by FlexibleInterpVar: a nominal value plus the ...
std::vector< double > high
std::vector< double > low
std::vector< std::string > parameters
std::vector< Interpolation > interpolations
One per parameter.
How a modifier of a HistFactory distribution interpolates and extrapolates its effect.
std::optional< InterpolationFunction > out
If not set, the function inside the bounds is used outside as well.
std::vector< double > contents
std::optional< std::vector< double > > errors
std::vector< Modifier > modifiers
Scales each bin by its own parameter. The modifier type "shapesys" is a deprecated alias of "shapefac...
Scales each bin by a parameter, that is constrained by the statistical uncertainty of all samples tha...
The parameter of the modifier is not constrained.
Combines lambdas into one visitor for std::visit(). The compiler complains about the alternatives wit...
static uint64_t sum(uint64_t i)