Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:48:54

0001 #ifndef Geometry_MTDNumberingBuilder_GeometricTimingDet_H
0002 #define Geometry_MTDNumberingBuilder_GeometricTimingDet_H
0003 
0004 #include "CondFormats/GeometryObjects/interface/PGeometricTimingDet.h"
0005 #include "DetectorDescription/DDCMS/interface/DDSolidShapes.h"
0006 #include "DataFormats/GeometrySurface/interface/Surface.h"
0007 #include "DataFormats/GeometrySurface/interface/Bounds.h"
0008 #include "DataFormats/DetId/interface/DetId.h"
0009 #include <Math/Rotation3D.h>
0010 #include <Math/Vector3D.h>
0011 
0012 #include <vector>
0013 #include <memory>
0014 #include "FWCore/ParameterSet/interface/types.h"
0015 
0016 #include <ext/pool_allocator.h>
0017 
0018 class DDFilteredView;
0019 
0020 namespace cms {
0021   class DDFilteredView;
0022 }
0023 
0024 /**
0025  * Composite class GeometricTimingDet. A composite can contain other composites, and so on;
0026  * You can understand what you are looking at via enum.
0027  */
0028 
0029 class GeometricTimingDet {
0030 public:
0031   using NavRange = std::pair<int const*, size_t>;
0032   using ConstGeometricTimingDetContainer = std::vector<GeometricTimingDet const*>;
0033   using GeometricTimingDetContainer = std::vector<GeometricTimingDet*>;
0034   using RotationMatrix = ROOT::Math::Rotation3D;
0035   using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >;
0036 
0037 #ifdef PoolAlloc
0038   using nav_type = std::vector<int, PoolAlloc<int> >;
0039 #else
0040   using nav_type = std::vector<int>;
0041 #endif
0042 
0043   using Position = Surface::PositionType;
0044   using Rotation = Surface::RotationType;
0045 
0046   //
0047   // more can be added; please add at the end!
0048   //
0049   using GeometricTimingEnumType = enum GTDEnumType {
0050     unknown = 100,
0051     MTD = 0,
0052     BTL = 1,
0053     BTLLayer = 2,
0054     BTLTray = 3,
0055     BTLModule = 4,
0056     BTLSensor = 5,
0057     BTLCrystal = 6,
0058     ETL = 7,
0059     ETLDisc = 8,
0060     ETLRing = 9,
0061     ETLModule = 10,
0062     ETLSensor = 11
0063   };
0064 
0065   /**
0066    * Constructors to be used when looping over DD
0067    */
0068   GeometricTimingDet(DDFilteredView* fv, GeometricTimingEnumType dd);
0069   GeometricTimingDet(cms::DDFilteredView* fv, GeometricTimingEnumType dd);
0070   GeometricTimingDet(const PGeometricTimingDet::Item& onePGD, GeometricTimingEnumType dd);
0071 
0072   /**
0073    * set or add or clear components
0074    */
0075   void setGeographicalID(DetId id) { geographicalID_ = id; }
0076   void addComponents(GeometricTimingDetContainer const& cont);
0077   void addComponents(ConstGeometricTimingDetContainer const& cont);
0078   void addComponent(GeometricTimingDet*);
0079   /**
0080    * clearComponents() only empties the container, the components are not deleted!
0081    */
0082   void clearComponents() { container_.clear(); }
0083 
0084   /**
0085    * deleteComponents() explicitly deletes the daughters
0086    * 
0087    */
0088   void deleteComponents();
0089 
0090   bool isLeaf() const { return container_.empty(); }
0091 
0092   GeometricTimingDet* component(size_t index) { return const_cast<GeometricTimingDet*>(container_[index]); }
0093 
0094   /**
0095    * Access methods
0096    */
0097   RotationMatrix const& rotation() const { return rot_; }
0098   Translation const& translation() const { return trans_; }
0099   double phi() const { return phi_; }
0100   double rho() const { return rho_; }
0101 
0102   LegacySolidShape shape() const { return cms::dd::value(cms::LegacySolidShapeMap, shape_); }
0103   cms::DDSolidShape shape_dd4hep() const { return shape_; }
0104   GeometricTimingEnumType type() const { return type_; }
0105   std::string const& name() const { return ddname_; }
0106   // internal representaion
0107   nav_type const& navType() const { return ddd_; }
0108   // representation neutral interface
0109   NavRange navRange() const { return NavRange(&ddd_.front(), ddd_.size()); }
0110   // more meaningfull name (maybe)
0111   NavRange navpos() const { return NavRange(&ddd_.front(), ddd_.size()); }
0112   std::vector<double> const& params() const { return params_; }
0113 
0114   ~GeometricTimingDet();
0115 
0116   /**
0117    * components() returns explicit components; please note that in case of a leaf 
0118    * GeometricTimingDet it returns nothing (an empty vector)
0119    */
0120   ConstGeometricTimingDetContainer& components() { return container_; }
0121   ConstGeometricTimingDetContainer const& components() const { return container_; }
0122 
0123   /**
0124    * deepComponents() returns all the components below; please note that 
0125    * if the current GeometricTimingDet is a leaf, it returns it!
0126    */
0127 
0128   ConstGeometricTimingDetContainer deepComponents() const;
0129   void deepComponents(ConstGeometricTimingDetContainer& cont) const;
0130 
0131   /**
0132    *geometricalID() returns the ID associated to the GeometricTimingDet.
0133    */
0134   DetId geographicalID() const { return geographicalID_; }
0135   DetId geographicalId() const { return geographicalID_; }
0136 
0137   /**
0138    *positionBounds() returns the position in cm. 
0139    */
0140   Position positionBounds() const;
0141 
0142   /**
0143    *rotationBounds() returns the rotation matrix. 
0144    */
0145   Rotation rotationBounds() const;
0146 
0147   /**
0148    *bounds() returns the Bounds.
0149    */
0150   std::unique_ptr<Bounds> bounds() const;
0151   double radLength() const { return radLength_; }
0152   double xi() const { return xi_; }
0153   /**
0154    * The following four pix* methods only return meaningful results for pixels.
0155    */
0156   double pixROCRows() const { return pixROCRows_; }
0157   double pixROCCols() const { return pixROCCols_; }
0158   double pixROCx() const { return pixROCx_; }
0159   double pixROCy() const { return pixROCy_; }
0160 
0161   /**
0162    * The following two are only meaningful for the silicon tracker.
0163    */
0164   bool stereo() const { return stereo_; }
0165   double siliconAPVNum() const { return siliconAPVNum_; }
0166 
0167 private:
0168   ConstGeometricTimingDetContainer container_;
0169   Translation trans_;
0170   double phi_;
0171   double rho_;
0172   RotationMatrix rot_;
0173   cms::DDSolidShape shape_;
0174   nav_type ddd_;
0175   std::string ddname_;
0176   GeometricTimingEnumType type_;
0177   std::vector<double> params_;
0178 
0179   DetId geographicalID_;
0180   double radLength_;
0181   double xi_;
0182   double pixROCRows_;
0183   double pixROCCols_;
0184   double pixROCx_;
0185   double pixROCy_;
0186   bool stereo_;
0187   double siliconAPVNum_;
0188 };
0189 
0190 #undef PoolAlloc
0191 #endif