Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:48

0001 /** \class MuonChamberResidual
0002  *  $Id: $
0003  *  \author V. Khotilovich - Texas A&M University <khotilov@cern.ch>
0004  */
0005 
0006 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonChamberResidual.h"
0007 
0008 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0009 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
0010 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
0011 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0012 
0013 MuonChamberResidual::MuonChamberResidual(edm::ESHandle<GlobalTrackingGeometry> globalGeometry,
0014                                          AlignableNavigator *navigator,
0015                                          DetId chamberId,
0016                                          AlignableDetOrUnitPtr chamberAlignable)
0017     : m_globalGeometry(globalGeometry),
0018       m_navigator(navigator),
0019       m_chamberId(chamberId),
0020       m_chamberAlignable(chamberAlignable),
0021       m_numHits(0),
0022       m_type(-1),
0023       m_sign(0.),
0024       m_chi2(-999.),
0025       m_ndof(-1),
0026       m_residual(-999.),
0027       m_residual_error(-999.),
0028       m_resslope(-999.),
0029       m_resslope_error(-999.),
0030       m_trackdxdz(-999.),
0031       m_trackdydz(-999.),
0032       m_trackx(-999.),
0033       m_tracky(-999.),
0034       m_segdxdz(-999.),
0035       m_segdydz(-999.),
0036       m_segx(-999.),
0037       m_segy(-999.),
0038       m_ChambW(-999),
0039       m_Chambl(-999) {}
0040 
0041 align::GlobalPoint MuonChamberResidual::global_trackpos() {
0042   return chamberAlignable()->surface().toGlobal(align::LocalPoint(trackx(), tracky(), 0.));
0043 }
0044 
0045 align::GlobalPoint MuonChamberResidual::global_stubpos() {
0046   return chamberAlignable()->surface().toGlobal(align::LocalPoint(segx(), segy(), 0.));
0047 }
0048 
0049 double MuonChamberResidual::global_residual() const { return residual() * signConvention(); }
0050 
0051 double MuonChamberResidual::global_resslope() const { return resslope() * signConvention(); }
0052 
0053 double MuonChamberResidual::global_hitresid(int i) const { return hitresid(i) * signConvention(); }
0054 
0055 double MuonChamberResidual::hitresid(int i) const {
0056   assert(0 <= i && i < int(m_localIDs.size()));
0057   return m_localResids[i];
0058 }
0059 
0060 int MuonChamberResidual::hitlayer(int i) const {  // only difference between DTs and CSCs is the DetId subclass
0061   assert(0 <= i && i < int(m_localIDs.size()));
0062   if (m_chamberId.subdetId() == MuonSubdetId::DT) {
0063     DTLayerId layerId(m_localIDs[i].rawId());
0064     return 4 * (layerId.superlayer() - 1) + layerId.layer();
0065   } else if (m_chamberId.subdetId() == MuonSubdetId::CSC) {
0066     CSCDetId layerId(m_localIDs[i].rawId());
0067     return layerId.layer();
0068   } else
0069     assert(false);
0070 }
0071 
0072 double MuonChamberResidual::hitposition(int i) const {
0073   assert(0 <= i && i < int(m_localIDs.size()));
0074   if (m_chamberId.subdetId() == MuonSubdetId::DT) {
0075     align::GlobalPoint pos = m_globalGeometry->idToDet(m_localIDs[i])->position();
0076     return sqrt(pow(pos.x(), 2) + pow(pos.y(), 2));  // R for DTs
0077   } else if (m_chamberId.subdetId() == MuonSubdetId::CSC) {
0078     return m_globalGeometry->idToDet(m_localIDs[i])->position().z();  // Z for CSCs
0079   } else
0080     assert(false);
0081 }