Go to the documentation of this file.00001
00009
00010 #include "RecoLocalMuon/DTSegment/src/DTHitPairForFit.h"
00011
00012
00013 #include "FWCore/Utilities/interface/Exception.h"
00014
00015
00016 #include <iostream>
00017 using namespace std;
00018
00019
00020
00022 DTHitPairForFit::DTHitPairForFit(const DTRecHit1DPair& pair,
00023 const DTSuperLayer& sl,
00024 const edm::ESHandle<DTGeometry>& dtGeom) {
00025
00026 theWireId = pair.wireId();
00027 theDigiTime = pair.digiTime();
00028
00029 const DTLayer* layer = dtGeom->layer(theWireId.layerId());
00030
00031
00032 theLeftPos =
00033 sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Left)->localPosition()));
00034 theRightPos =
00035 sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Right)->localPosition()));
00036
00037
00038 theError = pair.componentRecHit(DTEnums::Left)->localPositionError();
00039
00040
00041
00042 }
00043
00045 DTHitPairForFit::~DTHitPairForFit() {
00046 }
00047
00048
00049 LocalPoint DTHitPairForFit::localPosition(DTEnums::DTCellSide s) const {
00050 if (s==DTEnums::Left) return theLeftPos;
00051 else if (s==DTEnums::Right) return theRightPos;
00052 else{
00053 throw cms::Exception("DTHitPairForFit")<<" localPosition called with undef LR code"<<endl;
00054 return LocalPoint();
00055 }
00056 }
00057
00058 pair<bool,bool>
00059 DTHitPairForFit::isCompatible(const LocalPoint& posIni,
00060 const LocalVector& dirIni) const {
00061
00062
00063 pair<bool,bool> ret;
00064 LocalPoint segPosAtZLeft = posIni+dirIni*(theLeftPos.z() -posIni.z())/dirIni.z();
00065 LocalPoint segPosAtZRight = posIni+dirIni*(theRightPos.z()-posIni.z())/dirIni.z();
00066 float dxLeft = fabs(theLeftPos.x() - segPosAtZLeft.x());
00067 float dxRight = fabs(theRightPos.x() - segPosAtZRight.x());
00068 float exx = sqrt(theError.xx());
00069
00070
00071
00072 if (std::max(dxLeft, dxRight) < 3*exx) {
00073 ret = make_pair(true,true);
00074 } else if (std::min(dxLeft, dxRight) >= 10*exx) {
00075 ret = make_pair(false,false);
00076 } else {
00077 float sigmasL = floorf(dxLeft/exx), sigmasR = floorf(dxRight/exx);
00078 ret.first = ( sigmasL < sigmasR );
00079 ret.second = ( sigmasR < sigmasL );
00080 }
00081 return ret;
00082 }
00083
00084 bool DTHitPairForFit::operator<(const DTHitPairForFit& hit) const {
00085
00086 if (id()==hit.id())
00087 return (theLeftPos.x() < hit.localPosition(DTEnums::Left).x());
00088 return (id() < hit.id());
00089 }
00090
00091 bool DTHitPairForFit::operator==(const DTHitPairForFit& hit) const {
00092 return (id() == hit.id() && fabs(digiTime() - hit.digiTime()) < 0.1 );
00093 }
00094
00095 ostream& operator<<(ostream& out, const DTHitPairForFit& hit) {
00096 out << hit.leftPos() << " " << hit.rightPos() ;
00097 return out;
00098 }