Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooNovosibirsk.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$Id$
5 * Authors: *
6 * DB, Dieter Best, UC Irvine, best@slac.stanford.edu *
7 * HT, Hirohisa Tanaka SLAC tanaka@slac.stanford.edu *
8 * *
9 * Updated version with analytical integral *
10 * MP, Marko Petric, J. Stefan Institute, marko.petric@ijs.si *
11 * *
12 * Copyright (c) 2000-2013, Regents of the University of California *
13 * and Stanford University. All rights reserved. *
14 * *
15 * Redistribution and use in source and binary forms, *
16 * with or without modification, are permitted according to the terms *
17 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
18 *****************************************************************************/
19
20/** \class RooNovosibirsk
21 \ingroup Roofit
22
23RooNovosibirsk implements the Novosibirsk function
24
25Function taken from H. Ikeda et al. NIM A441 (2000), p. 401 (Belle Collaboration)
26
27**/
28#include "RooNovosibirsk.h"
29#include "RooRealVar.h"
30#include "RooBatchCompute.h"
31
32#include "TMath.h"
33
34#include <cmath>
35using namespace std;
36
38
39////////////////////////////////////////////////////////////////////////////////
40
41RooNovosibirsk::RooNovosibirsk(const char *name, const char *title,
42 RooAbsReal& _x, RooAbsReal& _peak,
43 RooAbsReal& _width, RooAbsReal& _tail) :
44 // The two addresses refer to our first dependent variable and
45 // parameter, respectively, as declared in the rdl file
46 RooAbsPdf(name, title),
47 x("x","x",this,_x),
48 width("width","width",this,_width),
49 peak("peak","peak",this,_peak),
50 tail("tail","tail",this,_tail)
51{
52}
53
54////////////////////////////////////////////////////////////////////////////////
55
57 RooAbsPdf(other,name),
58 x("x",this,other.x),
59 width("width",this,other.width),
60 peak("peak",this,other.peak),
61 tail("tail",this,other.tail)
62{
63}
64
65////////////////////////////////////////////////////////////////////////////////
66///If tail=eta=0 the Belle distribution becomes gaussian
67
69{
70 if (TMath::Abs(tail) < 1.e-7) {
71 return TMath::Exp( -0.5 * TMath::Power( ( (x - peak) / width ), 2 ));
72 }
73
74 double arg = 1.0 - ( x - peak ) * tail / width;
75
76 if (arg < 1.e-7) {
77 //Argument of logarithm negative. Real continuation -> function equals zero
78 return 0.0;
79 }
80
81 double log = TMath::Log(arg);
82 static const double xi = 2.3548200450309494; // 2 Sqrt( Ln(4) )
83
84 double width_zero = ( 2.0 / xi ) * TMath::ASinH( tail * xi * 0.5 );
85 double width_zero2 = width_zero * width_zero;
86 double exponent = ( -0.5 / (width_zero2) * log * log ) - ( width_zero2 * 0.5 );
87
88 return TMath::Exp(exponent) ;
89}
90////////////////////////////////////////////////////////////////////////////////
91/// Compute multiple values of Novosibirsk distribution.
92void RooNovosibirsk::computeBatch(double* output, size_t nEvents, RooFit::Detail::DataMap const& dataMap) const
93{
95 {dataMap.at(x), dataMap.at(peak), dataMap.at(width), dataMap.at(tail)});
96}
97
98////////////////////////////////////////////////////////////////////////////////
99
100Int_t RooNovosibirsk::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* ) const
101{
102 if (matchArgs(allVars,analVars,x)) return 1 ;
103 if (matchArgs(allVars,analVars,peak)) return 2 ;
104
105 //The other two integrals over tali and width are not integrable
106
107 return 0 ;
108}
109
110////////////////////////////////////////////////////////////////////////////////
111
112double RooNovosibirsk::analyticalIntegral(Int_t code, const char* rangeName) const
113{
114 assert(code==1 || code==2) ;
115
116 //The range is defined as [A,B]
117
118 //Numerical values need for the evaluation of the integral
119 static const double sqrt2 = 1.4142135623730950; // Sqrt(2)
120 static const double sqlog2 = 0.832554611157697756; //Sqrt( Log(2) )
121 static const double sqlog4 = 1.17741002251547469; //Sqrt( Log(4) )
122 static const double log4 = 1.38629436111989062; //Log(2)
123 static const double rootpiby2 = 1.2533141373155003; // Sqrt(pi/2)
124 static const double sqpibylog2 = 2.12893403886245236; //Sqrt( pi/Log(2) )
125
126 if (code==1) {
127 double A = x.min(rangeName);
128 double B = x.max(rangeName);
129
130 double result = 0;
131
132
133 //If tail==0 the function becomes gaussian, thus we return a Gaussian integral
134 if (TMath::Abs(tail) < 1.e-7) {
135
136 double xscale = sqrt2*width;
137
138 result = rootpiby2*width*(TMath::Erf((B-peak)/xscale)-TMath::Erf((A-peak)/xscale));
139
140 return result;
141
142 }
143
144 // If the range is not defined correctly the function becomes complex
145 double log_argument_A = ( (peak - A)*tail + width ) / width ;
146 double log_argument_B = ( (peak - B)*tail + width ) / width ;
147
148 //lower limit
149 if ( log_argument_A < 1.e-7) {
150 log_argument_A = 1.e-7;
151 }
152
153 //upper limit
154 if ( log_argument_B < 1.e-7) {
155 log_argument_B = 1.e-7;
156 }
157
158 double term1 = TMath::ASinH( tail * sqlog4 );
159 double term1_2 = term1 * term1;
160
161 //Calculate the error function arguments
162 double erf_termA = ( term1_2 - log4 * TMath::Log( log_argument_A ) ) / ( 2 * term1 * sqlog2 );
163 double erf_termB = ( term1_2 - log4 * TMath::Log( log_argument_B ) ) / ( 2 * term1 * sqlog2 );
164
165 result = 0.5 / tail * width * term1 * ( TMath::Erf(erf_termB) - TMath::Erf(erf_termA)) * sqpibylog2;
166
167 return result;
168
169 } else if (code==2) {
170 double A = x.min(rangeName);
171 double B = x.max(rangeName);
172
173 double result = 0;
174
175
176 //If tail==0 the function becomes gaussian, thus we return a Gaussian integral
177 if (TMath::Abs(tail) < 1.e-7) {
178
179 double xscale = sqrt2*width;
180
181 result = rootpiby2*width*(TMath::Erf((B-x)/xscale)-TMath::Erf((A-x)/xscale));
182
183 return result;
184
185 }
186
187 // If the range is not defined correctly the function becomes complex
188 double log_argument_A = ( (A - x)*tail + width ) / width;
189 double log_argument_B = ( (B - x)*tail + width ) / width;
190
191 //lower limit
192 if ( log_argument_A < 1.e-7) {
193 log_argument_A = 1.e-7;
194 }
195
196 //upper limit
197 if ( log_argument_B < 1.e-7) {
198 log_argument_B = 1.e-7;
199 }
200
201 double term1 = TMath::ASinH( tail * sqlog4 );
202 double term1_2 = term1 * term1;
203
204 //Calculate the error function arguments
205 double erf_termA = ( term1_2 - log4 * TMath::Log( log_argument_A ) ) / ( 2 * term1 * sqlog2 );
206 double erf_termB = ( term1_2 - log4 * TMath::Log( log_argument_B ) ) / ( 2 * term1 * sqlog2 );
207
208 result = 0.5 / tail * width * term1 * ( TMath::Erf(erf_termB) - TMath::Erf(erf_termA)) * sqpibylog2;
209
210 return result;
211
212 }
213
214 // Emit fatal error
215 coutF(Eval) << "Error in RooNovosibirsk::analyticalIntegral" << std::endl;
216
217 // Put dummy return here to avoid compiler warnings
218 return 1.0 ;
219}
#define coutF(a)
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t width
char name[80]
Definition TGX11.cxx:110
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
bool matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
RooBatchCompute::Config config(RooAbsArg const *arg) const
Definition DataMap.cxx:40
RooNovosibirsk implements the Novosibirsk function.
RooRealProxy width
void computeBatch(double *output, size_t nEvents, RooFit::Detail::DataMap const &) const override
Compute multiple values of Novosibirsk distribution.
RooRealProxy peak
RooRealProxy tail
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
double evaluate() const override
If tail=eta=0 the Belle distribution becomes gaussian.
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
RooRealProxy x
double max(const char *rname=nullptr) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
double min(const char *rname=nullptr) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
Double_t x[n]
Definition legend1.C:17
void compute(Config cfg, Computer comp, RestrictArr output, size_t size, const VarVector &vars, ArgVector &extraArgs)
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Definition TMath.h:709
Double_t Erf(Double_t x)
Computation of the error function erf(x).
Definition TMath.cxx:190
Double_t ASinH(Double_t)
Returns the area hyperbolic sine of x.
Definition TMath.cxx:67
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Definition TMath.h:756
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:721
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
static void output()