Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooNLLVarNew.h
Go to the documentation of this file.
1/// \cond ROOFIT_INTERNAL
2
3/*
4 * Project: RooFit
5 * Authors:
6 * Jonas Rembser, CERN 2021
7 * Emmanouil Michalainas, CERN 2021
8 *
9 * Copyright (c) 2021, CERN
10 *
11 * Redistribution and use in source and binary forms,
12 * with or without modification, are permitted according to the terms
13 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
14 */
15
16#ifndef RooFit_RooNLLVarNew_h
17#define RooFit_RooNLLVarNew_h
18
19#include <RooAbsPdf.h>
20#include <RooAbsReal.h>
21#include <RooGlobalFunc.h>
22#include <RooTemplateProxy.h>
23
24#include <Math/Util.h>
25
26namespace RooFit {
27namespace Detail {
28
29class RooNLLVarNew : public RooAbsReal {
30
31public:
32 // The names for the weight variables that the RooNLLVarNew expects
33 static constexpr const char *weightVarName = "_weight";
34 static constexpr const char *weightVarNameSumW2 = "_weight_sumW2";
35
36 RooNLLVarNew(const char *name, const char *title, RooAbsPdf &pdf, RooArgSet const &observables, bool isExtended,
37 RooFit::OffsetMode offsetMode);
38 RooNLLVarNew(const RooNLLVarNew &other, const char *name = nullptr);
39 TObject *clone(const char *newname) const override { return new RooNLLVarNew(*this, newname); }
40
41 /// Return default level for MINUIT error analysis.
42 double defaultErrorLevel() const override { return 0.5; }
43
44 void doEval(RooFit::EvalContext &) const override;
45 bool canComputeBatchWithCuda() const override { return !_binnedL; }
46 bool isReducerNode() const override { return true; }
47
48 void setPrefix(std::string const &prefix);
49
50 void applyWeightSquared(bool flag) override;
51
52 void enableOffsetting(bool) override;
53
54 void enableBinOffsetting(bool on = true) { _doBinOffset = on; }
55
56 void setSimCount(int simCount) { _simCount = simCount; }
57
58 RooAbsPdf const &pdf() const { return *_pdf; }
59 RooAbsReal const &weightVar() const { return *_weightVar; }
60 bool binnedL() const { return _binnedL; }
61 int simCount() const { return _simCount; }
62 RooAbsReal const *expectedEvents() const { return _expectedEvents ? &**_expectedEvents : nullptr; }
63
64private:
65 double evaluate() const override { return _value; }
66 void resetWeightVarNames();
67 void finalizeResult(RooFit::EvalContext &, ROOT::Math::KahanSum<double> result, double weightSum) const;
68 void fillBinWidthsFromPdfBoundaries(RooAbsReal const &pdf, RooArgSet const &observables);
69 void doEvalBinnedL(RooFit::EvalContext &, std::span<const double> preds, std::span<const double> weights) const;
70
73 RooTemplateProxy<RooAbsReal> _weightSquaredVar;
74 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _expectedEvents;
75 std::unique_ptr<RooTemplateProxy<RooAbsPdf>> _offsetPdf;
76 mutable double _sumWeight = 0.0; //!
77 mutable double _sumWeight2 = 0.0; //!
78 bool _weightSquared = false;
79 bool _binnedL = false;
80 bool _doOffset = false;
81 bool _doBinOffset = false;
82 int _simCount = 1;
83 std::string _prefix;
84 std::vector<double> _binw;
85 mutable ROOT::Math::KahanSum<double> _offset{0.}; ///<! Offset as KahanSum to avoid loss of precision
86
87 ClassDefOverride(RooFit::Detail::RooNLLVarNew, 0);
88};
89
90} // namespace Detail
91} // namespace RooFit
92
93#endif
94
95/// \endcond
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
char name[80]
Definition TGX11.cxx:110
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Definition Util.h:122
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Mother of all ROOT objects.
Definition TObject.h:41
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:64
OffsetMode
For setting the offset mode with the Offset() command argument to RooAbsPdf::fitTo()
void evaluate(typename Architecture_t::Tensor_t &A, EActivationFunction f)
Apply the given activation function to each value in the given tensor A.
Definition Functions.h:98