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;
35
36class RooEvaluatorWrapper final : public RooAbsReal {
37public:
38 RooEvaluatorWrapper(RooAbsReal &topNode, RooAbsData *data, bool useGPU, std::string const &rangeName,
39 RooAbsPdf const *simPdf, bool takeGlobalObservablesFromData);
40
41 RooEvaluatorWrapper(const RooEvaluatorWrapper &other, const char *name = nullptr);
42
43 TObject *clone(const char *newname) const override { return new RooEvaluatorWrapper(*this, newname); }
44
45 double defaultErrorLevel() const override { return _topNode->defaultErrorLevel(); }
46
47 bool getParameters(const RooArgSet *observables, RooArgSet &outputSet, bool stripDisconnected) const override;
48
49 bool setData(RooAbsData &data, bool cloneData) override;
50
51 double getValV(const RooArgSet *) const override { return evaluate(); }
52
53 void applyWeightSquared(bool flag) override { _topNode->applyWeightSquared(flag); }
54
55 void printMultiline(std::ostream &os, Int_t /*contents*/, bool /*verbose*/ = false,
56 TString /*indent*/ = "") const override
57 {
58 _evaluator->print(os);
59 }
60
61 /// The RooFit::Evaluator is dealing with constant terms itself.
62 void constOptimizeTestStatistic(ConstOpCode /*opcode*/, bool /*doAlsoTrackingOpt*/) override {}
63
64protected:
65 double evaluate() const override;
66
67private:
68 std::shared_ptr<RooFit::Evaluator> _evaluator;
69 RooRealProxy _topNode;
70 RooAbsData *_data = nullptr;
71 RooSetProxy _paramSet;
72 std::string _rangeName;
73 RooAbsPdf const *_pdf = nullptr;
74 const bool _takeGlobalObservablesFromData;
75 std::stack<std::vector<double>> _vectorBuffers; // used for preserving resources
76 std::map<RooFit::Detail::DataKey, std::span<const double>> _dataSpans;
77};
78
79#endif
80
81/// \endcond
int Int_t
Definition RtypesCore.h:45
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:77
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: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:24
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
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