CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/Alignment/MuonAlignmentAlgorithms/src/MuonChamberResidual.cc

Go to the documentation of this file.
00001 
00006 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonChamberResidual.h"
00007 
00008 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00009 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
00010 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00011 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00012 
00013 
00014 MuonChamberResidual::MuonChamberResidual(edm::ESHandle<GlobalTrackingGeometry> globalGeometry,
00015                                          AlignableNavigator *navigator, 
00016                                          DetId chamberId,
00017                                          AlignableDetOrUnitPtr chamberAlignable):
00018     m_globalGeometry(globalGeometry)
00019   , m_navigator(navigator)
00020   , m_chamberId(chamberId)
00021   , m_chamberAlignable(chamberAlignable)
00022   , m_numHits(0)
00023   , m_type(-1)
00024   , m_sign(0.)
00025   , m_chi2(-999.)
00026   , m_ndof(-1)
00027   , m_residual(-999.)
00028   , m_residual_error(-999.)
00029   , m_resslope(-999.)
00030   , m_resslope_error(-999.)
00031   , m_trackdxdz(-999.)
00032   , m_trackdydz(-999.)
00033   , m_trackx(-999.)
00034   , m_tracky(-999.)
00035   , m_segdxdz(-999.)
00036   , m_segdydz(-999.)
00037   , m_segx(-999.)
00038   , m_segy(-999.)
00039 {}
00040 
00041 
00042 align::GlobalPoint MuonChamberResidual::global_trackpos()
00043 {
00044   return chamberAlignable()->surface().toGlobal(align::LocalPoint(trackx(), tracky(), 0.));
00045 }
00046 
00047 
00048 align::GlobalPoint MuonChamberResidual::global_stubpos()
00049 {
00050   return chamberAlignable()->surface().toGlobal(align::LocalPoint(segx(), segy(), 0.));
00051 }
00052 
00053 
00054 double MuonChamberResidual::global_residual() const 
00055 {
00056   return residual() * signConvention();
00057 }
00058 
00059 
00060 double MuonChamberResidual::global_resslope() const
00061 {
00062   return resslope() * signConvention();
00063 }
00064 
00065 
00066 double MuonChamberResidual::global_hitresid(int i) const
00067 {
00068   return hitresid(i) * signConvention();
00069 }
00070 
00071 
00072 double MuonChamberResidual::hitresid(int i) const
00073 {
00074   assert(0 <= i  &&  i < int(m_localIDs.size()));
00075   return m_localResids[i];
00076 }
00077 
00078 
00079 int MuonChamberResidual::hitlayer(int i) const 
00080 {  // only difference between DTs and CSCs is the DetId subclass
00081   assert(0 <= i  &&  i < int(m_localIDs.size()));
00082   if (m_chamberId.subdetId() == MuonSubdetId::DT) {
00083     DTLayerId layerId(m_localIDs[i].rawId());
00084     return 4*(layerId.superlayer() - 1) + layerId.layer();
00085   }
00086   else if (m_chamberId.subdetId() == MuonSubdetId::CSC) {
00087     CSCDetId layerId(m_localIDs[i].rawId());
00088     return layerId.layer();
00089   }
00090   else assert(false);
00091 }
00092 
00093 
00094 double MuonChamberResidual::hitposition(int i) const
00095 {
00096   assert(0 <= i  &&  i < int(m_localIDs.size()));
00097   if (m_chamberId.subdetId() == MuonSubdetId::DT) {
00098     align::GlobalPoint pos = m_globalGeometry->idToDet(m_localIDs[i])->position();
00099     return sqrt(pow(pos.x(), 2) + pow(pos.y(), 2));                   // R for DTs
00100   }
00101   else if (m_chamberId.subdetId() == MuonSubdetId::CSC) {
00102     return m_globalGeometry->idToDet(m_localIDs[i])->position().z();  // Z for CSCs
00103   }
00104   else assert(false);
00105 }