18 edm::LogVerbatim(
"MuonSegFit") <<
"[MuonSegFit::fit] - cannot fit just 1 hit!!";
47 MuonRecHitContainer::const_iterator ih =
hits_.begin();
57 float dz = h2pos.
z()-h1pos.
z();
59 uslope_ = ( h2pos.
x() - h1pos.
x() ) / dz ;
60 vslope_ = ( h2pos.
y() - h1pos.
y() ) / dz ;
63 float uintercept = ( h1pos.
x()*h2pos.
z() - h2pos.
x()*h1pos.
z() ) / dz;
64 float vintercept = ( h1pos.
y()*h2pos.
z() - h2pos.
y()*h1pos.
z() ) / dz;
145 MuonRecHitContainer::const_iterator ih =
hits_.begin();
148 for (ih =
hits_.begin(); ih !=
hits_.end(); ++ih) {
158 IC(0,0) = (*ih)->localPositionError().xx();
159 IC(1,1) = (*ih)->localPositionError().yy();
162 IC(1,0) = (*ih)->localPositionError().xy();
166 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::fit] 2x2 covariance matrix for this GEMRecHit :: [[" << IC(0,0) <<
", "<< IC(0,1) <<
"]["<< IC(1,0) <<
","<<IC(1,1)<<
"]]";
170 bool ok = IC.Invert();
172 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::fit] Failed to invert covariance matrix: \n" << IC;
178 M(0,2) += IC(0,0) *
z;
179 M(0,3) += IC(0,1) *
z;
180 B(0) += u * IC(0,0) + v * IC(0,1);
184 M(1,2) += IC(1,0) *
z;
185 M(1,3) += IC(1,1) *
z;
186 B(1) += u * IC(1,0) + v * IC(1,1);
188 M(2,0) += IC(0,0) *
z;
189 M(2,1) += IC(0,1) *
z;
190 M(2,2) += IC(0,0) * z *
z;
191 M(2,3) += IC(0,1) * z *
z;
192 B(2) += ( u * IC(0,0) + v * IC(0,1) ) * z;
194 M(3,0) += IC(1,0) *
z;
195 M(3,1) += IC(1,1) *
z;
196 M(3,2) += IC(1,0) * z *
z;
197 M(3,3) += IC(1,1) * z *
z;
198 B(3) += ( u * IC(1,0) + v * IC(1,1) ) * z;
203 bool ok = M.Invert();
205 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::fit] Failed to invert matrix: \n" << M;
213 LogTrace(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::fit] p = " 214 <<
p(0) <<
", " <<
p(1) <<
", " <<
p(2) <<
", " <<
p(3);
239 MuonRecHitContainer::const_iterator ih;
241 for (ih =
hits_.begin(); ih !=
hits_.end(); ++ih) {
253 IC(0,0) = (*ih)->localPositionError().xx();
255 IC(1,0) = (*ih)->localPositionError().xy();
256 IC(1,1) = (*ih)->localPositionError().yy();
260 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::setChi2] IC before = \n" << IC;
264 bool ok = IC.Invert();
266 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::setChi2] Failed to invert covariance matrix: \n" << IC;
269 chsq += du*du*IC(0,0) + 2.*du*dv*IC(0,1) + dv*dv*IC(1,1);
272 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::setChi2] IC after = \n" << IC;
273 edm::LogVerbatim(
"MuonSegFit") <<
"[GEM RecHit ] Contribution to Chi^2 of this hit :: du^2*Cov(0,0) + 2*du*dv*Cov(0,1) + dv^2*IC(1,1) = "<<du*du<<
"*"<<IC(0,0)<<
" + 2.*"<<du<<
"*"<<dv<<
"*"<<IC(0,1)<<
" + "<<dv*dv<<
"*"<<IC(1,1)<<
" = "<<chsq;
283 edm::LogVerbatim(
"MuonSegFit") <<
"-----------------------------------------------------";
292 edm::LogVerbatim(
"MuonSegFit") <<
"Now extrapolate to each of the GEMRecHits XY plane (so constant z = RH LP.z()) to obtain [x1,y1]";
304 for (MuonRecHitContainer::const_iterator it =
hits_.begin(); it !=
hits_.end(); ++it) {
307 matrix(row, row+1) = (*it)->localPositionError().xy();
309 matrix(row, row-1) = (*it)->localPositionError().xy();
310 matrix(row, row) = (*it)->localPositionError().yy();
314 ok = matrix.Invert();
316 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::weightMatrix] Failed to invert matrix: \n" <<
matrix;
328 for( MuonRecHitContainer::const_iterator it =
hits_.begin(); it !=
hits_.end(); ++it) {
350 double dz = 1./
sqrt(1. + dxdz*dxdz + dydz*dydz);
357 edm::LogVerbatim(
"MuonSegFit") <<
"[MuonSegFit::setOutFromIP] :: dxdz = uslope_ = "<<std::setw(9)<<
uslope_<<
" dydz = vslope_ = "<<std::setw(9)<<
vslope_<<
" local dir = "<<localDir;
369 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::covarianceMatrix] weights matrix W: \n" <<
weights;
370 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::covarianceMatrix] derivatives matrix A: \n" <<
A;
382 ok = result.Invert();
384 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::calculateError] Failed to invert matrix: \n" <<
result;
388 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::covarianceMatrix] (AT W A)^-1: \n" <<
result;
406 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::flipErrors] input: \n" <<
a;
411 for (
short j=0; j!=4; ++j) {
412 for (
short i=0;
i!=4; ++
i) {
413 hold(
i+1,j+1) =
a(
i,j);
418 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::flipErrors] after copy:";
419 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"(" << hold(1,1) <<
" " << hold(1,2) <<
" " << hold(1,3) <<
" " << hold(1,4);
420 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
" " << hold(2,1) <<
" " << hold(2,2) <<
" " << hold(2,3) <<
" " << hold(2,4);
421 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
" " << hold(3,1) <<
" " << hold(3,2) <<
" " << hold(3,3) <<
" " << hold(3,4);
422 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
" " << hold(4,1) <<
" " << hold(4,2) <<
" " << hold(4,3) <<
" " << hold(4,4) <<
")";
444 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"[MuonSegFit::flipErrors] after flip:";
445 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
"(" << hold(1,1) <<
" " << hold(1,2) <<
" " << hold(1,3) <<
" " << hold(1,4);
446 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
" " << hold(2,1) <<
" " << hold(2,2) <<
" " << hold(2,3) <<
" " << hold(2,4);
447 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
" " << hold(3,1) <<
" " << hold(3,2) <<
" " << hold(3,3) <<
" " << hold(3,4);
448 edm::LogVerbatim(
"MuonSegFitMatrixDetails") <<
" " << hold(4,1) <<
" " << hold(4,2) <<
" " << hold(4,3) <<
" " << hold(4,4) <<
")";
static const int MaxHits2
AlgebraicSymMatrix covarianceMatrix(void)
double scaleXError(void) const
Point3DBase< Scalar, LocalTag > LocalPoint
float ydev(float y, float z) const
float xfit(float z) const
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > SMatrixSym4
SMatrixSym12 weightMatrix(void)
SMatrix12by4 derivativeMatrix(void)
float Rdev(float x, float y, float z) const
Geom::Phi< T > phi() const
ROOT::Math::SMatrix< double, MaxHits2, MaxHits2, ROOT::Math::MatRepSym< double, MaxHits2 > > SMatrixSym12
float xdev(float x, float z) const
AlgebraicSymMatrix flipErrors(const SMatrixSym4 &)
float yfit(float z) const
MuonRecHitContainer hits_
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > SMatrixSym2
CLHEP::HepSymMatrix AlgebraicSymMatrix
ROOT::Math::SVector< double, 4 > SVector4
ROOT::Math::SMatrix< double, 4 > SMatrix4
ROOT::Math::SMatrix< double, MaxHits2, 4 > SMatrix12by4