CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual CSCWireGeometry::~CSCWireGeometry ( )
inlinevirtual

Definition at line 19 of file CSCWireGeometry.h.

19 {}
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

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=().

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 176 of file CSCWireGeometry.cc.

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

Referenced by CSCWireTopology::equationOfWire().

176  {
177 
178  const float fprec = 1.E-06;
179 
180  // slope of wire
181  float wangle = wireAngle();
182  float mw = 0;
183  if ( fabs(wangle) > fprec ) mw = tan( wangle );
184 
185  // intercept of wire
186  float cw = yOfWire( wire );
187 
188  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire=" << wire <<
189  ", wire angle = " << wangle <<
190  ", intercept on y axis=" << cw;
191 
192  return std::pair<float,float>(mw, cw);
193 }
virtual float yOfWire(float wire, float x=0.) const =0
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
#define LogTrace(id)
virtual float wireAngle() const =0
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, x, and y.

Referenced by wireEnds().

8  {
9 
10  // Calculate the point of intersection of two straight lines (in 2-dim)
11  // BEWARE! Do not call with m1 = m2 ! No trapping !
12 
13  float x = (c2-c1)/(m1-m2);
14  float y = (m1*c2-m2*c1)/(m1-m2);
15  return LocalPoint( x, y );
16 }
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
double CSCWireGeometry::lengthOfPlane ( ) const
inline

Extent of wire plane along long axis of trapezoid

Definition at line 57 of file CSCWireGeometry.h.

References theLengthOfPlane.

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

57  {
58  return theLengthOfPlane; }
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  {
46  return theNarrowWidthOfPlane; }
double theNarrowWidthOfPlane
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().

double CSCWireGeometry::wideWidthOfPlane ( ) const
inline

Extent of wire plane at wide end of trapezoid

Definition at line 51 of file CSCWireGeometry.h.

References theWideWidthOfPlane.

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

51  {
52  return theWideWidthOfPlane; }
double theWideWidthOfPlane
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().

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 35 of file CSCWireGeometry.cc.

References alignmentValidation::c1, i, intersection(), j, lengthOfPlane(), LogTrace, narrowWidthOfPlane(), funct::tan(), wideWidthOfPlane(), wireAngle(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), yOfFirstWire(), and yOfWire().

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

35  {
36 
37  // return local (x, y) of each end of wire.
38  // If wire does not intersect active area set all values to 0.
39 
40  const float fprec = 1.E-06;
41 
42  // slope of wire
43  float wangle = wireAngle();
44  float mw = 0;
45  if ( fabs(wangle) > fprec ) mw = tan( wireAngle() );
46 
47  // intercept of wire
48  float cw = yOfWire( wire );
49 
50  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire=" << wire <<
51  ", wire angle = " << wangle <<
52  ", intercept on y axis=" << cw;
53 
54  // Find extent of wire plane
55  double ww = wideWidthOfPlane();
56  double nw = narrowWidthOfPlane();
57  double len = lengthOfPlane();
58 
59  // slope & intercept of line defining one non-parallel edge of wire-plane trapezoid
60  float m1 = 2.*len/(ww-nw);
61  float c1 = 0.;
62  if ( fabs(wangle) < fprec ) {
63  c1 = yOfFirstWire() - nw*len/(ww-nw) ; // non-ME11
64  }
65  else {
66  c1 = -len/2. - nw*len/(ww-nw); // ME11
67  }
68 
69  // slope & intercept of other non-parallel edge of wire-plane trapezoid
70  float m2 = -m1;
71  float c2 = c1;
72 
73  // wire intersects edge 1 at
74  LocalPoint pw1 = intersection(mw, cw, m1, c1);
75  // wire intersects edge 2 at
76  LocalPoint pw2 = intersection(mw, cw, m2, c2);
77 
78  float x1 = pw1.x();
79  float y1 = pw1.y();
80 
81  float x2 = pw2.x();
82  float y2 = pw2.y();
83 
84  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire intersects edges of plane at " <<
85  "\n x1=" << x1 << " y1=" << y1 <<
86  " x2=" << x2 << " y2=" << y2;
87 
88  // WIRES ARE NOT TILTED?
89 
90  if ( fabs(wangle) < fprec ) {
91 
92  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wires are not tilted ";
93  return std::pair< LocalPoint, LocalPoint >( LocalPoint(x1,y1), LocalPoint(x2,y2) );
94  }
95 
96  // WIRES ARE TILTED
97 
98  // ht and hb will be used to check where wire intersects edges of wire plane
99  float ht = ww/2. ;
100  float hb = nw/2. ;
101  float mt = 0.; // slope of top edge
102  float mb = 0.; //slope of bottom edge
103  float cb = -len/2.; // intercept bottom edge of wire plane
104  float ct = len/2.; // intercept top edge of wire plane
105 
106  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: slopes & intercepts " <<
107  "\n mt=" << mt << " ct=" << ct << " mb=" << mb << " cb=" << cb <<
108  "\n m1=" << m1 << " c1=" << c1 << " m2=" << m2 << " c2=" << c2 <<
109  "\n mw=" << mw << " cw=" << cw;
110 
111  // wire intersects top edge at
112  LocalPoint pwt = intersection(mw, cw, mt, ct);
113  // wire intersects bottom edge at
114  LocalPoint pwb = intersection(mw, cw, mb, cb);
115 
116  // get the local coordinates
117  float xt = pwt.x();
118  float yt = pwt.y();
119 
120  float xb = pwb.x();
121  float yb = pwb.y();
122 
123  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire intersects top & bottom of wire plane at " <<
124  "\n xt=" << xt << " yt=" << yt <<
125  " xb=" << xb << " yb=" << yb ;
126 
127  float xWireEnd[4], yWireEnd[4];
128 
129  int i = 0;
130  if ( fabs(x1) >= hb && fabs(x1) <= ht ) {
131  // wire does intersect side edge 1 of wire plane
132  xWireEnd[i] = x1;
133  yWireEnd[i] = y1;
134  i++;
135  }
136  if ( fabs(xb) <= hb ) {
137  // wire does intersect bottom edge of wire plane
138  xWireEnd[i] = xb;
139  yWireEnd[i] = yb;
140  i++;
141  }
142  if ( fabs(x2) >= hb && fabs(x2) <= ht ) {
143  // wire does intersect side edge 2 of wire plane
144  xWireEnd[i] = x2;
145  yWireEnd[i] = y2;
146  i++;
147  }
148  if ( fabs(xt) <= ht ) {
149  // wire does intersect top edge of wire plane
150  xWireEnd[i] = xt;
151  yWireEnd[i] = yt;
152  i++;
153  }
154 
155  if ( i != 2 ) {
156  // the wire does not intersect the wire plane (!)
157 
158  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire does not intersect wire plane!!";
159  // throw cms::Exception("BadCSCGeometry") << "the wire has " << i <<
160  // " ends!" << "\n";
161 
162  return std::pair< LocalPoint, LocalPoint >( LocalPoint(0.,0.), LocalPoint(0.,0.) );
163  }
164 
165  LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: ME11 wire ends ";
166  for ( int j = 0; j<i; j++ ) {
167  LogTrace("CSCWireGeometry|CSC") << " x = " << xWireEnd[j] << " y = " << yWireEnd[j];
168  }
169 
170  return std::pair< LocalPoint, LocalPoint >
171  ( LocalPoint(xWireEnd[0],yWireEnd[0]), LocalPoint(xWireEnd[1],yWireEnd[1]) );
172 }
int i
Definition: DBlmapReader.cc:9
double narrowWidthOfPlane() const
double wideWidthOfPlane() const
T y() const
Definition: PV3DBase.h:63
virtual float yOfWire(float wire, float x=0.) const =0
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int j
Definition: DBlmapReader.cc:9
double lengthOfPlane() const
#define LogTrace(id)
LocalPoint intersection(float m1, float c1, float m2, float c2) const
double yOfFirstWire() const
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
T x() const
Definition: PV3DBase.h:62
virtual float wireAngle() const =0
double CSCWireGeometry::wireSpacing ( ) const
inline
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 18 of file CSCWireGeometry.cc.

