Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 for (RooAbsArg *server : arg.servers()) {
42 this->compile(*server, arg, normSet);
43 }
44 arg.redirectServers(_replacements);
45}
46
48{
49 this->compile(server, arg, normSet);
50 arg.redirectServers(_replacements);
51}
52
54{
55 if (auto existingServerClone = this->find(arg)) {
56 return existingServerClone;
57 }
58 if (arg.isFundamental() && !_topLevelNormSet.find(arg)) {
59 return nullptr;
60 }
61 if (isMarkedAsCompiled(arg)) {
62 return nullptr;
63 }
64
65 std::unique_ptr<RooAbsArg> newArg = arg.compileForNormSet(normSet, *this);
66 markAsCompiled(*newArg);
67 _replacements[&arg] = newArg.get();
68 this->add(*newArg);
69 RooAbsArg *out = newArg.get();
70 owner.addOwnedComponents(std::move(newArg));
71 return out;
72}
73
75{
76 arg.setAttribute("_COMPILED");
77}
78
80{
81 return arg.getAttribute("_COMPILED");
82}
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:74
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
Definition RooAbsArg.h:560
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
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.
virtual std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const
const RefCountList_t & servers() const
List of all servers of this object.
Definition RooAbsArg.h:204
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Definition RooAbsArg.h:247
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
void markAsCompiled(RooAbsArg &arg) const
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
RooAbsArg * find(RooAbsArg &arg) const
RooAbsArg * compileImpl(RooAbsArg &arg, RooAbsArg &owner, RooArgSet const &normSet)
bool isMarkedAsCompiled(RooAbsArg const &arg) const
CompileContext(RooArgSet const &topLevelNormSet)
void compileServer(RooAbsArg &server, RooAbsArg &arg, RooArgSet const &normSet)