CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CSCWireGeometry Class Referenceabstract

#include <CSCWireGeometry.h>

Inheritance diagram for CSCWireGeometry:
CSCNonslantedWireGeometry CSCSlantedWireGeometry

Public Member Functions

virtual CSCWireGeometryclone () const =0
 
 CSCWireGeometry (double wireSpacing, double yOfFirstWire, double narrowWidthOfPlane, double wideWidthOfPlane, double lengthOfPlane)
 
std::pair< float, float > equationOfWire (float wire) const
 
LocalPoint intersection (float m1, float c1, float m2, float c2) const
 
double lengthOfPlane () const
 
double narrowWidthOfPlane () const
 
virtual int nearestWire (const LocalPoint &lp) const =0
 
double wideWidthOfPlane () const
 
virtual float wireAngle () const =0
 
std::pair< LocalPoint, LocalPointwireEnds (float wire) const
 
double wireSpacing () const
 
std::vector< float > wireValues (float wire) const
 
std::pair< float, float > yLimitsOfWirePlane () const
 
double yOfFirstWire () const
 
virtual float yOfWire (float wire, float x=0.) const =0
 
virtual ~CSCWireGeometry ()
 

Private Attributes

double theLengthOfPlane
 
double theNarrowWidthOfPlane
 
double theWideWidthOfPlane
 
double theWireSpacing
 
double theYOfFirstWire
 

Detailed Description

An ABC defining interface for geometry related to angle which wires of a detector modelled by a WireTopology make with the local x axis.

Author
Tim Cox

Definition at line 17 of file CSCWireGeometry.h.

Constructor & Destructor Documentation

◆ ~CSCWireGeometry()

virtual CSCWireGeometry::~CSCWireGeometry ( )
inlinevirtual

Definition at line 19 of file CSCWireGeometry.h.

19 {}

◆ CSCWireGeometry()

CSCWireGeometry::CSCWireGeometry ( double  wireSpacing,
double  yOfFirstWire,
double  narrowWidthOfPlane,
double  wideWidthOfPlane,
double  lengthOfPlane 
)
inline

Constructor from wire spacing (in cm)

Definition at line 24 of file CSCWireGeometry.h.

Member Function Documentation

◆ clone()

virtual CSCWireGeometry* CSCWireGeometry::clone ( ) const
pure virtual

Allow proper copying of derived classes via base pointer

Implemented in CSCNonslantedWireGeometry, and CSCSlantedWireGeometry.

Referenced by CSCWireTopology::CSCWireTopology(), and CSCWireTopology::operator=().

◆ equationOfWire()

std::pair< float, float > CSCWireGeometry::equationOfWire ( float  wire) const

Return slope and intercept of straight line representing a wire in 2-dim local coordinates.

The return value is a pair p with p.first = m, p.second = c, where y=mx+c.

Definition at line 166 of file CSCWireGeometry.cc.

References LogTrace, funct::tan(), nano_mu_digi_cff::wire, wireAngle(), and yOfWire().

Referenced by CSCWireTopology::equationOfWire().

166  {
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 }
#define LogTrace(id)
virtual float yOfWire(float wire, float x=0.) const =0
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
virtual float wireAngle() const =0

◆ intersection()

LocalPoint CSCWireGeometry::intersection ( float  m1,
float  c1,
float  m2,
float  c2 
) const

2D point of intersection of two straight lines defined by
y = m1*x + c1 and y = m2*x + c2
(in local coordinates x, y)

Definition at line 7 of file CSCWireGeometry.cc.

References alignmentValidation::c1, callgraph::m2, x, and y.

Referenced by wireEnds().

