Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:24

0001 // This is OffsetRadialStripTopology.cc
0002 
0003 // Implementation and use of base class RST depends crucially on stripAngle() being defined
0004 // to include the angular strip offset relative to the local coordinate frame, while
0005 // phiOfOneEdge() remains unchanged from its RST interpretation (i.e. phiOfOneEdge remains
0006 // measured relative to the symmetry axis of the strip plane even in the OffsetRST case.)
0007 // To help understand the implementation below I use the notation 'prime' for the local
0008 // coordinate system rotated from the true local coordinate system by the angular offset
0009 // of the offset RST. Thus the 'prime' system is aligned with the symmetry axes of the
0010 // strip plane of the ORST.
0011 // The following functions in the base class RST work fine for the ORST too since
0012 // they're implemented in terms of stripAngle() and this is overridden for the ORST
0013 // so that the angular offset is included:
0014 //  xOfStrip(.)
0015 //  localPitch(.)
0016 //  localError(.,.)
0017 //  localError(.,.)
0018 //  measurementError(.,.)
0019 
0020 #include <Geometry/CSCGeometry/interface/OffsetRadialStripTopology.h>
0021 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0022 
0023 #include <iostream>
0024 #include <cmath>
0025 
0026 OffsetRadialStripTopology::OffsetRadialStripTopology(int numberOfStrips,
0027                                                      float stripPhiPitch,
0028                                                      float detectorHeight,
0029                                                      float radialDistance,
0030                                                      float stripOffset,
0031                                                      float yCentre)
0032     : CSCRadialStripTopology(numberOfStrips, stripPhiPitch, detectorHeight, radialDistance, +1, yCentre),
0033       theStripOffset(stripOffset) {
0034   float rotate_by = stripOffset * angularWidth();  // now in angular units (radians, I hope)
0035   theCosOff = cos(rotate_by);
0036   theSinOff = sin(rotate_by);
0037 
0038   LogTrace("CSCStripTopology|CSC") << "fractional strip offset = " << stripOffset << "\n angle = " << rotate_by
0039                                    << " cos = " << theCosOff << " sin = " << theSinOff;
0040 }
0041 
0042 LocalPoint OffsetRadialStripTopology::localPosition(const MeasurementPoint& mp) const {
0043   // Local coordinates are (x,y). Coordinates along symmetry axes of strip
0044   // plane are (x',y'). These are rotated w.r.t. (x,y)
0045 
0046   // You might first think you could implement this as follows (cf. measurementPosition below):
0047   //  LocalPoint lpp = RST::localPosition(MP);
0048   //  return this->toLocal(lpp);
0049   // But this does not work because RST::localPosition makes use of stripAngle() - virtual - and thus
0050   // this is not the appropriate angle - it has the offset added, which is unwanted in this case!
0051   // So have to implement it directly...
0052 
0053   // 1st component of MP measures angular position within strip plane
0054   float phi = phiOfOneEdge() + mp.x() * angularWidth();
0055   // 2nd component of MP is fractional position along strip, with range +/-0.5,
0056   // so distance along strip, measured from mid-point of length of strip, is
0057   //     mp.y() * (length of strip).
0058   // Distance in direction of coordinate y' is
0059   //    mp.y() * (length of strip) * cos(phi)
0060   // where phi is angle between strip and y' axis.
0061   // But (length of strip) = detHeight/cos(phi), so
0062   float yprime = mp.y() * detHeight() + yCentreOfStripPlane();
0063   float xprime = (originToIntersection() + yprime) * tan(phi);
0064   //  Rotate to (x,y)
0065   return toLocal(xprime, yprime);
0066 }
0067 
0068 MeasurementPoint OffsetRadialStripTopology::measurementPosition(const LocalPoint& lp) const {
0069   LocalPoint lpp = this->toPrime(lp);                       // in prime system, aligned with strip plane sym axes
0070   return CSCRadialStripTopology::measurementPosition(lpp);  // now can use the base class method
0071 }
0072 
0073 float OffsetRadialStripTopology::strip(const LocalPoint& lp) const {
0074   LocalPoint pnt = toPrime(lp);
0075   float phi = atan2(pnt.x(), pnt.y() + originToIntersection());
0076   float fstrip = (phi - phiOfOneEdge()) / angularWidth();
0077   fstrip = (fstrip >= 0. ? fstrip : 0.);
0078   fstrip = (fstrip <= nstrips() ? fstrip : nstrips());
0079   return fstrip;
0080 }
0081 
0082 float OffsetRadialStripTopology::stripAngle(float strip) const {
0083   return (phiOfOneEdge() + (strip + theStripOffset) * angularWidth());
0084 }
0085 
0086 LocalPoint OffsetRadialStripTopology::toLocal(float xprime, float yprime) const {
0087   float x = theCosOff * xprime + theSinOff * yprime + originToIntersection() * theSinOff;
0088   float y = -theSinOff * xprime + theCosOff * yprime - originToIntersection() * (1. - theCosOff);
0089   return LocalPoint(x, y);
0090 }
0091 
0092 LocalPoint OffsetRadialStripTopology::toPrime(const LocalPoint& lp) const {
0093   float xprime = theCosOff * lp.x() - theSinOff * lp.y() - originToIntersection() * theSinOff;
0094   float yprime = theSinOff * lp.x() + theCosOff * lp.y() - originToIntersection() * (1. - theCosOff);
0095   return LocalPoint(xprime, yprime);
0096 }
0097 
0098 std::ostream& operator<<(std::ostream& os, const OffsetRadialStripTopology& orst) {
0099   os << "OffsetRadialStripTopology isa " << static_cast<const CSCRadialStripTopology&>(orst)
0100      << "fractional strip offset   " << orst.stripOffset() << "\ncos(angular offset)       " << orst.theCosOff
0101      << "\nsin(angular offset)       " << orst.theSinOff << std::endl;
0102   return os;
0103 }