Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h"
0002 
0003 #include <iostream>
0004 #include <cmath>
0005 #include <algorithm>
0006 
0007 TrapezoidalStripTopology::TrapezoidalStripTopology(int ns, float p, float l, float r0)
0008     : theNumberOfStrips(ns), thePitch(p), theDistToBeam(r0), theDetHeight(l) {
0009   theOffset = -theNumberOfStrips / 2. * thePitch;
0010   theYAxOr = 1;
0011 #ifdef VERBOSE
0012   cout << "Constructing TrapezoidalStripTopology with"
0013        << " nstrips = " << ns << " pitch = " << p << " length = " << l << " r0 =" << r0 << endl;
0014 #endif
0015 }
0016 
0017 TrapezoidalStripTopology::TrapezoidalStripTopology(int ns, float p, float l, float r0, int yAx)
0018     : theNumberOfStrips(ns), thePitch(p), theDistToBeam(r0), theDetHeight(l), theYAxOr(yAx) {
0019   theOffset = -theNumberOfStrips / 2. * thePitch;
0020 #ifdef VERBOSE
0021   cout << "Constructing TrapezoidalStripTopology with"
0022        << " nstrips = " << ns << " pitch = " << p << " length = " << l << " r0 =" << r0 << " yAxOrientation =" << yAx
0023        << endl;
0024 #endif
0025 }
0026 
0027 LocalPoint TrapezoidalStripTopology::localPosition(float strip) const {
0028   return LocalPoint(strip * thePitch + theOffset, 0.0);
0029 }
0030 
0031 LocalPoint TrapezoidalStripTopology::localPosition(const MeasurementPoint& mp) const {
0032   float y = mp.y() * theDetHeight;
0033   float x = (mp.x() * thePitch + theOffset) * (theYAxOr * y + theDistToBeam) / theDistToBeam;
0034   return LocalPoint(x, y);
0035 }
0036 
0037 LocalError TrapezoidalStripTopology::localError(float strip, float stripErr2) const {
0038   float lt, lc2, ls2, lslc;
0039   float localL2, localP2;
0040   float sl2, sp2;
0041   // angle from strip to local frame (see CMS TN / 95-170)
0042   lt = -(strip * thePitch + theOffset) * theYAxOr / theDistToBeam;
0043   lc2 = 1.f / (1. + lt * lt);
0044   lslc = lt * lc2;
0045   ls2 = 1.f - lc2;
0046   localL2 = theDetHeight * theDetHeight / lc2;
0047   localP2 = thePitch * thePitch * lc2;
0048   sl2 = localL2 / 12.;
0049   sp2 = stripErr2 * localP2;
0050   return LocalError(lc2 * sp2 + ls2 * sl2, lslc * (sp2 - sl2), ls2 * sp2 + lc2 * sl2);
0051 }
0052 
0053 LocalError TrapezoidalStripTopology::localError(const MeasurementPoint& mp, const MeasurementError& merr) const {
0054   float lt, lc2, ls2, lslc;
0055   float localL, localP;
0056   float sl2, sp2, spl;
0057   // angle from strip to local frame (see CMS TN / 95-170)
0058   lt = -(mp.x() * thePitch + theOffset) * theYAxOr / theDistToBeam;
0059   lc2 = 1. / (1. + lt * lt);
0060   lslc = lt * lc2;
0061   ls2 = 1.f - lc2;
0062   localL = theDetHeight / std::sqrt(lc2);
0063   localP = localPitch(localPosition(mp));
0064   sp2 = merr.uu() * localP * localP;
0065   sl2 = merr.vv() * localL * localL;
0066   spl = merr.uv() * localP * localL;
0067   return LocalError(lc2 * sp2 + ls2 * sl2 - 2 * lslc * spl,
0068                     lslc * (sp2 - sl2) + (lc2 - ls2) * spl,
0069                     ls2 * sp2 + lc2 * sl2 + 2 * lslc * spl);
0070 }
0071 
0072 float TrapezoidalStripTopology::strip(const LocalPoint& lp) const {
0073   float aStrip = ((lp.x() * theDistToBeam / (theYAxOr * lp.y() + theDistToBeam)) - theOffset) / thePitch;
0074   if (aStrip < 0)
0075     aStrip = 0;
0076   else if (aStrip > theNumberOfStrips)
0077     aStrip = theNumberOfStrips;
0078   return aStrip;
0079 }
0080 
0081 MeasurementPoint TrapezoidalStripTopology::measurementPosition(const LocalPoint& lp) const {
0082   return MeasurementPoint(((lp.x() * theDistToBeam / (theYAxOr * lp.y() + theDistToBeam)) - theOffset) / thePitch,
0083                           lp.y() / theDetHeight);
0084 }
0085 
0086 MeasurementError TrapezoidalStripTopology::measurementError(const LocalPoint& lp, const LocalError& lerr) const {
0087   float lt, lc2, ls2, lslc;
0088   float localL, localP;
0089   float sl2, sp2, spl;
0090   lt = -lp.x() / (theYAxOr * lp.y() + theDistToBeam) * theYAxOr;
0091   lc2 = 1. / (1. + lt * lt);
0092   lslc = lt * lc2;
0093   ls2 = 1. - lc2;
0094   localL = theDetHeight / std::sqrt(lc2);
0095   localP = localPitch(lp);
0096   sp2 = lc2 * lerr.xx() + ls2 * lerr.yy() + 2 * lslc * lerr.xy();
0097   sl2 = ls2 * lerr.xx() + lc2 * lerr.yy() - 2 * lslc * lerr.xy();
0098   spl = lslc * (lerr.yy() - lerr.xx()) + (lc2 - ls2) * lerr.xy();
0099   return MeasurementError(sp2 / (localP * localP), spl / (localP * localL), sl2 / (localL * localL));
0100 }
0101 
0102 int TrapezoidalStripTopology::channel(const LocalPoint& lp) const {
0103   return std::min(int(strip(lp)), theNumberOfStrips - 1);
0104 }
0105 
0106 float TrapezoidalStripTopology::pitch() const { return thePitch; }
0107 
0108 float TrapezoidalStripTopology::localPitch(const LocalPoint& lp) const {
0109   float x = lp.x();
0110   float y = theYAxOr * lp.y() + theDistToBeam;
0111   return thePitch * y / (theDistToBeam * std::sqrt(1.f + x * x / (y * y)));
0112 }
0113 
0114 float TrapezoidalStripTopology::stripAngle(float strip) const {
0115   return std::atan(-(strip * thePitch + theOffset) * theYAxOr / theDistToBeam);
0116 }
0117 
0118 int TrapezoidalStripTopology::nstrips() const { return theNumberOfStrips; }
0119 
0120 float TrapezoidalStripTopology::shiftOffset(float pitch_fraction) {
0121   theOffset += thePitch * pitch_fraction;
0122   return theOffset;
0123 }
0124 
0125 float TrapezoidalStripTopology::localStripLength(const LocalPoint& lp) const {
0126   float ltan = -lp.x() / (theYAxOr * lp.y() + theDistToBeam) * theYAxOr;
0127   float localL = theDetHeight * std::sqrt(1.f + ltan * ltan);
0128   //  float lcos2 = 1.f/(1.f+ltan*ltan);
0129   //  float localL = theDetHeight / std::sqrt(lcos2);
0130 
0131   return localL;
0132 }