File indexing completed on 2024-04-06 12:26:08
0001
0002
0003
0004
0005
0006
0007
0008 #include "RecoLocalMuon/DTSegment/src/DTHitPairForFit.h"
0009
0010
0011 #include "FWCore/Utilities/interface/Exception.h"
0012
0013
0014 #include <iostream>
0015 using namespace std;
0016
0017
0018
0019
0020 DTHitPairForFit::DTHitPairForFit(const DTRecHit1DPair& pair,
0021 const DTSuperLayer& sl,
0022 const edm::ESHandle<DTGeometry>& dtGeom) {
0023 theWireId = pair.wireId();
0024 theDigiTime = pair.digiTime();
0025
0026 const DTLayer* layer = dtGeom->layer(theWireId.layerId());
0027
0028
0029 theLeftPos = sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Left)->localPosition()));
0030 theRightPos = sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Right)->localPosition()));
0031
0032
0033 theError = pair.componentRecHit(DTEnums::Left)->localPositionError();
0034
0035
0036 }
0037
0038
0039 DTHitPairForFit::~DTHitPairForFit() {}
0040
0041
0042 LocalPoint DTHitPairForFit::localPosition(DTEnums::DTCellSide s) const {
0043 if (s == DTEnums::Left)
0044 return theLeftPos;
0045 else if (s == DTEnums::Right)
0046 return theRightPos;
0047 else {
0048 throw cms::Exception("DTHitPairForFit") << " localPosition called with undef LR code" << endl;
0049 return LocalPoint();
0050 }
0051 }
0052
0053 pair<bool, bool> DTHitPairForFit::isCompatible(const LocalPoint& posIni, const LocalVector& dirIni) const {
0054 pair<bool, bool> ret;
0055 LocalPoint segPosAtZLeft = posIni + dirIni * (theLeftPos.z() - posIni.z()) / dirIni.z();
0056 LocalPoint segPosAtZRight = posIni + dirIni * (theRightPos.z() - posIni.z()) / dirIni.z();
0057 float dxLeft = fabs(theLeftPos.x() - segPosAtZLeft.x());
0058 float dxRight = fabs(theRightPos.x() - segPosAtZRight.x());
0059 float exx = sqrt(theError.xx());
0060
0061
0062
0063 if (std::max(dxLeft, dxRight) < 3 * exx) {
0064 ret = make_pair(true, true);
0065 } else if (std::min(dxLeft, dxRight) >= 10 * exx) {
0066 ret = make_pair(false, false);
0067 } else {
0068 float sigmasL = floorf(dxLeft / exx), sigmasR = floorf(dxRight / exx);
0069 ret.first = (sigmasL < sigmasR);
0070 ret.second = (sigmasR < sigmasL);
0071 }
0072 return ret;
0073 }
0074
0075 bool DTHitPairForFit::operator<(const DTHitPairForFit& hit) const {
0076
0077 if (id() == hit.id())
0078 return (theLeftPos.x() < hit.localPosition(DTEnums::Left).x());
0079 return (id() < hit.id());
0080 }
0081
0082 bool DTHitPairForFit::operator==(const DTHitPairForFit& hit) const {
0083 return (id() == hit.id() && fabs(digiTime() - hit.digiTime()) < 0.1);
0084 }
0085
0086 ostream& operator<<(ostream& out, const DTHitPairForFit& hit) {
0087 out << hit.leftPos() << " " << hit.rightPos();
0088 return out;
0089 }