Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooEvaluatorWrapper.cxx
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/**
16\internal
17\file RooEvaluatorWrapper.cxx
18\class RooEvaluatorWrapper
19\ingroup Roofitcore
20
21Wraps a RooFit::Evaluator that evaluates a RooAbsReal back into a RooAbsReal.
22**/
23
24#include "RooEvaluatorWrapper.h"
25
26#include <RooAbsData.h>
27#include <RooAbsReal.h>
28#include <RooRealVar.h>
29#include <RooHelpers.h>
30#include <RooMsgService.h>
32#include <RooSimultaneous.h>
33
34#include <TList.h>
35
36RooEvaluatorWrapper::RooEvaluatorWrapper(RooAbsReal &topNode, std::unique_ptr<RooFit::Evaluator> evaluator,
37 std::string const &rangeName, RooSimultaneous const *simPdf,
38 bool takeGlobalObservablesFromData)
39 : RooAbsReal{"RooEvaluatorWrapper", "RooEvaluatorWrapper"},
40 _evaluator{std::move(evaluator)},
41 _topNode("topNode", "top node", this, topNode),
42 _rangeName{rangeName},
43 _simPdf{simPdf},
44 _takeGlobalObservablesFromData{takeGlobalObservablesFromData}
45{
46}
47
48RooEvaluatorWrapper::RooEvaluatorWrapper(const RooEvaluatorWrapper &other, const char *name)
49 : RooAbsReal{other, name},
50 _evaluator{other._evaluator},
51 _topNode("topNode", this, other._topNode),
52 _data{other._data},
53 _rangeName{other._rangeName},
54 _simPdf{other._simPdf},
55 _takeGlobalObservablesFromData{other._takeGlobalObservablesFromData}
56{
57}
58
59bool RooEvaluatorWrapper::getParameters(const RooArgSet *observables, RooArgSet &outputSet,
60 bool /*stripDisconnected*/) const
61{
62 outputSet.add(_evaluator->getParameters());
63 if (observables) {
64 outputSet.remove(*observables);
65 }
66 // If we take the global observables as data, we have to return these as
67 // parameters instead of the parameters in the model. Otherwise, the
68 // constant parameters in the fit result that are global observables will
69 // not have the right values.
70 if (_takeGlobalObservablesFromData && _data->getGlobalObservables()) {
71 outputSet.replace(*_data->getGlobalObservables());
72 }
73 return false;
74}
75
76bool RooEvaluatorWrapper::setData(RooAbsData &data, bool /*cloneData*/)
77{
78 _data = &data;
79 std::stack<std::vector<double>>{}.swap(_vectorBuffers);
80 auto dataSpans = RooFit::BatchModeDataHelpers::getDataSpans(*_data, _rangeName, _simPdf, /*skipZeroWeights=*/true,
81 _takeGlobalObservablesFromData, _vectorBuffers);
82 for (auto const &item : dataSpans) {
83 _evaluator->setInput(item.first->GetName(), item.second, false);
84 }
85 return true;
86}
87
88/// \endcond
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
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual bool replace(const RooAbsArg &var1, const RooAbsArg &var2)
Replace var1 with var2 and return true for success.
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.