File indexing completed on 2024-04-06 12:14:26
0001
0002
0003
0004
0005
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "Geometry/DTGeometry/interface/DTTopology.h"
0008 #include <FWCore/Utilities/interface/Exception.h>
0009
0010 #include <iostream>
0011
0012
0013
0014
0015 const float DTTopology::theWidth = 4.2;
0016 const float DTTopology::theHeight = 1.3;
0017
0018 const float DTTopology::IBeamWingThickness = 0.13;
0019 const float DTTopology::IBeamWingLength = 0.635;
0020
0021 const float DTTopology::plateThickness = 0.15;
0022 const float DTTopology::IBeamThickness = 0.13;
0023
0024 DTTopology::DTTopology(int firstWire, int nChannels, float semilenght)
0025 : theFirstChannel(firstWire), theNChannels(nChannels), theLength(semilenght * 2) {
0026 theOffSet = Local2DPoint(-theNChannels / 2. * theWidth, -theLength / 2.);
0027
0028 #ifdef EDM_ML_DEBUG
0029 edm::LogVerbatim("DTGeometry") << "Constructing DTTopology with:" << std::endl
0030 << "number of wires = " << theNChannels << ", first wire number = " << theFirstChannel
0031 << std::endl
0032 << ", width = " << theWidth << ", height = " << theHeight
0033 << ", length = " << theLength;
0034 #endif
0035 }
0036
0037 float DTTopology::sensibleWidth() const { return theWidth - IBeamThickness; }
0038
0039 float DTTopology::sensibleHeight() const { return theHeight - plateThickness; }
0040
0041 LocalPoint DTTopology::localPosition(const MeasurementPoint& mp) const {
0042 return LocalPoint((mp.x() - theFirstChannel) * theWidth + theOffSet.x(), (1 - mp.y()) * theLength + theOffSet.y());
0043 }
0044
0045 LocalError DTTopology::localError(const MeasurementPoint& , const MeasurementError& me) const {
0046 return LocalError(me.uu() * (theWidth * theWidth), 0, me.vv() * (theLength * theLength));
0047 }
0048
0049 MeasurementPoint DTTopology::measurementPosition(const LocalPoint& lp) const {
0050 return MeasurementPoint(static_cast<int>((lp.x() - theOffSet.x()) / theWidth + theFirstChannel),
0051 1 - (lp.y() - theOffSet.y()) / theLength);
0052 }
0053
0054 MeasurementError DTTopology::measurementError(const LocalPoint& , const LocalError& le) const {
0055 return MeasurementError(le.xx() / (theWidth * theWidth), 0, le.yy() / (theLength * theLength));
0056 }
0057
0058 int DTTopology::channel(const LocalPoint& lp) const {
0059 return static_cast<int>((lp.x() - theOffSet.x()) / theWidth + theFirstChannel);
0060 }
0061
0062
0063 float DTTopology::wirePosition(int wireNumber) const {
0064 if (!isWireValid(wireNumber))
0065 throw cms::Exception("InvalidWireNumber")
0066 << "DTTopology::wirePosition:"
0067 << " Requested wire number: " << wireNumber << " ,but the first wire number is " << theFirstChannel
0068 << " and the last wire number is " << lastChannel() << std::endl;
0069 else
0070 return (wireNumber - (theFirstChannel - 1) - 0.5) * theWidth + theOffSet.x();
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 DTTopology::Side DTTopology::onWhichBorder(float x, float , float z) const {
0083
0084
0085
0086 const float epsilon = 0.0015;
0087
0088
0089
0090
0091
0092
0093 Side side = none;
0094
0095 if (fabs(z) > (sensibleHeight() / 2. - epsilon) ||
0096 (fabs(x) > (sensibleWidth() / 2. - IBeamWingLength - epsilon) &&
0097 fabs(z) > (sensibleHeight() / 2. - IBeamWingThickness - epsilon))) {
0098
0099 if (z > 0.)
0100 side = zMax;
0101 else
0102 side = zMin;
0103 }
0104
0105 else if (fabs(x) > (sensibleWidth() / 2. - epsilon)) {
0106 if (x > 0.)
0107 side = xMax;
0108 else
0109 side = xMin;
0110 }
0111
0112 return side;
0113 }
0114
0115
0116 DTTopology::Side DTTopology::onWhichBorder_old(float x, float , float z) const {
0117
0118
0119
0120 const float epsilon = 0.0015;
0121
0122 Side side = none;
0123
0124 if (fabs(z) > (sensibleHeight() / 2. - epsilon)) {
0125 if (z > 0.) {
0126 side = zMax;
0127 } else {
0128 side = zMin;
0129 }
0130 } else if (fabs(x) > (sensibleWidth() / 2. - epsilon)) {
0131 if (x > 0.) {
0132 side = xMax;
0133 } else {
0134 side = xMin;
0135 }
0136 }
0137
0138 return side;
0139 }