ROOT
master
Reference Guide
Loading...
Searching...
No Matches
RooRatio.cxx
Go to the documentation of this file.
1
/*
2
* Project: RooFit
3
* Author:
4
* Rahul Balasubramanian, Nikhef 01 Apr 2021
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
13
/**
14
\file RooRatio.cxx
15
\class RooRatio
16
\ingroup Roofitcore
17
18
Represents the ratio of two RooAbsReal objects.
19
20
**/
21
22
#include <
RooRatio.h
>
23
24
#include <
RooBatchCompute.h
>
25
#include <
RooMsgService.h
>
26
#include <
RooProduct.h
>
27
#include <
RooRealVar.h
>
28
#include <
RooTrace.h
>
29
30
#include "
RooFit/Detail/MathFuncs.h
"
31
32
#include <
Riostream.h
>
33
34
#include <
TMath.h
>
35
36
#include <cmath>
37
38
39
RooRatio::RooRatio
()
40
{
41
TRACE_CREATE
;
42
}
43
44
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
RooAbsReal
&
nr
,
RooAbsReal
&
dr
)
45
:
RooAbsReal
(
name
, title),
46
_numerator(
"numerator"
,
"numerator"
,
this
,
nr
),
47
_denominator(
"denominator"
,
"denominator"
,
this
,
dr
)
48
{
49
TRACE_CREATE
;
50
}
51
52
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
RooAbsReal
&
nr
,
double
dr
)
53
:
RooAbsReal
(
name
, title),
54
_numerator(
"numerator"
,
"numerator"
,
this
,
nr
),
55
_denominator(
"denominator"
,
"denominator"
,
this
)
56
{
57
auto
drvar
=
new
RooRealVar
(
Form
(
"%s_dr"
,
name
),
Form
(
"%s_dr"
,
name
),
dr
);
58
_denominator
.
setArg
(*
drvar
);
59
addOwnedComponents
(
RooArgSet
(*
drvar
));
60
TRACE_CREATE
;
61
}
62
63
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
double
nr
,
RooAbsReal
&
dr
)
64
:
RooAbsReal
(
name
, title),
65
_numerator(
"numerator"
,
"numerator"
,
this
),
66
_denominator(
"denominator"
,
"denominator"
,
this
,
dr
)
67
{
68
auto
nrvar
=
new
RooRealVar
(
Form
(
"%s_nr"
,
name
),
Form
(
"%s_nr"
,
name
),
nr
);
69
_numerator
.
setArg
(*
nrvar
);
70
addOwnedComponents
(
RooArgSet
(*
nrvar
));
71
TRACE_CREATE
;
72
}
73
74
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
double
nr
,
double
dr
)
75
:
RooAbsReal
(
name
, title),
76
_numerator(
"numerator"
,
"numerator"
,
this
),
77
_denominator(
"denominator"
,
"denominator"
,
this
)
78
{
79
auto
nrvar
=
new
RooRealVar
(
Form
(
"%s_nr"
,
name
),
Form
(
"%s_nr"
,
name
),
nr
);
80
auto
drvar
=
new
RooRealVar
(
Form
(
"%s_dr"
,
name
),
Form
(
"%s_dr"
,
name
),
dr
);
81
_numerator
.
setArg
(*
nrvar
);
82
_denominator
.
setArg
(*
drvar
);
83
addOwnedComponents
(
RooArgSet
(*
nrvar
, *
drvar
));
84
TRACE_CREATE
;
85
}
86
87
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
const
RooArgList
&
nrlist
,
const
RooArgList
&
drlist
)
88
:
RooAbsReal
(
name
, title),
89
_numerator(
"numerator"
,
"numerator"
,
this
),
90
_denominator(
"denominator"
,
"denominator"
,
this
)
91
{
92
auto
nrprod
=
new
RooProduct
(
Form
(
"%s_nr"
,
name
),
Form
(
"%s_nr"
,
name
),
nrlist
);
93
auto
drprod
=
new
RooProduct
(
Form
(
"%s_dr"
,
name
),
Form
(
"%s_dr"
,
name
),
drlist
);
94
_numerator
.
setArg
(*
nrprod
);
95
_denominator
.
setArg
(*
drprod
);
96
addOwnedComponents
(
RooArgSet
(*
nrprod
, *
drprod
));
97
TRACE_CREATE
;
98
}
99
100
RooRatio::~RooRatio
()
101
{
102
TRACE_DESTROY
;
103
}
104
105
RooRatio::RooRatio
(
const
RooRatio
&
other
,
const
char
*
name
)
106
:
RooAbsReal
(
other
,
name
),
107
_numerator(
"numerator"
,
this
,
other
._numerator),
108
_denominator(
"denominator"
,
this
,
other
._denominator)
109
{
110
TRACE_CREATE
;
111
}
112
113
double
RooRatio::evaluate
()
const
114
{
115
return
RooFit::Detail::MathFuncs::ratio
(
_numerator
,
_denominator
);
116
}
117
118
////////////////////////////////////////////////////////////////////////////////
119
/// Evaluate in batch mode.
120
void
RooRatio::doEval
(
RooFit::EvalContext
&ctx)
const
121
{
122
RooBatchCompute::compute
(ctx.
config
(
this
),
RooBatchCompute::Ratio
, ctx.
output
(),
123
{ctx.at(_numerator), ctx.at(_denominator)});
124
}
MathFuncs.h
Riostream.h
RooBatchCompute.h
RooMsgService.h
RooProduct.h
RooRatio.h
RooRealVar.h
RooTrace.h
TRACE_DESTROY
#define TRACE_DESTROY
Definition
RooTrace.h:24
TRACE_CREATE
#define TRACE_CREATE
Definition
RooTrace.h:23
name
char name[80]
Definition
TGX11.cxx:110
TMath.h
Form
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition
TString.cxx:2489
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
RooAbsArg::addOwnedComponents
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
Definition
RooAbsArg.cxx:2238
RooAbsReal
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition
RooAbsReal.h:59
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition
RooArgList.h:22
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition
RooArgSet.h:24
RooFit::EvalContext
Definition
EvalContext.h:84
RooFit::EvalContext::output
std::span< double > output()
Definition
EvalContext.h:112
RooFit::EvalContext::config
RooBatchCompute::Config config(RooAbsArg const *arg) const
Definition
EvalContext.cxx:73
RooProduct
Represents the product of a given set of RooAbsReal objects.
Definition
RooProduct.h:29
RooRatio
Represents the ratio of two RooAbsReal objects.
Definition
RooRatio.h:21
RooRatio::_numerator
RooRealProxy _numerator
Definition
RooRatio.h:42
RooRatio::~RooRatio
~RooRatio() override
Definition
RooRatio.cxx:100
RooRatio::evaluate
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition
RooRatio.cxx:113
RooRatio::RooRatio
RooRatio()
Definition
RooRatio.cxx:39
RooRatio::doEval
void doEval(RooFit::EvalContext &) const override
Evaluate in batch mode.
Definition
RooRatio.cxx:120
RooRatio::_denominator
RooRealProxy _denominator
Definition
RooRatio.h:43
RooRealVar
Variable that can be changed from the outside.
Definition
RooRealVar.h:37
RooTemplateProxy::setArg
bool setArg(T &newRef)
Change object held in proxy into newRef.
Definition
RooTemplateProxy.h:253
RooBatchCompute::compute
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})
Definition
RooBatchCompute.h:205
RooBatchCompute::Ratio
@ Ratio
Definition
RooBatchCompute.h:98
RooFit::Detail::MathFuncs::ratio
double ratio(double numerator, double denominator)
Definition
MathFuncs.h:102
roofit
roofitcore
src
RooRatio.cxx
ROOT master - Reference Guide Generated on Thu Mar 13 2025 15:06:49 (GVA Time) using Doxygen 1.10.0