7  {
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 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30

◆ lengthOfPlane()

double CSCWireGeometry::lengthOfPlane ( ) const
inline

Extent of wire plane along long axis of trapezoid

Definition at line 55 of file CSCWireGeometry.h.

References theLengthOfPlane.

Referenced by CSCWireTopology::lengthOfPlane(), wireEnds(), and yLimitsOfWirePlane().

55 { return theLengthOfPlane; }

◆ narrowWidthOfPlane()

double CSCWireGeometry::narrowWidthOfPlane ( ) const
inline

Extent of wire plane at narrow end of trapezoid

Definition at line 45 of file CSCWireGeometry.h.

References theNarrowWidthOfPlane.

Referenced by CSCWireTopology::narrowWidthOfPlane(), wireEnds(), and yLimitsOfWirePlane().

45 { return theNarrowWidthOfPlane; }
double theNarrowWidthOfPlane

◆ nearestWire()

virtual int CSCWireGeometry::nearestWire ( const LocalPoint lp) const
pure virtual

The nearest (virtual) wire to a given LocalPoint. Beware that this wire might not exist or be read out!

Implemented in CSCNonslantedWireGeometry, and CSCSlantedWireGeometry.

Referenced by CSCWireTopology::channel(), and CSCWireTopology::nearestWire().

◆ wideWidthOfPlane()

double CSCWireGeometry::wideWidthOfPlane ( ) const
inline

Extent of wire plane at wide end of trapezoid

Definition at line 50 of file CSCWireGeometry.h.

References theWideWidthOfPlane.

Referenced by CSCWireTopology::wideWidthOfPlane(), and wireEnds().

50 { return theWideWidthOfPlane; }
double theWideWidthOfPlane

◆ wireAngle()

virtual float CSCWireGeometry::wireAngle ( ) const
pure virtual

The angle of the wires w.r.t local x axis (in radians)

Implemented in CSCNonslantedWireGeometry, and CSCSlantedWireGeometry.

Referenced by equationOfWire(), CSCWireTopology::wireAngle(), wireEnds(), and yLimitsOfWirePlane().

◆ wireEnds()

std::pair< LocalPoint, LocalPoint > CSCWireGeometry::wireEnds ( float  wire) const

Return 2-dim local coords of the two ends of a wire

The returned value is a pair of LocalPoints.

Definition at line 32 of file CSCWireGeometry.cc.

References alignmentValidation::c1, hgcalPlots::ct, hcalSimParameters_cfi::hb, mps_fire::i, intersection(), dqmiolumiharvest::j, lengthOfPlane(), LogTrace, callgraph::m2, TtSemiLepEvtBuilder_cfi::mt, narrowWidthOfPlane(), funct::tan(), wideWidthOfPlane(), nano_mu_digi_cff::wire, wireAngle(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::ww, PV3DBase< T, PVType, FrameType >::x(), testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, PV3DBase< T, PVType, FrameType >::y(), testProducerWithPsetDescEmpty_cfi::y1, testProducerWithPsetDescEmpty_cfi::y2, yOfFirstWire(), and yOfWire().

Referenced by CSCWireTopology::wireEnds(), and wireValues().

32  {
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 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
double narrowWidthOfPlane() const
double lengthOfPlane() const
LocalPoint intersection(float m1, float c1, float m2, float c2) const
#define LogTrace(id)
virtual float yOfWire(float wire, float x=0.) const =0
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double wideWidthOfPlane() const
double yOfFirstWire() const
virtual float wireAngle() const =0

◆ wireSpacing()

double CSCWireGeometry::wireSpacing ( ) const
inline

◆ wireValues()

std::vector< float > CSCWireGeometry::wireValues ( float  wire) const

Return mid-point of a wire in local coordinates, and its length across the chamber volume, in a vector as x, y, length

Definition at line 16 of file CSCWireGeometry.cc.

References visDQMUpload::buf, mathSSE::sqrt(), nano_mu_digi_cff::wire, and wireEnds().

Referenced by CSCWireTopology::wireValues().

16  {
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 }
T sqrt(T t)
Definition: SSEVec.h:23
std::pair< LocalPoint, LocalPoint > wireEnds(float wire) const

◆ yLimitsOfWirePlane()

std::pair< float, float > CSCWireGeometry::yLimitsOfWirePlane ( ) const

Return pair containing y extremes of wire-plane: p.first = low y, p.second= high y

This is supposed to approximate the 'sensitive' region covered by wires (and strips) but there is no sophisticated handling of edge effects, or attempt to estimate a precise region overlapped by both wires and strips.

Definition at line 186 of file CSCWireGeometry.cc.

References funct::abs(), lengthOfPlane(), narrowWidthOfPlane(), funct::tan(), wireAngle(), and yOfFirstWire().

Referenced by CSCWireTopology::insideYOfWirePlane(), and CSCWireTopology::restrictToYOfWirePlane().

186  {
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 }
double narrowWidthOfPlane() const
double lengthOfPlane() const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double yOfFirstWire() const
virtual float wireAngle() const =0

◆ yOfFirstWire()

double CSCWireGeometry::yOfFirstWire ( ) const
inline

◆ yOfWire()

virtual float CSCWireGeometry::yOfWire ( float  wire,
float  x = 0. 
) const
pure virtual

Local y of a given wire 'number' (float) at given x

Implemented in CSCNonslantedWireGeometry, and CSCSlantedWireGeometry.

Referenced by equationOfWire(), wireEnds(), CSCWireTopology::yOfWire(), and CSCWireTopology::yOfWireGroup().

Member Data Documentation

◆ theLengthOfPlane

double CSCWireGeometry::theLengthOfPlane
private

Definition at line 116 of file CSCWireGeometry.h.

Referenced by lengthOfPlane().

◆ theNarrowWidthOfPlane

double CSCWireGeometry::theNarrowWidthOfPlane
private

Definition at line 114 of file CSCWireGeometry.h.

Referenced by narrowWidthOfPlane().

◆ theWideWidthOfPlane

double CSCWireGeometry::theWideWidthOfPlane
private

Definition at line 115 of file CSCWireGeometry.h.

Referenced by wideWidthOfPlane().

◆ theWireSpacing

double CSCWireGeometry::theWireSpacing
private

Definition at line 112 of file CSCWireGeometry.h.

Referenced by wireSpacing().

◆ theYOfFirstWire

double CSCWireGeometry::theYOfFirstWire
private

Definition at line 113 of file CSCWireGeometry.h.

Referenced by yOfFirstWire().