ATLAS Offline Software
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 
103 Int_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  }
BeamSpotPdf::y
RooRealProxy y
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:54
fitman.sy
sy
Definition: fitman.py:524
fitman.sz
sz
Definition: fitman.py:527
BeamSpotPdf::sx
RooRealProxy sx
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:60
BeamSpotPdf
Definition: InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotPdf.h:21
fitman.ax
ax
Definition: fitman.py:522
fitman.my
my
Definition: fitman.py:523
BeamSpotPdf::my
RooRealProxy my
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:62
python.compressB64.sx
string sx
Definition: compressB64.py:96
BeamSpotPdf::analyticalIntegral
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Definition: InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotPdf.cxx:144
fitman.mx
mx
Definition: fitman.py:520
BeamSpotPdf::rho
RooRealProxy rho
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:68
BeamSpotPdf::x
RooRealProxy x
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:53
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
x
#define x
fitman.vxy
vxy
Definition: fitman.py:506
pi
#define pi
Definition: TileMuonFitter.cxx:65
BeamSpotPdf::ax
RooRealProxy ax
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:61
ClassImp
ClassImp(BeamSpotPdf) BeamSpotPdf
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.cxx:21
BeamSpotPdf::vxx
RooRealProxy vxx
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:56
BeamSpotPdf::BeamSpotPdf
BeamSpotPdf()
Definition: InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotPdf.h:28
BeamSpotPdf::mz
RooRealProxy mz
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:65
BeamSpotPdf::ay
RooRealProxy ay
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:64
BeamSpotPdf::z
RooRealProxy z
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:55
BeamSpotPdf::mx
RooRealProxy mx
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:59
BeamSpotPdf::vyy
RooRealProxy vyy
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:57
z
#define z
BeamSpotPdf::getAnalyticalIntegral
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *) const
Definition: InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotPdf.cxx:104
BeamSpotPdf::sz
RooRealProxy sz
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:66
fitman.mz
mz
Definition: fitman.py:526
covarianceTool.title
title
Definition: covarianceTool.py:542
BeamSpotPdf::vxy
RooRealProxy vxy
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:58
create_dcsc_inputs_sqlite.arg
list arg
Definition: create_dcsc_inputs_sqlite.py:48
BeamSpotPdf.h
pmontree.code
code
Definition: pmontree.py:443
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
BeamSpotPdf::evaluate
Double_t evaluate() const
Definition: InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotPdf.cxx:85
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
y
#define y
fitman.vxx
vxx
Definition: fitman.py:504
fitman.vyy
vyy
Definition: fitman.py:505
BeamSpotPdf::k
RooRealProxy k
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:67
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
BeamSpotPdf::sy
RooRealProxy sy
Definition: InDetExample/InDetBeamSpotExample/roofit/BeamSpotPdf.h:63
fitman.rho
rho
Definition: fitman.py:532
fitman.k
k
Definition: fitman.py:528
fitman.ay
ay
Definition: fitman.py:525