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#include "RooNaNPacker.h"
18
19#include "TMath.h" // IsNaN
20
21namespace RooFit {
22namespace TestStatistics {
23
24/** \class LikelihoodSerial
25 * \brief Serial likelihood calculation strategy implementation
26 *
27 * This class serves as a baseline reference implementation of the LikelihoodWrapper. It reimplements the previous
28 * RooNLLVar "BulkPartition" single CPU strategy in the new RooFit::TestStatistics framework.
29 *
30 * \note The class is not intended for use by end-users. We recommend to either use RooMinimizer with a RooAbsL derived
31 * likelihood object, or to use a higher level entry point like RooAbsPdf::fitTo() or RooAbsPdf::createNLL().
32 */
33
34LikelihoodSerial::LikelihoodSerial(std::shared_ptr<RooAbsL> likelihood,
35 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean,
37 : LikelihoodWrapper(std::move(likelihood), std::move(calculation_is_clean), std::move(offset))
38{
39 initVars();
40}
41
42/// \brief Helper function for the constructor.
43///
44/// This is a separate function (instead of just in ctor) for historical reasons.
46{
47 // Empty current lists
50
51 // Retrieve non-constant parameters
52 std::unique_ptr<RooArgSet> vars{likelihood_->getParameters()};
53
54 RooArgList varList(*vars);
55
56 // Save in lists
59}
60
62{
63 if (do_offset_ && shared_offset_.offsets().empty()) {
65 }
66
67 switch (likelihood_type_) {
70 result = likelihood_->evaluatePartition({0, 1}, 0, 0);
71 if (do_offset_) {
73 }
74 break;
75 }
77 result = likelihood_->evaluatePartition({0, 1}, 0, 0);
80 }
81 break;
82 }
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 packedNaN.accumulate(component_result.Sum());
89
92 } else {
94 }
95 }
96 if (packedNaN.getPayload() != 0) {
97 result = ROOT::Math::KahanSum<double>(packedNaN.getNaNWithPayload());
98 }
99 break;
100 }
101 }
102
103 if (TMath::IsNaN(result.Sum())) {
104 RooAbsReal::logEvalError(nullptr, GetName().c_str(), "function value is NAN");
105 }
106}
107
108} // namespace TestStatistics
109} // namespace RooFit
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:141
T Sum() const
Definition Util.h:259
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.
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
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 CodegenImpl.h:73
Bool_t IsNaN(Double_t x)
Definition TMath.h:905
Little struct that can pack a float into the unused bits of the mantissa of a NaN double.