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
25
26namespace ROOT {
27namespace Experimental {
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
37 RooNLLVarNew(const char *name, const char *title, RooAbsPdf &pdf, RooArgSet const &observables, bool isExtended,
38 RooFit::OffsetMode offsetMode);
39 RooNLLVarNew(const RooNLLVarNew &other, const char *name = nullptr);
40 TObject *clone(const char *newname) const override { return new RooNLLVarNew(*this, newname); }
41
42 void getParametersHook(const RooArgSet *nset, RooArgSet *list, bool stripDisconnected) const override;
43
44 /// Return default level for MINUIT error analysis.
45 double defaultErrorLevel() const override { return 0.5; }
46
47 void computeBatch(cudaStream_t *, double *output, size_t nOut, RooFit::Detail::DataMap const &) const override;
48 bool canComputeBatchWithCuda() const override { return !_binnedL; }
49 bool isReducerNode() const override { return true; }
50
51 void setPrefix(std::string const &prefix);
52
53 void applyWeightSquared(bool flag) override;
54
55 void enableOffsetting(bool) override;
56
57 void enableBinOffsetting(bool on = true) { _doBinOffset = on; }
58
59 void setSimCount(int simCount) { _simCount = simCount; }
60
61private:
62 double evaluate() const override { return _value; }
64 double finalizeResult(ROOT::Math::KahanSum<double> result, double weightSum) const;
65 void fillBinWidthsFromPdfBoundaries(RooAbsReal const &pdf, RooArgSet const &observables);
67
72 std::unique_ptr<RooTemplateProxy<RooAbsReal>> _expectedEvents;
73 mutable double _sumWeight = 0.0; //!
74 mutable double _sumWeight2 = 0.0; //!
75 bool _weightSquared = false;
76 bool _binnedL = false;
77 bool _doOffset = false;
78 bool _doBinOffset = false;
79 int _simCount = 1;
80 std::string _prefix;
81 std::vector<double> _binw;
82 mutable ROOT::Math::KahanSum<double> _offset{0.}; ///<! Offset as KahanSum to avoid loss of precision
83
84}; // end class RooNLLVar
85
86} // end namespace Experimental
87} // end namespace ROOT
88
89#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
RooTemplateProxy< RooAbsReal > _binVolumeVar
RooTemplateProxy< RooAbsReal > _weightVar
void enableOffsetting(bool) override
TObject * clone(const char *newname) const override
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
bool canComputeBatchWithCuda() const override
void computeBatch(cudaStream_t *, double *output, size_t nOut, RooFit::Detail::DataMap const &) const override
Compute multiple negative logs of propabilities.
void applyWeightSquared(bool flag) override
Toggles the weight square correction.
void getParametersHook(const RooArgSet *nset, RooArgSet *list, bool stripDisconnected) const override
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
void setPrefix(std::string const &prefix)
Sets the prefix for the special variables of this NLL, like weights or bin volumes.
void fillBinWidthsFromPdfBoundaries(RooAbsReal const &pdf, RooArgSet const &observables)
RooTemplateProxy< RooAbsPdf > _pdf
double defaultErrorLevel() const override
Return default level for MINUIT error analysis.
void enableBinOffsetting(bool on=true)
RooTemplateProxy< RooAbsReal > _weightSquaredVar
std::unique_ptr< RooTemplateProxy< RooAbsReal > > _expectedEvents
double computeBatchBinnedL(RooSpan< const double > preds, RooSpan< const double > weights) const
std::vector< double > _binw
static constexpr const char * weightVarName
double finalizeResult(ROOT::Math::KahanSum< double > result, double weightSum) const
bool isReducerNode() const override
static constexpr const char * weightVarNameSumW2
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Definition Util.h:122
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:62
double _value
Cache for current value of object.
Definition RooAbsReal.h:509
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
A simple container to hold a batch of data values.
Definition RooSpan.h:34
Mother of all ROOT objects.
Definition TObject.h:41
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
OffsetMode
For setting the offset mode with the Offset() command argument to RooAbsPdf::fitTo()
static void output()