Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
LikelihoodSerial.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
13#include "LikelihoodSerial.h"
14
16#include "RooRealVar.h"
17
18namespace RooFit {
19namespace TestStatistics {
20
21/** \class LikelihoodSerial
22 * \brief Serial likelihood calculation strategy implementation
23 *
24 * This class serves as a baseline reference implementation of the LikelihoodWrapper. It reimplements the previous
25 * RooNLLVar "BulkPartition" single CPU strategy in the new RooFit::TestStatistics framework.
26 *
27 * \note The class is not intended for use by end-users. We recommend to either use RooMinimizer with a RooAbsL derived
28 * likelihood object, or to use a higher level entry point like RooAbsPdf::fitTo() or RooAbsPdf::createNLL().
29 */
30
31LikelihoodSerial::LikelihoodSerial(std::shared_ptr<RooAbsL> likelihood,
32 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean,
34 : LikelihoodWrapper(std::move(likelihood), std::move(calculation_is_clean), std::move(offset))
35{
36 initVars();
37}
38
39/// \brief Helper function for the constructor.
40///
41/// This is a separate function (instead of just in ctor) for historical reasons.
42/// Its predecessor RooRealMPFE::initVars() was used from multiple ctors, but also
43/// from RooRealMPFE::constOptimizeTestStatistic at the end, which makes sense,
44/// because it might change the set of variables. We may at some point want to do
45/// this here as well.
47{
48 // Empty current lists
51
52 // Retrieve non-constant parameters
53 std::unique_ptr<RooArgSet> vars{likelihood_->getParameters()};
54
55 RooArgList varList(*vars);
56
57 // Save in lists
58 _vars.add(varList);
59 _saveVars.addClone(varList);
60}
61
63{
64 if (do_offset_ && shared_offset_.offsets().empty()) {
66 }
67
68 switch (likelihood_type_) {
71 result = likelihood_->evaluatePartition({0, 1}, 0, 0);
72 if (do_offset_) {
74 }
75 break;
76 }
78 result = likelihood_->evaluatePartition({0, 1}, 0, 0);
81 }
82 break;
83 }
86 for (std::size_t comp_ix = 0; comp_ix < likelihood_->getNComponents(); ++comp_ix) {
87 auto component_result = likelihood_->evaluatePartition({0, 1}, comp_ix, comp_ix + 1);
88
90 result += (component_result - shared_offset_.offsets()[comp_ix]);
91 } else {
92 result += component_result;
93 }
94 }
95 break;
96 }
97 }
98}
99
100} // namespace TestStatistics
101} // namespace RooFit
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Definition Util.h:122
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgList _saveVars
Copy of variables.
void evaluate() override
Triggers (possibly asynchronous) evaluation of the likelihood.
ROOT::Math::KahanSum< double > result
void initVars()
Helper function for the constructor.
LikelihoodSerial(std::shared_ptr< RooAbsL > _likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean, SharedOffset offset)
Virtual base class for implementation of likelihood calculation strategies.
void calculate_offsets()
(Re)calculate (on each worker) all component offsets.
OffsetVec & offsets()
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26