Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:42:23

0001 
0002 /*
0003  *  See header file for a description of this class.
0004  *
0005  */
0006 
0007 #include "CalibMuon/DTCalibration/interface/DTRecHitSegmentResidual.h"
0008 
0009 //Geometry
0010 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0011 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0012 
0013 //RecHit
0014 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0015 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
0016 
0017 float DTRecHitSegmentResidual::compute(const DTGeometry* dtGeom,
0018                                        const DTRecHit1D& recHit1D,
0019                                        const DTRecSegment4D& segment) {
0020   const DTWireId wireId = recHit1D.wireId();
0021 
0022   // Get the layer and the wire position
0023   const DTLayer* layer = dtGeom->layer(wireId);
0024   float wireX = layer->specificTopology().wirePosition(wireId.wire());
0025 
0026   // Extrapolate the segment to the z of the wire
0027   // Get wire position in chamber RF
0028   // (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)
0029   LocalPoint wirePosInLay(wireX, recHit1D.localPosition().y(), recHit1D.localPosition().z());
0030   GlobalPoint wirePosGlob = layer->toGlobal(wirePosInLay);
0031   const DTChamber* chamber = dtGeom->chamber(wireId.layerId().chamberId());
0032   LocalPoint wirePosInChamber = chamber->toLocal(wirePosGlob);
0033 
0034   // Segment position at Wire z in chamber local frame
0035   LocalPoint segPosAtZWire =
0036       segment.localPosition() + segment.localDirection() * wirePosInChamber.z() / cos(segment.localDirection().theta());
0037 
0038   // Compute the distance of the segment from the wire
0039   int sl = wireId.superlayer();
0040   float segmDistance = -1;
0041   if (sl == 1 || sl == 3)
0042     segmDistance = fabs(wirePosInChamber.x() - segPosAtZWire.x());
0043   else if (sl == 2)
0044     segmDistance = fabs(segPosAtZWire.y() - wirePosInChamber.y());
0045 
0046   // Compute the distance of the recHit from the wire
0047   float recHitWireDist = fabs(recHit1D.localPosition().x() - wireX);
0048 
0049   // Compute the residuals
0050   float residualOnDistance = recHitWireDist - segmDistance;
0051 
0052   return residualOnDistance;
0053 }