16#ifndef RooFit_RooNLLVarNew_h
17#define RooFit_RooNLLVarNew_h
34 static constexpr const char *weightVarName =
"_weight";
35 static constexpr const char *weightVarNameSumW2 =
"_weight_sumW2";
36 static constexpr const char *binVolumeVarName =
"_bin_volume";
37 static constexpr const char *weightErrorLoVarName =
"_weight_err_lo";
38 static constexpr const char *weightErrorHiVarName =
"_weight_err_hi";
40 enum class Statistic {
49 Statistic statistic = Statistic::NLL;
50 bool extended =
false;
55 RooNLLVarNew(
const char *
name,
const char *title,
RooAbsReal &func,
RooArgSet const &observables, Config
const &cfg);
56 RooNLLVarNew(
const RooNLLVarNew &other,
const char *
name =
nullptr);
57 TObject *clone(
const char *newname)
const override {
return new RooNLLVarNew(*
this, newname); }
60 double defaultErrorLevel()
const override {
return _statistic == Statistic::Chi2 ? 1.0 : 0.5; }
63 bool canComputeBatchWithCuda()
const override {
return _statistic == Statistic::NLL && !_binnedL; }
64 bool isReducerNode()
const override {
return true; }
65 bool canUseLogarithmOf(
RooAbsArg const &server,
bool outputsLogarithm)
const override;
67 void setPrefix(std::string
const &prefix);
69 void applyWeightSquared(
bool flag)
override;
71 void enableOffsetting(
bool)
override;
73 void enableBinOffsetting(
bool on =
true) { _doBinOffset =
on; }
75 void setSimCount(
int simCount)
78 _logSimCount = std::log(
static_cast<double>(simCount));
87 RooAbsReal const &func()
const {
return *_func; }
88 RooAbsReal const &weightVar()
const {
return *_weightVar; }
89 RooAbsReal const &weightSquaredVar()
const {
return *_weightSquaredVar; }
90 bool binnedL()
const {
return _binnedL; }
91 int simCount()
const {
return _simCount; }
92 Statistic statistic()
const {
return _statistic; }
93 FuncMode funcMode()
const {
return _funcMode; }
95 RooAbsReal const *expectedEvents()
const {
return _expectedEvents ? &**_expectedEvents :
nullptr; }
96 RooAbsReal const *binVolumes()
const {
return _binVolumes ? &**_binVolumes :
nullptr; }
97 RooAbsReal const *weightErrLo()
const {
return _weightErrLo ? &**_weightErrLo :
nullptr; }
98 RooAbsReal const *weightErrHi()
const {
return _weightErrHi ? &**_weightErrHi :
nullptr; }
101 double evaluate()
const override {
return _value; }
102 void resetWeightVarNames();
103 double sumOfWeights(
RooFit::EvalContext &, std::span<const double> weights,
bool squared)
const;
106 void doEvalBinnedL(
RooFit::EvalContext &, std::span<const double> preds, std::span<const double> weights)
const;
107 void doEvalChi2(
RooFit::EvalContext &, std::span<const double> preds, std::span<const double> weights,
108 std::span<const double> weightsSumW2)
const;
113 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _expectedEvents;
114 std::unique_ptr<RooTemplateProxy<RooAbsPdf>> _offsetPdf;
115 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _binVolumes;
116 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _weightErrLo;
117 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _weightErrHi;
118 bool _weightSquared =
false;
119 bool _binnedL =
false;
120 bool _doOffset =
false;
121 bool _doBinOffset =
false;
122 Statistic _statistic = Statistic::NLL;
123 FuncMode _funcMode = FuncMode::Pdf;
126 double _logSimCount = 0.;
128 std::vector<double> _binw;
130 mutable std::size_t _sumWeightGen = 0;
131 mutable double _sumWeightCache = 0.0;
132 mutable std::size_t _sumWeight2Gen = 0;
133 mutable double _sumWeight2Cache = 0.0;
#define ClassDefOverride(name, id)
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
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Abstract base class for objects that represent a real value and implements functionality common to al...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Mother of all ROOT objects.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
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.