CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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
 
void setLimits (float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
 
double Up () const
 
 ~FcnBeamSpotFitPV ()
 

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 ( const std::vector< BeamSpotFitPVData > &  data)

Definition at line 12 of file FcnBeamSpotFitPV.cc.

References lowerLimits_, and upperLimits_.

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

Definition at line 26 of file FcnBeamSpotFitPV.h.

26 {}

Member Function Documentation

unsigned int FcnBeamSpotFitPV::nrOfVerticesUsed ( ) const

Definition at line 35 of file FcnBeamSpotFitPV.cc.

References data_, lowerLimits_, and upperLimits_.

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

Definition at line 60 of file FcnBeamSpotFitPV.cc.

References gather_cfg::cout, data_, cmsBatch::log, lowerLimits_, and upperLimits_.

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

Definition at line 32 of file FcnBeamSpotFitPV.h.

References errorDef_.

32 {return errorDef_;}

Member Data Documentation

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

Definition at line 38 of file FcnBeamSpotFitPV.h.

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

double FcnBeamSpotFitPV::errorDef_
private

Definition at line 39 of file FcnBeamSpotFitPV.h.

Referenced by Up().

float FcnBeamSpotFitPV::lowerLimits_[3]
private

Definition at line 41 of file FcnBeamSpotFitPV.h.

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

float FcnBeamSpotFitPV::upperLimits_[3]
private

Definition at line 42 of file FcnBeamSpotFitPV.h.

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