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#include "RooFitImplHelpers.h"
17
18#include <array>
19
20/**
21 * \class RooNormalizedPdf
22 *
23 * A RooNormalizedPdf wraps a pdf divided by its integral for a given
24 * normalization set into a new self-normalized pdf.
25 */
26
27namespace RooFit::Detail {
28
30{
31 auto nums = ctx.at(_pdf);
33
34 // We use the extraArgs as output parameter to count evaluation errors.
36
37 auto config = ctx.config(this);
38 RooBatchCompute::compute(config, RooBatchCompute::NormalizedPdf, ctx.output(), {nums, integralSpan},
40
41 if (config.useCuda()) {
42 // In CUDA mode, the counters are read back from the GPU without
43 // synchronizing the stream: they only arrive in _evalErrorCounts with
44 // the synchronization at the end of the evaluation of the full
45 // computation graph, so the logging has to be deferred until then.
46 ctx.deferAction([this] { logEvalErrorCounts(); });
47 } else {
49 }
50}
51
53{
54 const std::size_t nEvalErrorsType0 = _evalErrorCounts[0];
55 const std::size_t nEvalErrorsType1 = _evalErrorCounts[1];
56 const std::size_t nEvalErrorsType2 = _evalErrorCounts[2];
57
58 for (std::size_t i = 0; i < nEvalErrorsType0; ++i) {
59 logEvalError("p.d.f normalization integral is zero or negative");
60 }
61 for (std::size_t i = 0; i < nEvalErrorsType1; ++i) {
62 logEvalError("p.d.f value is less than zero, trying to recover");
63 }
64 for (std::size_t i = 0; i < nEvalErrorsType2; ++i) {
65 logEvalError("p.d.f value is Not-a-Number");
66 }
67}
68
69double RooNormalizedPdf::getValV(const RooArgSet * /*normSet*/) const
70{
72}
73
74} // namespace RooFit::Detail
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:107
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
RooTemplateProxy< RooAbsPdf > _pdf
double getValV(const RooArgSet *normSet) const override
Return current value, normalized by integrating over the observables in nset.
std::array< double, 3 > _evalErrorCounts
Evaluation error counters, filled by the compute function.
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})
double normalizeWithNaNPacking(RooAbsPdf const &pdf, double rawVal, double normVal)