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>
20#include <RooGlobalFunc.h>
21#include <RooHelpers.h>
22#include <RooRealProxy.h>
23#include <RooFit/Evaluator.h>
24
26
27#include <chrono>
28#include <memory>
29#include <stack>
30
31class RooAbsArg;
32class RooAbsCategory;
33class RooSimultaneous;
34
35class RooEvaluatorWrapper final : public RooAbsReal {
36public:
37 RooEvaluatorWrapper(RooAbsReal &topNode, std::unique_ptr<RooFit::Evaluator> evaluator, std::string const &rangeName,
38 RooSimultaneous const *simPdf, bool takeGlobalObservablesFromData);
39
40 RooEvaluatorWrapper(const RooEvaluatorWrapper &other, const char *name = nullptr);
41
42 TObject *clone(const char *newname) const override { return new RooEvaluatorWrapper(*this, newname); }
43
44 double defaultErrorLevel() const override { return _topNode->defaultErrorLevel(); }
45
46 bool getParameters(const RooArgSet *observables, RooArgSet &outputSet, bool stripDisconnected) const override;
47
48 bool setData(RooAbsData &data, bool cloneData) override;
49
50 double getValV(const RooArgSet *) const override { return evaluate(); }
51
52 void applyWeightSquared(bool flag) override { _topNode->applyWeightSquared(flag); }
53
54 void printMultiline(std::ostream &os, Int_t /*contents*/, bool /*verbose*/ = false,
55 TString /*indent*/ = "") const override
56 {
57 _evaluator->print(os);
58 }
59
60 /// The RooFit::Evaluator is dealing with constant terms itself.
61 void constOptimizeTestStatistic(ConstOpCode /*opcode*/, bool /*doAlsoTrackingOpt*/) override {}
62
63protected:
64 double evaluate() const override { return _evaluator ? _evaluator->run()[0] : 0.0; }
65
66private:
67 std::shared_ptr<RooFit::Evaluator> _evaluator;
68 RooRealProxy _topNode;
69 RooAbsData *_data = nullptr;
70 RooArgSet _parameters;
71 std::string _rangeName;
72 RooSimultaneous const *_simPdf = nullptr;
73 const bool _takeGlobalObservablesFromData;
74 std::stack<std::vector<double>> _vectorBuffers; // used for preserving resources
75};
76
77#endif
78
79/// \endcond
TObject * clone(const char *newname) const override
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:79
A space to attach TBranches.
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
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:55
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
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