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
26class RooNLLVarNew : public RooAbsReal {
27
28public:
29 // The names for the weight variables that the RooNLLVarNew expects
30 static constexpr const char *weightVarName = "_weight";
31 static constexpr const char *weightVarNameSumW2 = "_weight_sumW2";
32
33 RooNLLVarNew(const char *name, const char *title, RooAbsPdf &pdf, RooArgSet const &observables, bool isExtended,
34 RooFit::OffsetMode offsetMode);
35 RooNLLVarNew(const RooNLLVarNew &other, const char *name = nullptr);
36 TObject *clone(const char *newname) const override { return new RooNLLVarNew(*this, newname); }
37
38 void getParametersHook(const RooArgSet *nset, RooArgSet *list, bool stripDisconnected) const override;
39
40 /// Return default level for MINUIT error analysis.
41 double defaultErrorLevel() const override { return 0.5; }
42
43 void computeBatch(double *output, size_t nOut, RooFit::Detail::DataMap const &) const override;
44 bool canComputeBatchWithCuda() const override { return !_binnedL; }
45 bool isReducerNode() const override { return true; }
46
47 void setPrefix(std::string const &prefix);
48
49 void applyWeightSquared(bool flag) override;
50
51 void enableOffsetting(bool) override;
52
53 void enableBinOffsetting(bool on = true) { _doBinOffset = on; }
54
55 void setSimCount(int simCount) { _simCount = simCount; }
56
57 void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
58
59private:
60 double evaluate() const override { return _value; }
61 void resetWeightVarNames();
62 double finalizeResult(ROOT::Math::KahanSum<double> result, double weightSum) const;
63 void fillBinWidthsFromPdfBoundaries(RooAbsReal const &pdf, RooArgSet const &observables);
64 double computeBatchBinnedL(std::span<const double> preds, std::span<const double> weights) const;
65
68 RooTemplateProxy<RooAbsReal> _weightSquaredVar;
69 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _expectedEvents;
70 std::unique_ptr<RooTemplateProxy<RooAbsPdf>> _offsetPdf;
71 mutable double _sumWeight = 0.0; //!
72 mutable double _sumWeight2 = 0.0; //!
73 bool _weightSquared = false;
74 bool _binnedL = false;
75 bool _doOffset = false;
76 bool _doBinOffset = false;
77 int _simCount = 1;
78 std::string _prefix;
79 std::vector<double> _binw;
80 mutable ROOT::Math::KahanSum<double> _offset{0.}; ///<! Offset as KahanSum to avoid loss of precision
81
82}; // end class RooNLLVar
83
84#endif
85
86/// \endcond
bool _doOffset
Apply interval value offset to control numeric precision?
void enableOffsetting(bool flag) override
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
void setSimCount(Int_t simCount)
Int_t _simCount
Total number of component p.d.f.s in RooSimultaneous (if any)
double evaluate() const override
TObject * clone(const char *newname) const override
Definition RooChi2Var.h:9
double defaultErrorLevel() const override
Definition RooChi2Var.h:17
void applyWeightSquared(bool flag) override
bool _doBinOffset
Definition RooNLLVar.h:44
std::vector< double > _binw
!
Definition RooNLLVar.h:49
std::unique_ptr< RooAbsPdf > _offsetPdf
! An optional per-bin likelihood offset
Definition RooNLLVar.h:51
void enableBinOffsetting(bool on=true)
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:55
A class to maintain the context for squashing of RooFit models into code.
Mother of all ROOT objects.
Definition TObject.h:41
OffsetMode
For setting the offset mode with the Offset() command argument to RooAbsPdf::fitTo()
static void output()