File indexing completed on 2023-01-21 00:19:33
0001 #ifndef Geometry_TrackerNumberingBuilder_GeometricDet_H
0002 #define Geometry_TrackerNumberingBuilder_GeometricDet_H
0003
0004 #include "CondFormats/GeometryObjects/interface/PGeometricDet.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 "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/ParameterSet/interface/types.h"
0011
0012 #include <DD4hep/Shapes.h>
0013 #include <Math/Rotation3D.h>
0014 #include <Math/Vector3D.h>
0015
0016 #include <vector>
0017 #include <memory>
0018 #include <ext/pool_allocator.h>
0019
0020 class DDFilteredView;
0021
0022 namespace cms {
0023 class DDFilteredView;
0024 }
0025
0026
0027
0028
0029
0030
0031 class GeometricDet {
0032 public:
0033 using NavRange = std::pair<int const*, size_t>;
0034 using ConstGeometricDetContainer = std::vector<GeometricDet const*>;
0035 using GeometricDetContainer = std::vector<GeometricDet*>;
0036 using RotationMatrix = ROOT::Math::Rotation3D;
0037 using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >;
0038
0039 #ifdef PoolAlloc
0040 using nav_type = std::vector<int, PoolAlloc<int> >;
0041 #else
0042 using nav_type = std::vector<int>;
0043 #endif
0044
0045 using Position = Surface::PositionType;
0046 using Rotation = Surface::RotationType;
0047
0048 typedef enum GDEnumType {
0049 unknown = 100,
0050 Tracker = 0,
0051 PixelBarrel = 1,
0052 PixelEndCap = 2,
0053 TIB = 3,
0054 TID = 4,
0055 TOB = 5,
0056 TEC = 6,
0057 layer = 8,
0058 wheel = 9,
0059 strng = 10,
0060 rod = 11,
0061 petal = 12,
0062 ring = 13,
0063 ladder = 14,
0064 mergedDet = 15,
0065 DetUnit = 16,
0066 disk = 17,
0067 panel = 18,
0068 PixelPhase1Barrel = 101,
0069 PixelPhase1EndCap = 102,
0070 PixelPhase1Disk = 117,
0071 OTPhase2EndCap = 204,
0072 OTPhase2Barrel = 205,
0073 OTPhase2Layer = 208,
0074 OTPhase2Stack = 215,
0075 PixelPhase2Barrel = 201,
0076 PixelPhase2EndCap = 202,
0077 OTPhase2Wheel = 209,
0078 PixelPhase2FullDisk = 217,
0079 PixelPhase2ReducedDisk = 227,
0080 PixelPhase2TDRDisk = 237,
0081 PixelPhase2DoubleDisk = 347,
0082 PixelPhase2SubDisk = 357
0083 } GeometricEnumType;
0084
0085
0086 GeometricDet(DDFilteredView* fv, GeometricEnumType dd);
0087 GeometricDet(cms::DDFilteredView* fv, GeometricEnumType dd);
0088
0089 GeometricDet(const PGeometricDet::Item& onePGD, GeometricEnumType dd);
0090
0091
0092 const std::string& name() const { return ddname_; }
0093 const GeometricEnumType& type() const { return type_; }
0094
0095
0096 const nav_type& navType() const { return ddd_; }
0097 NavRange navpos() const { return NavRange(&ddd_.front(), ddd_.size()); }
0098 const DetId& geographicalId() const { return geographicalID_; }
0099 void setGeographicalID(DetId id) { geographicalID_ = id; }
0100
0101
0102 const Translation& translation() const { return trans_; }
0103 double rho() const { return rho_; }
0104 double phi() const { return phi_; }
0105 const RotationMatrix& rotation() const { return rot_; }
0106
0107
0108 std::unique_ptr<Bounds> bounds() const;
0109 Position positionBounds() const;
0110 Rotation rotationBounds() const;
0111
0112
0113
0114 LegacySolidShape shape() const { return cms::dd::value(cms::LegacySolidShapeMap, shape_); }
0115
0116 const cms::DDSolidShape& shape_dd4hep() const { return shape_; }
0117
0118 const std::vector<double>& params() const {
0119 if (shape_ != cms::DDSolidShape::ddbox && shape_ != cms::DDSolidShape::ddtrap &&
0120 shape_ != cms::DDSolidShape::ddtubs) {
0121 edm::LogError("GeometricDet::params()")
0122 << "Called on a shape which is neither a box, a trap, nor a tub. This is not supported!";
0123 }
0124 return params_;
0125 }
0126
0127
0128 double radLength() const { return radLength_; }
0129 double xi() const { return xi_; }
0130
0131
0132
0133 double pixROCRows() const { return pixROCRows_; }
0134 double pixROCCols() const { return pixROCCols_; }
0135 double pixROCx() const { return pixROCx_; }
0136 double pixROCy() const { return pixROCy_; }
0137
0138 bool stereo() const { return stereo_; }
0139 bool isLowerSensor() const { return isLowerSensor_; }
0140 bool isUpperSensor() const { return isUpperSensor_; }
0141 double siliconAPVNum() const { return siliconAPVNum_; }
0142
0143
0144 bool isFromDD4hep() const { return isFromDD4hep_; }
0145
0146
0147 GeometricDet* component(size_t index) { return const_cast<GeometricDet*>(container_[index]); }
0148 bool isLeaf() const { return container_.empty(); }
0149
0150
0151 ConstGeometricDetContainer& components() { return container_; }
0152 const ConstGeometricDetContainer& components() const { return container_; }
0153
0154
0155 ConstGeometricDetContainer deepComponents() const;
0156 void deepComponents(ConstGeometricDetContainer& cont) const;
0157
0158
0159 void addComponents(GeometricDetContainer const& cont);
0160 void addComponents(ConstGeometricDetContainer const& cont);
0161 void addComponent(GeometricDet*);
0162 void clearComponents() { container_.clear(); }
0163 void deleteComponents();
0164
0165
0166 ~GeometricDet();
0167
0168
0169 static std::string printNavType(int const* n, size_t sz);
0170
0171 private:
0172 std::vector<double> computeLegacyShapeParameters(const cms::DDSolidShape& mySolidShape,
0173 const dd4hep::Solid& mySolid) const;
0174
0175 std::string ddname_;
0176 GeometricEnumType type_;
0177
0178 nav_type ddd_;
0179 DetId geographicalID_ = 0;
0180
0181 Translation trans_;
0182 double rho_ = 0.;
0183 double phi_ = 0.;
0184 RotationMatrix rot_;
0185
0186 cms::DDSolidShape shape_;
0187 std::vector<double> params_;
0188
0189 double radLength_ = 0.;
0190 double xi_ = 0.;
0191 double pixROCRows_ = 0.;
0192 double pixROCCols_ = 0.;
0193 double pixROCx_ = 0.;
0194 double pixROCy_ = 0.;
0195 bool stereo_ = false;
0196 bool isLowerSensor_ = false;
0197 bool isUpperSensor_ = false;
0198 double siliconAPVNum_ = 0.;
0199
0200 bool isFromDD4hep_ = false;
0201
0202 ConstGeometricDetContainer container_;
0203 };
0204
0205 namespace geometric_det_ns {
0206 inline std::ostream& operator<<(std::ostream& os, const GeometricDet::NavRange& n) {
0207 os << GeometricDet::printNavType(n.first, n.second);
0208 return os;
0209 }
0210 }
0211
0212 #undef PoolAlloc
0213 #endif