CMS 3D CMS Logo

CSCWireTopology.cc
Go to the documentation of this file.
2 
6 
8 
10 
11 #include <cmath>
12 
13 using namespace geant_units;
14 using namespace geant_units::operators;
15 
17  delete theWireGrouping;
18  delete theWireGeometry;
19 }
20 
22  const CSCWireGroupPackage& wg,
23  double yOfFirstWire,
24  float wireAngleInDegrees ) :
25  theWireGrouping( nullptr ), theWireGeometry( nullptr ),
26  theAlignmentPinToFirstWire( wg.alignmentPinToFirstWire / 10. ) {
27 
28  // Pass consecutiveGroups and wiresInConsecutiveGroups
29  // directly on to theWireGrouping ctor. These vectors
30  // are transient info and can go once ctor is complete.
31 
34 
35  const float zeroprecision = 1.E-06; // blur zero a bit, for comparisons
36 
37  float wireAngleInRadians = convertDegToRad( wireAngleInDegrees );
38 
39  //@@ Conversion from mm to cm
41  float nw = convertMmToCm( wg.narrowWidthOfWirePlane );
42  float ww = convertMmToCm( wg.wideWidthOfWirePlane );
43  float lw = convertMmToCm( wg.lengthOfWirePlane );
44 
45  LogTrace("CSCWireTopology|CSC") <<
46  "CSCWireTopology constructing CSCWireGeometry with:\n" <<
47  " wireSpacing = " << wireSpacing*10. << " (mm) " <<
48  ", yOfFirstWire = " << yOfFirstWire << " (cm) " <<
49  ", wireAngle = " << wireAngleInDegrees << " (deg) = " << wireAngleInRadians << " (rads)" <<
50  ", extent: n, w, l = " << nw << ", " << ww << ", " << lw << " (cm)";
51 
52  if ( fabs(wireAngleInDegrees) > zeroprecision ) {
53  theWireGeometry = new CSCSlantedWireGeometry( wireSpacing, yOfFirstWire, nw, ww, lw, wireAngleInRadians );
54  }
55  else {
56  theWireGeometry = new CSCNonslantedWireGeometry( wireSpacing, yOfFirstWire, nw, ww, lw );
57  }
58 }
59 
63  else theWireGrouping = nullptr;
65  else theWireGeometry = nullptr;
66 
67 }
68 
70  if ( &mewt != this ) {
71  delete theWireGrouping;
72  if ( mewt.theWireGrouping )
74  else
75  theWireGrouping = nullptr;
76 
77  delete theWireGeometry;
78  if ( mewt.theWireGeometry )
80  else
81  theWireGeometry = nullptr;
82 
84 
85  }
86  return *this;
87 }
88 
90  edm::LogWarning("CSC") << "CSCWireTopology: localPosition unimplemented. Don't use it." << "\n";
91  return LocalPoint();
92 }
93 
95  const MeasurementError& ) const {
96  edm::LogWarning("CSC") << "CSCWireTopology: localError unimplemented. Don't use it." << "\n";
97  return LocalError();
98 }
99 
101  const LocalPoint& ) const {
102  edm::LogWarning("CSC") << "CSCWireTopology: measurementPosition unimplemented. Don't use it." << "\n";
103  return MeasurementPoint();
104 }
105 
107  const LocalError& ) const {
108  edm::LogWarning("CSC") << "CSCWireTopology: measurementError unimplemented. Don't use it." << "\n";
109  return MeasurementError();
110 }
111 
112 int CSCWireTopology::channel( const LocalPoint& p ) const {
113  int wire = theWireGeometry->nearestWire( p );
114  int group = theWireGrouping->wireGroup( wire );
115  return group; // 0 means out of range or dead region
116 }
117 
118 float CSCWireTopology::yOfWireGroup(int wireGroup, float x) const {
119  float wire = middleWireOfGroup( wireGroup );
120  return theWireGeometry->yOfWire( wire, x );
121 }
122 
124  // Return the resolution in the wire group measurement (in cm).
125  // To really be resolution in local y this should be scaled by Sin
126  // factors involving strip and wire angles, and also add a contribution
127  // from strip measurement (which is negligible w.r.t. wire resolution.)
128  // These factors can increase the number here by up to 1.26.
129 
130  // Should be improvable for smaller partial wire groups
131 
132  return wireSpacing() * theWireGrouping->numberOfWiresPerGroup( wireGroup ) / sqrt(12.);
133 }
134 
135 std::pair<float, float> CSCWireTopology::equationOfWire( float wire ) const {
136  return theWireGeometry->equationOfWire( wire );
137 }
138 
140  // Reset y to lie within bounds of wire plane at top and bottom.
141 
142  std::pair<float, float> ylim = theWireGeometry->yLimitsOfWirePlane();
143 
144  if ( y < ylim.first ) {
145  y = ylim.first;
146  }
147  else if ( y > ylim.second ) {
148  y = ylim.second;
149  }
150  return y;
151 }
152 
154  // Returns true if arg falls within y limits of wire plane; false otherwise.
155 
156  std::pair<float, float> ylim = theWireGeometry->yLimitsOfWirePlane();
157 
158  if ( y < ylim.first ) {
159  return false;
160  }
161  else if ( y > ylim.second ) {
162  return false;
163  }
164  return true;
165 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
std::pair< float, float > equationOfWire(float wire) const
CSCWireTopology(const CSCWireGroupPackage &wg, double yOfFirstWire, float wireAngleInDegrees)
#define nullptr
MeasurementError measurementError(const LocalPoint &, const LocalError &) const override
double theAlignmentPinToFirstWire
CSCWireGrouping * theWireGrouping
double wireSpacing() const
float yOfWireGroup(int wireGroup, float x=0.) const
CSCWireTopology & operator=(const CSCWireTopology &)
bool insideYOfWirePlane(float y) const
~CSCWireTopology() override
LocalPoint localPosition(const MeasurementPoint &) const override
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
std::pair< float, float > yLimitsOfWirePlane() const
virtual float yOfWire(float wire, float x=0.) const =0
T sqrt(T t)
Definition: SSEVec.h:18
virtual int wireGroup(int wire) const =0
virtual CSCWireGeometry * clone() const =0
virtual CSCWireGrouping * clone() const =0
int wireGroup(int wire) const
MeasurementPoint measurementPosition(const LocalPoint &) const override
constexpr long double convertDegToRad(NumType degrees)
Definition: GeantUnits.h:104
#define LogTrace(id)
float middleWireOfGroup(int wireGroup) const
virtual int numberOfWiresPerGroup(int wireGroup) const =0
std::pair< float, float > equationOfWire(float wire) const
float yResolution(int wireGroup=1) const
float restrictToYOfWirePlane(float y) const
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:110
int channel(const LocalPoint &p) const override
LocalError localError(const MeasurementPoint &, const MeasurementError &) const override
CSCWireGeometry * theWireGeometry
virtual int nearestWire(const LocalPoint &lp) const =0