Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
JSONFactories_RooFitCore.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
15#include <RooAddPdf.h>
16#include <RooBinSamplingPdf.h>
17#include <RooBinWidthFunction.h>
18#include <RooCategory.h>
19#include <RooDataHist.h>
20#include <RooExponential.h>
22#include <RooFitHS3/JSONIO.h>
23#include <RooFormulaVar.h>
24#include <RooGenericPdf.h>
25#include <RooHistFunc.h>
26#include <RooHistPdf.h>
27#include <RooLognormal.h>
28#include <RooMultiVarGaussian.h>
29#include <RooPoisson.h>
30#include <RooPolynomial.h>
31#include <RooRealSumFunc.h>
32#include <RooRealSumPdf.h>
33#include <RooRealVar.h>
34#include <RooTFnBinding.h>
35#include <RooWorkspace.h>
36
37#include <TF1.h>
38#include <TH1.h>
39
40#include "static_execute.h"
41
42#include <algorithm>
43#include <cctype>
44
46
47///////////////////////////////////////////////////////////////////////////////////////////////////////
48// individually implemented importers
49///////////////////////////////////////////////////////////////////////////////////////////////////////
50
51namespace {
52/**
53 * Extracts arguments from a mathematical expression.
54 *
55 * This function takes a string representing a mathematical
56 * expression and extracts the arguments from it. The arguments are
57 * defined as sequences of characters that do not contain digits,
58 * spaces, or parentheses, and that start with a letter. Function
59 * calls such as "exp( ... )", identified as being followed by an
60 * opening parenthesis, are not treated as arguments. The extracted
61 * arguments are returned as a vector of strings.
62 *
63 * @param expr A string representing a mathematical expression.
64 * @return A vector of strings representing the extracted arguments.
65 */
66std::vector<std::string> extractArguments(std::string expr)
67{
68 // Get rid of whitespaces
69 expr.erase(std::remove_if(expr.begin(), expr.end(), [](unsigned char c) { return std::isspace(c); }), expr.end());
70
71 std::vector<std::string> arguments;
72 size_t startidx = expr.size();
73 for (size_t i = 0; i < expr.size(); ++i) {
74 if (startidx >= expr.size()) {
75 if (isalpha(expr[i])) {
76 startidx = i;
77 }
78 } else {
79 if (!isdigit(expr[i]) && !isalpha(expr[i]) && expr[i] != '_') {
80 if (expr[i] == '(') {
81 startidx = expr.size();
82 continue;
83 }
84 std::string arg(expr.substr(startidx, i - startidx));
85 startidx = expr.size();
86 arguments.push_back(arg);
87 }
88 }
89 }
90 if (startidx < expr.size()) {
91 arguments.push_back(expr.substr(startidx));
92 }
93 return arguments;
94}
95
96template <class RooArg_t>
97class RooFormulaArgFactory : public RooFit::JSONIO::Importer {
98public:
99 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
100 {
101 std::string name(RooJSONFactoryWSTool::name(p));
102 if (!p.has_child("expression")) {
103 RooJSONFactoryWSTool::error("no expression given for '" + name + "'");
104 }
105 TString formula(p["expression"].val());
106 RooArgList dependents;
107 for (const auto &d : extractArguments(formula.Data())) {
108 dependents.add(*tool->request<RooAbsReal>(d, name));
109 }
110 tool->wsImport(RooArg_t{name.c_str(), formula, dependents});
111 return true;
112 }
113};
114
115class RooAddPdfFactory : public RooFit::JSONIO::Importer {
116public:
117 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
118 {
119 std::string name(RooJSONFactoryWSTool::name(p));
120 tool->wsEmplace<RooAddPdf>(name, tool->requestArgList<RooAbsPdf>(p, "summands"),
121 tool->requestArgList<RooAbsReal>(p, "coefficients"));
122 return true;
123 }
124};
125
126class RooBinWidthFunctionFactory : public RooFit::JSONIO::Importer {
127public:
128 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
129 {
130 std::string name(RooJSONFactoryWSTool::name(p));
131 RooHistFunc *hf = static_cast<RooHistFunc *>(tool->request<RooAbsReal>(p["histogram"].val(), name));
132 tool->wsEmplace<RooBinWidthFunction>(name, *hf, p["divideByBinWidth"].val_bool());
133 return true;
134 }
135};
136
137class RooBinSamplingPdfFactory : public RooFit::JSONIO::Importer {
138public:
139 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
140 {
141 std::string name(RooJSONFactoryWSTool::name(p));
142
143 RooAbsPdf *pdf = tool->requestArg<RooAbsPdf>(p, "pdf");
144 RooRealVar *obs = tool->requestArg<RooRealVar>(p, "observable");
145
146 if (!pdf->dependsOn(*obs)) {
147 RooJSONFactoryWSTool::error(std::string("pdf '") + pdf->GetName() + "' does not depend on observable '" +
148 obs->GetName() + "' as indicated by parent RooBinSamplingPdf '" + name +
149 "', please check!");
150 }
151
152 if (!p.has_child("epsilon")) {
153 RooJSONFactoryWSTool::error("no epsilon given in '" + name + "'");
154 }
155 double epsilon(p["epsilon"].val_double());
156
157 tool->wsEmplace<RooBinSamplingPdf>(name, *obs, *pdf, epsilon);
158
159 return true;
160 }
161};
162
163class RooRealSumPdfFactory : public RooFit::JSONIO::Importer {
164public:
165 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
166 {
167 std::string name(RooJSONFactoryWSTool::name(p));
168
169 bool extended = false;
170 if (p.has_child("extended") && p["extended"].val_bool()) {
171 extended = true;
172 }
173 tool->wsEmplace<RooRealSumPdf>(name, tool->requestArgList<RooAbsReal>(p, "samples"),
174 tool->requestArgList<RooAbsReal>(p, "coefficients"), extended);
175 return true;
176 }
177};
178
179class RooRealSumFuncFactory : public RooFit::JSONIO::Importer {
180public:
181 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
182 {
183 std::string name(RooJSONFactoryWSTool::name(p));
184 tool->wsEmplace<RooRealSumFunc>(name, tool->requestArgList<RooAbsReal>(p, "samples"),
185 tool->requestArgList<RooAbsReal>(p, "coefficients"));
186 return true;
187 }
188};
189
190class RooPolynomialFactory : public RooFit::JSONIO::Importer {
191public:
192 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
193 {
194 std::string name(RooJSONFactoryWSTool::name(p));
195 if (!p.has_child("coefficients")) {
196 RooJSONFactoryWSTool::error("no coefficients given in '" + name + "'");
197 }
198 RooAbsReal *x = tool->requestArg<RooAbsReal>(p, "x");
199 RooArgList coefs;
200 int order = 0;
201 int lowestOrder = 0;
202 for (const auto &coef : p["coefficients"].children()) {
203 // As long as the coefficients match the default coefficients in
204 // RooFit, we don't have to instantiate RooFit objects but can
205 // increase the lowestOrder flag.
206 if (order == 0 && coef.val() == "1.0") {
207 ++lowestOrder;
208 } else if (coefs.empty() && coef.val() == "0.0") {
209 ++lowestOrder;
210 } else {
211 coefs.add(*tool->request<RooAbsReal>(coef.val(), name));
212 }
213 ++order;
214 }
215
216 tool->wsEmplace<RooPolynomial>(name, *x, coefs, lowestOrder);
217 return true;
218 }
219};
220
221class RooPoissonFactory : public RooFit::JSONIO::Importer {
222public:
223 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
224 {
225 std::string name(RooJSONFactoryWSTool::name(p));
226 RooAbsReal *x = tool->requestArg<RooAbsReal>(p, "x");
227 RooAbsReal *mean = tool->requestArg<RooAbsReal>(p, "mean");
228 tool->wsEmplace<RooPoisson>(name, *x, *mean, !p["integer"].val_bool());
229 return true;
230 }
231};
232
233class RooLogNormalFactory : public RooFit::JSONIO::Importer {
234public:
235 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
236 {
237 std::string name(RooJSONFactoryWSTool::name(p));
238 RooAbsReal *x = tool->requestArg<RooAbsReal>(p, "x");
239 RooAbsReal *mu = tool->requestArg<RooAbsReal>(p, "mu");
240 RooAbsReal *sigma = tool->requestArg<RooAbsReal>(p, "sigma");
241
242 // TODO: check if the pdf was originally exported by ROOT, in which case
243 // it can be imported back without using the standard parametrization.
244 tool->wsEmplace<RooLognormal>(name, *x, *mu, *sigma, true);
245 return true;
246 }
247};
248
249class RooExponentialFactory : public RooFit::JSONIO::Importer {
250public:
251 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
252 {
253 std::string name(RooJSONFactoryWSTool::name(p));
254 RooAbsReal *x = tool->requestArg<RooAbsReal>(p, "x");
255 RooAbsReal *c = tool->requestArg<RooAbsReal>(p, "c");
256
257 // TODO: check if the pdf was originally exported by ROOT, in which case
258 // it can be imported back without using the standard parametrization.
259 tool->wsEmplace<RooExponential>(name, *x, *c, true);
260 return true;
261 }
262};
263
264class RooMultiVarGaussianFactory : public RooFit::JSONIO::Importer {
265public:
266 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
267 {
268 std::string name(RooJSONFactoryWSTool::name(p));
269 bool has_cov = p.has_child("covariances");
270 bool has_corr = p.has_child("correlations") && p.has_child("standard_deviations");
271 if (!has_cov && !has_corr) {
272 RooJSONFactoryWSTool::error("no covariances or correlations+standard_deviations given in '" + name + "'");
273 }
274
275 TMatrixDSym covmat;
276
277 if (has_cov) {
278 int n = p["covariances"].num_children();
279 int i = 0;
280 covmat.ResizeTo(n, n);
281 for (const auto &row : p["covariances"].children()) {
282 int j = 0;
283 for (const auto &val : row.children()) {
284 covmat(i, j) = val.val_double();
285 ++j;
286 }
287 ++i;
288 }
289 } else {
290 std::vector<double> variances;
291 for (const auto &v : p["standard_deviations"].children()) {
292 variances.push_back(v.val_double());
293 }
294 covmat.ResizeTo(variances.size(), variances.size());
295 int i = 0;
296 for (const auto &row : p["correlations"].children()) {
297 int j = 0;
298 for (const auto &val : row.children()) {
299 covmat(i, j) = val.val_double() * variances[i] * variances[j];
300 ++j;
301 }
302 ++i;
303 }
304 }
306 tool->requestArgList<RooAbsReal>(p, "mean"), covmat);
307 return true;
308 }
309};
310
311///////////////////////////////////////////////////////////////////////////////////////////////////////
312// specialized exporter implementations
313///////////////////////////////////////////////////////////////////////////////////////////////////////
314
315class RooAddPdfStreamer : public RooFit::JSONIO::Exporter {
316public:
317 std::string const &key() const override;
318 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
319 {
320 const RooAddPdf *pdf = static_cast<const RooAddPdf *>(func);
321 elem["type"] << key();
322 RooJSONFactoryWSTool::fillSeq(elem["summands"], pdf->pdfList());
323 RooJSONFactoryWSTool::fillSeq(elem["coefficients"], pdf->coefList());
324 elem["extended"] << (pdf->extendMode() != RooAbsPdf::CanNotBeExtended);
325 return true;
326 }
327};
328
329class RooRealSumPdfStreamer : public RooFit::JSONIO::Exporter {
330public:
331 std::string const &key() const override;
332 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
333 {
334 const RooRealSumPdf *pdf = static_cast<const RooRealSumPdf *>(func);
335 elem["type"] << key();
336 RooJSONFactoryWSTool::fillSeq(elem["samples"], pdf->funcList());
337 RooJSONFactoryWSTool::fillSeq(elem["coefficients"], pdf->coefList());
338 elem["extended"] << (pdf->extendMode() != RooAbsPdf::CanNotBeExtended);
339 return true;
340 }
341};
342
343class RooRealSumFuncStreamer : public RooFit::JSONIO::Exporter {
344public:
345 std::string const &key() const override;
346 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
347 {
348 const RooRealSumFunc *pdf = static_cast<const RooRealSumFunc *>(func);
349 elem["type"] << key();
350 RooJSONFactoryWSTool::fillSeq(elem["samples"], pdf->funcList());
351 RooJSONFactoryWSTool::fillSeq(elem["coefficients"], pdf->coefList());
352 return true;
353 }
354};
355
356class RooHistFuncStreamer : public RooFit::JSONIO::Exporter {
357public:
358 std::string const &key() const override;
359 bool exportObject(RooJSONFactoryWSTool *tool, const RooAbsArg *func, JSONNode &elem) const override
360 {
361 const RooHistFunc *hf = static_cast<const RooHistFunc *>(func);
362 elem["type"] << key();
363 RooDataHist const &dh = hf->dataHist();
364 tool->exportHisto(*dh.get(), dh.numEntries(), dh.weightArray(), elem["data"].set_map());
365 return true;
366 }
367};
368
369class RooHistFuncFactory : public RooFit::JSONIO::Importer {
370public:
371 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
372 {
373 std::string name(RooJSONFactoryWSTool::name(p));
374 if (!p.has_child("data")) {
375 RooJSONFactoryWSTool::error("function '" + name + "' is of histogram type, but does not define a 'data' key");
376 }
377 std::unique_ptr<RooDataHist> dataHist =
379 tool->wsEmplace<RooHistFunc>(name, *dataHist->get(), *dataHist);
380 return true;
381 }
382};
383
384class RooHistPdfStreamer : public RooFit::JSONIO::Exporter {
385public:
386 std::string const &key() const override;
387 bool exportObject(RooJSONFactoryWSTool *tool, const RooAbsArg *func, JSONNode &elem) const override
388 {
389 const RooHistPdf *hf = static_cast<const RooHistPdf *>(func);
390 elem["type"] << key();
391 RooDataHist const &dh = hf->dataHist();
392 tool->exportHisto(*dh.get(), dh.numEntries(), dh.weightArray(), elem["data"].set_map());
393 return true;
394 }
395};
396
397class RooHistPdfFactory : public RooFit::JSONIO::Importer {
398public:
399 bool importArg(RooJSONFactoryWSTool *tool, const JSONNode &p) const override
400 {
401 std::string name(RooJSONFactoryWSTool::name(p));
402 if (!p.has_child("data")) {
403 RooJSONFactoryWSTool::error("function '" + name + "' is of histogram type, but does not define a 'data' key");
404 }
405 std::unique_ptr<RooDataHist> dataHist =
407 tool->wsEmplace<RooHistPdf>(name, *dataHist->get(), *dataHist);
408 return true;
409 }
410};
411
412class RooBinSamplingPdfStreamer : public RooFit::JSONIO::Exporter {
413public:
414 std::string const &key() const override;
415 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
416 {
417 const RooBinSamplingPdf *pdf = static_cast<const RooBinSamplingPdf *>(func);
418 elem["type"] << key();
419 elem["pdf"] << pdf->pdf().GetName();
420 elem["observable"] << pdf->observable().GetName();
421 elem["epsilon"] << pdf->epsilon();
422 return true;
423 }
424};
425
426class RooBinWidthFunctionStreamer : public RooFit::JSONIO::Exporter {
427public:
428 std::string const &key() const override;
429 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
430 {
431 const RooBinWidthFunction *pdf = static_cast<const RooBinWidthFunction *>(func);
432 elem["type"] << key();
433 elem["histogram"] << pdf->histFunc().GetName();
434 elem["divideByBinWidth"] << pdf->divideByBinWidth();
435 return true;
436 }
437};
438
439template <class RooArg_t>
440class RooFormulaArgStreamer : public RooFit::JSONIO::Exporter {
441public:
442 std::string const &key() const override;
443 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
444 {
445 const RooArg_t *pdf = static_cast<const RooArg_t *>(func);
446 elem["type"] << key();
447 TString expression(pdf->expression());
448 for (size_t i = 0; i < pdf->nParameters(); ++i) {
449 RooAbsArg *par = pdf->getParameter(i);
450 std::stringstream ss_1;
451 ss_1 << "x[" << i << "]";
452 std::stringstream ss_2;
453 ss_2 << "@" << i << "";
454 expression.ReplaceAll(ss_1.str().c_str(), par->GetName());
455 expression.ReplaceAll(ss_2.str().c_str(), par->GetName());
456 }
457 elem["expression"] << expression.Data();
458 return true;
459 }
460};
461
462class RooPolynomialStreamer : public RooFit::JSONIO::Exporter {
463public:
464 std::string const &key() const override;
465 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
466 {
467 auto *pdf = static_cast<const RooPolynomial *>(func);
468 elem["type"] << key();
469 elem["x"] << pdf->x().GetName();
470 auto &coefs = elem["coefficients"].set_seq();
471 // Write out the default coefficient that RooFit uses for the lower
472 // orders before the order of the first coefficient. Like this, the
473 // output is more self-documenting.
474 for (int i = 0; i < pdf->lowestOrder(); ++i) {
475 coefs.append_child() << (i == 0 ? "1.0" : "0.0");
476 }
477 for (const auto &coef : pdf->coefList()) {
478 coefs.append_child() << coef->GetName();
479 }
480 return true;
481 }
482};
483
484class RooPoissonStreamer : public RooFit::JSONIO::Exporter {
485public:
486 std::string const &key() const override;
487 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
488 {
489 auto *pdf = static_cast<const RooPoisson *>(func);
490 elem["type"] << key();
491 elem["x"] << pdf->getX().GetName();
492 elem["mean"] << pdf->getMean().GetName();
493 elem["integer"] << !pdf->getNoRounding();
494 return true;
495 }
496};
497
498class RooLogNormalStreamer : public RooFit::JSONIO::Exporter {
499public:
500 std::string const &key() const override;
501 bool exportObject(RooJSONFactoryWSTool *tool, const RooAbsArg *func, JSONNode &elem) const override
502 {
503 auto *pdf = static_cast<const RooLognormal *>(func);
504
505 elem["type"] << key();
506 elem["x"] << pdf->getX().GetName();
507
508 auto &m0 = pdf->getMedian();
509 auto &k = pdf->getShapeK();
510
511 if(pdf->useStandardParametrization()) {
512 elem["mu"] << m0.GetName();
513 elem["sigma"] << k.GetName();
514 } else {
515 elem["mu"] << tool->exportTransformed(&m0, "lognormal", "log", "log(%s)");
516 elem["sigma"] << tool->exportTransformed(&k, "lognormal", "log", "log(%s)");
517 }
518
519 return true;
520 }
521};
522
523class RooExponentialStreamer : public RooFit::JSONIO::Exporter {
524public:
525 std::string const &key() const override;
526 bool exportObject(RooJSONFactoryWSTool *tool, const RooAbsArg *func, JSONNode &elem) const override
527 {
528 auto *pdf = static_cast<const RooExponential *>(func);
529 elem["type"] << key();
530 elem["x"] << pdf->variable().GetName();
531 auto &c = pdf->coefficient();
532 if (pdf->negateCoefficient()) {
533 elem["c"] << c.GetName();
534 } else {
535 elem["c"] << tool->exportTransformed(&c, "exponential", "inverted", "-%s");
536 }
537
538 return true;
539 }
540};
541
542class RooMultiVarGaussianStreamer : public RooFit::JSONIO::Exporter {
543public:
544 std::string const &key() const override;
545 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
546 {
547 auto *pdf = static_cast<const RooMultiVarGaussian *>(func);
548 elem["type"] << key();
549 RooJSONFactoryWSTool::fillSeq(elem["x"], pdf->xVec());
550 RooJSONFactoryWSTool::fillSeq(elem["mean"], pdf->muVec());
551 elem["covariances"].fill_mat(pdf->covarianceMatrix());
552 return true;
553 }
554};
555
556class RooTFnBindingStreamer : public RooFit::JSONIO::Exporter {
557public:
558 std::string const &key() const override;
559 bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
560 {
561 auto *pdf = static_cast<const RooTFnBinding *>(func);
562 elem["type"] << key();
563
564 TString formula(pdf->function().GetExpFormula());
565 formula.ReplaceAll("x", pdf->observables()[0].GetName());
566 formula.ReplaceAll("y", pdf->observables()[1].GetName());
567 formula.ReplaceAll("z", pdf->observables()[2].GetName());
568 for (size_t i = 0; i < pdf->parameters().size(); ++i) {
569 TString pname(TString::Format("[%d]", (int)i));
570 formula.ReplaceAll(pname, pdf->parameters()[i].GetName());
571 }
572 elem["expression"] << formula.Data();
573 return true;
574 }
575};
576
577#define DEFINE_EXPORTER_KEY(class_name, name) \
578 std::string const &class_name::key() const \
579 { \
580 const static std::string keystring = name; \
581 return keystring; \
582 }
583
584DEFINE_EXPORTER_KEY(RooAddPdfStreamer, "mixture_dist");
585DEFINE_EXPORTER_KEY(RooBinSamplingPdfStreamer, "binsampling");
586DEFINE_EXPORTER_KEY(RooBinWidthFunctionStreamer, "binwidth");
587DEFINE_EXPORTER_KEY(RooExponentialStreamer, "exponential_dist");
588template <>
589DEFINE_EXPORTER_KEY(RooFormulaArgStreamer<RooFormulaVar>, "generic_function");
590template <>
591DEFINE_EXPORTER_KEY(RooFormulaArgStreamer<RooGenericPdf>, "generic_dist");
592DEFINE_EXPORTER_KEY(RooHistFuncStreamer, "histogram");
593DEFINE_EXPORTER_KEY(RooHistPdfStreamer, "histogram_dist");
594DEFINE_EXPORTER_KEY(RooLogNormalStreamer, "lognormal_dist");
595DEFINE_EXPORTER_KEY(RooMultiVarGaussianStreamer, "multivariate_normal_dist");
596DEFINE_EXPORTER_KEY(RooPoissonStreamer, "poisson_dist");
597DEFINE_EXPORTER_KEY(RooPolynomialStreamer, "polynomial_dist");
598DEFINE_EXPORTER_KEY(RooRealSumFuncStreamer, "weighted_sum");
599DEFINE_EXPORTER_KEY(RooRealSumPdfStreamer, "weighted_sum_dist");
600DEFINE_EXPORTER_KEY(RooTFnBindingStreamer, "generic_function");
601
602///////////////////////////////////////////////////////////////////////////////////////////////////////
603// instantiate all importers and exporters
604///////////////////////////////////////////////////////////////////////////////////////////////////////
605
606STATIC_EXECUTE([]() {
607 using namespace RooFit::JSONIO;
608
609 registerImporter<RooAddPdfFactory>("mixture_dist", false);
610 registerImporter<RooBinSamplingPdfFactory>("binsampling_dist", false);
611 registerImporter<RooBinWidthFunctionFactory>("binwidth", false);
612 registerImporter<RooExponentialFactory>("exponential_dist", false);
613 registerImporter<RooFormulaArgFactory<RooFormulaVar>>("generic_function", false);
614 registerImporter<RooFormulaArgFactory<RooGenericPdf>>("generic_dist", false);
615 registerImporter<RooHistFuncFactory>("histogram", false);
616 registerImporter<RooHistPdfFactory>("histogram_dist", false);
617 registerImporter<RooLogNormalFactory>("lognormal_dist", false);
618 registerImporter<RooMultiVarGaussianFactory>("multivariate_normal_dist", false);
619 registerImporter<RooPoissonFactory>("poisson_dist", false);
620 registerImporter<RooPolynomialFactory>("polynomial_dist", false);
621 registerImporter<RooRealSumPdfFactory>("weighted_sum_dist", false);
622 registerImporter<RooRealSumFuncFactory>("weighted_sum", false);
623
624 registerExporter<RooAddPdfStreamer>(RooAddPdf::Class(), false);
625 registerExporter<RooBinSamplingPdfStreamer>(RooBinSamplingPdf::Class(), false);
626 registerExporter<RooBinWidthFunctionStreamer>(RooBinWidthFunction::Class(), false);
627 registerExporter<RooExponentialStreamer>(RooExponential::Class(), false);
628 registerExporter<RooFormulaArgStreamer<RooFormulaVar>>(RooFormulaVar::Class(), false);
629 registerExporter<RooFormulaArgStreamer<RooGenericPdf>>(RooGenericPdf::Class(), false);
630 registerExporter<RooHistFuncStreamer>(RooHistFunc::Class(), false);
631 registerExporter<RooHistPdfStreamer>(RooHistPdf::Class(), false);
632 registerExporter<RooLogNormalStreamer>(RooLognormal::Class(), false);
633 registerExporter<RooMultiVarGaussianStreamer>(RooMultiVarGaussian::Class(), false);
634 registerExporter<RooPoissonStreamer>(RooPoisson::Class(), false);
635 registerExporter<RooPolynomialStreamer>(RooPolynomial::Class(), false);
636 registerExporter<RooRealSumFuncStreamer>(RooRealSumFunc::Class(), false);
637 registerExporter<RooRealSumPdfStreamer>(RooRealSumPdf::Class(), false);
638 registerExporter<RooTFnBindingStreamer>(RooTFnBinding::Class(), false);
639});
640
641} // namespace
#define DEFINE_EXPORTER_KEY(class_name, name)
#define d(i)
Definition RSha256.hxx:102
#define c(i)
Definition RSha256.hxx:101
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter p
char name[80]
Definition TGX11.cxx:110
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
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.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
@ CanNotBeExtended
Definition RooAbsPdf.h:212
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
Efficient implementation of a sum of PDFs of the form.
Definition RooAddPdf.h:33
const RooArgList & coefList() const
Definition RooAddPdf.h:74
ExtendMode extendMode() const override
Returns ability of PDF to provide extended likelihood terms.
Definition RooAddPdf.h:60
static TClass * Class()
const RooArgList & pdfList() const
Definition RooAddPdf.h:70
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
The RooBinSamplingPdf is supposed to be used as an adapter between a continuous PDF and a binned dist...
static TClass * Class()
double epsilon() const
const RooAbsPdf & pdf() const
const RooAbsReal & observable() const
RooBinWidthFunction is a class that returns the bin width (or volume) given a RooHistFunc.
const RooHistFunc & histFunc() const
static TClass * Class()
The RooDataHist is a container class to hold N-dimensional binned data.
Definition RooDataHist.h:39
double const * weightArray() const
const RooArgSet * get() const override
Get bin centre of current bin.
Definition RooDataHist.h:76
Exponential PDF.
static TClass * Class()
virtual JSONNode & append_child()=0
virtual JSONNode & set_seq()=0
void fill_mat(Matrix const &mat)
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
static TClass * Class()
static TClass * Class()
RooHistFunc implements a real-valued function sampled from a multidimensional histogram.
Definition RooHistFunc.h:31
RooDataHist & dataHist()
Return RooDataHist that is represented.
Definition RooHistFunc.h:45
static TClass * Class()
RooHistPdf implements a propability density function sampled from a multidimensional histogram.
Definition RooHistPdf.h:30
static TClass * Class()
RooDataHist & dataHist()
Definition RooHistPdf.h:43
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)
Obj_t & wsImport(Obj_t const &obj)
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 void exportHisto(RooArgSet const &vars, std::size_t n, double const *contents, RooFit::Detail::JSONNode &output)
Export histogram data to a JSONNode.
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.
std::string exportTransformed(const RooAbsReal *original, const std::string &tag, const std::string &operation_name, const std::string &formula)
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()
Multivariate Gaussian p.d.f.
static TClass * Class()
Poisson pdf.
Definition RooPoisson.h:19
static TClass * Class()
RooPolynomial implements a polynomial p.d.f of the form.
static TClass * Class()
const RooArgList & coefList() const
const RooArgList & funcList() const
static TClass * Class()
Implements a PDF constructed from a sum of functions:
const RooArgList & funcList() const
static TClass * Class()
ExtendMode extendMode() const override
Returns ability of PDF to provide extended likelihood terms.
const RooArgList & coefList() const
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:37
Use TF1, TF2, TF3 functions as RooFit objects.
static TClass * Class()
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Basic string class.
Definition TString.h:139
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2356
const Double_t sigma
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
#define STATIC_EXECUTE(MY_FUNC)
double epsilon
Definition triangle.c:618