Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooNLLVarNew.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Jonas Rembser, CERN 2021
5 * Emmanouil Michalainas, CERN 2021
6 *
7 * Copyright (c) 2021, CERN
8 *
9 * Redistribution and use in source and binary forms,
10 * with or without modification, are permitted according to the terms
11 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
12 */
13
14#ifndef RooFit_RooNLLVarNew_h
15#define RooFit_RooNLLVarNew_h
16
17#include <RooAbsPdf.h>
18#include <RooAbsReal.h>
19#include <RooGlobalFunc.h>
20#include <RooTemplateProxy.h>
21
22#include <Math/Util.h>
23
24class RooNLLVarNew : public RooAbsReal {
25
26public:
27 // The names for the weight variables that the RooNLLVarNew expects
28 static constexpr const char *weightVarName = "_weight";
29 static constexpr const char *weightVarNameSumW2 = "_weight_sumW2";
30
31 RooNLLVarNew(const char *name, const char *title, RooAbsPdf &pdf, RooArgSet const &observables, bool isExtended,
32 RooFit::OffsetMode offsetMode);
33 RooNLLVarNew(const RooNLLVarNew &other, const char *name = nullptr);
34 TObject *clone(const char *newname) const override { return new RooNLLVarNew(*this, newname); }
35
36 void getParametersHook(const RooArgSet *nset, RooArgSet *list, bool stripDisconnected) const override;
37
38 /// Return default level for MINUIT error analysis.
39 double defaultErrorLevel() const override { return 0.5; }
40
41 void computeBatch(double *output, size_t nOut, RooFit::Detail::DataMap const &) const override;
42 bool canComputeBatchWithCuda() const override { return !_binnedL; }
43 bool isReducerNode() const override { return true; }
44
45 void setPrefix(std::string const &prefix);
46
47 void applyWeightSquared(bool flag) override;
48
49 void enableOffsetting(bool) override;
50
51 void enableBinOffsetting(bool on = true) { _doBinOffset = on; }
52
53 void setSimCount(int simCount) { _simCount = simCount; }
54
55 void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
56
57private:
58 double evaluate() const override { return _value; }
60 double finalizeResult(ROOT::Math::KahanSum<double> result, double weightSum) const;
61 void fillBinWidthsFromPdfBoundaries(RooAbsReal const &pdf, RooArgSet const &observables);
62 double computeBatchBinnedL(std::span<const double> preds, std::span<const double> weights) const;
63
67 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _expectedEvents;
68 std::unique_ptr<RooTemplateProxy<RooAbsPdf>> _offsetPdf;
69 mutable double _sumWeight = 0.0; //!
70 mutable double _sumWeight2 = 0.0; //!
71 bool _weightSquared = false;
72 bool _binnedL = false;
73 bool _doOffset = false;
74 bool _doBinOffset = false;
75 int _simCount = 1;
76 std::string _prefix;
77 std::vector<double> _binw;
78 mutable ROOT::Math::KahanSum<double> _offset{0.}; ///<! Offset as KahanSum to avoid loss of precision
79
80}; // end class RooNLLVar
81
82#endif
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
double _value
Cache for current value of object.
Definition RooAbsReal.h:543
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.
This is a simple class designed to produce the nll values needed by the fitter.
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
void enableOffsetting(bool) override
bool isReducerNode() const override
std::unique_ptr< RooTemplateProxy< RooAbsReal > > _expectedEvents
bool _weightSquared
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
void applyWeightSquared(bool flag) override
Toggles the weight square correction.
void getParametersHook(const RooArgSet *nset, RooArgSet *list, bool stripDisconnected) const override
void enableBinOffsetting(bool on=true)
std::unique_ptr< RooTemplateProxy< RooAbsPdf > > _offsetPdf
void computeBatch(double *output, size_t nOut, RooFit::Detail::DataMap const &) const override
Compute multiple negative logs of probabilities.
void setPrefix(std::string const &prefix)
Sets the prefix for the special variables of this NLL, like weights or bin volumes.
double _sumWeight
void fillBinWidthsFromPdfBoundaries(RooAbsReal const &pdf, RooArgSet const &observables)
void resetWeightVarNames()
void setSimCount(int simCount)
TObject * clone(const char *newname) const override
bool canComputeBatchWithCuda() const override
std::string _prefix
std::vector< double > _binw
RooTemplateProxy< RooAbsPdf > _pdf
double computeBatchBinnedL(std::span< const double > preds, std::span< const double > weights) const
double _sumWeight2
RooTemplateProxy< RooAbsReal > _weightVar
double defaultErrorLevel() const override
Return default level for MINUIT error analysis.
static constexpr const char * weightVarName
double finalizeResult(ROOT::Math::KahanSum< double > result, double weightSum) const
static constexpr const char * weightVarNameSumW2
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
RooTemplateProxy< RooAbsReal > _weightSquaredVar
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()