CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CalibMuon/DTCalibration/src/DTRecHitSegmentResidual.cc

Go to the documentation of this file.
00001 
00002 /*
00003  *  See header file for a description of this class.
00004  *
00005  *  $Date: 2011/02/22 18:43:20 $
00006  *  $Revision: 1.1 $
00007  */
00008 
00009 #include "CalibMuon/DTCalibration/interface/DTRecHitSegmentResidual.h"
00010 
00011 //Geometry
00012 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00013 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00014 
00015 //RecHit
00016 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
00017 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
00018 
00019 float DTRecHitSegmentResidual::compute(const DTGeometry* dtGeom, const DTRecHit1D& recHit1D, const DTRecSegment4D& segment) {
00020 
00021   const DTWireId wireId = recHit1D.wireId();
00022       
00023   // Get the layer and the wire position
00024   const DTLayer* layer = dtGeom->layer(wireId);
00025   float wireX = layer->specificTopology().wirePosition(wireId.wire());
00026       
00027   // Extrapolate the segment to the z of the wire
00028   // Get wire position in chamber RF
00029   // (y and z must be those of the hit to be coherent in the transf. of RF in case of rotations of the layer alignment)
00030   LocalPoint wirePosInLay(wireX,recHit1D.localPosition().y(),recHit1D.localPosition().z());
00031   GlobalPoint wirePosGlob = layer->toGlobal(wirePosInLay);
00032   const DTChamber* chamber = dtGeom->chamber(wireId.layerId().chamberId());
00033   LocalPoint wirePosInChamber = chamber->toLocal(wirePosGlob);
00034       
00035   // Segment position at Wire z in chamber local frame
00036   LocalPoint segPosAtZWire = segment.localPosition() + segment.localDirection()*wirePosInChamber.z()/cos(segment.localDirection().theta());
00037       
00038   // Compute the distance of the segment from the wire
00039   int sl = wireId.superlayer();
00040   float segmDistance = -1;
00041   if(sl == 1 || sl == 3) segmDistance = fabs(wirePosInChamber.x() - segPosAtZWire.x());
00042   else if(sl == 2) segmDistance =  fabs(segPosAtZWire.y() - wirePosInChamber.y());
00043 
00044   // Compute the distance of the recHit from the wire
00045   float recHitWireDist = fabs( recHit1D.localPosition().x() - wireX );
00046  
00047   // Compute the residuals 
00048   float residualOnDistance = recHitWireDist - segmDistance;
00049 
00050   return residualOnDistance; 
00051 }