Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CommonDet_GeomDet_H
0002 #define CommonDet_GeomDet_H
0003 
0004 /** \class GeomDet
0005  *  Base class for GeomDetUnit and for composite GeomDet s. 
0006  *
0007  */
0008 
0009 #include "DataFormats/GeometrySurface/interface/Plane.h"
0010 #include "DataFormats/DetId/interface/DetId.h"
0011 
0012 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0013 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0014 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0015 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0016 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0017 #include "Geometry/CommonTopologies/interface/GeomDetEnumerators.h"
0018 
0019 #include <vector>
0020 
0021 class AlignmentPositionError;
0022 
0023 class Topology;
0024 class GeomDetType;
0025 class SurfaceDeformation;
0026 
0027 class GeomDet {
0028 public:
0029   using SubDetector = GeomDetEnumerators::SubDetector;
0030 
0031   explicit GeomDet(Plane* plane) : thePlane(plane) {}
0032   explicit GeomDet(const ReferenceCountingPointer<Plane>& plane) : thePlane(plane) {}
0033 
0034   virtual ~GeomDet();
0035 
0036   /// The nominal surface of the GeomDet
0037   const Plane& surface() const { return *thePlane; }
0038 
0039   /// Same as surface(), kept for backward compatibility
0040   const Plane& specificSurface() const { return *thePlane; }
0041 
0042   /// The position (origin of the R.F.)
0043   const Surface::PositionType& position() const { return surface().position(); }
0044 
0045   /// The rotation defining the local R.F.
0046   const Surface::RotationType& rotation() const { return surface().rotation(); }
0047 
0048   /// Conversion to the global R.F. from the R.F. of the GeomDet
0049   GlobalPoint toGlobal(const Local2DPoint& lp) const { return surface().toGlobal(lp); }
0050 
0051   /// Conversion to the global R.F. from the R.F. of the GeomDet
0052   GlobalPoint toGlobal(const Local3DPoint& lp) const { return surface().toGlobal(lp); }
0053 
0054   /// Conversion to the global R.F. from the R.F. of the GeomDet
0055   GlobalVector toGlobal(const LocalVector& lv) const { return surface().toGlobal(lv); }
0056 
0057   /// Conversion to the R.F. of the GeomDet
0058   LocalPoint toLocal(const GlobalPoint& gp) const { return surface().toLocal(gp); }
0059 
0060   /// Conversion to the R.F. of the GeomDet
0061   LocalVector toLocal(const GlobalVector& gv) const { return surface().toLocal(gv); }
0062 
0063   /// The label of this GeomDet
0064   DetId geographicalId() const { return m_detId; }
0065 
0066   /// Which subdetector
0067   virtual SubDetector subDetector() const;
0068 
0069   /// is a Unit
0070   virtual bool isLeaf() const { return components().empty(); }
0071 
0072   /// Returns direct components, if any
0073   virtual std::vector<const GeomDet*> components() const { return std::vector<const GeomDet*>(); }
0074 
0075   /// Returns a component GeomDet given its DetId, if existing
0076   // FIXME: must become pure virtual
0077   virtual const GeomDet* component(DetId /*id*/) const { return nullptr; }
0078 
0079   /// Return pointer to alignment errors.
0080   AlignmentPositionError const* alignmentPositionError() const { return theAlignmentPositionError; }
0081 
0082   // specific unit index in a given subdetector (such as Tracker)
0083   int index() const { return m_index; }
0084   void setIndex(int i) { m_index = i; }
0085 
0086   // specific geomDet index in a given subdetector (such as Tracker)
0087   int gdetIndex() const { return m_gdetIndex; }
0088   void setGdetIndex(int i) { m_gdetIndex = i; }
0089 
0090   virtual const Topology& topology() const;
0091 
0092   virtual const GeomDetType& type() const;
0093 
0094   /// Return pointer to surface deformation.
0095   /// Defaults to "null" if not reimplemented in the derived classes.
0096   virtual const SurfaceDeformation* surfaceDeformation() const { return nullptr; }
0097 
0098 protected:
0099   void setDetId(DetId id) { m_detId = id; }
0100 
0101 private:
0102   ReferenceCountingPointer<Plane> thePlane;
0103   DetId m_detId;
0104   int m_index = -1;
0105   int m_gdetIndex = -1;
0106   AlignmentPositionError* theAlignmentPositionError = nullptr;
0107 
0108 protected:
0109   /// set the LocalAlignmentError properly trasforming the ape
0110   /// Does not affect the AlignmentPositionError of components (if any).
0111   virtual bool setAlignmentPositionError(const AlignmentPositionError& ape);
0112 
0113 private:
0114   /// Alignment part of interface, available only to friend
0115   friend class DetPositioner;
0116 
0117   /// Relative displacement (with respect to current position).
0118   /// Does not move components (if any).
0119   void move(const GlobalVector& displacement);
0120 
0121   /// Relative rotation (with respect to current orientation).
0122   /// Does not move components (if any).
0123   void rotate(const Surface::RotationType& rotation);
0124 
0125   /// Replaces the current position and rotation with new ones.
0126   /// actually replaces the surface with a new surface.
0127   /// Does not move components (if any).
0128 
0129   void setPosition(const Surface::PositionType& position, const Surface::RotationType& rotation);
0130 
0131 private:
0132   /// set the SurfaceDeformation for this GeomDetUnit.
0133   /// Does not affect the SurfaceDeformation of components (if any).
0134   /// Throws if not implemented in derived class.
0135   virtual void setSurfaceDeformation(const SurfaceDeformation* deformation);
0136 };
0137 
0138 using GeomDetUnit = GeomDet;
0139 
0140 #endif