Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:36

0001 /* 
0002  * $Id: MuonTrackCSCChamberResidual.cc,v 1.3 2011/11/02 19:58:38 khotilov Exp $
0003  */
0004 
0005 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonTrackCSCChamberResidual.h"
0006 //#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0007 
0008 MuonTrackCSCChamberResidual::MuonTrackCSCChamberResidual(edm::ESHandle<GlobalTrackingGeometry> globalGeometry,
0009                                                          AlignableNavigator *navigator,
0010                                                          DetId chamberId,
0011                                                          AlignableDetOrUnitPtr chamberAlignable)
0012     : MuonChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable) {
0013   m_type = MuonChamberResidual::kCSC;
0014   align::GlobalVector zDirection(0., 0., 1.);
0015   m_sign = m_globalGeometry->idToDet(m_chamberId)->toLocal(zDirection).z() > 0. ? 1. : -1.;
0016 }
0017 
0018 void MuonTrackCSCChamberResidual::setSegmentResidual(const reco::MuonChamberMatch *trk,
0019                                                      const reco::MuonSegmentMatch *seg) {
0020   CSCDetId id(trk->id.rawId());
0021 
0022   CSCSegmentRef segmentCSC = seg->cscSegmentRef;
0023   if (segmentCSC.get() != nullptr) {
0024     const CSCSegment *segment = segmentCSC.get();
0025     m_numHits = segment->nRecHits();
0026     m_ndof = segment->degreesOfFreedom();
0027     m_chi2 = segment->chi2();
0028     //std::cout<<"csc seg position = "<<segment->localPosition()<<"  numhits="<<m_numHits<<"  id: "<<id<<std::endl;
0029   }
0030 
0031   align::LocalPoint l_seg(seg->x, seg->y, 0.);
0032   align::LocalPoint l_trk(trk->x, trk->y, 0.);
0033   //align::GlobalPoint g_seg = m_globalGeometry->idToDet(chamber)->toGlobal(l_seg);
0034   //align::GlobalPoint g_trk = m_globalGeometry->idToDet(chamber)->toGlobal(l_trk);
0035 
0036   /*
0037   double dphi = g_trk.phi() - g_seg.phi();
0038   while (dphi >  M_PI) dphi -= 2.*M_PI;
0039   while (dphi < -M_PI) dphi += 2.*M_PI;
0040   m_residual = - m_sign * g_trk.perp() * dphi; // coming from global, need to adjust the sign
0041   std::cout<<"cscres="<<m_residual<<"  dx="<<trk->x-seg->x<<"  diff="<<trk->x-seg->x - m_residual<<std::endl;
0042   */
0043   m_residual = trk->x - seg->x;
0044   m_residual_error = sqrt(pow(trk->xErr, 2) + pow(seg->xErr, 2));
0045   m_resslope = trk->dXdZ - seg->dXdZ;
0046   m_resslope_error = sqrt(pow(trk->dXdZErr, 2) + pow(seg->dXdZErr, 2));
0047 
0048   m_trackx = trk->x;
0049   m_tracky = trk->y;
0050   m_trackdxdz = trk->dXdZ;
0051   m_trackdydz = trk->dYdZ;
0052 
0053   m_segx = seg->x;
0054   m_segy = seg->y;
0055   m_segdxdz = seg->dXdZ;
0056   m_segdydz = seg->dYdZ;
0057 
0058   //double yresidual_error = sqrt( pow(trk->yErr, 2) + pow(seg->yErr, 2) );
0059   //double yresslope_error = sqrt( pow(trk->dYdZErr, 2) + pow(seg->dYdZErr, 2) );
0060   //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;
0061   //std::cout<<"csc trk "<<m_trackx<<" "<<m_tracky<<" "<<m_trackdxdz<<" "<<m_trackdydz<<std::endl;
0062   //std::cout<<"csc seg "<<m_segx<<" "<<m_segy<<" "<<m_segdxdz<<" "<<m_segdydz<<std::endl;
0063 }