Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:24

0001 #include "Geometry/CSCGeometry/interface/CSCWireTopology.h"
0002 
0003 #include "Geometry/CSCGeometry/src/CSCGangedWireGrouping.h"
0004 #include "Geometry/CSCGeometry/src/CSCNonslantedWireGeometry.h"
0005 #include "Geometry/CSCGeometry/src/CSCSlantedWireGeometry.h"
0006 
0007 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0008 
0009 #include "DataFormats/Math/interface/GeantUnits.h"
0010 
0011 #include <cmath>
0012 
0013 using namespace geant_units;
0014 using namespace geant_units::operators;
0015 
0016 CSCWireTopology::~CSCWireTopology() {
0017   delete theWireGrouping;
0018   delete theWireGeometry;
0019 }
0020 
0021 CSCWireTopology::CSCWireTopology(const CSCWireGroupPackage& wg, double yOfFirstWire, float wireAngleInDegrees)
0022     : theWireGrouping(nullptr), theWireGeometry(nullptr), theAlignmentPinToFirstWire(wg.alignmentPinToFirstWire / 10.) {
0023   // Pass consecutiveGroups and wiresInConsecutiveGroups
0024   // directly on to theWireGrouping ctor. These vectors
0025   // are transient info and can go once ctor is complete.
0026 
0027   theWireGrouping = new CSCGangedWireGrouping(wg.consecutiveGroups, wg.wiresInEachGroup, wg.numberOfGroups);
0028 
0029   const float zeroprecision = 1.E-06;  // blur zero a bit, for comparisons
0030 
0031   float wireAngleInRadians = convertDegToRad(wireAngleInDegrees);
0032 
0033   //@@ Conversion from mm to cm
0034   float wireSpacing = convertMmToCm(wg.wireSpacing);
0035   float nw = convertMmToCm(wg.narrowWidthOfWirePlane);
0036   float ww = convertMmToCm(wg.wideWidthOfWirePlane);
0037   float lw = convertMmToCm(wg.lengthOfWirePlane);
0038 
0039   LogTrace("CSCWireTopology|CSC") << "CSCWireTopology constructing CSCWireGeometry with:\n"
0040                                   << " wireSpacing = " << wireSpacing * 10. << " (mm) "
0041                                   << ", yOfFirstWire = " << yOfFirstWire << " (cm) "
0042                                   << ", wireAngle = " << wireAngleInDegrees << " (deg) = " << wireAngleInRadians
0043                                   << " (rads)"
0044                                   << ", extent: n, w, l = " << nw << ", " << ww << ", " << lw << " (cm)";
0045 
0046   if (fabs(wireAngleInDegrees) > zeroprecision) {
0047     theWireGeometry = new CSCSlantedWireGeometry(wireSpacing, yOfFirstWire, nw, ww, lw, wireAngleInRadians);
0048   } else {
0049     theWireGeometry = new CSCNonslantedWireGeometry(wireSpacing, yOfFirstWire, nw, ww, lw);
0050   }
0051 }
0052 
0053 CSCWireTopology::CSCWireTopology(const CSCWireTopology& mewt)
0054     : theAlignmentPinToFirstWire(mewt.theAlignmentPinToFirstWire) {
0055   if (mewt.theWireGrouping)
0056     theWireGrouping = mewt.theWireGrouping->clone();
0057   else
0058     theWireGrouping = nullptr;
0059   if (mewt.theWireGeometry)
0060     theWireGeometry = mewt.theWireGeometry->clone();
0061   else
0062     theWireGeometry = nullptr;
0063 }
0064 
0065 CSCWireTopology& CSCWireTopology::operator=(const CSCWireTopology& mewt) {
0066   if (&mewt != this) {
0067     delete theWireGrouping;
0068     if (mewt.theWireGrouping)
0069       theWireGrouping = mewt.theWireGrouping->clone();
0070     else
0071       theWireGrouping = nullptr;
0072 
0073     delete theWireGeometry;
0074     if (mewt.theWireGeometry)
0075       theWireGeometry = mewt.theWireGeometry->clone();
0076     else
0077       theWireGeometry = nullptr;
0078 
0079     theAlignmentPinToFirstWire = mewt.theAlignmentPinToFirstWire;
0080   }
0081   return *this;
0082 }
0083 
0084 LocalPoint CSCWireTopology::localPosition(const MeasurementPoint&) const {
0085   edm::LogWarning("CSC") << "CSCWireTopology: localPosition unimplemented. Don't use it."
0086                          << "\n";
0087   return LocalPoint();
0088 }
0089 
0090 LocalError CSCWireTopology::localError(const MeasurementPoint&, const MeasurementError&) const {
0091   edm::LogWarning("CSC") << "CSCWireTopology: localError unimplemented. Don't use it."
0092                          << "\n";
0093   return LocalError();
0094 }
0095 
0096 MeasurementPoint CSCWireTopology::measurementPosition(const LocalPoint&) const {
0097   edm::LogWarning("CSC") << "CSCWireTopology: measurementPosition unimplemented. Don't use it."
0098                          << "\n";
0099   return MeasurementPoint();
0100 }
0101 
0102 MeasurementError CSCWireTopology::measurementError(const LocalPoint&, const LocalError&) const {
0103   edm::LogWarning("CSC") << "CSCWireTopology: measurementError unimplemented. Don't use it."
0104                          << "\n";
0105   return MeasurementError();
0106 }
0107 
0108 int CSCWireTopology::channel(const LocalPoint& p) const {
0109   int wire = theWireGeometry->nearestWire(p);
0110   int group = theWireGrouping->wireGroup(wire);
0111   return group;  // 0 means out of range or dead region
0112 }
0113 
0114 float CSCWireTopology::yOfWireGroup(int wireGroup, float x) const {
0115   float wire = middleWireOfGroup(wireGroup);
0116   return theWireGeometry->yOfWire(wire, x);
0117 }
0118 
0119 float CSCWireTopology::yResolution(int wireGroup) const {
0120   // Return the resolution in the wire group measurement (in cm).
0121   // To really be resolution in local y this should be scaled by Sin
0122   // factors involving strip and wire angles, and also add a contribution
0123   // from strip measurement (which is negligible w.r.t. wire resolution.)
0124   // These factors can increase the number here by up to 1.26.
0125 
0126   // Should be improvable for smaller partial wire groups
0127 
0128   return wireSpacing() * theWireGrouping->numberOfWiresPerGroup(wireGroup) / sqrt(12.);
0129 }
0130 
0131 std::pair<float, float> CSCWireTopology::equationOfWire(float wire) const {
0132   return theWireGeometry->equationOfWire(wire);
0133 }
0134 
0135 float CSCWireTopology::restrictToYOfWirePlane(float y) const {
0136   // Reset y to lie within bounds of wire plane at top and bottom.
0137 
0138   std::pair<float, float> ylim = theWireGeometry->yLimitsOfWirePlane();
0139 
0140   if (y < ylim.first) {
0141     y = ylim.first;
0142   } else if (y > ylim.second) {
0143     y = ylim.second;
0144   }
0145   return y;
0146 }
0147 
0148 bool CSCWireTopology::insideYOfWirePlane(float y) const {
0149   // Returns true if arg falls within y limits of wire plane; false otherwise.
0150 
0151   std::pair<float, float> ylim = theWireGeometry->yLimitsOfWirePlane();
0152 
0153   if (y < ylim.first) {
0154     return false;
0155   } else if (y > ylim.second) {
0156     return false;
0157   }
0158   return true;
0159 }