Logo ROOT  
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
18Represents 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
30
31#include <Riostream.h>
32
33#include <TMath.h>
34
35#include <cmath>
36
37
41
42RooRatio::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
49RooRatio::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);
57}
58
59RooRatio::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);
67}
68
69RooRatio::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);
79}
80
81RooRatio::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);
91}
92
96
99 _numerator("numerator", this, other._numerator),
100 _denominator("denominator", this, other._denominator)
101{
102}
103
108
109////////////////////////////////////////////////////////////////////////////////
110/// Evaluate in batch mode.
112{
114 {ctx.at(_numerator), ctx.at(_denominator)});
115}
char name[80]
Definition TGX11.cxx:148
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2570
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
std::span< double > output()
RooBatchCompute::Config config(RooAbsArg const *arg) const
Represents the product of a given set of RooAbsReal objects.
Definition RooProduct.h:29
Represents the ratio of two RooAbsReal objects.
Definition RooRatio.h:21
RooRealProxy _numerator
Definition RooRatio.h:42
~RooRatio() override
Definition RooRatio.cxx:93
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition RooRatio.cxx:104
void doEval(RooFit::EvalContext &) const override
Evaluate in batch mode.
Definition RooRatio.cxx:111
RooRealProxy _denominator
Definition RooRatio.h:43
Variable that can be changed from the outside.
Definition RooRealVar.h:37
bool setArg(T &newRef)
Change object held in proxy into newRef.
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})
double ratio(double numerator, double denominator)
Definition MathFuncs.h:106