Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Geometry_CSCGeometry_CSCLayerGeometry_H
0002 #define Geometry_CSCGeometry_CSCLayerGeometry_H
0003 
0004 /** \class CSCLayerGeometry
0005  *
0006  * Encapsulates the geometrical details of a CSCLayer
0007  * in a WireTopology for the wires and in a StripTopology for the strips.
0008  * Note that it does not have the capability of calculating
0009  * global values, so all values are in local coordinates.
0010  *
0011  * \author Tim Cox
0012  */
0013 
0014 #include <Geometry/CSCGeometry/interface/CSCStripTopology.h>
0015 #include <Geometry/CSCGeometry/interface/CSCWireTopology.h>
0016 #include <DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h>
0017 #include <DataFormats/GeometryVector/interface/LocalPoint.h>
0018 #include <DataFormats/GeometrySurface/interface/LocalError.h>
0019 
0020 #include <utility>  // for std::pair
0021 
0022 class CSCGeometry;
0023 class CSCWireGroupPackage;
0024 
0025 class CSCLayerGeometry : public TrapezoidalPlaneBounds {
0026 public:
0027   /**
0028    * Ctor from basic trapezoidal Chamber parameters.
0029    * \param geom The pointer to the actual CSCGeometry we're building.
0030    * \param iChamberType The index 1-9 for station/ring combination.
0031    * \param TrapezoidalPlaneBounds describing geometry of face.
0032    * \param nstrips No. of strips in cathode plane of a Layer.
0033    * \param stripOffset Alternate strip planes are relatively shifted by +/-0.25 strip widths.
0034    * \param stripPhiPitch Delta-phi width of strips (they're fan-shaped) in radians
0035    * \param whereStripsMeet radial distance from projected intersection of strips to centre of strip plane
0036    * \param extentOfStripPlane height of strip plane (along its long symmetry axis)
0037    * \param yCentreOfStripPlane local y of symmetry centre of strip plane (before any offset rotation)
0038    * \param wg CSCWireGroupPackage encapsulating wire group info.
0039    * \param wireAngleInDegrees angle of wires w.r.t local x axis.
0040    * \param yOfFirstWire local y coordinate of first (lowest) wire in wire plane - nearest narrow edge.
0041    * \param hThickness half-thickness of chamber layer in cm (i.e. half the gas gap).
0042    */
0043   CSCLayerGeometry(const CSCGeometry* geom,
0044                    int iChamberType,
0045                    const TrapezoidalPlaneBounds& bounds,
0046                    int nstrips,
0047                    float stripOffset,
0048                    float stripPhiPitch,
0049                    float whereStripsMeet,
0050                    float extentOfStripPlane,
0051                    float yCentreOfStripPlane,
0052                    const CSCWireGroupPackage& wg,
0053                    float wireAngleInDegrees,
0054                    double yOfFirstWire,
0055                    float hThickness);
0056 
0057   CSCLayerGeometry(const CSCLayerGeometry&);
0058 
0059   CSCLayerGeometry& operator=(const CSCLayerGeometry&);
0060 
0061   ~CSCLayerGeometry() override;
0062 
0063   /**
0064    * How many strips in layer
0065    */
0066   int numberOfStrips() const { return theStripTopology->nstrips(); }
0067 
0068   /**
0069    * How many wires in layer
0070    */
0071   int numberOfWires() const { return theWireTopology->numberOfWires(); }
0072 
0073   /**
0074    * How many wire groups in Layer
0075    */
0076   int numberOfWireGroups() const { return theWireTopology->numberOfWireGroups(); }
0077 
0078   /**
0079    * How many wires in a wiregroup
0080    */
0081   int numberOfWiresPerGroup(int wireGroup) const { return theWireTopology->numberOfWiresPerGroup(wireGroup); }
0082 
0083   /**
0084    * Local point at which strip and wire intersect
0085    */
0086   LocalPoint stripWireIntersection(int strip, float wire) const;
0087 
0088   /**
0089    * Local point at which strip and centre of wire group intersect
0090    */
0091   LocalPoint stripWireGroupIntersection(int strip, int wireGroup) const;
0092 
0093   /**
0094    * Strip nearest a given local point
0095    */
0096   int nearestStrip(const LocalPoint& lp) const { return theStripTopology->nearestStrip(lp); }
0097 
0098   /**
0099    * Wire nearest a given local point
0100    */
0101   int nearestWire(const LocalPoint& lp) const { return theWireTopology->nearestWire(lp); }
0102 
0103   /**
0104    * Wire group containing a given wire
0105    */
0106   int wireGroup(int wire) const { return theWireTopology->wireGroup(wire); }
0107 
0108   /** 
0109    * Electronics channel corresponding to a given strip
0110    * ...sometimes there will be more than one strip OR'ed into a channel
0111    */
0112   int channel(int strip) const { return theStripTopology->channel(strip); }
0113 
0114   /**
0115    * Offset of strips from symmetrical distribution about local y axis
0116    * as a fraction of a strip (0 default, but usually +0.25 or -0.25)
0117    */
0118   float stripOffset(void) const { return theStripTopology->stripOffset(); }
0119 
0120   /**
0121    * Return +1 or -1 for a stripOffset of +0.25 or -0.25 respectively.
0122    * Requested by trigger people.
0123    */
0124   int stagger() const { return static_cast<int>(4.1 * stripOffset()); }
0125 
0126   /**
0127    * The angle (in radians) of a strip wrt local x-axis.
0128    */
0129   float stripAngle(int strip) const;
0130 
0131   /**
0132    * The angle (in radians) of (any) wire wrt local x-axis.
0133    */
0134   float wireAngle() const { return theWireTopology->wireAngle(); }
0135 
0136   /**
0137    * The distance (in cm) between anode wires
0138    */
0139   float wirePitch() const { return theWireTopology->wirePitch(); }
0140 
0141   /**
0142    * The measurement resolution from wire groups (in cm.)
0143    * This approximates the measurement resolution in the local
0144    * y direction but may be too small by a factor of up to 1.26
0145    * due to stripAngle contributions which are neglected here.
0146    * The last wiregroup may have more wires than others.
0147    * The other wiregroups, including the first, are the same.
0148    * One day the wiregroups will be matched to the hardware
0149    * by using the DDD.
0150    */
0151 
0152   float yResolution(int wireGroup = 1) const { return theWireTopology->yResolution(wireGroup); }
0153 
0154   /**
0155    * The phi width of the strips (radians)
0156    */
0157   float stripPhiPitch() const { return theStripTopology->phiPitch(); }
0158 
0159   /**
0160    * The width of the strips (in middle)
0161    */
0162   float stripPitch() const {
0163     //    return theStripTopology->pitch(); }
0164     return stripPitch(LocalPoint(0., 0.));
0165   }
0166 
0167   /**
0168    * The width of the strip at a given local point
0169    */
0170   float stripPitch(const LocalPoint& lp) const { return theStripTopology->localPitch(lp); }
0171 
0172   /**
0173    *  The local x-position of the center of the strip.
0174    */
0175   float xOfStrip(int strip, float y = 0.) const { return theStripTopology->xOfStrip(strip, y); }
0176 
0177   /** Strip in which a given LocalPoint lies. This is a float which
0178    * represents the fractional strip position within the detector.<BR>
0179    * Returns zero if the LocalPoint falls at the extreme low edge of the
0180    * detector or BELOW, and float(nstrips) if it falls at the extreme high
0181    * edge or ABOVE.
0182    */
0183   float strip(const LocalPoint& lp) const { return theStripTopology->strip(lp); }
0184 
0185   /**
0186    * Middle of wire-group.
0187    * This is the central wire no. for a group with an odd no. of wires.
0188    * This is a pseudo-wire no. for a group with an even no. of wires.
0189    * Accordingly, it is non-integer.
0190    */
0191   float middleWireOfGroup(int wireGroup) const { return theWireTopology->middleWireOfGroup(wireGroup); }
0192 
0193   /**
0194    * Local y of a given wire 'number' (float) at given x
0195    */
0196   float yOfWire(float wire, float x = 0.) const { return theWireTopology->yOfWire(wire, x); }
0197 
0198   /**
0199    * Local y of a given wire group at given x
0200    */
0201   float yOfWireGroup(int wireGroup, float x = 0.) const { return theWireTopology->yOfWireGroup(wireGroup, x); }
0202 
0203   /**
0204    * Local coordinates of center of a wire group.
0205    * \WARNING Used to be centerOfWireGroup in ORCA
0206    * but that version now returns GlobalPoint.
0207    */
0208   LocalPoint localCenterOfWireGroup(int wireGroup) const;
0209 
0210   /** 
0211    * Length of a wire group (center wire, across chamber face)
0212    */
0213   float lengthOfWireGroup(int wireGroup) const;
0214 
0215   /**
0216    * Local y limits of the strip plane
0217    */
0218   std::pair<float, float> yLimitsOfStripPlane() const { return theStripTopology->yLimitsOfStripPlane(); }
0219 
0220   /**
0221    * Is a supplied LocalPoint inside the strip region?
0222    * 
0223    * This is a more reliable fiducial cut for CSCs than the 'Bounds' of the GeomDet(Unit)
0224    * since those ranges are looser than the sensitive gas region.
0225    * There are three versions, to parallel those of the TrapezoidalPlaneBounds which
0226    * a naive user might otherwise employ.
0227    */
0228   bool inside(const Local3DPoint&, const LocalError&, float scale = 1.f) const override;
0229   bool inside(const Local3DPoint&) const override;
0230   bool inside(const Local2DPoint&) const override;
0231 
0232   /**
0233    * Return estimate of the 2-dim point of intersection of a strip and a cluster of wires.
0234    *
0235    * Input arguments: a (float) strip number, and the wires which delimit a cluster of wires.
0236    * The wires are expected to be real wire numbers, and not wire-group numbers.<br>
0237    *
0238    * Returned: pair, with members: <br>
0239    * first: LocalPoint which is midway along "the" strip between the wire limits, <br>
0240    * or the chamber edges, as appropriate. <bf>
0241    * second: length of the strip between the wires (or edges as appropriate).
0242    */
0243   std::pair<LocalPoint, float> possibleRecHitPosition(float s, int w1, int w2) const;
0244 
0245   /**
0246    * Return 2-dim point at which a strip and a wire intersects.
0247    *
0248    * Input arguments: a (float) strip number, and an (int) wire. <br>
0249    * Output: LocalPoint which is at their intersection, or at extreme y
0250    * of wire plane, as appropriate. (If y is adjusted, x is also adjusted to keep it on same strip.)
0251    */
0252   LocalPoint intersectionOfStripAndWire(float s, int w) const;
0253 
0254   /**
0255    * Return the point of intersection of two straight lines (in 2-dim).
0256    *
0257    * Input arguments are pair(m1,c1) and pair(m2,c2) where m=slope, c=intercept (y=mx+c). <br>
0258    * BEWARE! Do not call with m1 = m2 ! No trapping !
0259    */
0260   LocalPoint intersectionOfTwoLines(std::pair<float, float> p1, std::pair<float, float> p2) const;
0261 
0262   /**
0263    * Transform strip and wire errors to local x, y frame.
0264    * Need to supply (central) strip of the hit.
0265    * The sigma's are in distance units.
0266    */
0267   LocalError localError(int strip, float sigmaStrip, float sigmaWire) const;
0268 
0269   /**
0270    * 'The' Topology (i.e. Strip Topology) owned by this MELG
0271    */
0272   const CSCStripTopology* topology() const { return theStripTopology; }
0273 
0274   /**
0275    *  This class takes ownership of the pointer, and will destroy it
0276    */
0277   void setTopology(CSCStripTopology* topology);
0278 
0279   /**
0280    * The Wire Topology owned by this MELG
0281    */
0282   const CSCWireTopology* wireTopology() const { return theWireTopology; }
0283 
0284   /**
0285    * Utility method to handle proper copying of the class
0286    */
0287   Bounds* clone() const override { return new CSCLayerGeometry(*this); }
0288 
0289   /**
0290    * Output operator for members of class.
0291    */
0292   friend std::ostream& operator<<(std::ostream&, const CSCLayerGeometry&);
0293 
0294 private:
0295   // The wire information is encapsulated in a CSCWireTopology
0296   // This class is passed the pointer and takes ownership...
0297   // e.g. it destroys it.
0298 
0299   CSCWireTopology* theWireTopology;
0300 
0301   // The strip information is encapsulated in a CSCStripTopology
0302   // This class owns the pointer... so that copying works with
0303   // derived classes, need a clone() method which can be virtual.
0304 
0305   CSCStripTopology* theStripTopology;
0306 
0307   // Cache the trapezoid dimensions even though they could
0308   // be accessed from the TrapezoidalPlaneBounds
0309 
0310   float hBottomEdge;
0311   float hTopEdge;
0312   float apothem;
0313 
0314   const std::string myName;
0315   int chamberType;
0316 };
0317 #endif