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; }
66 void setPrefix(std::string
const &prefix);
68 void applyWeightSquared(
bool flag)
override;
70 void enableOffsetting(
bool)
override;
72 void enableBinOffsetting(
bool on =
true) { _doBinOffset =
on; }
74 void setSimCount(
int simCount) { _simCount = simCount; }
82 RooAbsReal const &func()
const {
return *_func; }
83 RooAbsReal const &weightVar()
const {
return *_weightVar; }
84 RooAbsReal const &weightSquaredVar()
const {
return *_weightSquaredVar; }
85 bool binnedL()
const {
return _binnedL; }
86 int simCount()
const {
return _simCount; }
87 Statistic statistic()
const {
return _statistic; }
88 FuncMode funcMode()
const {
return _funcMode; }
90 RooAbsReal const *expectedEvents()
const {
return _expectedEvents ? &**_expectedEvents :
nullptr; }
91 RooAbsReal const *binVolumes()
const {
return _binVolumes ? &**_binVolumes :
nullptr; }
92 RooAbsReal const *weightErrLo()
const {
return _weightErrLo ? &**_weightErrLo :
nullptr; }
93 RooAbsReal const *weightErrHi()
const {
return _weightErrHi ? &**_weightErrHi :
nullptr; }
96 double evaluate()
const override {
return _value; }
97 void resetWeightVarNames();
98 double sumOfWeights(
RooFit::EvalContext &, std::span<const double> weights,
bool squared)
const;
101 void doEvalBinnedL(
RooFit::EvalContext &, std::span<const double> preds, std::span<const double> weights)
const;
102 void doEvalChi2(
RooFit::EvalContext &, std::span<const double> preds, std::span<const double> weights,
103 std::span<const double> weightsSumW2)
const;
108 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _expectedEvents;
109 std::unique_ptr<RooTemplateProxy<RooAbsPdf>> _offsetPdf;
110 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _binVolumes;
111 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _weightErrLo;
112 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _weightErrHi;
113 bool _weightSquared =
false;
114 bool _binnedL =
false;
115 bool _doOffset =
false;
116 bool _doBinOffset =
false;
117 Statistic _statistic = Statistic::NLL;
118 FuncMode _funcMode = FuncMode::Pdf;
122 std::vector<double> _binw;
124 mutable std::size_t _sumWeightGen = 0;
125 mutable double _sumWeightCache = 0.0;
126 mutable std::size_t _sumWeight2Gen = 0;
127 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...
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.