ATLAS Offline Software
Loading...
Searching...
No Matches
InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*****************************************************************************
6 * Project: RooFit *
7 * *
8 * This code was autogenerated by RooClassFactory *
9 *****************************************************************************/
10
11// Your description goes here...
12
13#include "Riostream.h"
14
15#include "BeamSpotPdf.h"
16#include "RooAbsReal.h"
17#include "RooAbsCategory.h"
18#include <math.h>
19#include "TMath.h"
20
22
23 BeamSpotPdf::BeamSpotPdf(const char *name, const char *title,
24 RooAbsReal& _x,
25 RooAbsReal& _y,
26 RooAbsReal& _z,
27 RooAbsReal& _vxx,
28 RooAbsReal& _vyy,
29 RooAbsReal& _vxy,
30 RooAbsReal& _mx,
31 RooAbsReal& _sx,
32 RooAbsReal& _ax,
33 RooAbsReal& _my,
34 RooAbsReal& _sy,
35 RooAbsReal& _ay,
36 RooAbsReal& _mz,
37 RooAbsReal& _sz,
38 RooAbsReal& _k,
39 RooAbsReal& _rho) :
40 RooAbsPdf(name,title),
41 x("x","x",this,_x),
42 y("y","y",this,_y),
43 z("z","z",this,_z),
44 vxx("vxx","vxx",this,_vxx),
45 vyy("vyy","vyy",this,_vyy),
46 vxy("vxy","vxy",this,_vxy),
47 mx("mx","mx",this,_mx),
48 sx("sx","sx",this,_sx),
49 ax("ax","ax",this,_ax),
50 my("my","my",this,_my),
51 sy("sy","sy",this,_sy),
52 ay("ay","ay",this,_ay),
53 mz("mz","mz",this,_mz),
54 sz("sz","sz",this,_sz),
55 k("k","k",this,_k),
56 rho("rho","rho",this,_rho)
57 {
58 }
59
60
61 BeamSpotPdf::BeamSpotPdf(const BeamSpotPdf& other, const char* name) :
62 RooAbsPdf(other,name),
63 x("x",this,other.x),
64 y("y",this,other.y),
65 z("z",this,other.z),
66 vxx("vxx",this,other.vxx),
67 vyy("vyy",this,other.vyy),
68 vxy("vxy",this,other.vxy),
69 mx("mx",this,other.mx),
70 sx("sx",this,other.sx),
71 ax("ax",this,other.ax),
72 my("my",this,other.my),
73 sy("sy",this,other.sy),
74 ay("ay",this,other.ay),
75 mz("mz",this,other.mz),
76 sz("sz",this,other.sz),
77 k("k",this,other.k),
78 rho("rho",this,other.rho)
79 {
80 }
81
82
83
84 Double_t BeamSpotPdf::evaluate() const
85 {
86 // ENTER EXPRESSION IN TERMS OF VARIABLE ARGUMENTS HERE
87 double dx = x - (mx + ax*(z-mz));
88 double dy = y - (my + ay*(z-mz));
89 double dz = z - mz;
90 double k2 = k*k;
91 double wxx = sx*sx + k2*vxx;
92 double wyy = sy*sy + k2*vyy;
93 double wxy = rho*sx*sy + k2*vxy;
94 double detw = wxx*wyy - wxy*wxy;
95 double iwxx = wyy/detw;
96 double iwyy = wxx/detw;
97 double iwxy = -wxy/detw;
98 double arg = dx*iwxx*dx + 2*dx*iwxy*dy + dy*iwyy*dy;
99 arg += dz*dz/(sz*sz);
100 return exp(-0.5*arg);
101 }
102
103Int_t BeamSpotPdf::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
104 {
105 // LIST HERE OVER WHICH VARIABLES ANALYTICAL INTEGRATION IS SUPPORTED,
106 // ASSIGN A NUMERIC CODE FOR EACH SUPPORTED (SET OF) PARAMETERS
107 // THE EXAMPLE BELOW ASSIGNS CODE 1 TO INTEGRATION OVER VARIABLE X
108 // YOU CAN ALSO IMPLEMENT MORE THAN ONE ANALYTICAL INTEGRAL BY REPEATING THE matchArgs
109 // EXPRESSION MULTIPLE TIMES
110
111 if (matchArgs(allVars,analVars,x,y,z)) return 1 ;
112 if (matchArgs(allVars,analVars,x,y)) return 2 ;
113 return 0 ;
114 }
115
116 Double_t BeamSpotPdf::analyticalIntegral(Int_t code, const char* rangeName) const
117 {
118 // RETURN ANALYTICAL INTEGRAL DEFINED BY RETURN CODE ASSIGNED BY getAnalyticalIntegral
119 // THE MEMBER FUNCTION x.min(rangeName) AND x.max(rangeName) WILL RETURN THE INTEGRATION
120 // BOUNDARIES FOR EACH OBSERVABLE x
121
122 double pi = TMath::Pi();
123 double k2 = k*k;
124 double wxx = sx*sx + k2*vxx;
125 double wyy = sy*sy + k2*vyy;
126 double wxy = rho*sx*sy + k2*vxy;
127 double detw = wxx*wyy - wxy*wxy;
128
129 if (code==1) {
130 // Sloppy - for now assume integral can be approximated by integral
131 // from -infinity ... +infinity. Otherwise need to check on min and max.
132 //cout << x.min(rangeName) << " ... " << x.max(rangeName) << endl;
133 //cout << y.min(rangeName) << " ... " << y.max(rangeName) << endl;
134 //cout << z.min(rangeName) << " ... " << z.max(rangeName) << endl;
135 //cout << endl;
136 return 2*pi*sqrt(detw)*sqrt(2*pi)*sz;
137 }
138 if (code==2) {
139 double dz = z - mz;
140 return 2*pi*sqrt(detw)*exp(-0.5*dz*dz/(sz*sz));
141 }
142 return 0 ;
143 }
static Double_t sz
#define pi
#define y
#define x
#define z
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *) const
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const