File indexing completed on 2024-04-06 12:26:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "RecoLocalMuon/DTSegment/test/DTSegmentResidual.h"
0012
0013
0014 #include "DataFormats/DTRecHit/interface/DTRecSegment2D.h"
0015 #include "DataFormats/DTRecHit/interface/DTChamberRecSegment2D.h"
0016 #include "Geometry/DTGeometry/interface/DTChamber.h"
0017 #include "Geometry/DTGeometry/interface/DTSuperLayer.h"
0018 #include "Geometry/DTGeometry/interface/DTLayer.h"
0019
0020
0021 using namespace std;
0022 #include <cmath>
0023
0024
0025
0026
0027 DTSegmentResidual::DTResidual::DTResidual(double v, double wd, double a, DTEnums::DTCellSide s)
0028 : value(v), wireDistance(wd), angle(a), side(s) {}
0029
0030 DTSegmentResidual::DTSegmentResidual(const DTRecSegment2D* seg, const DTSuperLayer* sl)
0031 : theSeg(seg), theCh(0), theSL(sl) {}
0032
0033 DTSegmentResidual::DTSegmentResidual(const DTChamberRecSegment2D* seg, const DTChamber* ch)
0034 : theSeg(seg), theCh(ch), theSL(0) {}
0035
0036
0037 void DTSegmentResidual::run() {
0038 vector<DTRecHit1D> hits = theSeg->specificRecHits();
0039 for (vector<DTRecHit1D>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
0040
0041
0042 const DTLayer* lay = theSL ? theSL->layer((*hit).wireId().layer()) : theCh->layer((*hit).wireId().layerId());
0043 LocalPoint layPosInSL = theSL ? theSL->toLocal(lay->position()) : theCh->toLocal(lay->position());
0044
0045 LocalPoint posAtLay =
0046 theSeg->localPosition() + theSeg->localDirection() * (layPosInSL.z() / cos(theSeg->localDirection().theta()));
0047 posAtLay = lay->toLocal(theSL ? theSL->toGlobal(posAtLay) : theCh->toGlobal(posAtLay));
0048
0049 double deltaX = (*hit).localPosition().x() - posAtLay.x();
0050 double angle = M_PI - theSeg->localDirection().theta();
0051 double wireDistance = (*hit).localPosition().x() - lay->specificTopology().wirePosition((*hit).wireId().wire());
0052 DTEnums::DTCellSide side = (*hit).lrSide();
0053
0054 theResiduals.push_back(DTResidual(deltaX, wireDistance, angle, side));
0055 }
0056 }