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
20#include "RooRealVar.h"
21
22namespace RooFit {
23namespace TestStatistics {
24
25/** \class LikelihoodSerial
26 * \brief Serial likelihood calculation strategy implementation
27 *
28 * This class serves as a baseline reference implementation of the LikelihoodWrapper. It reimplements the previous
29 * RooNLLVar "BulkPartition" single CPU strategy in the new RooFit::TestStatistics framework.
30 *
31 * \note The class is not intended for use by end-users. We recommend to either use RooMinimizer with a RooAbsL derived
32 * likelihood object, or to use a higher level entry point like RooAbsPdf::fitTo() or RooAbsPdf::createNLL().
33 */
34
35LikelihoodSerial::LikelihoodSerial(std::shared_ptr<RooAbsL> likelihood, std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean)
36 : LikelihoodWrapper(std::move(likelihood), std::move(calculation_is_clean))
37{
38 initVars();
39 // determine likelihood type
40 if (dynamic_cast<RooUnbinnedL *>(likelihood_.get()) != nullptr) {
42 } else if (dynamic_cast<RooBinnedL *>(likelihood_.get()) != nullptr) {
44 } else if (dynamic_cast<RooSumL *>(likelihood_.get()) != nullptr) {
46 } else if (dynamic_cast<RooSubsidiaryL *>(likelihood_.get()) != nullptr) {
48 } else {
49 throw std::logic_error("in LikelihoodSerial constructor: _likelihood is not of a valid subclass!");
50 }
51 // Note to future maintainers: take care when storing the minimizer_fcn pointer. The
52 // RooAbsMinimizerFcn subclasses may get cloned inside MINUIT, which means the pointer
53 // should also somehow be updated in this class.
54}
55
56/// \brief Helper function for the constuctor.
57///
58/// This is a separate function (instead of just in ctor) for historical reasons.
59/// Its predecessor RooRealMPFE::initVars() was used from multiple ctors, but also
60/// from RooRealMPFE::constOptimizeTestStatistic at the end, which makes sense,
61/// because it might change the set of variables. We may at some point want to do
62/// this here as well.
64{
65 // Empty current lists
68
69 // Retrieve non-constant parameters
70 auto vars = std::make_unique<RooArgSet>(*likelihood_->getParameters());
71
72 RooArgList varList(*vars);
73
74 // Save in lists
75 _vars.add(varList);
76 _saveVars.addClone(varList);
77}
78
80 switch (likelihood_type) {
83 result = likelihood_->evaluatePartition({0, 1}, 0, 0);
84 break;
85 }
87 result = likelihood_->evaluatePartition({0, 1}, 0, likelihood_->getNComponents());
88 break;
89 }
90 default: {
91 throw std::logic_error("in LikelihoodSerial::evaluate_task: likelihood types other than binned, unbinned and simultaneous not yet implemented!");
92 break;
93 }
94 }
95
97}
98
99} // namespace TestStatistics
100} // namespace RooFit
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add 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 constuctor.
LikelihoodSerial(std::shared_ptr< RooAbsL > likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean)
Virtual base class for implementation of likelihood calculation strategies.
ROOT::Math::KahanSum< double > applyOffsetting(ROOT::Math::KahanSum< double > current_value)
Likelihood class that sums over multiple -log components.
Definition RooSumL.h:26
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition Common.h:18