Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooNormalizedPdf.cxx
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Jonas Rembser, CERN 2022
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 "RooBatchCompute.h"
16
17#include <array>
18
20
21/**
22 * \class RooNormalizedPdf
23 *
24 * A RooNormalizedPdf wraps a pdf divided by its integral for a given
25 * normalization set into a new self-normalized pdf.
26 */
27
28namespace RooFit {
29namespace Detail {
30
32{
33 auto nums = ctx.at(_pdf);
34 auto integralSpan = ctx.at(_normIntegral);
35
36 // We use the extraArgs as output parameter to count evaluation errors.
37 std::array<double, 3> extraArgs{0.0, 0.0, 0.0};
38
39 RooBatchCompute::compute(ctx.config(this), RooBatchCompute::NormalizedPdf, ctx.output(), {nums, integralSpan},
40 extraArgs);
41
42 std::size_t nEvalErrorsType0 = extraArgs[0];
43 std::size_t nEvalErrorsType1 = extraArgs[1];
44 std::size_t nEvalErrorsType2 = extraArgs[2];
45
46 for (std::size_t i = 0; i < nEvalErrorsType0; ++i) {
47 logEvalError("p.d.f normalization integral is zero or negative");
48 }
49 for (std::size_t i = 0; i < nEvalErrorsType1; ++i) {
50 logEvalError("p.d.f value is less than zero, trying to recover");
51 }
52 for (std::size_t i = 0; i < nEvalErrorsType2; ++i) {
53 logEvalError("p.d.f value is Not-a-Number");
54 }
55}
56
58{
59 // For now just return function/normalization integral.
60 ctx.addResult(this, ctx.getResult(_pdf) + "/" + ctx.getResult(_normIntegral));
61}
62
63} // namespace Detail
64} // namespace RooFit
#define ClassImp(name)
Definition Rtypes.h:382
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
A class to maintain the context for squashing of RooFit models into code.
void addResult(RooAbsArg const *key, std::string const &value)
A function to save an expression that includes/depends on the result of the input node.
std::string const & getResult(RooAbsArg const &arg)
Gets the result for the given node using the node name.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
RooTemplateProxy< RooAbsPdf > _pdf
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
std::span< double > output()
RooBatchCompute::Config config(RooAbsArg const *arg) const
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26