Logo ROOT  
Reference Guide
RooRatio.cxx
Go to the documentation of this file.
1 // Author: Rahul Balasubramanian, Nikhef 01 Apr 2021
2 
3 /*****************************************************************************
4  * RooFit
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2019, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 /**
18 \file RooRatio.cxx
19 \class RooRatio
20 \ingroup Roofitcore
21 
22 A RooRatio represents the ratio of two given RooAbsReal objects.
23 
24 **/
25 
26 #include "RooRatio.h"
27 #include "Riostream.h"
28 #include "RooAbsArg.h"
29 #include "RooMsgService.h"
30 #include "RooRealVar.h"
31 #include "RooTrace.h"
32 #include "TMath.h"
33 #include <math.h>
34 
36 
38 
39 RooRatio::RooRatio(const char *name, const char *title, RooAbsReal &nr,
40  RooAbsReal &dr)
41  : RooAbsReal(name, title), _numerator("numerator", "numerator", this, nr),
42  _denominator("denominator", "denominator", this, dr){TRACE_CREATE}
43 
44  RooRatio::RooRatio(const char *name, const char *title, RooAbsReal &nr,
45  Double_t dr)
46  : RooAbsReal(name, title), _numerator("numerator", "numerator", this, nr),
47  _denominator("denominator", "denominator", this) {
48  auto drvar = new RooRealVar(Form("%s_dr", name), Form("%s_dr", name), dr);
49  _denominator.setArg(*drvar);
52 }
53 
54 RooRatio::RooRatio(const char *name, const char *title, Double_t nr,
55  RooAbsReal &dr)
56  : RooAbsReal(name, title), _numerator("numerator", "numerator", this),
57  _denominator("denominator", "denominator", this, dr) {
58  auto nrvar = new RooRealVar(Form("%s_nr", name), Form("%s_nr", name), nr);
59  _numerator.setArg(*nrvar);
62 }
63 
64 RooRatio::RooRatio(const char *name, const char *title, Double_t nr,
65  Double_t dr)
66  : RooAbsReal(name, title), _numerator("numerator", "numerator", this),
67  _denominator("denominator", "denominator", this) {
68  auto nrvar = new RooRealVar(Form("%s_nr", name), Form("%s_nr", name), nr);
69  auto drvar = new RooRealVar(Form("%s_dr", name), Form("%s_dr", name), dr);
70  _numerator.setArg(*nrvar);
71  _denominator.setArg(*drvar);
72  addOwnedComponents(RooArgSet(*nrvar, *drvar));
74 }
75 
76 RooRatio::RooRatio(const char *name, const char *title,
77  const RooArgList &nrlist, const RooArgList &drlist)
78  : RooAbsReal(name, title), _numerator("numerator", "numerator", this),
79  _denominator("denominator", "denominator", this) {
80  auto nrprod =
81  new RooProduct(Form("%s_nr", name), Form("%s_nr", name), nrlist);
82  auto drprod =
83  new RooProduct(Form("%s_dr", name), Form("%s_dr", name), drlist);
84  _numerator.setArg(*nrprod);
85  _denominator.setArg(*drprod);
86  addOwnedComponents(RooArgSet(*nrprod, *drprod));
88 }
89 
91 
92 RooRatio::RooRatio(const RooRatio &other, const char *name)
93  : RooAbsReal(other, name), _numerator("numerator", this, other._numerator),
94  _denominator("denominator", this, other._denominator){TRACE_CREATE}
95 
97 
98  if (_denominator == 0.0) {
99  if (_numerator == 0.0)
100  return std::numeric_limits<double>::quiet_NaN();
101  else
102  return (_numerator > 0.0) ? RooNumber::infinity()
103  : -1.0 * RooNumber::infinity();
104  } else
105  return _numerator / _denominator;
106 }
RooMsgService.h
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
RooRatio
A RooRatio represents the ratio of two given RooAbsReal objects.
Definition: RooRatio.h:30
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooAbsArg.h
RooRatio::_denominator
RooRealProxy _denominator
Definition: RooRatio.h:52
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooTrace.h
RooProduct
A RooProduct represents the product of a given set of RooAbsReal objects.
Definition: RooProduct.h:29
TRACE_DESTROY
#define TRACE_DESTROY
Definition: RooTrace.h:24
RooAbsArg::RooArgSet
friend class RooArgSet
Definition: RooAbsArg.h:599
TRACE_CREATE
#define TRACE_CREATE
Definition: RooTrace.h:23
RooRatio::_numerator
RooRealProxy _numerator
Definition: RooRatio.h:51
RooTemplateProxy::setArg
bool setArg(T &newRef)
Change object held in proxy into newRef.
Definition: RooTemplateProxy.h:227
RooRealVar.h
RooRatio::RooRatio
RooRatio()
Definition: RooRatio.cxx:37
RooNumber::infinity
static Double_t infinity()
Return internal infinity representation.
Definition: RooNumber.cxx:49
RooRatio::evaluate
Double_t evaluate() const
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition: RooRatio.cxx:96
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsArg::addOwnedComponents
Bool_t addOwnedComponents(const RooArgSet &comps)
Take ownership of the contents of 'comps'.
Definition: RooAbsArg.cxx:2216
RooRatio::~RooRatio
virtual ~RooRatio()
Definition: RooRatio.cxx:90
name
char name[80]
Definition: TGX11.cxx:110
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
RooRatio.h
Riostream.h
TMath.h