Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
JSONFactories_HistFactory.cxx
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Carsten D. Burgard, DESY/ATLAS, Dec 2021
5 *
6 * Copyright (c) 2022, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
14#include <RooFitHS3/JSONIO.h>
16
21#include <RooConstVar.h>
22#include <RooRealVar.h>
23#include <RooDataHist.h>
24#include <RooHistFunc.h>
25#include <RooRealSumPdf.h>
26#include <RooBinWidthFunction.h>
27#include <RooProdPdf.h>
28#include <RooPoisson.h>
29#include <RooLognormal.h>
30#include <RooGaussian.h>
31#include <RooProduct.h>
32#include <RooWorkspace.h>
33
34#include "static_execute.h"
35#include "JSONIOUtils.h"
36
38
39using namespace RooStats::HistFactory;
40using namespace RooStats::HistFactory::Detail;
42
43namespace {
44
45inline void writeAxis(JSONNode &axis, RooRealVar const &obs)
46{
47 auto &binning = obs.getBinning();
48 if (binning.isUniform()) {
49 axis["nbins"] << obs.numBins();
50 axis["min"] << obs.getMin();
51 axis["max"] << obs.getMax();
52 } else {
53 auto &edges = axis["edges"];
54 edges.set_seq();
55 double val = binning.binLow(0);
56 edges.append_child() << val;
57 for (int i = 0; i < binning.numBins(); ++i) {
58 val = binning.binHigh(i);
59 edges.append_child() << val;
60 }
61 }
62}
63
64double round_prec(double d, int nSig)
65{
66 if (d == 0.0)
67 return 0.0;
68 int ndigits = std::floor(std::log10(std::abs(d))) + 1 - nSig;
69 double sf = std::pow(10, ndigits);
70 if (std::abs(d / sf) < 2)
71 ndigits--;
72 return sf * std::round(d / sf);
73}
74
75// To avoid repeating the same string literals that can potentially get out of
76// sync.
77namespace Literals {
78constexpr auto staterror = "staterror";
79}
80
81void erasePrefix(std::string &str, std::string_view prefix)
82{
83 if (startsWith(str, prefix)) {
84 str.erase(0, prefix.size());
85 }
86}
87
88void eraseSuffix(std::string &str, std::string_view suffix)
89{
90 if (endsWith(str, suffix)) {
91 str.erase(str.size() - suffix.size());
92 }
93}
94
95template <class Coll>
96void sortByName(Coll &coll)
97{
98 std::sort(coll.begin(), coll.end(), [](auto &l, auto &r) { return l.name < r.name; });
99}
100
101template <class T>
102T *findClient(RooAbsArg *gamma)
103{
104 for (const auto &client : gamma->clients()) {
105 if (auto casted = dynamic_cast<T *>(client)) {
106 return casted;
107 } else {
108 T *c = findClient<T>(client);
109 if (c)
110 return c;
111 }
112 }
113 return nullptr;
114}
115
116RooAbsPdf *findConstraint(RooAbsArg *g)
117{
118 RooPoisson *constraint_p = findClient<RooPoisson>(g);
119 if (constraint_p)
120 return constraint_p;
121 RooGaussian *constraint_g = findClient<RooGaussian>(g);
122 if (constraint_g)
123 return constraint_g;
124 RooLognormal *constraint_l = findClient<RooLognormal>(g);
125 if (constraint_l)
126 return constraint_l;
127 return nullptr;
128}
129
130std::string toString(TClass *c)
131{
132 if (!c) {
133 return "Const";
134 }
135 if (c == RooPoisson::Class()) {
136 return "Poisson";
137 }
138 if (c == RooGaussian::Class()) {
139 return "Gauss";
140 }
141 if (c == RooLognormal::Class()) {
142 return "Lognormal";
143 }
144 return "unknown";
145}
146
147inline std::string defaultGammaName(std::string const &sysname, std::size_t i)
148{
149 return "gamma_" + sysname + "_bin_" + std::to_string(i);
150}
151
152/// Export the names of the gamma parameters to the modifier struct if the
153/// names don't match the default gamma parameter names, which is gamma_<sysname>_bin_<i>
154void optionallyExportGammaParameters(JSONNode &mod, std::string const &sysname,
155 std::vector<std::string> const &paramNames)
156{
157 for (std::size_t i = 0; i < paramNames.size(); ++i) {
158 if (paramNames[i] != defaultGammaName(sysname, i)) {
159 mod["parameters"].fill_seq(paramNames);
160 return;
161 }
162 }
163}
164
165RooRealVar &createNominal(RooWorkspace &ws, std::string const &parname, double val, double min, double max)
166{
167 RooRealVar &nom = getOrCreate<RooRealVar>(ws, "nom_" + parname, val, min, max);
168 nom.setConstant(true);
169 return nom;
170}
171
172/// Get the conventional name of the constraint pdf for a constrained
173/// parameter.
174std::string constraintName(std::string const &paramName)
175{
176 return paramName + "Constraint";
177}
178
179RooAbsPdf &getConstraint(RooWorkspace &ws, const std::string &pname)
180{
181 RooRealVar *constrParam = ws.var(pname);
182 constrParam->setError(1.0);
183 return getOrCreate<RooGaussian>(ws, constraintName(pname), *constrParam, *ws.var("nom_" + pname), 1.);
184}
185
186ParamHistFunc &createPHF(const std::string &phfname, std::string const &sysname,
187 const std::vector<std::string> &parnames, const std::vector<double> &vals,
188 RooJSONFactoryWSTool &tool, RooArgList &constraints, const RooArgSet &observables,
189 const std::string &constraintType, double gammaMin, double gammaMax, double minSigma)
190{
191 RooWorkspace &ws = *tool.workspace();
192
193 RooArgList gammas;
194 for (std::size_t i = 0; i < vals.size(); ++i) {
195 const std::string name = parnames.empty() ? defaultGammaName(sysname, i) : parnames[i];
196 gammas.add(getOrCreate<RooRealVar>(ws, name, 1., gammaMin, gammaMax));
197 }
198
199 auto &phf = tool.wsEmplace<ParamHistFunc>(phfname, observables, gammas);
200
201 if (constraintType != "Const") {
202 auto constraintsInfo = createGammaConstraints(
203 gammas, vals, minSigma, constraintType == "Poisson" ? Constraint::Poisson : Constraint::Gaussian);
204 for (auto const &term : constraintsInfo.constraints) {
206 constraints.add(*ws.pdf(term->GetName()));
207 }
208 } else {
209 for (auto *gamma : static_range_cast<RooRealVar *>(gammas)) {
210 gamma->setConstant(true);
211 }
212 }
213
214 return phf;
215}
216
217bool hasStaterror(const JSONNode &comp)
218{
219 if (!comp.has_child("modifiers"))
220 return false;
221 for (const auto &mod : comp["modifiers"].children()) {
222 if (mod["type"].val() == ::Literals::staterror)
223 return true;
224 }
225 return false;
226}
227
228const JSONNode &findStaterror(const JSONNode &comp)
229{
230 if (comp.has_child("modifiers")) {
231 for (const auto &mod : comp["modifiers"].children()) {
232 if (mod["type"].val() == ::Literals::staterror)
233 return mod;
234 }
235 }
236 RooJSONFactoryWSTool::error("sample '" + RooJSONFactoryWSTool::name(comp) + "' does not have a " +
237 ::Literals::staterror + " modifier!");
238}
239
240bool importHistSample(RooJSONFactoryWSTool &tool, RooDataHist &dh, RooArgSet const &varlist,
241 RooAbsArg const *mcStatObject, const std::string &fprefix, const JSONNode &p,
242 RooArgList &constraints)
243{
244 RooWorkspace &ws = *tool.workspace();
245
246 std::string sampleName = RooJSONFactoryWSTool::name(p);
247 std::string prefixedName = fprefix + "_" + sampleName;
248
249 std::string channelName = fprefix;
250 erasePrefix(channelName, "model_");
251
252 if (!p.has_child("data")) {
253 RooJSONFactoryWSTool::error("sample '" + sampleName + "' does not define a 'data' key");
254 }
255
256 auto &hf = tool.wsEmplace<RooHistFunc>("hist_" + prefixedName, varlist, dh);
258
259 RooArgList shapeElems;
260 RooArgList normElems;
261
262 shapeElems.add(tool.wsEmplace<RooBinWidthFunction>(prefixedName + "_binWidth", hf, true));
263
264 if (hasStaterror(p)) {
265 shapeElems.add(*mcStatObject);
266 }
267
268 if (p.has_child("modifiers")) {
269 RooArgList overall_nps;
270 std::vector<double> overall_low;
271 std::vector<double> overall_high;
272
273 RooArgList histNps;
274 RooArgList histoLo;
275 RooArgList histoHi;
276
277 int idx = 0;
278 for (const auto &mod : p["modifiers"].children()) {
279 std::string const &modtype = mod["type"].val();
280 std::string const &sysname =
281 mod.has_child("name")
282 ? mod["name"].val()
283 : (mod.has_child("parameter") ? mod["parameter"].val() : "syst_" + std::to_string(idx));
284 ++idx;
285 if (modtype == "staterror") {
286 // this is dealt with at a different place, ignore it for now
287 } else if (modtype == "normfactor") {
288 RooRealVar &constrParam = getOrCreate<RooRealVar>(ws, sysname, 1., -3, 5);
289 normElems.add(constrParam);
290 if (auto constrInfo = mod.find("constraint_name")) {
291 auto constraint = tool.request<RooAbsReal>(constrInfo->val(), sampleName);
292 if (auto gauss = dynamic_cast<RooGaussian const *>(constraint)) {
293 constrParam.setError(gauss->getSigma().getVal());
294 }
295 constraints.add(*constraint);
296 }
297 } else if (modtype == "normsys") {
298 auto *parameter = mod.find("parameter");
299 std::string parname(parameter ? parameter->val() : "alpha_" + sysname);
300 createNominal(ws, parname, 0.0, -10, 10);
301 overall_nps.add(getOrCreate<RooRealVar>(ws, parname, 0., -5, 5));
302 auto &data = mod["data"];
303 // the below contains a a hack to cut off variations that go below 0
304 // this is needed because with interpolation code 4, which is the default, interpolation is done in
305 // log-space. hence, values <= 0 result in NaN which propagate throughout the model and cause evaluations to
306 // fail if you know a nicer way to solve this, please go ahead and fix the lines below
307 overall_low.push_back(data["lo"].val_double() > 0 ? data["lo"].val_double()
308 : std::numeric_limits<double>::epsilon());
309 overall_high.push_back(data["hi"].val_double() > 0 ? data["hi"].val_double()
310 : std::numeric_limits<double>::epsilon());
311 constraints.add(getConstraint(ws, parname));
312 } else if (modtype == "histosys") {
313 auto *parameter = mod.find("parameter");
314 std::string parname(parameter ? parameter->val() : "alpha_" + sysname);
315 createNominal(ws, parname, 0.0, -10, 10);
316 histNps.add(getOrCreate<RooRealVar>(ws, parname, 0., -5, 5));
317 auto &data = mod["data"];
318 histoLo.add(tool.wsEmplace<RooHistFunc>(
319 sysname + "Low_" + prefixedName, varlist,
320 RooJSONFactoryWSTool::readBinnedData(data["lo"], sysname + "Low_" + prefixedName, varlist)));
321 histoHi.add(tool.wsEmplace<RooHistFunc>(
322 sysname + "High_" + prefixedName, varlist,
323 RooJSONFactoryWSTool::readBinnedData(data["hi"], sysname + "High_" + prefixedName, varlist)));
324 constraints.add(getConstraint(ws, parname));
325 } else if (modtype == "shapesys") {
326 std::string funcName = channelName + "_" + sysname + "_ShapeSys";
327 // funcName should be "<channel_name>_<sysname>_ShapeSys"
328 std::vector<double> vals;
329 for (const auto &v : mod["data"]["vals"].children()) {
330 vals.push_back(v.val_double());
331 }
332 std::vector<std::string> parnames;
333 for (const auto &v : mod["parameters"].children()) {
334 parnames.push_back(v.val());
335 }
336 if (vals.empty()) {
337 RooJSONFactoryWSTool::error("unable to instantiate shapesys '" + sysname + "' with 0 values!");
338 }
339 std::string constraint(mod["constraint"].val());
340 shapeElems.add(createPHF(funcName, sysname, parnames, vals, tool, constraints, varlist, constraint,
342 } else if (modtype == "custom") {
343 RooAbsReal *obj = ws.function(sysname);
344 if (!obj) {
345 RooJSONFactoryWSTool::error("unable to find custom modifier '" + sysname + "'");
346 }
347 if (obj->dependsOn(varlist)) {
348 shapeElems.add(*obj);
349 } else {
350 normElems.add(*obj);
351 }
352 } else {
353 RooJSONFactoryWSTool::error("modifier '" + sysname + "' of unknown type '" + modtype + "'");
354 }
355 }
356
357 std::string interpName = sampleName + "_" + channelName + "_epsilon";
358 if (!overall_nps.empty()) {
359 auto &v = tool.wsEmplace<RooStats::HistFactory::FlexibleInterpVar>(interpName, overall_nps, 1., overall_low,
360 overall_high);
361 v.setAllInterpCodes(4); // default HistFactory interpCode
362 normElems.add(v);
363 } else {
364 RooConstVar interp(interpName.c_str(), "", 1.);
365 ws.import(interp);
366 }
367 if (!histNps.empty()) {
368 auto &v = tool.wsEmplace<PiecewiseInterpolation>("histoSys_" + prefixedName, hf, histoLo, histoHi, histNps);
370 v.setAllInterpCodes(4); // default interpCode for HistFactory
371 shapeElems.add(v);
372 } else {
373 shapeElems.add(hf);
374 }
375 }
376
377 tool.wsEmplace<RooProduct>(prefixedName + "_shapes", shapeElems);
378 if (!normElems.empty()) {
379 tool.wsEmplace<RooProduct>(prefixedName + "_scaleFactors", normElems);
380 } else {
381 ws.factory("RooConstVar::" + prefixedName + "_scaleFactors(1.)");
382 }
383
384 return true;
385}
386
387class HistFactoryImporter : public RooFit::JSONIO::Importer {
388public:
389 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
390 {
391 std::string name = RooJSONFactoryWSTool::name(p);
392 if (!p.has_child("samples")) {
393 RooJSONFactoryWSTool::error("no samples in '" + name + "', skipping.");
394 }
395 double statErrThresh = 0;
396 std::string statErrType = "Poisson";
397 if (p.has_child(::Literals::staterror)) {
398 auto &staterr = p[::Literals::staterror];
399 if (staterr.has_child("relThreshold"))
400 statErrThresh = staterr["relThreshold"].val_double();
401 if (staterr.has_child("constraint"))
402 statErrType = staterr["constraint"].val();
403 }
404 std::vector<double> sumW;
405 std::vector<double> sumW2;
406 std::vector<std::string> gammaParnames;
408
409 std::string fprefix = name;
410
411 std::vector<std::unique_ptr<RooDataHist>> data;
412 for (const auto &comp : p["samples"].children()) {
413 std::unique_ptr<RooDataHist> dh = RooJSONFactoryWSTool::readBinnedData(
414 comp["data"], fprefix + "_" + RooJSONFactoryWSTool::name(comp) + "_dataHist", observables);
415 size_t nbins = dh->numEntries();
416
417 if (hasStaterror(comp)) {
418 if (sumW.empty()) {
419 sumW.resize(nbins);
420 sumW2.resize(nbins);
421 }
422 for (size_t i = 0; i < nbins; ++i) {
423 sumW[i] += dh->weight(i);
424 sumW2[i] += dh->weightSquared(i);
425 }
426 if (gammaParnames.empty()) {
427 if (auto staterrorParams = findStaterror(comp).find("parameters")) {
428 for (const auto &v : staterrorParams->children()) {
429 gammaParnames.push_back(v.val());
430 }
431 }
432 }
433 }
434 data.emplace_back(std::move(dh));
435 }
436
437 RooAbsArg *mcStatObject = nullptr;
438 RooArgList constraints;
439 if (!sumW.empty()) {
440 std::string channelName = name;
441 erasePrefix(channelName, "model_");
442
443 std::vector<double> errs(sumW.size());
444 for (size_t i = 0; i < sumW.size(); ++i) {
445 errs[i] = std::sqrt(sumW2[i]) / sumW[i];
446 // avoid negative sigma. This NP will be set constant anyway later
447 errs[i] = std::max(errs[i], 0.);
448 }
449
450 mcStatObject =
451 &createPHF("mc_stat_" + channelName, "stat_" + channelName, gammaParnames, errs, *tool, constraints,
452 observables, statErrType, defaultGammaMin, defaultStatErrorGammaMax, statErrThresh);
453 }
454
455 int idx = 0;
457 RooArgList coefs;
458 for (const auto &comp : p["samples"].children()) {
459 importHistSample(*tool, *data[idx], observables, mcStatObject, fprefix, comp, constraints);
460 ++idx;
461
462 std::string const &compName = RooJSONFactoryWSTool::name(comp);
463 funcs.add(*tool->request<RooAbsReal>(fprefix + "_" + compName + "_shapes", name));
464 coefs.add(*tool->request<RooAbsReal>(fprefix + "_" + compName + "_scaleFactors", name));
465 }
466
467 if (constraints.empty()) {
468 tool->wsEmplace<RooRealSumPdf>(name, funcs, coefs, true);
469 } else {
470 std::string sumName = name + "_model";
471 erasePrefix(sumName, "model_");
472 auto &sum = tool->wsEmplace<RooRealSumPdf>(sumName, funcs, coefs, true);
473 sum.SetTitle(name.c_str());
474 tool->wsEmplace<RooProdPdf>(name, constraints, RooFit::Conditional(sum, observables));
475 }
476 return true;
477 }
478};
479
480class FlexibleInterpVarStreamer : public RooFit::JSONIO::Exporter {
481public:
482 std::string const &key() const override
483 {
484 static const std::string keystring = "interpolation0d";
485 return keystring;
486 }
487 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
488 {
489 auto fip = static_cast<const RooStats::HistFactory::FlexibleInterpVar *>(func);
490 elem["type"] << key();
491 elem["interpolationCodes"].fill_seq(fip->interpolationCodes());
492 RooJSONFactoryWSTool::fillSeq(elem["vars"], fip->variables());
493 elem["nom"] << fip->nominal();
494 elem["high"].fill_seq(fip->high(), fip->variables().size());
495 elem["low"].fill_seq(fip->low(), fip->variables().size());
496 return true;
497 }
498};
499
500class PiecewiseInterpolationStreamer : public RooFit::JSONIO::Exporter {
501public:
502 std::string const &key() const override
503 {
504 static const std::string keystring = "interpolation";
505 return keystring;
506 }
507 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
508 {
509 const PiecewiseInterpolation *pip = static_cast<const PiecewiseInterpolation *>(func);
510 elem["type"] << key();
511 elem["interpolationCodes"].fill_seq(pip->interpolationCodes());
512 elem["positiveDefinite"] << pip->positiveDefinite();
513 RooJSONFactoryWSTool::fillSeq(elem["vars"], pip->paramList());
514 elem["nom"] << pip->nominalHist()->GetName();
515 RooJSONFactoryWSTool::fillSeq(elem["high"], pip->highList(), pip->paramList().size());
516 RooJSONFactoryWSTool::fillSeq(elem["low"], pip->lowList(), pip->paramList().size());
517 return true;
518 }
519};
520
521class PiecewiseInterpolationFactory : public RooFit::JSONIO::Importer {
522public:
523 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
524 {
525 std::string name(RooJSONFactoryWSTool::name(p));
526
527 RooArgList vars{tool->requestArgList<RooRealVar>(p, "vars")};
528
529 auto &pip = tool->wsEmplace<PiecewiseInterpolation>(name, *tool->requestArg<RooAbsReal>(p, "nom"),
530 tool->requestArgList<RooAbsReal>(p, "low"),
531 tool->requestArgList<RooAbsReal>(p, "high"), vars);
532
533 pip.setPositiveDefinite(p["positiveDefinite"].val_bool());
534
535 if (p.has_child("interpolationCodes")) {
536 std::size_t i = 0;
537 for (auto const &node : p["interpolationCodes"].children()) {
538 pip.setInterpCode(*static_cast<RooAbsReal *>(vars.at(i)), node.val_int(), true);
539 ++i;
540 }
541 }
542
543 return true;
544 }
545};
546
547class FlexibleInterpVarFactory : public RooFit::JSONIO::Importer {
548public:
549 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
550 {
551 std::string name(RooJSONFactoryWSTool::name(p));
552 if (!p.has_child("high")) {
553 RooJSONFactoryWSTool::error("no high variations of '" + name + "'");
554 }
555 if (!p.has_child("low")) {
556 RooJSONFactoryWSTool::error("no low variations of '" + name + "'");
557 }
558 if (!p.has_child("nom")) {
559 RooJSONFactoryWSTool::error("no nominal variation of '" + name + "'");
560 }
561
562 double nom(p["nom"].val_double());
563
564 RooArgList vars{tool->requestArgList<RooRealVar>(p, "vars")};
565
566 std::vector<double> high;
567 high << p["high"];
568
569 std::vector<double> low;
570 low << p["low"];
571
572 if (vars.size() != low.size() || vars.size() != high.size()) {
573 RooJSONFactoryWSTool::error("FlexibleInterpVar '" + name +
574 "' has non-matching lengths of 'vars', 'high' and 'low'!");
575 }
576
577 auto &fip = tool->wsEmplace<RooStats::HistFactory::FlexibleInterpVar>(name, vars, nom, low, high);
578
579 if (p.has_child("interpolationCodes")) {
580 size_t i = 0;
581 for (auto const &node : p["interpolationCodes"].children()) {
582 fip.setInterpCode(*static_cast<RooAbsReal *>(vars.at(i)), node.val_int());
583 ++i;
584 }
585 }
586
587 return true;
588 }
589};
590
591void collectElements(RooArgSet &elems, RooAbsArg *arg)
592{
593 if (auto prod = dynamic_cast<RooProduct *>(arg)) {
594 for (const auto &e : prod->components()) {
595 collectElements(elems, e);
596 }
597 } else {
598 elems.add(*arg);
599 }
600}
601
602struct NormFactor {
603 std::string name;
604 RooAbsArg const *param = nullptr;
605 RooAbsPdf const *constraint = nullptr;
606 NormFactor(RooAbsArg const &par, RooAbsPdf const *constr = nullptr)
607 : name{par.GetName()}, param{&par}, constraint{constr}
608 {
609 }
610};
611
612struct NormSys {
613 std::string name;
614 RooAbsArg const *param = nullptr;
615 double low;
616 double high;
617 TClass *constraint = RooGaussian::Class();
618 NormSys(const std::string &n, RooAbsArg *const p, double h, double l, TClass *c)
619 : name(n), param(p), low(l), high(h), constraint(c)
620 {
621 }
622};
623struct HistoSys {
624 std::string name;
625 RooAbsArg const *param = nullptr;
626 std::vector<double> low;
627 std::vector<double> high;
628 TClass *constraint = RooGaussian::Class();
629 HistoSys(const std::string &n, RooAbsArg *const p, RooHistFunc *l, RooHistFunc *h, TClass *c)
630 : name(n), param(p), constraint(c)
631 {
632 low.assign(l->dataHist().weightArray(), l->dataHist().weightArray() + l->dataHist().numEntries());
633 high.assign(h->dataHist().weightArray(), h->dataHist().weightArray() + h->dataHist().numEntries());
634 }
635};
636struct ShapeSys {
637 std::string name;
638 std::vector<double> constraints;
639 std::vector<std::string> parameters;
640 TClass *constraint = nullptr;
641 ShapeSys(const std::string &n) : name{n} {}
642};
643struct Sample {
644 std::string name;
645 std::vector<double> hist;
646 std::vector<double> histError;
647 std::vector<NormFactor> normfactors;
648 std::vector<NormSys> normsys;
649 std::vector<HistoSys> histosys;
650 std::vector<ShapeSys> shapesys;
651 std::vector<RooAbsReal *> otherElements;
652 bool useBarlowBeestonLight = false;
653 std::vector<std::string> staterrorParameters;
654 TClass *barlowBeestonLightConstraint = RooPoisson::Class();
655 Sample(const std::string &n) : name{n} {}
656};
657
658void addNormFactor(RooRealVar const *par, Sample &sample, RooWorkspace *ws)
659{
660 std::string parname = par->GetName();
661 bool isConstrained = false;
662 for (RooAbsArg const *pdf : ws->allPdfs()) {
663 if (auto gauss = dynamic_cast<RooGaussian const *>(pdf)) {
664 if (parname == gauss->getX().GetName()) {
665 sample.normfactors.emplace_back(*par, gauss);
666 isConstrained = true;
667 }
668 }
669 }
670 if (!isConstrained)
671 sample.normfactors.emplace_back(*par);
672}
673
674bool tryExportHistFactory(RooJSONFactoryWSTool *tool, const std::string &pdfname, const RooRealSumPdf *sumpdf,
675 JSONNode &elem)
676{
677 RooWorkspace *ws = tool->workspace();
678 RooArgSet customModifiers;
679
680 if (!sumpdf)
681 return false;
682
683 std::string channelName = pdfname;
684 erasePrefix(channelName, "model_");
685 eraseSuffix(channelName, "_model");
686
687 for (RooAbsArg *sample : sumpdf->funcList()) {
688 if (!dynamic_cast<RooProduct *>(sample) && !dynamic_cast<RooRealSumPdf *>(sample)) {
689 return false;
690 }
691 }
692
693 std::map<int, double> tot_yield;
694 std::map<int, double> tot_yield2;
695 std::map<int, double> rel_errors;
696 RooArgSet const *varSet = nullptr;
697 long unsigned int nBins = 0;
698
699 std::vector<Sample> samples;
700
701 for (size_t sampleidx = 0; sampleidx < sumpdf->funcList().size(); ++sampleidx) {
702 PiecewiseInterpolation *pip = nullptr;
704 std::vector<ParamHistFunc *> phfs;
705
706 const auto func = sumpdf->funcList().at(sampleidx);
707 Sample sample(func->GetName());
708 erasePrefix(sample.name, "L_x_");
709 eraseSuffix(sample.name, "_shapes");
710 eraseSuffix(sample.name, "_" + channelName);
711 erasePrefix(sample.name, pdfname + "_");
712 RooArgSet elems;
713 collectElements(elems, func);
714 collectElements(elems, sumpdf->coefList().at(sampleidx));
715
716 auto updateObservables = [&](RooDataHist const &dataHist) {
717 if (varSet == nullptr) {
718 varSet = dataHist.get();
719 nBins = dataHist.numEntries();
720 }
721 if (sample.hist.empty()) {
722 auto *w = dataHist.weightArray();
723 sample.hist.assign(w, w + dataHist.numEntries());
724 }
725 };
726
727 for (RooAbsArg *e : elems) {
728 if (TString(e->GetName()).Contains("binWidth")) {
729 // The bin width modifiers are handled separately. We can't just
730 // check for the RooBinWidthFunction type here, because prior to
731 // ROOT 6.26, the multiplication with the inverse bin width was
732 // done in a different way (like a normfactor with a RooRealVar,
733 // but it was stored in the dataset).
734 // Fortunately, the name was similar, so we can match the modifier
735 // name.
736 } else if (auto constVar = dynamic_cast<RooConstVar *>(e)) {
737 if (constVar->getVal() != 1.) {
738 sample.normfactors.emplace_back(*e);
739 }
740 } else if (auto par = dynamic_cast<RooRealVar *>(e)) {
741 addNormFactor(par, sample, ws);
742 } else if (auto hf = dynamic_cast<const RooHistFunc *>(e)) {
743 updateObservables(hf->dataHist());
744 } else if (auto phf = dynamic_cast<ParamHistFunc *>(e)) {
745 phfs.push_back(phf);
746 } else if (!fip && (fip = dynamic_cast<RooStats::HistFactory::FlexibleInterpVar *>(e))) {
747 } else if (!pip && (pip = dynamic_cast<PiecewiseInterpolation *>(e))) {
748 } else if (auto real = dynamic_cast<RooAbsReal *>(e)) {
749 sample.otherElements.push_back(real);
750 }
751 }
752
753 // see if we can get the observables
754 if (pip) {
755 if (auto nh = dynamic_cast<RooHistFunc const *>(pip->nominalHist())) {
756 updateObservables(nh->dataHist());
757 }
758 }
759
760 // sort and configure norms
761 sortByName(sample.normfactors);
762
763 // sort and configure the normsys
764 if (fip) {
765 for (size_t i = 0; i < fip->variables().size(); ++i) {
766 RooAbsArg *var = fip->variables().at(i);
767 std::string sysname(var->GetName());
768 erasePrefix(sysname, "alpha_");
769 sample.normsys.emplace_back(sysname, var, fip->high()[i], fip->low()[i], findConstraint(var)->IsA());
770 }
771 sortByName(sample.normsys);
772 }
773
774 // sort and configure the histosys
775 if (pip) {
776 for (size_t i = 0; i < pip->paramList().size(); ++i) {
777 RooAbsArg *var = pip->paramList().at(i);
778 std::string sysname(var->GetName());
779 erasePrefix(sysname, "alpha_");
780 if (auto lo = dynamic_cast<RooHistFunc *>(pip->lowList().at(i))) {
781 if (auto hi = dynamic_cast<RooHistFunc *>(pip->highList().at(i))) {
782 sample.histosys.emplace_back(sysname, var, lo, hi, findConstraint(var)->IsA());
783 }
784 }
785 }
786 sortByName(sample.histosys);
787 }
788
789 for (ParamHistFunc *phf : phfs) {
790 if (startsWith(std::string(phf->GetName()), "mc_stat_")) { // MC stat uncertainty
791 int idx = 0;
792 for (const auto &g : phf->paramList()) {
793 sample.staterrorParameters.push_back(g->GetName());
794 ++idx;
795 RooAbsPdf *constraint = findConstraint(g);
796 if (tot_yield.find(idx) == tot_yield.end()) {
797 tot_yield[idx] = 0;
798 tot_yield2[idx] = 0;
799 }
800 tot_yield[idx] += sample.hist[idx - 1];
801 tot_yield2[idx] += (sample.hist[idx - 1] * sample.hist[idx - 1]);
802 if (constraint) {
803 sample.barlowBeestonLightConstraint = constraint->IsA();
804 if (RooPoisson *constraint_p = dynamic_cast<RooPoisson *>(constraint)) {
805 double erel = 1. / std::sqrt(constraint_p->getX().getVal());
806 rel_errors[idx] = erel;
807 } else if (RooGaussian *constraint_g = dynamic_cast<RooGaussian *>(constraint)) {
808 double erel = constraint_g->getSigma().getVal() / constraint_g->getMean().getVal();
809 rel_errors[idx] = erel;
810 } else {
812 "currently, only RooPoisson and RooGaussian are supported as constraint types");
813 }
814 }
815 }
816 sample.useBarlowBeestonLight = true;
817 } else { // other ShapeSys
818 ShapeSys sys(phf->GetName());
819 erasePrefix(sys.name, channelName + "_");
820 eraseSuffix(sys.name, "_ShapeSys");
821
822 for (const auto &g : phf->paramList()) {
823 sys.parameters.push_back(g->GetName());
824 RooAbsPdf *constraint = findConstraint(g);
825 if (!constraint)
826 constraint = ws->pdf(constraintName(g->GetName()));
827 if (!constraint && !g->isConstant()) {
828 RooJSONFactoryWSTool::error("cannot find constraint for " + std::string(g->GetName()));
829 } else if (!constraint) {
830 sys.constraints.push_back(0.0);
831 } else if (auto constraint_p = dynamic_cast<RooPoisson *>(constraint)) {
832 sys.constraints.push_back(1. / std::sqrt(constraint_p->getX().getVal()));
833 if (!sys.constraint) {
834 sys.constraint = RooPoisson::Class();
835 }
836 } else if (auto constraint_g = dynamic_cast<RooGaussian *>(constraint)) {
837 sys.constraints.push_back(constraint_g->getSigma().getVal() / constraint_g->getMean().getVal());
838 if (!sys.constraint) {
839 sys.constraint = RooGaussian::Class();
840 }
841 }
842 }
843 sample.shapesys.emplace_back(std::move(sys));
844 }
845 }
846 sortByName(sample.shapesys);
847
848 // add the sample
849 samples.emplace_back(std::move(sample));
850 }
851
852 sortByName(samples);
853
854 for (auto &sample : samples) {
855 if (sample.hist.empty()) {
856 return false;
857 }
858 if (sample.useBarlowBeestonLight) {
859 sample.histError.resize(sample.hist.size());
860 for (auto bin : rel_errors) {
861 // reverse engineering the correct partial error
862 // the (arbitrary) convention used here is that all samples should have the same relative error
863 const int i = bin.first;
864 const double relerr_tot = bin.second;
865 const double count = sample.hist[i - 1];
866 // this reconstruction is inherently imprecise, so we truncate it at some decimal places to make sure that
867 // we don't carry around too many useless digits
868 sample.histError[i - 1] = round_prec(relerr_tot * tot_yield[i] / std::sqrt(tot_yield2[i]) * count, 7);
869 }
870 }
871 }
872
873 bool observablesWritten = false;
874 for (const auto &sample : samples) {
875
876 elem["type"] << "histfactory_dist";
877
878 auto &s = RooJSONFactoryWSTool::appendNamedChild(elem["samples"], sample.name);
879
880 auto &modifiers = s["modifiers"];
881 modifiers.set_seq();
882
883 for (const auto &nf : sample.normfactors) {
884 auto &mod = modifiers.append_child();
885 mod.set_map();
886 mod["name"] << nf.name;
887 mod["parameter"] << nf.param->GetName();
888 mod["type"] << "normfactor";
889 if (nf.constraint) {
890 mod["constraint_name"] << nf.constraint->GetName();
891 tool->queueExport(*nf.constraint);
892 }
893 }
894
895 for (const auto &sys : sample.normsys) {
896 auto &mod = modifiers.append_child();
897 mod.set_map();
898 mod["name"] << sys.name;
899 mod["type"] << "normsys";
900 mod["parameter"] << sys.param->GetName();
901 mod["constraint"] << toString(sys.constraint);
902 auto &data = mod["data"].set_map();
903 data["lo"] << sys.low;
904 data["hi"] << sys.high;
905 }
906
907 for (const auto &sys : sample.histosys) {
908 auto &mod = modifiers.append_child();
909 mod.set_map();
910 mod["name"] << sys.name;
911 mod["type"] << "histosys";
912 mod["parameter"] << sys.param->GetName();
913 mod["constraint"] << toString(sys.constraint);
914 auto &data = mod["data"].set_map();
915 if (nBins != sys.low.size() || nBins != sys.high.size()) {
916 std::stringstream ss;
917 ss << "inconsistent binning: " << nBins << " bins expected, but " << sys.low.size() << "/"
918 << sys.high.size() << " found in nominal histogram errors!";
919 RooJSONFactoryWSTool::error(ss.str().c_str());
920 }
921 RooJSONFactoryWSTool::exportArray(nBins, sys.low.data(), data["lo"].set_map()["contents"]);
922 RooJSONFactoryWSTool::exportArray(nBins, sys.high.data(), data["hi"].set_map()["contents"]);
923 }
924
925 for (const auto &sys : sample.shapesys) {
926 auto &mod = modifiers.append_child();
927 mod.set_map();
928 mod["name"] << sys.name;
929 mod["type"] << "shapesys";
930 optionallyExportGammaParameters(mod, sys.name, sys.parameters);
931 mod["constraint"] << toString(sys.constraint);
932 if (sys.constraint) {
933 auto &vals = mod["data"].set_map()["vals"];
934 vals.fill_seq(sys.constraints);
935 } else {
936 auto &vals = mod["data"].set_map()["vals"];
937 vals.set_seq();
938 for (std::size_t i = 0; i < sys.parameters.size(); ++i) {
939 vals.append_child() << 0;
940 }
941 }
942 }
943
944 for (const auto &other : sample.otherElements) {
945 auto &mod = modifiers.append_child();
946 mod.set_map();
947 mod["name"] << other->GetName();
948 customModifiers.add(*other);
949 mod["type"] << "custom";
950 }
951
952 if (sample.useBarlowBeestonLight) {
953 auto &mod = modifiers.append_child();
954 mod.set_map();
955 mod["name"] << ::Literals::staterror;
956 mod["type"] << ::Literals::staterror;
957 optionallyExportGammaParameters(mod, "stat_" + channelName, sample.staterrorParameters);
958 mod["constraint"] << toString(sample.barlowBeestonLightConstraint);
959 }
960
961 if (!observablesWritten) {
962 auto &output = elem["axes"].set_seq();
963 for (auto *obs : static_range_cast<RooRealVar *>(*varSet)) {
964 auto &out = output.append_child().set_map();
965 out["name"] << obs->GetName();
966 writeAxis(out, *obs);
967 }
968 observablesWritten = true;
969 }
970 auto &dataNode = s["data"].set_map();
971 if (nBins != sample.hist.size()) {
972 std::stringstream ss;
973 ss << "inconsistent binning: " << nBins << " bins expected, but " << sample.hist.size()
974 << " found in nominal histogram!";
975 RooJSONFactoryWSTool::error(ss.str().c_str());
976 }
977 RooJSONFactoryWSTool::exportArray(nBins, sample.hist.data(), dataNode["contents"]);
978 if (!sample.histError.empty()) {
979 if (nBins != sample.histError.size()) {
980 std::stringstream ss;
981 ss << "inconsistent binning: " << nBins << " bins expected, but " << sample.histError.size()
982 << " found in nominal histogram errors!";
983 RooJSONFactoryWSTool::error(ss.str().c_str());
984 }
985 RooJSONFactoryWSTool::exportArray(nBins, sample.histError.data(), dataNode["errors"]);
986 }
987 }
988
989 // Export all the custom modifiers
990 for (RooAbsArg *modifier : customModifiers) {
991 tool->queueExport(*modifier);
992 }
993
994 // Export all model parameters
995 RooArgSet parameters;
996 sumpdf->getParameters(varSet, parameters);
997 for (RooAbsArg *param : parameters) {
998 // This should exclude the global observables
999 if (!startsWith(std::string{param->GetName()}, "nom_")) {
1000 tool->queueExport(*param);
1001 }
1002 }
1003
1004 return true;
1005}
1006
1007class HistFactoryStreamer_ProdPdf : public RooFit::JSONIO::Exporter {
1008public:
1009 bool autoExportDependants() const override { return false; }
1010 bool tryExport(RooJSONFactoryWSTool *tool, const RooProdPdf *prodpdf, JSONNode &elem) const
1011 {
1012 RooRealSumPdf *sumpdf = nullptr;
1013 for (RooAbsArg *v : prodpdf->pdfList()) {
1014 sumpdf = dynamic_cast<RooRealSumPdf *>(v);
1015 }
1016 return tryExportHistFactory(tool, prodpdf->GetName(), sumpdf, elem);
1017 }
1018 std::string const &key() const override
1019 {
1020 static const std::string keystring = "histfactory_dist";
1021 return keystring;
1022 }
1023 bool exportObject(RooJSONFactoryWSTool *tool, const RooAbsArg *p, JSONNode &elem) const override
1024 {
1025 return tryExport(tool, static_cast<const RooProdPdf *>(p), elem);
1026 }
1027};
1028
1029class HistFactoryStreamer_SumPdf : public RooFit::JSONIO::Exporter {
1030public:
1031 bool autoExportDependants() const override { return false; }
1032 bool tryExport(RooJSONFactoryWSTool *tool, const RooRealSumPdf *sumpdf, JSONNode &elem) const
1033 {
1034 return tryExportHistFactory(tool, sumpdf->GetName(), sumpdf, elem);
1035 }
1036 std::string const &key() const override
1037 {
1038 static const std::string keystring = "histfactory_dist";
1039 return keystring;
1040 }
1041 bool exportObject(RooJSONFactoryWSTool *tool, const RooAbsArg *p, JSONNode &elem) const override
1042 {
1043 return tryExport(tool, static_cast<const RooRealSumPdf *>(p), elem);
1044 }
1045};
1046
1047STATIC_EXECUTE([]() {
1048 using namespace RooFit::JSONIO;
1049
1050 registerImporter<HistFactoryImporter>("histfactory_dist", true);
1051 registerImporter<PiecewiseInterpolationFactory>("interpolation", true);
1052 registerImporter<FlexibleInterpVarFactory>("interpolation0d", true);
1053 registerExporter<FlexibleInterpVarStreamer>(RooStats::HistFactory::FlexibleInterpVar::Class(), true);
1054 registerExporter<PiecewiseInterpolationStreamer>(PiecewiseInterpolation::Class(), true);
1055 registerExporter<HistFactoryStreamer_ProdPdf>(RooProdPdf::Class(), true);
1056 registerExporter<HistFactoryStreamer_SumPdf>(RooRealSumPdf::Class(), true);
1057});
1058
1059} // namespace
bool startsWith(std::string_view str, std::string_view prefix)
bool endsWith(std::string_view str, std::string_view suffix)
#define d(i)
Definition RSha256.hxx:102
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
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 funcs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t modifier
char name[80]
Definition TGX11.cxx:110
#define hi
TClass * IsA() const override
Definition TStringLong.h:20
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
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.
void setInterpCode(RooAbsReal &param, int code, bool silent=false)
static TClass * Class()
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.
Definition RooAbsArg.h:77
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.
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...
Storage_t const & get() const
Const access to the underlying stl container.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
TClass * IsA() const override
Definition RooAbsPdf.h:352
Int_t numBins(const char *rangeName=nullptr) const override
void setConstant(bool value=true)
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition RooArgList.h:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Returns the bin width (or volume) given a RooHistFunc.
Represents a constant real-valued object.
Definition RooConstVar.h:23
Container class to hold N-dimensional binned data.
Definition RooDataHist.h:39
virtual std::string val() const =0
void fill_seq(Collection const &coll)
virtual JSONNode & set_map()=0
virtual JSONNode & append_child()=0
virtual JSONNode & set_seq()=0
virtual bool has_child(std::string const &) const =0
JSONNode const * find(std::string const &key) const
virtual bool autoExportDependants() const
Definition JSONIO.h:58
virtual std::string const & key() const =0
virtual bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *, RooFit::Detail::JSONNode &) const
Definition JSONIO.h:59
virtual bool importArg(RooJSONFactoryWSTool *tool, const RooFit::Detail::JSONNode &node) const
Definition JSONIO.h:37
Plain Gaussian p.d.f.
Definition RooGaussian.h:24
static TClass * Class()
RooAbsReal const & getMean() const
Get the mean parameter.
Definition RooGaussian.h:48
RooAbsReal const & getSigma() const
Get the sigma parameter.
Definition RooGaussian.h:51
A real-valued function sampled from a multidimensional histogram.
Definition RooHistFunc.h:31
When using RooFit, statistical models can be conveniently handled and stored as a RooWorkspace.
static void fillSeq(RooFit::Detail::JSONNode &node, RooAbsCollection const &coll, size_t nMax=-1)
T * requestArg(const RooFit::Detail::JSONNode &node, const std::string &key)
T * request(const std::string &objname, const std::string &requestAuthor)
static std::unique_ptr< RooDataHist > readBinnedData(const RooFit::Detail::JSONNode &n, const std::string &namecomp, RooArgSet const &vars)
Read binned data from the JSONNode and create a RooDataHist object.
static RooFit::Detail::JSONNode & appendNamedChild(RooFit::Detail::JSONNode &node, std::string const &name)
static void exportArray(std::size_t n, double const *contents, RooFit::Detail::JSONNode &output)
Export an array of doubles to a JSONNode.
void queueExport(RooAbsArg const &arg)
RooArgList requestArgList(const RooFit::Detail::JSONNode &node, const std::string &seqName)
static void error(const char *s)
Writes an error message to the RooFit message service and throws a runtime_error.
Obj_t & wsEmplace(RooStringView name, Args_t &&...args)
static std::string name(const RooFit::Detail::JSONNode &n)
static RooArgSet readAxes(const RooFit::Detail::JSONNode &node)
Read axes from the JSONNode and create a RooArgSet representing them.
RooFit Lognormal PDF.
static TClass * Class()
Poisson pdf.
Definition RooPoisson.h:19
RooAbsReal const & getX() const
Get the x variable.
Definition RooPoisson.h:43
static TClass * Class()
Efficient implementation of a product of PDFs of the form.
Definition RooProdPdf.h:33
static TClass * Class()
Represents the product of a given set of RooAbsReal objects.
Definition RooProduct.h:29
Implements a PDF constructed from a sum of functions:
const RooArgList & funcList() const
static TClass * Class()
const RooArgList & coefList() const
Variable that can be changed from the outside.
Definition RooRealVar.h:37
void setError(double value)
Definition RooRealVar.h:60
const RooAbsBinning & getBinning(const char *name=nullptr, bool verbose=true, bool createOnTheFly=false) const override
Return binning definition with name.
void setInterpCode(RooAbsReal &param, int code)
const RooListProxy & variables() const
const std::vector< double > & high() const
const std::vector< double > & low() const
Configuration for a constrained, coherent shape variation of affected samples.
Configuration for an un- constrained overall systematic to scale sample normalisations.
Definition Systematics.h:62
Constrained bin-by-bin variation of affected histogram.
Persistable container for RooFit projects.
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooAbsReal * function(RooStringView name) const
Retrieve function (RooAbsReal) with given name. Note that all RooAbsPdfs are also RooAbsReals....
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.
RooFactoryWSTool & factory()
Return instance to factory tool.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Basic string class.
Definition TString.h:139
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
RooCmdArg RecycleConflictNodes(bool flag=true)
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, bool depsAreCond=false)
const Int_t n
Definition legend1.C:16
double gamma(double x)
double T(double x)
CreateGammaConstraintsOutput createGammaConstraints(RooArgList const &paramList, std::span< const double > relSigmas, double minSigma, Constraint::Type type)
#define STATIC_EXECUTE(MY_FUNC)
TLine l
Definition textangle.C:4
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345
static void output()