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
29
#include "
RooFit/Detail/MathFuncs.h
"
30
31
#include <
Riostream.h
>
32
33
#include <
TMath.h
>
34
35
#include <cmath>
36
37
38
RooRatio::RooRatio
()
39
{
40
}
41
42
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
RooAbsReal
&
nr
,
RooAbsReal
&
dr
)
43
:
RooAbsReal
(
name
, title),
44
_numerator(
"numerator"
,
"numerator"
,
this
,
nr
),
45
_denominator(
"denominator"
,
"denominator"
,
this
,
dr
)
46
{
47
}
48
49
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
RooAbsReal
&
nr
,
double
dr
)
50
:
RooAbsReal
(
name
, title),
51
_numerator(
"numerator"
,
"numerator"
,
this
,
nr
),
52
_denominator(
"denominator"
,
"denominator"
,
this
)
53
{
54
auto
drvar
=
new
RooRealVar
(
Form
(
"%s_dr"
,
name
),
Form
(
"%s_dr"
,
name
),
dr
);
55
_denominator
.
setArg
(*
drvar
);
56
addOwnedComponents
(
RooArgSet
(*
drvar
));
57
}
58
59
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
double
nr
,
RooAbsReal
&
dr
)
60
:
RooAbsReal
(
name
, title),
61
_numerator(
"numerator"
,
"numerator"
,
this
),
62
_denominator(
"denominator"
,
"denominator"
,
this
,
dr
)
63
{
64
auto
nrvar
=
new
RooRealVar
(
Form
(
"%s_nr"
,
name
),
Form
(
"%s_nr"
,
name
),
nr
);
65
_numerator
.
setArg
(*
nrvar
);
66
addOwnedComponents
(
RooArgSet
(*
nrvar
));
67
}
68
69
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
double
nr
,
double
dr
)
70
:
RooAbsReal
(
name
, title),
71
_numerator(
"numerator"
,
"numerator"
,
this
),
72
_denominator(
"denominator"
,
"denominator"
,
this
)
73
{
74
auto
nrvar
=
new
RooRealVar
(
Form
(
"%s_nr"
,
name
),
Form
(
"%s_nr"
,
name
),
nr
);
75
auto
drvar
=
new
RooRealVar
(
Form
(
"%s_dr"
,
name
),
Form
(
"%s_dr"
,
name
),
dr
);
76
_numerator
.
setArg
(*
nrvar
);
77
_denominator
.
setArg
(*
drvar
);
78
addOwnedComponents
(
RooArgSet
(*
nrvar
, *
drvar
));
79
}
80
81
RooRatio::RooRatio
(
const
char
*
name
,
const
char
*title,
const
RooArgList
&
nrlist
,
const
RooArgList
&
drlist
)
82
:
RooAbsReal
(
name
, title),
83
_numerator(
"numerator"
,
"numerator"
,
this
),
84
_denominator(
"denominator"
,
"denominator"
,
this
)
85
{
86
auto
nrprod
=
new
RooProduct
(
Form
(
"%s_nr"
,
name
),
Form
(
"%s_nr"
,
name
),
nrlist
);
87
auto
drprod
=
new
RooProduct
(
Form
(
"%s_dr"
,
name
),
Form
(
"%s_dr"
,
name
),
drlist
);
88
_numerator
.
setArg
(*
nrprod
);
89
_denominator
.
setArg
(*
drprod
);
90
addOwnedComponents
(
RooArgSet
(*
nrprod
, *
drprod
));
91
}
92
93
RooRatio::~RooRatio
()
94
{
95
}
96
97
RooRatio::RooRatio
(
const
RooRatio
&
other
,
const
char
*
name
)
98
:
RooAbsReal
(
other
,
name
),
99
_numerator(
"numerator"
,
this
,
other
._numerator),
100
_denominator(
"denominator"
,
this
,
other
._denominator)
101
{
102
}
103
104
double
RooRatio::evaluate
()
const
105
{
106
return
RooFit::Detail::MathFuncs::ratio
(
_numerator
,
_denominator
);
107
}
108
109
////////////////////////////////////////////////////////////////////////////////
110
/// Evaluate in batch mode.
111
void
RooRatio::doEval
(
RooFit::EvalContext
&ctx)
const
112
{
113
RooBatchCompute::compute
(ctx.
config
(
this
),
RooBatchCompute::Ratio
, ctx.
output
(),
114
{ctx.at(_numerator), ctx.at(_denominator)});
115
}
MathFuncs.h
Riostream.h
RooBatchCompute.h
RooMsgService.h
RooProduct.h
RooRatio.h
RooRealVar.h
name
char name[80]
Definition
TGX11.cxx:148
TMath.h
Form
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition
TString.cxx:2570
ROOT::Detail::TRangeCast
Definition
TCollection.h:312
RooAbsArg::addOwnedComponents
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
Definition
RooAbsArg.cxx:2012
RooAbsReal
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition
RooAbsReal.h:63
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:93
RooRatio::evaluate
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition
RooRatio.cxx:104
RooRatio::RooRatio
RooRatio()
Definition
RooRatio.cxx:38
RooRatio::doEval
void doEval(RooFit::EvalContext &) const override
Evaluate in batch mode.
Definition
RooRatio.cxx:111
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:212
RooBatchCompute::Ratio
@ Ratio
Definition
RooBatchCompute.h:105
RooFit::Detail::MathFuncs::ratio
double ratio(double numerator, double denominator)
Definition
MathFuncs.h:106
roofit
roofitcore
src
RooRatio.cxx
ROOTmaster - Reference Guide Generated on Sun Aug 16 2026 04:54:05 (GVA Time) using Doxygen 1.10.0