CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Alignment/MuonAlignmentAlgorithms/src/MuonDT13ChamberResidual.cc

Go to the documentation of this file.
00001 /*
00002  * $Id: MuonDT13ChamberResidual.cc,v 1.3 2011/10/12 23:40:24 khotilov Exp $
00003  */
00004 
00005 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonDT13ChamberResidual.h"
00006 
00007 
00008 MuonDT13ChamberResidual::MuonDT13ChamberResidual(edm::ESHandle<GlobalTrackingGeometry> globalGeometry, AlignableNavigator *navigator,
00009                                                  DetId chamberId, AlignableDetOrUnitPtr chamberAlignable)
00010   : MuonHitsChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable)
00011 {
00012   m_type = MuonChamberResidual::kDT13;
00013   double rphiAngle = atan2(m_globalGeometry->idToDet(m_chamberId)->position().y(), m_globalGeometry->idToDet(m_chamberId)->position().x()) + M_PI/2.;
00014   align::GlobalVector rphiDirection(cos(rphiAngle), sin(rphiAngle), 0.);
00015   m_sign = m_globalGeometry->idToDet(m_chamberId)->toLocal(rphiDirection).x() > 0. ? 1. : -1.;
00016 }
00017 
00018 
00019 void MuonDT13ChamberResidual::addResidual(const TrajectoryStateOnSurface *tsos, const TransientTrackingRecHit *hit)
00020 {
00021   DetId id = hit->geographicalId();
00022 
00023   align::LocalPoint hitChamberPos  = m_chamberAlignable->surface().toLocal(m_globalGeometry->idToDet(id)->toGlobal(hit->localPosition()));
00024   align::LocalPoint tsosChamberPos = m_chamberAlignable->surface().toLocal(m_globalGeometry->idToDet(id)->toGlobal(tsos->localPosition()));
00025 
00026   double residual = tsosChamberPos.x() - hitChamberPos.x();  // residual is hit minus hit
00027   double weight = 1. / hit->localPositionError().xx();  // weight linear fit by hit-only local error
00028   double layerPosition = tsosChamberPos.z();  // the layer's position in the chamber's coordinate system
00029   double layerHitPos = hitChamberPos.z();
00030 
00031   m_numHits++;
00032 
00033   // "x" is the layerPosition, "y" is the residual (this is a linear fit to residual versus layerPosition)
00034   m_residual_1 += weight;
00035   m_residual_x += weight * layerPosition;
00036   m_residual_y += weight * residual;
00037   m_residual_xx += weight * layerPosition * layerPosition;
00038   m_residual_xy += weight * layerPosition * residual;
00039 
00040   // "x" is the layerPosition, "y" is chamberx (this is a linear fit to chamberx versus layerPosition)
00041   m_trackx_1 += weight;
00042   m_trackx_x += weight * layerPosition;
00043   m_trackx_y += weight * tsosChamberPos.x();
00044   m_trackx_xx += weight * layerPosition * layerPosition;
00045   m_trackx_xy += weight * layerPosition * tsosChamberPos.x();
00046   
00047   // "x" is the layerPosition, "y" is chambery (this is a linear fit to chambery versus layerPosition)
00048   m_tracky_1 += weight;
00049   m_tracky_x += weight * layerPosition;
00050   m_tracky_y += weight * tsosChamberPos.y();
00051   m_tracky_xx += weight * layerPosition * layerPosition;
00052   m_tracky_xy += weight * layerPosition * tsosChamberPos.y();
00053 
00054   m_hitx_1 += weight;
00055   m_hitx_x += weight * layerHitPos;
00056   m_hitx_y += weight * hitChamberPos.x();
00057   m_hitx_xx += weight * layerHitPos * layerHitPos;
00058   m_hitx_xy += weight * layerHitPos * hitChamberPos.x();
00059   
00060   m_hity_1 += weight;
00061   m_hity_x += weight * layerHitPos;
00062   m_hity_y += weight * hitChamberPos.y();
00063   m_hity_xx += weight * layerHitPos * layerPosition;
00064   m_hity_xy += weight * layerHitPos * hitChamberPos.y();
00065 
00066   m_localIDs.push_back(id);
00067   m_localResids.push_back(tsos->localPosition().x() - hit->localPosition().x());
00068   m_individual_x.push_back(layerPosition);
00069   m_individual_y.push_back(residual);
00070   m_individual_weight.push_back(weight);
00071 
00072   if (m_numHits>1) segment_fit();
00073 }