References mathSSE::sqrt(), and wireEnds().

Referenced by CSCWireTopology::wireValues().

18  {
19 
20  // return x and y of mid-point of wire, and length of wire, as 3-dim vector.
21  // If wire does not intersect active area the returned vector is filled with 0's.
22 
23  std::pair< LocalPoint, LocalPoint > ends = wireEnds( wire );
24 
25  std::vector<float> buf(3); // note all elem init to 0
26 
27  buf[0] = (ends.first.x() + ends.second.x())/2.; // x is first elem of first & second pairs
28  buf[1] = (ends.first.y() + ends.second.y())/2.; // y is second elem of first & second pairs
29  float d2 = (ends.first.x() - ends.second.x()) * (ends.first.x() - ends.second.x()) +
30  (ends.first.y() - ends.second.y()) * (ends.first.y() - ends.second.y());
31  buf[2] = sqrt(d2) ;
32  return buf;
33 }
T sqrt(T t)
Definition: SSEVec.h:48
std::pair< LocalPoint, LocalPoint > wireEnds(float wire) const
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 197 of file CSCWireGeometry.cc.

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

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

197  {
198 
199  const float fprec = 0.1; // wire angle is either 0 or 29 degrees = 0.506 rads
200  float ylow = yOfFirstWire(); // non-ME11 chambers
201  float wangle = wireAngle();
202  if ( fabs(wangle) > fprec ) {
203  ylow += tan( std::abs(wangle) ) * narrowWidthOfPlane()/2.; // correction for ME11
204  }
205  float yhigh = ylow + lengthOfPlane(); // add extent of wire plane in y
206 
207  return std::pair<float, float>(ylow, yhigh);
208 }
double narrowWidthOfPlane() const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double lengthOfPlane() const
double yOfFirstWire() const
virtual float wireAngle() const =0
double CSCWireGeometry::yOfFirstWire ( ) const
inline

The local y of the first wire

Definition at line 39 of file CSCWireGeometry.h.

References theYOfFirstWire.

Referenced by CSCNonslantedWireGeometry::nearestWire(), wireEnds(), yLimitsOfWirePlane(), and CSCNonslantedWireGeometry::yOfWire().

39  {
40  return theYOfFirstWire; }
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

double CSCWireGeometry::theLengthOfPlane
private

Definition at line 119 of file CSCWireGeometry.h.

Referenced by lengthOfPlane().

double CSCWireGeometry::theNarrowWidthOfPlane
private

Definition at line 117 of file CSCWireGeometry.h.

Referenced by narrowWidthOfPlane().

double CSCWireGeometry::theWideWidthOfPlane
private

Definition at line 118 of file CSCWireGeometry.h.

Referenced by wideWidthOfPlane().

double CSCWireGeometry::theWireSpacing
private

Definition at line 115 of file CSCWireGeometry.h.

Referenced by wireSpacing().

double CSCWireGeometry::theYOfFirstWire
private

Definition at line 116 of file CSCWireGeometry.h.

Referenced by yOfFirstWire().