Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:52

0001 #include <Geometry/CommonTopologies/interface/CSCRadialStripTopology.h>
0002 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0003 
0004 #include <cmath>
0005 #include <algorithm>
0006 
0007 CSCRadialStripTopology::CSCRadialStripTopology(int ns, float aw, float dh, float r, float yAx, float yMid)
0008     : theNumberOfStrips(ns),
0009       theAngularWidth(aw),
0010       theDetHeight(dh),
0011       theCentreToIntersection(r),
0012       theYAxisOrientation(yAx),
0013       yCentre(yMid) {
0014   // Angular offset of extreme edge of detector, so that angle is
0015   // zero for a strip lying along local y axis = long symmetry axis of plane of strips
0016   thePhiOfOneEdge = -(0.5 * theNumberOfStrips) * theAngularWidth * yAx;
0017 
0018   LogTrace("CSCRadialStripTopology") << "CSCRadialStripTopology: constructed with"
0019                                      << " strips = " << ns << " width = " << aw << " rad "
0020                                      << " det_height = " << dh << " ctoi = " << r << " phi_edge = " << thePhiOfOneEdge
0021                                      << " rad "
0022                                      << " y_ax_ori = " << theYAxisOrientation << " y_det_centre = " << yCentre << "\n";
0023 }
0024 
0025 int CSCRadialStripTopology::channel(const LocalPoint& lp) const {
0026   return std::min(int(strip(lp)), theNumberOfStrips - 1);
0027 }
0028 
0029 int CSCRadialStripTopology::nearestStrip(const LocalPoint& lp) const {
0030   return std::min(nstrips(), static_cast<int>(std::max(float(0), strip(lp))) + 1);
0031 }
0032 
0033 float CSCRadialStripTopology::stripAngle(float strip) const {
0034   return phiOfOneEdge() + yAxisOrientation() * strip * angularWidth();
0035 }
0036 
0037 float CSCRadialStripTopology::yDistanceToIntersection(float y) const {
0038   return yAxisOrientation() * y + originToIntersection();
0039 }
0040 
0041 float CSCRadialStripTopology::localStripLength(const LocalPoint& lp) const {
0042   return detHeight() * std::sqrt(1.f + std::pow(lp.x() / yDistanceToIntersection(lp.y()), 2.f));
0043 }
0044 
0045 float CSCRadialStripTopology::xOfStrip(int strip, float y) const {
0046   return yAxisOrientation() * yDistanceToIntersection(y) * std::tan(stripAngle(static_cast<float>(strip) - 0.5));
0047 }
0048 
0049 float CSCRadialStripTopology::strip(const LocalPoint& lp) const {
0050   const float  // phi is measured from y axis --> sign of angle is sign of x * yAxisOrientation --> use atan2(x,y), not atan2(y,x)
0051       phi(std::atan2(lp.x(), yDistanceToIntersection(lp.y()))),
0052       aStrip((phi - yAxisOrientation() * phiOfOneEdge()) / angularWidth());
0053   return std::max(float(0), std::min((float)nstrips(), aStrip));
0054 }
0055 
0056 LocalPoint CSCRadialStripTopology::localPosition(float strip) const {
0057   return LocalPoint(yAxisOrientation() * originToIntersection() * tan(stripAngle(strip)), 0);
0058 }
0059 
0060 LocalPoint CSCRadialStripTopology::localPosition(const MeasurementPoint& mp) const {
0061   const float  // y = (L/cos(phi))*mp.y()*cos(phi)
0062       y(mp.y() * detHeight() + yCentreOfStripPlane()),
0063       x(yAxisOrientation() * yDistanceToIntersection(y) * std::tan(stripAngle(mp.x())));
0064   return LocalPoint(x, y);
0065 }
0066 
0067 MeasurementPoint CSCRadialStripTopology::measurementPosition(const LocalPoint& lp) const {
0068   const float  // phi is [pi/2 - conventional local phi], use atan2(x,y) rather than atan2(y,x)
0069       phi(yAxisOrientation() * std::atan2(lp.x(), yDistanceToIntersection(lp.y())));
0070   return MeasurementPoint(yAxisOrientation() * (phi - phiOfOneEdge()) / angularWidth(),
0071                           (lp.y() - yCentreOfStripPlane()) / detHeight());
0072 }
0073 
0074 LocalError CSCRadialStripTopology::localError(float strip, float stripErr2) const {
0075   const double phi(stripAngle(strip)), t1(std::tan(phi)), t2(t1 * t1),
0076       // s1(std::sin(phi)), c1(std::cos(phi)),
0077       // cs(s1*c1), s2(s1*s1), c2(1-s2), // rotation matrix
0078 
0079       tt(stripErr2 * std::pow(centreToIntersection() * angularWidth(), 2.f)),  // tangential sigma^2   *c2
0080       rr(std::pow(detHeight(), 2.f) * (1.f / 12.f)),  // radial sigma^2( uniform prob density along strip)  *c2
0081 
0082       xx(tt + t2 * rr), yy(t2 * tt + rr), xy(t1 * (rr - tt));
0083 
0084   return LocalError(xx, xy, yy);
0085 }
0086 
0087 LocalError CSCRadialStripTopology::localError(const MeasurementPoint& mp, const MeasurementError& me) const {
0088   const double phi(stripAngle(mp.x())), s1(std::sin(phi)), c1(std::cos(phi)), cs(s1 * c1), s2(s1 * s1),
0089       c2(1 - s2),  // rotation matrix
0090 
0091       T(angularWidth() * (centreToIntersection() + yAxisOrientation() * mp.y() * detHeight()) /
0092         c1),                // tangential measurement unit (local pitch)
0093       R(detHeight() / c1),  // radial measurement unit (strip length)
0094       tt(me.uu() * T * T),  // tangential sigma^2
0095       rr(me.vv() * R * R),  // radial sigma^2
0096       tr(me.uv() * T * R),
0097 
0098       xx(c2 * tt + 2 * cs * tr + s2 * rr), yy(s2 * tt - 2 * cs * tr + c2 * rr), xy(cs * (rr - tt) + tr * (c2 - s2));
0099 
0100   return LocalError(xx, xy, yy);
0101 }
0102 
0103 MeasurementError CSCRadialStripTopology::measurementError(const LocalPoint& p, const LocalError& e) const {
0104   const double yHitToInter(yDistanceToIntersection(p.y())),
0105       t(yAxisOrientation() * p.x() / yHitToInter),  // tan(strip angle)
0106       cs(t / (1 + t * t)), s2(t * cs), c2(1 - s2),  // rotation matrix
0107 
0108       T2(1. / (std::pow(angularWidth(), 2.f) *
0109                (std::pow(p.x(), 2.f) + std::pow(yHitToInter, 2)))),  // 1./tangential measurement unit (local pitch) ^2
0110       R2(c2 / std::pow(detHeight(), 2.f)),                           // 1./ radial measurement unit (strip length) ^2
0111 
0112       uu((c2 * e.xx() - 2 * cs * e.xy() + s2 * e.yy()) * T2), vv((s2 * e.xx() + 2 * cs * e.xy() + c2 * e.yy()) * R2),
0113       uv((cs * (e.xx() - e.yy()) + e.xy() * (c2 - s2)) * std::sqrt(T2 * R2));
0114 
0115   return MeasurementError(uu, uv, vv);
0116 }
0117 
0118 float CSCRadialStripTopology::localPitch(const LocalPoint& lp) const {
0119   // The local pitch is the local x width of the strip at the local (x,y)
0120   const int istrip = std::min(nstrips(), static_cast<int>(strip(lp)) + 1);  // which strip number
0121   const float fangle = stripAngle(static_cast<float>(istrip) - 0.5);        // angle of strip centre
0122   return yDistanceToIntersection(lp.y()) * std::sin(angularWidth()) /
0123          std::pow(std::cos(fangle - 0.5f * angularWidth()), 2.f);
0124 }