Go to the documentation of this file.00001 #include "Geometry/CSCGeometry/interface/CSCWireGeometry.h"
00002
00003 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00004
00005 #include <cmath>
00006
00007 LocalPoint CSCWireGeometry::intersection( float m1, float c1,
00008 float m2, float c2 ) const {
00009
00010
00011
00012
00013 float x = (c2-c1)/(m1-m2);
00014 float y = (m1*c2-m2*c1)/(m1-m2);
00015 return LocalPoint( x, y );
00016 }
00017
00018 std::vector<float> CSCWireGeometry::wireValues( float wire ) const {
00019
00020
00021
00022
00023 std::pair< LocalPoint, LocalPoint > ends = wireEnds( wire );
00024
00025 std::vector<float> buf(3);
00026
00027 buf[0] = (ends.first.x() + ends.second.x())/2.;
00028 buf[1] = (ends.first.y() + ends.second.y())/2.;
00029 float d2 = (ends.first.x() - ends.second.x()) * (ends.first.x() - ends.second.x()) +
00030 (ends.first.y() - ends.second.y()) * (ends.first.y() - ends.second.y());
00031 buf[2] = sqrt(d2) ;
00032 return buf;
00033 }
00034
00035 std::pair< LocalPoint, LocalPoint > CSCWireGeometry::wireEnds( float wire ) const {
00036
00037
00038
00039
00040 const float fprec = 1.E-06;
00041
00042
00043 float wangle = wireAngle();
00044 float mw = 0;
00045 if ( fabs(wangle) > fprec ) mw = tan( wireAngle() );
00046
00047
00048 float cw = yOfWire( wire );
00049
00050 LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire=" << wire <<
00051 ", wire angle = " << wangle <<
00052 ", intercept on y axis=" << cw;
00053
00054
00055 double ww = wideWidthOfPlane();
00056 double nw = narrowWidthOfPlane();
00057 double len = lengthOfPlane();
00058
00059
00060 float m1 = 2.*len/(ww-nw);
00061 float c1 = 0.;
00062 if ( fabs(wangle) < fprec ) {
00063 c1 = yOfFirstWire() - nw*len/(ww-nw) ;
00064 }
00065 else {
00066 c1 = -len/2. - nw*len/(ww-nw);
00067 }
00068
00069
00070 float m2 = -m1;
00071 float c2 = c1;
00072
00073
00074 LocalPoint pw1 = intersection(mw, cw, m1, c1);
00075
00076 LocalPoint pw2 = intersection(mw, cw, m2, c2);
00077
00078 float x1 = pw1.x();
00079 float y1 = pw1.y();
00080
00081 float x2 = pw2.x();
00082 float y2 = pw2.y();
00083
00084 LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire intersects edges of plane at " <<
00085 "\n x1=" << x1 << " y1=" << y1 <<
00086 " x2=" << x2 << " y2=" << y2;
00087
00088
00089
00090 if ( fabs(wangle) < fprec ) {
00091
00092 LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wires are not tilted ";
00093 return std::pair< LocalPoint, LocalPoint >( LocalPoint(x1,y1), LocalPoint(x2,y2) );
00094 }
00095
00096
00097
00098
00099 float ht = ww/2. ;
00100 float hb = nw/2. ;
00101 float mt = 0.;
00102 float mb = 0.;
00103 float cb = -len/2.;
00104 float ct = len/2.;
00105
00106 LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: slopes & intercepts " <<
00107 "\n mt=" << mt << " ct=" << ct << " mb=" << mb << " cb=" << cb <<
00108 "\n m1=" << m1 << " c1=" << c1 << " m2=" << m2 << " c2=" << c2 <<
00109 "\n mw=" << mw << " cw=" << cw;
00110
00111
00112 LocalPoint pwt = intersection(mw, cw, mt, ct);
00113
00114 LocalPoint pwb = intersection(mw, cw, mb, cb);
00115
00116
00117 float xt = pwt.x();
00118 float yt = pwt.y();
00119
00120 float xb = pwb.x();
00121 float yb = pwb.y();
00122
00123 LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire intersects top & bottom of wire plane at " <<
00124 "\n xt=" << xt << " yt=" << yt <<
00125 " xb=" << xb << " yb=" << yb ;
00126
00127 float xWireEnd[4], yWireEnd[4];
00128
00129 int i = 0;
00130 if ( fabs(x1) >= hb && fabs(x1) <= ht ) {
00131
00132 xWireEnd[i] = x1;
00133 yWireEnd[i] = y1;
00134 i++;
00135 }
00136 if ( fabs(xb) <= hb ) {
00137
00138 xWireEnd[i] = xb;
00139 yWireEnd[i] = yb;
00140 i++;
00141 }
00142 if ( fabs(x2) >= hb && fabs(x2) <= ht ) {
00143
00144 xWireEnd[i] = x2;
00145 yWireEnd[i] = y2;
00146 i++;
00147 }
00148 if ( fabs(xt) <= ht ) {
00149
00150 xWireEnd[i] = xt;
00151 yWireEnd[i] = yt;
00152 i++;
00153 }
00154
00155 if ( i != 2 ) {
00156
00157
00158 LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire does not intersect wire plane!!";
00159
00160
00161
00162 return std::pair< LocalPoint, LocalPoint >( LocalPoint(0.,0.), LocalPoint(0.,0.) );
00163 }
00164
00165 LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: ME11 wire ends ";
00166 for ( int j = 0; j<i; j++ ) {
00167 LogTrace("CSCWireGeometry|CSC") << " x = " << xWireEnd[j] << " y = " << yWireEnd[j];
00168 }
00169
00170 return std::pair< LocalPoint, LocalPoint >
00171 ( LocalPoint(xWireEnd[0],yWireEnd[0]), LocalPoint(xWireEnd[1],yWireEnd[1]) );
00172 }
00173
00174
00175
00176 std::pair<float, float> CSCWireGeometry::equationOfWire( float wire ) const {
00177
00178 const float fprec = 1.E-06;
00179
00180
00181 float wangle = wireAngle();
00182 float mw = 0;
00183 if ( fabs(wangle) > fprec ) mw = tan( wangle );
00184
00185
00186 float cw = yOfWire( wire );
00187
00188 LogTrace("CSCWireGeometry|CSC") << "CSCWireGeometry: wire=" << wire <<
00189 ", wire angle = " << wangle <<
00190 ", intercept on y axis=" << cw;
00191
00192 return std::pair<float,float>(mw, cw);
00193 }
00194
00195
00196
00197 std::pair<float, float> CSCWireGeometry::yLimitsOfWirePlane() const{
00198
00199 const float fprec = 0.1;
00200 float ylow = yOfFirstWire();
00201 float wangle = wireAngle();
00202 if ( fabs(wangle) > fprec ) {
00203 ylow += tan( wangle ) * narrowWidthOfPlane()/2.;
00204 }
00205 float yhigh = ylow + lengthOfPlane();
00206
00207 return std::pair<float, float>(ylow, yhigh);
00208 }
00209