CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/Alignment/MuonAlignmentAlgorithms/src/MuonTrackCSCChamberResidual.cc

Go to the documentation of this file.
00001 /* 
00002  * $Id: MuonTrackCSCChamberResidual.cc,v 1.2 2011/11/02 07:38:30 mussgill Exp $
00003  */
00004 
00005 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonTrackCSCChamberResidual.h"
00006 //#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00007 
00008 
00009 MuonTrackCSCChamberResidual::MuonTrackCSCChamberResidual(edm::ESHandle<GlobalTrackingGeometry> globalGeometry, AlignableNavigator *navigator,
00010                                                          DetId chamberId, AlignableDetOrUnitPtr chamberAlignable)
00011   : MuonChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable)
00012 {
00013   m_type = MuonChamberResidual::kCSC;
00014   align::GlobalVector zDirection(0., 0., 1.);
00015   m_sign = m_globalGeometry->idToDet(m_chamberId)->toLocal(zDirection).z() > 0. ? 1. : -1.;
00016 }
00017 
00018 
00019 void MuonTrackCSCChamberResidual::setSegmentResidual(const reco::MuonChamberMatch *trk, const reco::MuonSegmentMatch *seg)
00020 {
00021   CSCDetId id(trk->id.rawId());
00022   CSCDetId chamber(id.chamberId());
00023   
00024   CSCSegmentRef segmentCSC = seg->cscSegmentRef;
00025   if (segmentCSC.get() != 0)
00026   {
00027     const CSCSegment* segment = segmentCSC.get();
00028     m_numHits = segment->nRecHits();
00029     m_ndof = segment->degreesOfFreedom();
00030     m_chi2 = segment->chi2();
00031     //std::cout<<"csc seg position = "<<segment->localPosition()<<"  numhits="<<m_numHits<<"  id: "<<id<<std::endl;
00032   }
00033 
00034   align::LocalPoint l_seg(seg->x, seg->y, 0.);
00035   align::LocalPoint l_trk(trk->x, trk->y, 0.);
00036 
00037   /*
00038   double dphi = g_trk.phi() - g_seg.phi();
00039   while (dphi >  M_PI) dphi -= 2.*M_PI;
00040   while (dphi < -M_PI) dphi += 2.*M_PI;
00041   m_residual = - m_sign * g_trk.perp() * dphi; // coming from global, need to adjust the sign
00042   std::cout<<"cscres="<<m_residual<<"  dx="<<trk->x-seg->x<<"  diff="<<trk->x-seg->x - m_residual<<std::endl;
00043   */
00044   m_residual = trk->x-seg->x;
00045   m_residual_error = sqrt( pow(trk->xErr, 2) + pow(seg->xErr, 2) );
00046   m_resslope = trk->dXdZ - seg->dXdZ;
00047   m_resslope_error = sqrt( pow(trk->dXdZErr, 2) + pow(seg->dXdZErr, 2) );
00048   
00049   m_trackx = trk->x;
00050   m_tracky = trk->y;
00051   m_trackdxdz = trk->dXdZ;
00052   m_trackdydz = trk->dYdZ;
00053 
00054   m_segx = seg->x;
00055   m_segy = seg->y;
00056   m_segdxdz = seg->dXdZ;
00057   m_segdydz = seg->dYdZ;
00058 
00059   //double yresidual_error = sqrt( pow(trk->yErr, 2) + pow(seg->yErr, 2) );
00060   //double yresslope_error = sqrt( pow(trk->dYdZErr, 2) + pow(seg->dYdZErr, 2) );
00061   //std::cout<<"csc res "<<m_residual<<"+-"<<m_residual_error<<"  "<<m_resslope<<"+-"<<m_resslope_error<<"  "<<trk->y-seg->y<<"+-"<<yresidual_error<<"  "<<trk->dYdZ - seg->dYdZ<<"+-"<<yresslope_error<<std::endl;
00062   //std::cout<<"csc trk "<<m_trackx<<" "<<m_tracky<<" "<<m_trackdxdz<<" "<<m_trackdydz<<std::endl;
00063   //std::cout<<"csc seg "<<m_segx<<" "<<m_segy<<" "<<m_segdxdz<<" "<<m_segdydz<<std::endl;
00064 }