Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFitImplHelpers.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 *
4 * Copyright (c) 2023, CERN
5 *
6 * Redistribution and use in source and binary forms,
7 * with or without modification, are permitted according to the terms
8 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
9 */
10
11#ifndef RooFit_RooFitImplHelpers_h
12#define RooFit_RooFitImplHelpers_h
13
14#include <RooMsgService.h>
15#include <RooAbsArg.h>
16#include <RooAbsReal.h>
17
18#include <sstream>
19#include <vector>
20#include <string>
21#include <utility>
22
23class RooAbsPdf;
24class RooAbsData;
25
26/// Disable all caches for sub-branches in an expression tree.
27/// This is helpful when an expression with cached sub-branches needs to be integrated numerically.
29public:
30 /// Inhibit all dirty-state propagation, and assume every node as dirty.
31 /// \param[in] oldState Restore this state when going out of scope.
32 DisableCachingRAII(bool oldState) : _oldState(oldState) { RooAbsArg::setDirtyInhibit(true); }
33
34 DisableCachingRAII(DisableCachingRAII const &other) = delete;
36
38
39private:
41};
42
43/// Struct to temporarily change the operation mode of a RooAbsArg until it
44/// goes out of scope.
46public:
48 {
49 arg->setOperMode(opMode, /*recurse=*/false);
50 }
51
52 ChangeOperModeRAII(ChangeOperModeRAII const &other) = delete;
54
55 ~ChangeOperModeRAII() { _arg->setOperMode(_oldOpMode, /*recurse=*/false); }
56
57private:
58 RooAbsArg *_arg = nullptr;
60};
61
62namespace RooHelpers {
63
64std::pair<double, double> getRangeOrBinningInterval(RooAbsArg const *arg, const char *rangeName);
65
66bool checkIfRangesOverlap(RooArgSet const &observables, std::vector<std::string> const &rangeNames);
67
68std::string getColonSeparatedNameString(RooArgSet const &argSet, char delim = ':');
69RooArgSet selectFromArgSet(RooArgSet const &, std::string const &names);
70
71namespace Detail {
72
73bool snapshotImpl(RooAbsCollection const &input, RooAbsCollection &output, bool deepCopy, RooArgSet const *observables);
75
76} // namespace Detail
77
78/// Clone RooAbsArg object and reattach to original parameters.
79template <class T>
80std::unique_ptr<T> cloneTreeWithSameParameters(T const &arg, RooArgSet const *observables = nullptr)
81{
82 return std::unique_ptr<T>{static_cast<T *>(Detail::cloneTreeWithSameParametersImpl(arg, observables))};
83}
84
85std::string getRangeNameForSimComponent(std::string const &rangeName, bool splitRange, std::string const &catName);
86
88 RooAbsPdf *binnedPdf = nullptr;
89 bool isBinnedL = false;
90};
91
93
95
96} // namespace RooHelpers
97
98namespace RooFit {
99namespace Detail {
100
101std::string makeValidVarName(std::string const &in);
102
103} // namespace Detail
104} // namespace RooFit
105
106#endif
GOFOpMode operMode() const
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Struct to temporarily change the operation mode of a RooAbsArg until it goes out of scope.
ChangeOperModeRAII(RooAbsArg *arg, RooAbsArg::OperMode opMode)
ChangeOperModeRAII & operator=(ChangeOperModeRAII const &other)=delete
RooAbsArg::OperMode _oldOpMode
ChangeOperModeRAII(ChangeOperModeRAII const &other)=delete
Disable all caches for sub-branches in an expression tree.
DisableCachingRAII(DisableCachingRAII const &other)=delete
DisableCachingRAII & operator=(DisableCachingRAII const &other)=delete
DisableCachingRAII(bool oldState)
Inhibit all dirty-state propagation, and assume every node as dirty.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
void setOperMode(OperMode mode, bool recurseADirty=true)
Set the operation mode of this node.
static void setDirtyInhibit(bool flag)
Control global dirty inhibit mode.
Abstract container object that can hold multiple RooAbsArg objects.
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
std::string makeValidVarName(std::string const &in)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26
RooAbsArg * cloneTreeWithSameParametersImpl(RooAbsArg const &arg, RooArgSet const *observables)
bool snapshotImpl(RooAbsCollection const &input, RooAbsCollection &output, bool deepCopy, RooArgSet const *observables)
RooArgSet selectFromArgSet(RooArgSet const &, std::string const &names)
bool checkIfRangesOverlap(RooArgSet const &observables, std::vector< std::string > const &rangeNames)
std::unique_ptr< T > cloneTreeWithSameParameters(T const &arg, RooArgSet const *observables=nullptr)
Clone RooAbsArg object and reattach to original parameters.
std::string getRangeNameForSimComponent(std::string const &rangeName, bool splitRange, std::string const &catName)
void getSortedComputationGraph(RooAbsArg const &func, RooArgSet &out)
BinnedLOutput getBinnedL(RooAbsPdf const &pdf)
std::string getColonSeparatedNameString(RooArgSet const &argSet, char delim=':')
std::pair< double, double > getRangeOrBinningInterval(RooAbsArg const *arg, const char *rangeName)
static void output()