Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooRealL.cxx
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * PB, Patrick Bos, Netherlands eScience Center, p.bos@esciencecenter.nl
5 *
6 * Copyright (c) 2021, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
15#include <RooRealVar.h>
16
17namespace RooFit {
18namespace TestStatistics {
19
20/** \class RooRealL
21 * \ingroup Roofitcore
22 *
23 * \brief RooAbsReal that wraps RooAbsL likelihoods for use in RooFit outside of the RooMinimizer context
24 *
25 * This class provides a simple wrapper to evaluate RooAbsL derived likelihood objects like a regular RooFit real value.
26 * Whereas the RooAbsL objects are meant to be used within the context of minimization, RooRealL can be used in any
27 * RooFit context, like plotting. The value can be accessed through getVal(), like with other RooFit real variables.
28 **/
29
30RooRealL::RooRealL(const char *name, const char *title, std::shared_ptr<RooAbsL> likelihood)
31 : RooAbsReal(name, title), likelihood_(std::move(likelihood)),
32 vars_proxy_("varsProxy", "proxy set of parameters", this)
33{
34 std::unique_ptr<RooArgSet> params{likelihood_->getParameters()};
35 vars_obs_.add(*params);
36 vars_proxy_.add(*params);
37}
38
39RooRealL::RooRealL(const RooRealL &other, const char *name)
40 : RooAbsReal(other, name), likelihood_(other.likelihood_), vars_proxy_("varsProxy", this, other.vars_proxy_)
41{
42 vars_obs_.add(other.vars_obs_) ;
43}
44
45double RooRealL::evaluate() const
46{
47 // Transfer values from proxy variables to internal variables of likelihood
48 if (!vars_proxy_.empty()) {
49 for (auto i = 0u; i < vars_obs_.size(); ++i) {
50 auto harg = vars_obs_[i];
51 const auto parg = vars_proxy_[i];
52
53 if (harg != parg) {
54 ((RooAbsRealLValue*)harg)->setVal(((RooAbsReal*)parg)->getVal());
55 }
56 }
57 }
58 // Evaluate as straight FUNC
59 std::size_t last_component = likelihood_->getNComponents();
60
61 auto ret_kahan = likelihood_->evaluatePartition({0, 1}, 0, last_component);
62
63 const double norm = globalNormalization();
64 double ret = ret_kahan.Sum() / norm;
65 eval_carry = ret_kahan.Carry() / norm;
66
67 return ret;
68}
69
70} // namespace TestStatistics
71} // namespace RooFit
char name[80]
Definition TGX11.cxx:110
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooAbsReal that wraps RooAbsL likelihoods for use in RooFit outside of the RooMinimizer context.
Definition RooRealL.h:28
std::shared_ptr< RooAbsL > likelihood_
Definition RooRealL.h:50
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition RooRealL.cxx:45
RooSetProxy vars_proxy_
sets up client-server connections
Definition RooRealL.h:52
double globalNormalization() const
Definition RooRealL.h:35
RooArgSet vars_obs_
list of observables
Definition RooRealL.h:53
RooRealL(const char *name, const char *title, std::shared_ptr< RooAbsL > likelihood)
Definition RooRealL.cxx:30
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26