Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooEvaluatorWrapper.h
Go to the documentation of this file.
1/// \cond ROOFIT_INTERNAL
2
3/*
4 * Project: RooFit
5 * Authors:
6 * Jonas Rembser, CERN 2023
7 *
8 * Copyright (c) 2023, CERN
9 *
10 * Redistribution and use in source and binary forms,
11 * with or without modification, are permitted according to the terms
12 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
13 */
14
15#ifndef RooFit_RooEvaluatorWrapper_h
16#define RooFit_RooEvaluatorWrapper_h
17
18#include <RooAbsData.h>
19#include <RooFit/Evaluator.h>
20#include <RooGlobalFunc.h>
21#include <RooRealProxy.h>
22#include <RooSetProxy.h>
23
24#include <memory>
25#include <stack>
26
28class RooAbsArg;
29class RooAbsCategory;
30class RooAbsPdf;
31
32namespace RooFit::Experimental {
33
34class RooFuncWrapper;
35
37public:
40
41 RooEvaluatorWrapper(const RooEvaluatorWrapper &other, const char *name = nullptr);
42
44
45 TObject *clone(const char *newname) const override { return new RooEvaluatorWrapper(*this, newname); }
46
47 double defaultErrorLevel() const override { return _topNode->defaultErrorLevel(); }
48
49 bool getParameters(const RooArgSet *observables, RooArgSet &outputSet, bool stripDisconnected = true) const override;
50
51 bool setData(RooAbsData &data, bool cloneData) override;
52
53 double getValV(const RooArgSet *) const override { return evaluate(); }
54
55 void applyWeightSquared(bool flag) override { _topNode->applyWeightSquared(flag); }
56
57 /// The RooFit::Evaluator is dealing with constant terms itself.
58 void constOptimizeTestStatistic(ConstOpCode /*opcode*/, bool /*doAlsoTrackingOpt*/) override {}
59
60 bool hasGradient() const override;
61 bool hasHessian() const override;
62
63 void gradient(double *out) const override;
64 void hessian(double *out) const override;
65
66 void generateGradient();
67 void generateHessian();
68
70 void writeDebugMacro(std::string const &) const;
71
72 std::unique_ptr<ChangeOperModeRAII> setOperModes(RooAbsArg::OperMode opMode);
73
74 RooFit::Evaluator &evaluator() const { return *_evaluator; }
75
76protected:
77 double evaluate() const override;
78
79private:
80 void createFuncWrapper();
81
82 std::shared_ptr<RooFit::Evaluator> _evaluator;
83 std::shared_ptr<RooFuncWrapper> _funcWrapper;
84 RooRealProxy _topNode;
85 RooAbsData *_data = nullptr;
86 RooSetProxy _paramSet;
87 std::string _rangeName;
88 RooAbsPdf const *_pdf = nullptr;
89 const bool _takeGlobalObservablesFromData;
90 bool _useGeneratedFunctionCode = false;
91 std::stack<std::vector<double>> _vectorBuffers; // used for preserving resources
92 std::map<RooFit::Detail::DataKey, std::span<const double>> _dataSpans;
93};
94
95} // namespace RooFit::Experimental
96
97#endif
98
99/// \endcond
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:148
Scope guard that temporarily changes the operation mode of one or more RooAbsArg instances.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
A space to attach TBranches.
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:56
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Evaluates a RooAbsReal object in other ways than recursive graph traversal.
Definition Evaluator.h:35
Mother of all ROOT objects.
Definition TObject.h:42
void evaluate(typename Architecture_t::Tensor_t &A, EActivationFunction f)
Apply the given activation function to each value in the given tensor A.
Definition Functions.h:98