// transform the Local position in Layer-rf in a SL local position0029 theLeftPos = sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Left)->localPosition())); 0030 theRightPos = sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Right)->localPosition())); 0031 0032 // TODO how do I transform an error from local to global? 0033 theError = pair.componentRecHit(DTEnums::Left)->localPositionError(); 0034 // theError = 0035 // layer->surface().toLocal(sl.surface().toGlobal(pair.componentRecHit(DTEnums::Left)->localPositionError())); 0036 } 0037 0038 /// Destructor 0039 DTHitPairForFit::~DTHitPairForFit() {} 0040 0041 /* Operations */ 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 // if both below 3 sigma, return both 0061 // if both at 10 sigma or above, return none 0062 // if one is below N sigma and one above, for 10>=N>=3, match only that one, otherwise none 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 //SL if same layer use x() for strict ordering 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 }