CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Alignment/MuonAlignmentAlgorithms/src/MuonTrackDT13ChamberResidual.cc

Go to the documentation of this file.
00001 /*
00002  * $Id: MuonTrackDT13ChamberResidual.cc,v 1.1 2011/10/12 23:32:08 khotilov Exp $
00003  */
00004 
00005 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonTrackDT13ChamberResidual.h"
00006 
00007 
00008 MuonTrackDT13ChamberResidual::MuonTrackDT13ChamberResidual(edm::ESHandle<GlobalTrackingGeometry> globalGeometry, AlignableNavigator *navigator,
00009                                                            DetId chamberId, AlignableDetOrUnitPtr chamberAlignable)
00010   : MuonChamberResidual(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 MuonTrackDT13ChamberResidual::setSegmentResidual(const reco::MuonChamberMatch *trk, const reco::MuonSegmentMatch *seg)
00020 {
00021   DTRecSegment4DRef segmentDT = seg->dtSegmentRef;
00022   if (segmentDT.get() != 0)
00023   {
00024     const DTRecSegment4D* segment = segmentDT.get();
00025     assert(segment->hasPhi());
00026     const DTChamberRecSegment2D* phiSeg = segment->phiSegment();
00027     m_numHits = phiSeg->recHits().size();
00028     m_ndof = phiSeg->degreesOfFreedom();
00029     m_chi2 = phiSeg->chi2();
00030     //std::cout<<"phi seg position = "<<phiSeg->localPosition()<<"  numhits="<<m_numHits<<std::endl;
00031   }
00032 
00033   m_residual = trk->x - seg->x;
00034   m_residual_error = sqrt( pow(trk->xErr, 2) + pow(seg->xErr, 2) );
00035   m_resslope = trk->dXdZ - seg->dXdZ;
00036   m_resslope_error = sqrt( pow(trk->dXdZErr, 2) + pow(seg->dXdZErr, 2) );
00037   
00038   m_trackx = trk->x;
00039   m_tracky = trk->y;
00040   m_trackdxdz = trk->dXdZ;
00041   m_trackdydz = trk->dYdZ;
00042 
00043   m_segx = seg->x;
00044   m_segy = seg->y;
00045   m_segdxdz = seg->dXdZ;
00046   m_segdydz = seg->dYdZ;
00047   
00048   //std::cout<<"d13 res "<<m_residual<<"+-"<<m_residual_error<<"  "<<m_resslope<<"+-"<<m_resslope_error<<std::endl;
00049   //std::cout<<"d13 trk "<<m_trackx<<" "<<m_tracky<<" "<<m_trackdxdz<<" "<<m_trackdydz<<std::endl;
00050   //std::cout<<"d13 seg "<<m_segx<<" "<<m_segy<<" "<<m_segdxdz<<" "<<m_segdydz<<std::endl;
00051 }