Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
NormalizationHelpers.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Jonas Rembser, CERN 2022
5 *
6 * Copyright (c) 2022, 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#ifndef RooFit_Detail_NormalizationHelpers_h
14#define RooFit_Detail_NormalizationHelpers_h
15
16#include <memory>
17#include <string>
18#include <unordered_map>
19
20class RooAbsArg;
21class RooArgSet;
22
23class TNamed;
24
25namespace RooFit {
26
27namespace Detail {
28
30public:
31 CompileContext(RooArgSet const &topLevelNormSet);
32
34
35 template <class T>
36 T *compile(T &arg, RooAbsArg &owner, RooArgSet const &normSet)
37 {
38 return static_cast<T *>(compileImpl(arg, owner, normSet));
39 }
40
41 void compileServers(RooAbsArg &arg, RooArgSet const &normSet);
42 void compileServer(RooAbsArg &server, RooAbsArg &arg, RooArgSet const &normSet);
43
44 void markAsCompiled(RooAbsArg &arg) const;
45
46 // This information is used for the binned likelihood optimization.
47 void setLikelihoodMode(bool flag) { _likelihoodMode = flag; }
48 bool likelihoodMode() const { return _likelihoodMode; }
51 void setBinWidthFuncFlag(bool flag) { _binWidthFuncFlag = flag; }
52 bool binWidthFuncFlag() const { return _binWidthFuncFlag; }
53
54private:
55 RooAbsArg *compileImpl(RooAbsArg &arg, RooAbsArg &owner, RooArgSet const &normSet);
56 void add(RooAbsArg &arg);
57 RooAbsArg *find(RooAbsArg &arg) const;
58 bool isMarkedAsCompiled(RooAbsArg const &arg) const;
59
61 std::unordered_map<TNamed const *, RooAbsArg *> _clonedArgsSet;
62 std::unordered_map<RooAbsArg *, RooAbsArg *> _replacements;
63
64 bool _likelihoodMode = false;
66 bool _binWidthFuncFlag = false;
67};
68
69template <class T>
70std::unique_ptr<T> compileForNormSet(T const &arg, RooArgSet const &normSet)
71{
73 std::unique_ptr<RooAbsArg> head = arg.compileForNormSet(normSet, ctx);
74 return std::unique_ptr<T>{static_cast<T *>(head.release())};
75}
76
77} // namespace Detail
78
79} // namespace RooFit
80
81#endif
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
void markAsCompiled(RooAbsArg &arg) const
std::unordered_map< RooAbsArg *, RooAbsArg * > _replacements
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
RooAbsArg * find(RooAbsArg &arg) const
RooAbsArg * compileImpl(RooAbsArg &arg, RooAbsArg &owner, RooArgSet const &normSet)
std::unordered_map< TNamed const *, RooAbsArg * > _clonedArgsSet
bool isMarkedAsCompiled(RooAbsArg const &arg) const
void compileServer(RooAbsArg &server, RooAbsArg &arg, RooArgSet const &normSet)
T * compile(T &arg, RooAbsArg &owner, RooArgSet const &normSet)
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
std::unique_ptr< T > compileForNormSet(T const &arg, RooArgSet const &normSet)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26