CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Alignment/MuonAlignmentAlgorithms/src/MuonCSCChamberResidual.cc

Go to the documentation of this file.
00001 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonCSCChamberResidual.h"
00002 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00003 
00004 void MuonCSCChamberResidual::addResidual(const TrajectoryStateOnSurface *tsos, const TransientTrackingRecHit *hit) {
00005   DetId id = hit->geographicalId();
00006   const CSCGeometry *cscGeometry = dynamic_cast<const CSCGeometry*>(m_globalGeometry->slaveGeometry(id));
00007   assert(cscGeometry);
00008 
00009   LocalPoint hitChamberPos = m_chamberAlignable->surface().toLocal(m_globalGeometry->idToDet(id)->toGlobal(hit->localPosition()));
00010   LocalPoint tsosChamberPos = m_chamberAlignable->surface().toLocal(m_globalGeometry->idToDet(id)->toGlobal(tsos->localPosition()));
00011 
00012   int strip = cscGeometry->layer(id)->geometry()->nearestStrip(hit->localPosition());
00013   double angle = cscGeometry->layer(id)->geometry()->stripAngle(strip) - M_PI/2.;
00014   double sinAngle = sin(angle);
00015   double cosAngle = cos(angle);
00016 
00017   double residual = cosAngle * (tsosChamberPos.x() - hitChamberPos.x()) + sinAngle * (tsosChamberPos.y() - hitChamberPos.y());  // yes, that's +sin()
00018 
00019   double xx = hit->localPositionError().xx();
00020   double xy = hit->localPositionError().xy();
00021   double yy = hit->localPositionError().yy();
00022   double weight = 1. / (xx*cosAngle*cosAngle + 2.*xy*sinAngle*cosAngle + yy*sinAngle*sinAngle);
00023 
00024   double layerPosition = tsosChamberPos.z();  // the layer's position in the chamber's coordinate system
00025 
00026   m_numHits++;
00027 
00028   // "x" is the layerPosition, "y" is the residual (this is a linear fit to residual versus layerPosition)
00029   m_residual_1 += weight;
00030   m_residual_x += weight * layerPosition;
00031   m_residual_y += weight * residual;
00032   m_residual_xx += weight * layerPosition * layerPosition;
00033   m_residual_xy += weight * layerPosition * residual;
00034 
00035   // "x" is the layerPosition, "y" is chamberx (this is a linear fit to chamberx versus layerPosition)
00036   m_trackx_1 += weight;
00037   m_trackx_x += weight * layerPosition;
00038   m_trackx_y += weight * tsosChamberPos.x();
00039   m_trackx_xx += weight * layerPosition * layerPosition;
00040   m_trackx_xy += weight * layerPosition * tsosChamberPos.x();
00041 
00042   // "x" is the layerPosition, "y" is chambery (this is a linear fit to chambery versus layerPosition)
00043   m_tracky_1 += weight;
00044   m_tracky_x += weight * layerPosition;
00045   m_tracky_y += weight * tsosChamberPos.y();
00046   m_tracky_xx += weight * layerPosition * layerPosition;
00047   m_tracky_xy += weight * layerPosition * tsosChamberPos.y();
00048 
00049   m_localIDs.push_back(id);
00050   m_localResids.push_back(residual);
00051   m_individual_x.push_back(layerPosition);
00052   m_individual_y.push_back(residual);
00053   m_individual_weight.push_back(weight);
00054 }