File indexing completed on 2024-04-06 12:04:13
0001
0002
0003
0004
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "DataFormats/GEMRecHit/interface/GEMSegment.h"
0007 #include <iostream>
0008
0009 namespace {
0010
0011 inline DetId buildDetId(GEMDetId id) { return GEMDetId(id.superChamberId()); }
0012 }
0013
0014 class ProjectionMatrixDiag {
0015
0016 protected:
0017 AlgebraicMatrix theProjectionMatrix;
0018
0019 public:
0020 ProjectionMatrixDiag() : theProjectionMatrix(4, 5, 0) {
0021 theProjectionMatrix[0][1] = 1;
0022 theProjectionMatrix[1][2] = 1;
0023 theProjectionMatrix[2][3] = 1;
0024 theProjectionMatrix[3][4] = 1;
0025 }
0026 const AlgebraicMatrix& getMatrix() const { return (theProjectionMatrix); }
0027 };
0028
0029 GEMSegment::GEMSegment(const std::vector<const GEMRecHit*>& proto_segment,
0030 const LocalPoint& origin,
0031 const LocalVector& direction,
0032 const AlgebraicSymMatrix& errors,
0033 double chi2)
0034 : RecSegment(buildDetId(proto_segment.front()->gemId())),
0035 theOrigin(origin),
0036 theLocalDirection(direction),
0037 theCovMatrix(errors),
0038 theChi2(chi2) {
0039 theBX = -10.0;
0040 theDeltaPhi = -10.0;
0041 for (unsigned int i = 0; i < proto_segment.size(); ++i)
0042 theGEMRecHits.push_back(*proto_segment[i]);
0043 }
0044
0045 GEMSegment::GEMSegment(const std::vector<const GEMRecHit*>& proto_segment,
0046 const LocalPoint& origin,
0047 const LocalVector& direction,
0048 const AlgebraicSymMatrix& errors,
0049 double chi2,
0050 float bx)
0051 : RecSegment(buildDetId(proto_segment.front()->gemId())),
0052 theOrigin(origin),
0053 theLocalDirection(direction),
0054 theCovMatrix(errors),
0055 theChi2(chi2),
0056 theBX(bx) {
0057 theDeltaPhi = -10.0;
0058 for (unsigned int i = 0; i < proto_segment.size(); ++i)
0059 theGEMRecHits.push_back(*proto_segment[i]);
0060 }
0061
0062 GEMSegment::GEMSegment(const std::vector<const GEMRecHit*>& proto_segment,
0063 const LocalPoint& origin,
0064 const LocalVector& direction,
0065 const AlgebraicSymMatrix& errors,
0066 double chi2,
0067 float bx,
0068 float deltaPhi)
0069 : RecSegment(buildDetId(proto_segment.front()->gemId())),
0070 theOrigin(origin),
0071 theLocalDirection(direction),
0072 theCovMatrix(errors),
0073 theChi2(chi2),
0074 theBX(bx),
0075 theDeltaPhi(deltaPhi) {
0076 for (unsigned int i = 0; i < proto_segment.size(); ++i)
0077 theGEMRecHits.push_back(*proto_segment[i]);
0078 }
0079
0080 GEMSegment::~GEMSegment() {}
0081
0082 std::vector<const TrackingRecHit*> GEMSegment::recHits() const {
0083 std::vector<const TrackingRecHit*> pointersOfRecHits;
0084 for (std::vector<GEMRecHit>::const_iterator irh = theGEMRecHits.begin(); irh != theGEMRecHits.end(); ++irh) {
0085 pointersOfRecHits.push_back(&(*irh));
0086 }
0087 return pointersOfRecHits;
0088 }
0089
0090 std::vector<TrackingRecHit*> GEMSegment::recHits() {
0091 std::vector<TrackingRecHit*> pointersOfRecHits;
0092 for (std::vector<GEMRecHit>::iterator irh = theGEMRecHits.begin(); irh != theGEMRecHits.end(); ++irh) {
0093 pointersOfRecHits.push_back(&(*irh));
0094 }
0095 return pointersOfRecHits;
0096 }
0097
0098 LocalError GEMSegment::localPositionError() const {
0099 return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
0100 }
0101
0102 LocalError GEMSegment::localDirectionError() const {
0103 return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
0104 }
0105
0106 AlgebraicVector GEMSegment::parameters() const {
0107
0108
0109
0110 AlgebraicVector result(4);
0111
0112 if (theLocalDirection.z() != 0) {
0113 result[0] = theLocalDirection.x() / theLocalDirection.z();
0114 result[1] = theLocalDirection.y() / theLocalDirection.z();
0115 }
0116 result[2] = theOrigin.x();
0117 result[3] = theOrigin.y();
0118
0119 return result;
0120 }
0121
0122 AlgebraicMatrix GEMSegment::projectionMatrix() const {
0123 static const ProjectionMatrixDiag theProjectionMatrix;
0124 return (theProjectionMatrix.getMatrix());
0125 }
0126
0127
0128 void GEMSegment::print() const { LogDebug("GEMSegment") << *this; }
0129
0130 std::ostream& operator<<(std::ostream& os, const GEMSegment& seg) {
0131 os << "GEMSegment: local pos = " << seg.localPosition() << " posErr = (" << sqrt(seg.localPositionError().xx()) << ","
0132 << sqrt(seg.localPositionError().yy()) << "0,)\n"
0133 << " dir = " << seg.localDirection() << " dirErr = (" << sqrt(seg.localDirectionError().xx()) << ","
0134 << sqrt(seg.localDirectionError().yy()) << "0,)\n"
0135 << " chi2/ndf = " << ((seg.degreesOfFreedom() != 0.) ? seg.chi2() / double(seg.degreesOfFreedom()) : 0)
0136 << " #rechits = " << seg.specificRecHits().size() << " bx = " << seg.bunchX() << " deltaPhi = " << seg.deltaPhi();
0137
0138 return os;
0139 }