File indexing completed on 2024-04-06 12:04:02
0001
0002
0003
0004
0005
0006 #include "DataFormats/DTRecHit/interface/DTRecHit1DPair.h"
0007 #include "DataFormats/DTDigi/interface/DTDigi.h"
0008
0009 #include "FWCore/Utilities/interface/Exception.h"
0010
0011 using namespace DTEnums;
0012 using namespace std;
0013
0014
0015 DTRecHit1DPair::DTRecHit1DPair(const DTWireId& wireId, const DTDigi& digi)
0016 : theLeftHit(wireId, Left, digi.time()), theRightHit(wireId, Right, digi.time()) {}
0017
0018
0019 DTRecHit1DPair::DTRecHit1DPair() : theLeftHit(), theRightHit() {}
0020
0021
0022 DTRecHit1DPair::~DTRecHit1DPair() {}
0023
0024 DTRecHit1DPair* DTRecHit1DPair::clone() const { return new DTRecHit1DPair(*this); }
0025
0026
0027
0028
0029 LocalPoint DTRecHit1DPair::localPosition() const {
0030 return theLeftHit.localPosition() + (theRightHit.localPosition() - theLeftHit.localPosition()) / 2.;
0031 }
0032
0033
0034
0035
0036 LocalError DTRecHit1DPair::localPositionError() const {
0037 return LocalError((theRightHit.localPosition().x() - theLeftHit.localPosition().x()) / 2., 0., 0.);
0038 }
0039
0040
0041 vector<const TrackingRecHit*> DTRecHit1DPair::recHits() const {
0042 vector<const TrackingRecHit*> result;
0043 result.push_back(componentRecHit(Left));
0044 result.push_back(componentRecHit(Right));
0045 return result;
0046 }
0047
0048
0049 vector<TrackingRecHit*> DTRecHit1DPair::recHits() {
0050 vector<TrackingRecHit*> result;
0051 result.push_back(componentRecHit(Left));
0052 result.push_back(componentRecHit(Right));
0053 return result;
0054 }
0055
0056
0057 DetId DTRecHit1DPair::geographicalId() const { return wireId().layerId(); }
0058
0059
0060 bool DTRecHit1DPair::operator==(const DTRecHit1DPair& hit) const {
0061 return wireId() == hit.wireId() && fabs(digiTime() - hit.digiTime()) < 0.1;
0062 }
0063
0064
0065
0066 LocalPoint DTRecHit1DPair::localPosition(DTCellSide lrside) const { return componentRecHit(lrside)->localPosition(); }
0067
0068
0069
0070 LocalError DTRecHit1DPair::localPositionError(DTCellSide lrside) const {
0071 return componentRecHit(lrside)->localPositionError();
0072 }
0073
0074
0075
0076 void DTRecHit1DPair::setPosition(DTCellSide lrside, const LocalPoint& point) {
0077 if (lrside != undefLR)
0078 componentRecHit(lrside)->setPosition(point);
0079 else
0080 throw cms::Exception("DTRecHit1DPair::setPosition with undefined LR");
0081 }
0082
0083
0084
0085 void DTRecHit1DPair::setPositionAndError(DTCellSide lrside, const LocalPoint& point, const LocalError& err) {
0086 if (lrside != undefLR) {
0087 componentRecHit(lrside)->setPosition(point);
0088 componentRecHit(lrside)->setError(err);
0089 } else
0090 throw cms::Exception("DTRecHit1DPair::setPosition with undefined LR");
0091 }
0092
0093
0094 const DTRecHit1D* DTRecHit1DPair::componentRecHit(DTCellSide lrSide) const {
0095 if (lrSide == Left) {
0096 return &theLeftHit;
0097 } else if (lrSide == Right) {
0098 return &theRightHit;
0099 } else {
0100 throw cms::Exception("DTRecHit1DPair::recHit with undefined LR");
0101 }
0102 }
0103
0104
0105 DTRecHit1D* DTRecHit1DPair::componentRecHit(DTCellSide lrSide) {
0106 if (lrSide == Left) {
0107 return &theLeftHit;
0108 } else if (lrSide == Right) {
0109 return &theRightHit;
0110 } else {
0111 throw cms::Exception("DTRecHit1DPair::recHit with undefined LR");
0112 }
0113 }
0114
0115
0116 pair<const DTRecHit1D*, const DTRecHit1D*> DTRecHit1DPair::componentRecHits() const {
0117 return make_pair(componentRecHit(Left), componentRecHit(Right));
0118 }
0119
0120
0121 ostream& operator<<(ostream& os, const DTRecHit1DPair& hit) {
0122 os << "Pos: " << hit.localPosition();
0123 return os;
0124 }