CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 /* 
00002  * $Id: MuonTrackCSCChamberResidual.cc,v 1.4 2013/01/02 15:07:22 eulisse 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   
00023   CSCSegmentRef segmentCSC = seg->cscSegmentRef;
00024   if (segmentCSC.get() != 0)
00025   {
00026     const CSCSegment* segment = segmentCSC.get();
00027     m_numHits = segment->nRecHits();
00028     m_ndof = segment->degreesOfFreedom();
00029     m_chi2 = segment->chi2();
00030     //std::cout<<"csc seg position = "<<segment->localPosition()<<"  numhits="<<m_numHits<<"  id: "<<id<<std::endl;
00031   }
00032 
00033   align::LocalPoint l_seg(seg->x, seg->y, 0.);
00034   align::LocalPoint l_trk(trk->x, trk->y, 0.);
00035   //align::GlobalPoint g_seg = m_globalGeometry->idToDet(chamber)->toGlobal(l_seg);
00036   //align::GlobalPoint g_trk = m_globalGeometry->idToDet(chamber)->toGlobal(l_trk);
00037 
00038   /*
00039   double dphi = g_trk.phi() - g_seg.phi();
00040   while (dphi >  M_PI) dphi -= 2.*M_PI;
00041   while (dphi < -M_PI) dphi += 2.*M_PI;
00042   m_residual = - m_sign * g_trk.perp() * dphi; // coming from global, need to adjust the sign
00043   std::cout<<"cscres="<<m_residual<<"  dx="<<trk->x-seg->x<<"  diff="<<trk->x-seg->x - m_residual<<std::endl;
00044   */
00045   m_residual = trk->x-seg->x;
00046   m_residual_error = sqrt( pow(trk->xErr, 2) + pow(seg->xErr, 2) );
00047   m_resslope = trk->dXdZ - seg->dXdZ;
00048   m_resslope_error = sqrt( pow(trk->dXdZErr, 2) + pow(seg->dXdZErr, 2) );
00049   
00050   m_trackx = trk->x;
00051   m_tracky = trk->y;
00052   m_trackdxdz = trk->dXdZ;
00053   m_trackdydz = trk->dYdZ;
00054 
00055   m_segx = seg->x;
00056   m_segy = seg->y;
00057   m_segdxdz = seg->dXdZ;
00058   m_segdydz = seg->dYdZ;
00059 
00060   //double yresidual_error = sqrt( pow(trk->yErr, 2) + pow(seg->yErr, 2) );
00061   //double yresslope_error = sqrt( pow(trk->dYdZErr, 2) + pow(seg->dYdZErr, 2) );
00062   //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;
00063   //std::cout<<"csc trk "<<m_trackx<<" "<<m_tracky<<" "<<m_trackdxdz<<" "<<m_trackdydz<<std::endl;
00064   //std::cout<<"csc seg "<<m_segx<<" "<<m_segy<<" "<<m_segdxdz<<" "<<m_segdydz<<std::endl;
00065 }