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/EvalContext.h>
20#include <RooFit/Evaluator.h>
21#include <RooGlobalFunc.h>
22#include <RooHelpers.h>
23#include <RooRealProxy.h>
24#include <RooSetProxy.h>
25
27
28#include <chrono>
29#include <memory>
30#include <stack>
31
32class RooAbsArg;
33class RooAbsCategory;
34class RooAbsPdf;
35class RooFuncWrapper;
36
38public:
41
42 RooEvaluatorWrapper(const RooEvaluatorWrapper &other, const char *name = nullptr);
43
45
46 TObject *clone(const char *newname) const override { return new RooEvaluatorWrapper(*this, newname); }
47
48 double defaultErrorLevel() const override { return _topNode->defaultErrorLevel(); }
49
50 bool getParameters(const RooArgSet *observables, RooArgSet &outputSet, bool stripDisconnected = true) const override;
51
52 bool setData(RooAbsData &data, bool cloneData) override;
53
54 double getValV(const RooArgSet *) const override { return evaluate(); }
55
56 void applyWeightSquared(bool flag) override { _topNode->applyWeightSquared(flag); }
57
58 void printMultiline(std::ostream &os, Int_t /*contents*/, bool /*verbose*/ = false,
59 TString /*indent*/ = "") const override
60 {
61 _evaluator->print(os);
62 }
63
64 /// The RooFit::Evaluator is dealing with constant terms itself.
65 void constOptimizeTestStatistic(ConstOpCode /*opcode*/, bool /*doAlsoTrackingOpt*/) override {}
66
67 bool hasGradient() const override;
68
69 void gradient(double *out) const override;
70
71 void generateGradient();
72
74
75protected:
76 double evaluate() const override;
77
78private:
79 void createFuncWrapper();
80
81 std::shared_ptr<RooFit::Evaluator> _evaluator;
82 std::shared_ptr<RooFuncWrapper> _funcWrapper;
83 RooRealProxy _topNode;
84 RooAbsData *_data = nullptr;
85 RooSetProxy _paramSet;
86 std::string _rangeName;
87 RooAbsPdf const *_pdf = nullptr;
88 const bool _takeGlobalObservablesFromData;
89 bool _useGeneratedFunctionCode = false;
90 std::stack<std::vector<double>> _vectorBuffers; // used for preserving resources
91 std::map<RooFit::Detail::DataKey, std::span<const double>> _dataSpans;
92};
93
94#endif
95
96/// \endcond
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
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:110
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:57
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
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:138
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