CMS 3D CMS Logo

CSCWireGeometry.cc
Go to the documentation of this file.
2 
4 
5 #include <cmath>
6 
7 LocalPoint CSCWireGeometry::intersection(float m1, float c1, float m2, float c2) const {
8  // Calculate the point of intersection of two straight lines (in 2-dim)
9  // BEWARE! Do not call with m1 = m2 ! No trapping !
10 
11  float x = (c2 - c1) / (m1 - m2);
12  float y = (m1 * c2 - m2 * c1) / (m1 - m2);
13  return LocalPoint(x, y);
14 }
15 
16 std::vector<float> CSCWireGeometry::wireValues(float wire) const {
17  // return x and y of mid-point of wire, and length of wire, as 3-dim vector.
18  // If wire does not intersect active area the returned vector is filled with 0's.
19 
20  std::pair<LocalPoint, LocalPoint> ends = wireEnds(wire);
21 
22  std::vector<float> buf(3); // note all elem init to 0
23 
24  buf[0] = (ends.first.x() + ends.second.x()) / 2.; // x is first elem of first & second pairs
25  buf[1] = (ends.first.y() + ends.second.y()) / 2.; // y is second elem of first & second pairs
26  float d2 = (ends.first.x() - ends.second.x()) * (ends.first.x() - ends.second.x()) +
27  (ends.first.y() - ends.second.y()) * (ends.first.y() - ends.second.y());
28  buf[2] = sqrt(d2);
29  return buf;
30 }
31 
32 std::pair<LocalPoint, LocalPoint> CSCWireGeometry::wireEnds(float wire) const {
33  // return local (x, y) of each end of wire.
34  // If wire does not intersect active area set all values to 0.
35 
36  const float fprec = 1.E-06;
37 
38  // slope of wire
39  float wangle = wireAngle();
40  float mw = 0;
41  if (fabs(wangle) > fprec)
42  mw = tan(wireAngle());
43 
44  // intercept of wire
45  float cw = yOfWire(wire);
46 
47  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire=" << wire << ", wire angle = " << wangle
48  << ", intercept on y axis=" << cw;
49 
50  // Find extent of wire plane
51  double ww = wideWidthOfPlane();
52  double nw = narrowWidthOfPlane();
53  double len = lengthOfPlane();
54 
55  // slope & intercept of line defining one non-parallel edge of wire-plane trapezoid
56  float m1 = 2. * len / (ww - nw);
57  float c1 = 0.;
58  if (fabs(wangle) < fprec) {
59  c1 = yOfFirstWire() - nw * len / (ww - nw); // non-ME11
60  } else {
61  c1 = -len / 2. - nw * len / (ww - nw); // ME11
62  }
63 
64  // slope & intercept of other non-parallel edge of wire-plane trapezoid
65  float m2 = -m1;
66  float c2 = c1;
67 
68  // wire intersects edge 1 at
69  LocalPoint pw1 = intersection(mw, cw, m1, c1);
70  // wire intersects edge 2 at
71  LocalPoint pw2 = intersection(mw, cw, m2, c2);
72 
73  float x1 = pw1.x();
74  float y1 = pw1.y();
75 
76  float x2 = pw2.x();
77  float y2 = pw2.y();
78 
79  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire intersects edges of plane at "
80  << "\n x1=" << x1 << " y1=" << y1 << " x2=" << x2 << " y2=" << y2;
81 
82  // WIRES ARE NOT TILTED?
83 
84  if (fabs(wangle) < fprec) {
85  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wires are not tilted ";
86  return std::pair<LocalPoint, LocalPoint>(LocalPoint(x1, y1), LocalPoint(x2, y2));
87  }
88 
89  // WIRES ARE TILTED
90 
91  // ht and hb will be used to check where wire intersects edges of wire plane
92  float ht = ww / 2.;
93  float hb = nw / 2.;
94  float mt = 0.; // slope of top edge
95  float mb = 0.; //slope of bottom edge
96  float cb = -len / 2.; // intercept bottom edge of wire plane
97  float ct = len / 2.; // intercept top edge of wire plane
98 
99  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: slopes & intercepts "
100  << "\n mt=" << mt << " ct=" << ct << " mb=" << mb << " cb=" << cb << "\n m1=" << m1
101  << " c1=" << c1 << " m2=" << m2 << " c2=" << c2 << "\n mw=" << mw << " cw=" << cw;
102 
103  // wire intersects top edge at
104  LocalPoint pwt = intersection(mw, cw, mt, ct);
105  // wire intersects bottom edge at
106  LocalPoint pwb = intersection(mw, cw, mb, cb);
107 
108  // get the local coordinates
109  float xt = pwt.x();
110  float yt = pwt.y();
111 
112  float xb = pwb.x();
113  float yb = pwb.y();
114 
115  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire intersects top & bottom of wire plane at "
116  << "\n xt=" << xt << " yt=" << yt << " xb=" << xb << " yb=" << yb;
117 
118  float xWireEnd[4], yWireEnd[4];
119 
120  int i = 0;
121  if (fabs(x1) >= hb && fabs(x1) <= ht) {
122  // wire does intersect side edge 1 of wire plane
123  xWireEnd[i] = x1;
124  yWireEnd[i] = y1;
125  i++;
126  }
127  if (fabs(xb) <= hb) {
128  // wire does intersect bottom edge of wire plane
129  xWireEnd[i] = xb;
130  yWireEnd[i] = yb;
131  i++;
132  }
133  if (fabs(x2) >= hb && fabs(x2) <= ht) {
134  // wire does intersect side edge 2 of wire plane
135  xWireEnd[i] = x2;
136  yWireEnd[i] = y2;
137  i++;
138  }
139  if (fabs(xt) <= ht) {
140  // wire does intersect top edge of wire plane
141  xWireEnd[i] = xt;
142  yWireEnd[i] = yt;
143  i++;
144  }
145 
146  if (i != 2) {
147  // the wire does not intersect the wire plane (!)
148 
149  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire does not intersect wire plane!!";
150  // throw cms::Exception("BadCSCGeometry") << "the wire has " << i <<
151  // " ends!" << "\n";
152 
153  return std::pair<LocalPoint, LocalPoint>(LocalPoint(0., 0.), LocalPoint(0., 0.));
154  }
155 
156  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: ME11 wire ends ";
157  for (int j = 0; j < i; j++) {
158  LogTrace("CSCWireGeometry|CSC") << " x = " << xWireEnd[j] << " y = " << yWireEnd[j];
159  }
160 
161  return std::pair<LocalPoint, LocalPoint>(LocalPoint(xWireEnd[0], yWireEnd[0]), LocalPoint(xWireEnd[1], yWireEnd[1]));
162 }
163 
164 //@@ COULD/SHOULD BE IMPLEMENTED IN Slanted & Nonslanted DERIVED CLASSES
165 
166 std::pair<float, float> CSCWireGeometry::equationOfWire(float wire) const {
167  const float fprec = 1.E-06;
168 
169  // slope of wire
170  float wangle = wireAngle();
171  float mw = 0;
172  if (fabs(wangle) > fprec)
173  mw = tan(wangle);
174 
175  // intercept of wire
176  float cw = yOfWire(wire);
177 
178  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire=" << wire << ", wire angle = " << wangle
179  << ", intercept on y axis=" << cw;
180 
181  return std::pair<float, float>(mw, cw);
182 }
183 
184 //@@ COULD/SHOULD BE IMPLEMENTED IN Slanted & Nonslanted DERIVED CLASSES
185 
186 std::pair<float, float> CSCWireGeometry::yLimitsOfWirePlane() const {
187  const float fprec = 0.1; // wire angle is either 0 or 29 degrees = 0.506 rads
188  float ylow = yOfFirstWire(); // non-ME11 chambers
189  float wangle = wireAngle();
190  if (fabs(wangle) > fprec) {
191  ylow += tan(std::abs(wangle)) * narrowWidthOfPlane() / 2.; // correction for ME11
192  }
193  float yhigh = ylow + lengthOfPlane(); // add extent of wire plane in y
194 
195  return std::pair<float, float>(ylow, yhigh);
196 }
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
DDAxes::x
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
CSCWireGeometry::yLimitsOfWirePlane
std::pair< float, float > yLimitsOfWirePlane() const
Definition: CSCWireGeometry.cc:186
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
CSCWireGeometry::yOfWire
virtual float yOfWire(float wire, float x=0.) const =0
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CSCWireGeometry.h
Point3DBase< float, LocalTag >
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
CSCWireGeometry::narrowWidthOfPlane
double narrowWidthOfPlane() const
Definition: CSCWireGeometry.h:45
hcalSimParameters_cfi.hb
hb
Definition: hcalSimParameters_cfi.py:60
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
CSCWireGeometry::lengthOfPlane
double lengthOfPlane() const
Definition: CSCWireGeometry.h:55
CSCWireGeometry::wireAngle
virtual float wireAngle() const =0
CSCWireGeometry::wireEnds
std::pair< LocalPoint, LocalPoint > wireEnds(float wire) const
Definition: CSCWireGeometry.cc:32
TtSemiLepEvtBuilder_cfi.mt
mt
Definition: TtSemiLepEvtBuilder_cfi.py:47
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
CSCWireGeometry::yOfFirstWire
double yOfFirstWire() const
Definition: CSCWireGeometry.h:40
CSCWireGeometry::wideWidthOfPlane
double wideWidthOfPlane() const
Definition: CSCWireGeometry.h:50
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CSCWireGeometry::intersection
LocalPoint intersection(float m1, float c1, float m2, float c2) const
Definition: CSCWireGeometry.cc:7
CSCWireGeometry::equationOfWire
std::pair< float, float > equationOfWire(float wire) const
Definition: CSCWireGeometry.cc:166
CSCWireGeometry::wireValues
std::vector< float > wireValues(float wire) const
Definition: CSCWireGeometry.cc:16