Logo ROOT  
Reference Guide
NormalizationHelpers.cxx
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Jonas Rembser, CERN 2023
5 *
6 * Copyright (c) 2023, 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
14
15#include <RooAbsArg.h>
16#include <RooArgList.h>
17#include <RooArgSet.h>
18
19#include <TNamed.h>
20
21RooFit::Detail::CompileContext::CompileContext(RooArgSet const &topLevelNormSet) : _topLevelNormSet{topLevelNormSet} {}
22
24
26{
27 _clonedArgsSet.emplace(arg.namePtr(), &arg);
28}
29
31{
32 auto existingServerClone = _clonedArgsSet.find(arg.namePtr());
33 if (existingServerClone != _clonedArgsSet.end()) {
34 return existingServerClone->second;
35 }
36 return nullptr;
37}
38
40{
41 RooArgList serverClones;
42 for (const auto server : arg.servers()) {
43 if (auto serverClone = this->compile(*server, arg, normSet)) {
44 serverClones.add(*serverClone);
45 }
46 }
47 arg.redirectServers(serverClones, false, true);
48}
49
51{
52 if (auto existingServerClone = this->find(arg)) {
53 return existingServerClone;
54 }
55 if (arg.isFundamental() && !_topLevelNormSet.find(arg)) {
56 return nullptr;
57 }
58 if (arg.getAttribute("_COMPILED")) {
59 return nullptr;
60 }
61
62 std::unique_ptr<RooAbsArg> newArg = arg.compileForNormSet(normSet, *this);
63 newArg->setAttribute("_COMPILED");
64 const std::string attrib = std::string("ORIGNAME:") + arg.GetName();
65 newArg->setAttribute(attrib.c_str());
66 this->add(*newArg);
67 RooAbsArg *out = newArg.get();
68 owner.addOwnedComponents(std::move(newArg));
69 return out;
70}
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
Definition: RooAbsArg.h:566
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
Definition: RooAbsArg.cxx:2207
bool redirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool isRecursionStep=false)
Replace all direct servers of this object with the new servers in newServerList.
Definition: RooAbsArg.cxx:1020
virtual std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const
Definition: RooAbsArg.cxx:2495
const RefCountList_t & servers() const
List of all servers of this object.
Definition: RooAbsArg.h:199
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
Definition: RooAbsArg.cxx:268
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Definition: RooAbsArg.h:242
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
RooAbsArg * find(RooAbsArg &arg) const
RooAbsArg * compileImpl(RooAbsArg &arg, RooAbsArg &owner, RooArgSet const &normSet)
CompileContext(RooArgSet const &topLevelNormSet)
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47