ROOT   Reference Guide
RooBukinPdf.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$Id$
5 * Authors: *
6 * RW, Ruddick William UC Colorado wor@slac.stanford.edu *
7 * *
8 * Copyright (c) 2000-2005, Regents of the University of California *
10 * *
11 * Redistribution and use in source and binary forms, *
12 * with or without modification, are permitted according to the terms *
14 *****************************************************************************/
15
16/** \class RooBukinPdf
17 \ingroup Roofit
18
19The RooBukinPdf implements the NovosibirskA function. For the parameters, see
20RooBukinPdf().
21
22Credits:
23May 26, 2003.
24A.Bukin, Budker INP, Novosibirsk
25
26\image html RooBukin.png
27http://www.slac.stanford.edu/BFROOT/www/Organization/CollabMtgs/2003/detJuly2003/Tues3a/bukin.ps
28**/
29
30#include "RooBukinPdf.h"
31#include "RooRealVar.h"
32#include "RooHelpers.h"
33#include "RooBatchCompute.h"
34
35#include <cmath>
36using namespace std;
37
39
40////////////////////////////////////////////////////////////////////////////////
41/// Construct a Bukin PDF.
42/// \param name The name of the PDF for RooFit's bookkeeping.
43/// \param title The title for e.g. plotting it.
44/// \param _x The variable.
45/// \param _Xp The peak position.
46/// \param _sigp The peak width as FWHM divided by 2*sqrt(2*log(2))=2.35
47/// \param _xi Peak asymmetry. Use values around 0.
48/// \param _rho1 Left tail. Use slightly negative starting values.
49/// \param _rho2 Right tail. Use slightly positive starting values.
50RooBukinPdf::RooBukinPdf(const char *name, const char *title,
51 RooAbsReal& _x, RooAbsReal& _Xp,
52 RooAbsReal& _sigp, RooAbsReal& _xi,
53 RooAbsReal& _rho1, RooAbsReal& _rho2) :
54 // The two addresses refer to our first dependent variable and
55 // parameter, respectively, as declared in the rdl file
56 RooAbsPdf(name, title),
57 x("x","x",this,_x),
58 Xp("Xp","Xp",this,_Xp),
59 sigp("sigp","sigp",this,_sigp),
60 xi("xi","xi",this,_xi),
61 rho1("rho1","rho1",this,_rho1),
62 rho2("rho2","rho2",this,_rho2)
63{
64 RooHelpers::checkRangeOfParameters(this, {&_sigp}, 0.0);
65 RooHelpers::checkRangeOfParameters(this, {&_rho1},-1.0, 0.0);
66 RooHelpers::checkRangeOfParameters(this, {&_rho2}, 0.0, 1.0);
67 RooHelpers::checkRangeOfParameters(this, {&_xi}, -1.0, 1.0);
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Copy a Bukin PDF.
72RooBukinPdf::RooBukinPdf(const RooBukinPdf& other, const char *name):
73 RooAbsPdf(other,name),
74 x("x",this,other.x),
75 Xp("Xp",this,other.Xp),
76 sigp("sigp",this,other.sigp),
77 xi("xi",this,other.xi),
78 rho1("rho1",this,other.rho1),
79 rho2("rho2",this,other.rho2)
80
81{
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Implementation
86
88{
89 const double consts = 2*sqrt(2*log(2.0));
90 double r1=0,r2=0,r3=0,r4=0,r5=0,hp=0;
91 double x1 = 0,x2 = 0;
92 double fit_result = 0;
93
94 hp=sigp*consts;
95 r3=log(2.);
96 r4=sqrt(xi*xi+1);
97 r1=xi/r4;
98
99 if(std::abs(xi) > exp(-6.)){
100 r5=xi/log(r4+xi);
101 }
102 else
103 r5=1;
104
105 x1 = Xp + (hp / 2) * (r1-1);
106 x2 = Xp + (hp / 2) * (r1+1);
107
108 //--- Left Side
109 if(x < x1){
110 r2=rho1*(x-x1)*(x-x1)/(Xp-x1)/(Xp-x1)-r3 + 4 * r3 * (x-x1)/hp * r5 * r4/(r4-xi)/(r4-xi);
111 }
112
113
114 //--- Center
115 else if(x < x2) {
116 if(std::abs(xi) > exp(-6.)) {
117 r2=log(1 + 4 * xi * r4 * (x-Xp)/hp)/log(1+2*xi*(xi-r4));
118 r2=-r3*r2*r2;
119 }
120 else{
121 r2=-4*r3*(x-Xp)*(x-Xp)/hp/hp;
122 }
123 }
124
125
126 //--- Right Side
127 else {
128 r2=rho2*(x-x2)*(x-x2)/(Xp-x2)/(Xp-x2)-r3 - 4 * r3 * (x-x2)/hp * r5 * r4/(r4+xi)/(r4+xi);
129 }
130
131 if(std::abs(r2) > 100){
132 fit_result = 0;
133 }
134 else{
135 //---- Normalize the result
136 fit_result = exp(r2);
137 }
138
139 return fit_result;
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Compute multiple values of Bukin distribution.
144void RooBukinPdf::computeBatch(cudaStream_t* stream, double* output, size_t nEvents, RooFit::Detail::DataMap const& dataMap) const
145{
147 dispatch->compute(stream, RooBatchCompute::Bukin, output, nEvents,
148 {dataMap.at(x), dataMap.at(Xp), dataMap.at(sigp), dataMap.at(xi), dataMap.at(rho1), dataMap.at(rho2)});
149}
#define ClassImp(name)
Definition: Rtypes.h:375
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
char name[80]
Definition: TGX11.cxx:110
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:60
virtual void compute(cudaStream_t *, Computer, RestrictArr, size_t, const VarVector &, const ArgVector &={})=0
The RooBukinPdf implements the NovosibirskA function.
Definition: RooBukinPdf.h:29
RooRealProxy rho2
Definition: RooBukinPdf.h:49
RooRealProxy sigp
Definition: RooBukinPdf.h:46
RooRealProxy rho1
Definition: RooBukinPdf.h:48
RooRealProxy x
Definition: RooBukinPdf.h:44
RooRealProxy xi
Definition: RooBukinPdf.h:47
void computeBatch(cudaStream_t *, double *output, size_t nEvents, RooFit::Detail::DataMap const &) const override
Compute multiple values of Bukin distribution.
double evaluate() const override
Implementation.
Definition: RooBukinPdf.cxx:87
RooRealProxy Xp
Definition: RooBukinPdf.h:45
auto & at(RooAbsArg const *arg, RooAbsArg const *=nullptr)
Definition: DataMap.h:88
RVec< PromoteType< T > > abs(const RVec< T > &v)
Definition: RVec.hxx:1778
RVec< PromoteType< T > > log(const RVec< T > &v)
Definition: RVec.hxx:1787
RVec< PromoteType< T > > exp(const RVec< T > &v)
Definition: RVec.hxx:1783
Double_t x[n]
Definition: legend1.C:17
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
R__EXTERN RooBatchComputeInterface * dispatchCUDA
R__EXTERN RooBatchComputeInterface * dispatchCPU
This dispatch pointer points to an implementation of the compute library, provided one has been loade...
void checkRangeOfParameters(const RooAbsReal *callingClass, std::initializer_list< const RooAbsReal * > pars, double min=-std::numeric_limits< double >::max(), double max=std::numeric_limits< double >::max(), bool limitsInAllowedRange=false, std::string const &extraMessage="")
Check if the parameters have a range, and warn if the range extends below / above the set limits.
Definition: RooHelpers.cxx:123
static void output()