CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Attributes
FcnBeamSpotFitPV Class Reference

#include <FcnBeamSpotFitPV.h>

Inheritance diagram for FcnBeamSpotFitPV:

Public Member Functions

 FcnBeamSpotFitPV (const std::vector< BeamSpotFitPVData > &data)
 
unsigned int nrOfVerticesUsed () const
 
double operator() (const std::vector< double > &) const override
 
void setLimits (float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
 
double Up () const override
 
 ~FcnBeamSpotFitPV () override
 

Private Attributes

const std::vector< BeamSpotFitPVData > & data_
 
double errorDef_
 
float lowerLimits_ [3]
 
float upperLimits_ [3]
 

Detailed Description

LogLH function for 3D beam spot fit from primary vertex data. Assumes a Gaussian resolution function for the vertices provided in the form of a vector of BeamSpotFitPVData and a Gaussian beam profile in 3D: based on a covariance without xz and yz correlations + linearized rotations in the xz and yz planes. Parameters: x, y, z, ex, corrxy, ey, dxdz, dydz, ez, scale x, y, z ...... beamspot position ex, ey, ez ... beamspot width corrxy ....... xy correlation in the system of the beam line dxdz, dydz ... rotations in xz and yz scale ........ scaling factor for vertex errors

Author
WA, 9/3/2010

Definition at line 22 of file FcnBeamSpotFitPV.h.

Constructor & Destructor Documentation

◆ FcnBeamSpotFitPV()

FcnBeamSpotFitPV::FcnBeamSpotFitPV ( const std::vector< BeamSpotFitPVData > &  data)

Definition at line 12 of file FcnBeamSpotFitPV.cc.

References lowerLimits_, and upperLimits_.

12  : data_(data), errorDef_(1.) {
13  //
14  // default: no additional cuts
15  //
16  lowerLimits_[0] = lowerLimits_[1] = lowerLimits_[2] = -1.e30;
17  upperLimits_[0] = upperLimits_[1] = upperLimits_[2] = 1.e30;
18 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
const std::vector< BeamSpotFitPVData > & data_

◆ ~FcnBeamSpotFitPV()

FcnBeamSpotFitPV::~FcnBeamSpotFitPV ( )
inlineoverride

Definition at line 26 of file FcnBeamSpotFitPV.h.

26 {}

Member Function Documentation

◆ nrOfVerticesUsed()

unsigned int FcnBeamSpotFitPV::nrOfVerticesUsed ( ) const

Definition at line 29 of file FcnBeamSpotFitPV.cc.

References data_, lowerLimits_, L1TkPrimaryVertex_cfi::nVtx, and upperLimits_.

29  {
30  //
31  // count vertices imposing the current limits
32  //
33  unsigned int nVtx = 0;
34  double v1(0);
35  double v2(0);
36  double v3(0);
37  for (vector<BeamSpotFitPVData>::const_iterator ipv = data_.begin(); ipv != data_.end(); ++ipv) {
38  v1 = (*ipv).position[0];
39  if (v1 < lowerLimits_[0] || v1 > upperLimits_[0])
40  continue;
41  v2 = (*ipv).position[1];
42  if (v2 < lowerLimits_[1] || v2 > upperLimits_[1])
43  continue;
44  v3 = (*ipv).position[2];
45  if (v3 < lowerLimits_[2] || v3 > upperLimits_[2])
46  continue;
47 
48  ++nVtx;
49  }
50 
51  return nVtx;
52 }
const std::vector< BeamSpotFitPVData > & data_

◆ operator()()

double FcnBeamSpotFitPV::operator() ( const std::vector< double > &  pars) const
override

Definition at line 54 of file FcnBeamSpotFitPV.cc.

References gather_cfg::cout, data_, dxdz, dydz, simpleEdmComparison::ev1, simpleEdmComparison::ev2, dqm-mbProfile::log, lowerLimits_, and upperLimits_.

54  {
55  //
56  // fit parameters
57  //
58  double vb1 = pars[0];
59  double vb2 = pars[1];
60  double vb3 = pars[2];
61  double sigb1 = pars[3];
62  double corrb12 = pars[4];
63  double sigb2 = pars[5];
64  double dxdz = pars[6];
65  double dydz = pars[7];
66  double sigb3 = pars[8];
67  double escale = pars[9];
68  //
69  // covariance matrix of the beamspot distribution
70  //
71  typedef ROOT::Math::SVector<double, 3> Vector3D;
72  typedef ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > Matrix3D;
73  Matrix3D covb;
74  double varb1 = sigb1 * sigb1;
75  double varb2 = sigb2 * sigb2;
76  double varb3 = sigb3 * sigb3;
77  // parametrisation: rotation (dx/dz, dy/dz); covxy
78  covb(0, 0) = varb1;
79  covb(1, 0) = covb(0, 1) = corrb12 * sigb1 * sigb2;
80  covb(1, 1) = varb2;
81  covb(2, 0) = covb(0, 2) = dxdz * (varb3 - varb1) - dydz * covb(1, 0);
82  covb(2, 1) = covb(1, 2) = dydz * (varb3 - varb2) - dxdz * covb(1, 0);
83  covb(2, 2) = varb3;
84 
85  //
86  // calculation of the likelihood function
87  //
88  double sumLL(0);
89  double v1(0);
90  double v2(0);
91  double v3(0);
92  double ev1(0);
93  double corr12(0);
94  double ev2(0);
95  double corr13(0);
96  double corr23(0);
97  double ev3(0);
98  //
99  // vertex - beamspot difference and total covariance matrix
100  //
101  Vector3D dv;
102  Matrix3D cov;
103  Matrix3D wgt;
104  //
105  // iteration over vertices
106  //
107  for (vector<BeamSpotFitPVData>::const_iterator ipv = data_.begin(); ipv != data_.end(); ++ipv) {
108  //
109  // additional selection
110  //
111  v1 = (*ipv).position[0];
112  if (v1 < lowerLimits_[0] || v1 > upperLimits_[0])
113  continue;
114  v2 = (*ipv).position[1];
115  if (v2 < lowerLimits_[1] || v2 > upperLimits_[1])
116  continue;
117  v3 = (*ipv).position[2];
118  if (v3 < lowerLimits_[2] || v3 > upperLimits_[2])
119  continue;
120  //
121  // vertex errors (after scaling) and correlations
122  //
123  ev1 = (*ipv).posError[0];
124  corr12 = (*ipv).posCorr[0];
125  ev2 = (*ipv).posError[1];
126  corr13 = (*ipv).posCorr[1];
127  corr23 = (*ipv).posCorr[2];
128  ev3 = (*ipv).posError[2];
129  ev1 *= escale;
130  ev2 *= escale;
131  ev3 *= escale;
132  //
133  // vertex covariance matrix
134  //
135  cov(0, 0) = ev1 * ev1;
136  cov(1, 0) = cov(0, 1) = ev1 * ev2 * corr12;
137  cov(1, 1) = ev2 * ev2;
138  cov(2, 0) = cov(0, 2) = ev1 * ev3 * corr13;
139  cov(2, 1) = cov(1, 2) = ev2 * ev3 * corr23;
140  cov(2, 2) = ev3 * ev3;
141  //
142  // total covariance and weight matrix
143  //
144  cov += covb;
145  int ifail;
146  wgt = cov.Inverse(ifail);
147  if (ifail) {
148  //edm::LogWarning("FcnBeamSpotFitPV")
149  cout << "Inversion failed" << endl;
150  return -1.e30;
151  }
152  //
153  // difference of vertex and beamspot positions
154  //
155  dv(0) = v1 - vb1;
156  dv(1) = v2 - vb2;
157  dv(2) = v3 - vb3;
158  //
159  // exponential term and normalization
160  // (neglecting the additional cut)
161  //
162  sumLL += ROOT::Math::Similarity(dv, wgt);
163  double det;
164  cov.Det2(det);
165  sumLL += log(det);
166  }
167 
168  return sumLL;
169 }
float dydz
float dxdz
const std::vector< BeamSpotFitPVData > & data_

◆ setLimits()

void FcnBeamSpotFitPV::setLimits ( float  xmin,
float  xmax,
float  ymin,
float  ymax,
float  zmin,
float  zmax 
)

◆ Up()

double FcnBeamSpotFitPV::Up ( ) const
inlineoverride

Definition at line 30 of file FcnBeamSpotFitPV.h.

References errorDef_.

30 { return errorDef_; }

Member Data Documentation

◆ data_

const std::vector<BeamSpotFitPVData>& FcnBeamSpotFitPV::data_
private

Definition at line 37 of file FcnBeamSpotFitPV.h.

Referenced by nrOfVerticesUsed(), and operator()().

◆ errorDef_

double FcnBeamSpotFitPV::errorDef_
private

Definition at line 38 of file FcnBeamSpotFitPV.h.

Referenced by Up().

◆ lowerLimits_

float FcnBeamSpotFitPV::lowerLimits_[3]
private

Definition at line 40 of file FcnBeamSpotFitPV.h.

Referenced by FcnBeamSpotFitPV(), nrOfVerticesUsed(), operator()(), and setLimits().

◆ upperLimits_

float FcnBeamSpotFitPV::upperLimits_[3]
private

Definition at line 41 of file FcnBeamSpotFitPV.h.

Referenced by FcnBeamSpotFitPV(), nrOfVerticesUsed(), operator()(), and setLimits().