Logo ROOT  
Reference Guide
Go to the documentation of this file.
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 */
14\file RooSubsidiaryL.cxx
15\class RooSubsidiaryL
16\ingroup Roofitcore
18\brief RooSubsidiaryL calculates the sum of the -(log) likelihoods of a set of RooAbsPdf objects that represent
19subsidiary or constraint functions.
21This class is used to gather all subsidiary PDF terms from the component PDFs of RooSumL likelihoods and calculate the
22composite -log(L). Such subsidiary terms can be marked using RooFit::Constrain arguments to RooAbsPdf::fitTo() or
25Subsidiary terms are summed separately for increased numerical stability, since these terms are often small and cause
26numerical variances in their original PDFs, whereas by summing as one separate subsidiary collective term, it is
27numerically very stable.
29\note When a subsidiary PDF is part of multiple component PDFs, it will only be summed once in this class! This doesn't
30change the derivative of the log likelihood (which is what matters in fitting the likelihood), but does change the
31value of the (log-)likelihood itself.
35#include <RooAbsPdf.h> // for dynamic cast
36#include <RooErrorHandler.h>
38#include "Math/Util.h" // KahanSum
40namespace RooFit {
41namespace TestStatistics {
43RooSubsidiaryL::RooSubsidiaryL(const std::string &parent_pdf_name, const RooArgSet &pdfs,
44 const RooArgSet &parameter_set)
45 : RooAbsL(nullptr, nullptr, 0, 0, RooAbsL::Extended::No), parent_pdf_name_(parent_pdf_name)
47 for (const auto comp : pdfs) {
48 if (!dynamic_cast<RooAbsPdf *>(comp)) {
49 oocoutE(nullptr, InputArguments) << "RooSubsidiaryL::ctor(" << GetName() << ") ERROR: component "
50 << comp->GetName() << " is not of type RooAbsPdf" << std::endl;
52 }
53 subsidiary_pdfs_.add(*comp);
54 }
55 parameter_set_.add(parameter_set);
58/// \note The subsidiary term is only calculated together with the last event.
59/// While this is meaningless for the subsidiary term itself (it has no
60/// events), it is useful when calculating RooSumLs by parts. The Section
61/// from each part is forwarded here if the component is a RooSubsidiaryL.
63 std::size_t /*components_begin*/,
64 std::size_t /*components_end*/)
68 if (events.end_fraction == 1) {
69 for (const auto comp : subsidiary_pdfs_) {
70 sum += -static_cast<RooAbsPdf*>(comp)->getLogVal(&parameter_set_);
71 }
72 }
74 return sum;
77void RooSubsidiaryL::constOptimizeTestStatistic(RooAbsArg::ConstOpCode /*opcode*/, bool /*doAlsoTrackingOpt*/) {}
79} // namespace TestStatistics
80} // namespace RooFit
#define oocoutE(o, a)
Definition: RooMsgService.h:52
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
static void softAbort()
Soft abort function that interrupts macro execution but doesn't kill ROOT.
void constOptimizeTestStatistic(RooAbsArg::ConstOpCode opcode, bool doAlsoTrackingOpt) override
Interface function signaling a request to perform constant term optimization.
RooArgSet parameter_set_
Set of parameters to which constraints apply.
ROOT::Math::KahanSum< double > evaluatePartition(Section events, std::size_t components_begin, std::size_t components_end) override
std::string GetName() const override
RooArgList subsidiary_pdfs_
Set of subsidiary PDF or "constraint" terms.
RooSubsidiaryL(const std::string &parent_pdf_name, const RooArgSet &pdfs, const RooArgSet &parameter_set)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition: Common.h:18
@ InputArguments
Definition: RooGlobalFunc.h:63
A part of some range delimited by two fractional points between 0 and 1 (inclusive).
Definition: RooAbsL.h:58