File indexing completed on 2024-04-06 12:15:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef Geometry_VeryForwardGeometryBuilder_DetGeomDesc
0013 #define Geometry_VeryForwardGeometryBuilder_DetGeomDesc
0014
0015 #include <utility>
0016 #include <vector>
0017
0018 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0019 #include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
0020 #include "CondFormats/GeometryObjects/interface/PDetGeomDesc.h"
0021
0022 #include "DataFormats/DetId/interface/DetId.h"
0023 #include <Math/Rotation3D.h>
0024
0025 class CTPPSRPAlignmentCorrectionData;
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 struct DiamondDimensions {
0046 double xHalfWidth;
0047 double yHalfWidth;
0048 double zHalfWidth;
0049 };
0050
0051 class DetGeomDesc {
0052 public:
0053 using Container = std::vector<DetGeomDesc*>;
0054 using RotationMatrix = ROOT::Math::Rotation3D;
0055 using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
0056
0057
0058
0059 DetGeomDesc(const DDFilteredView& fv, const bool isRun2);
0060
0061
0062 DetGeomDesc(const cms::DDFilteredView& fv, const bool isRun2);
0063
0064 DetGeomDesc(const PDetGeomDesc& gd);
0065
0066 DetGeomDesc(const PDetGeomDesc::Item& item);
0067 virtual ~DetGeomDesc();
0068
0069 enum CopyMode { cmWithChildren, cmWithoutChildren };
0070 DetGeomDesc(const DetGeomDesc& ref, CopyMode cm = cmWithChildren);
0071
0072
0073 const std::string& name() const { return m_name; }
0074 int copyno() const { return m_copy; }
0075
0076
0077 bool isDD4hep() const { return m_isDD4hep; }
0078
0079
0080 const Translation& translation() const { return m_trans; }
0081 const RotationMatrix& rotation() const { return m_rot; }
0082
0083
0084
0085
0086
0087
0088 const std::vector<double>& params() const { return m_params; }
0089 bool isABox() const { return m_isABox; }
0090 const DiamondDimensions& getDiamondDimensions() const {
0091 if (!isABox()) {
0092 edm::LogError("DetGeomDesc::getDiamondDimensions is not called on a box, for solid ")
0093 << name() << ", Id = " << geographicalID();
0094 }
0095 return m_diamondBoxParams;
0096 }
0097
0098
0099 const std::string& sensorType() const { return m_sensorType; }
0100
0101
0102 DetId geographicalID() const { return m_geographicalID; }
0103
0104
0105 const Container& components() const { return m_container; }
0106 float parentZPosition() const { return m_z; }
0107 void addComponent(DetGeomDesc*);
0108 bool isLeaf() const { return m_container.empty(); }
0109
0110
0111 void applyAlignment(const CTPPSRPAlignmentCorrectionData&);
0112
0113 void print() const;
0114
0115 void invertZSign() { m_trans.SetZ(-m_trans.z()); }
0116
0117 private:
0118 void deleteComponents();
0119 void deepDeleteComponents();
0120 void clearComponents() { m_container.resize(0); }
0121
0122 std::string computeNameWithNoNamespace(std::string_view nameFromView) const;
0123 std::vector<double> computeParameters(const cms::DDFilteredView& fv) const;
0124 DiamondDimensions computeDiamondDimensions(const bool isABox,
0125 const bool isDD4hep,
0126 const std::vector<double>& params) const;
0127 DetId computeDetID(const std::string& name,
0128 const std::vector<int>& copyNos,
0129 const unsigned int copyNum,
0130 const bool isRun2) const;
0131 DetId computeDetIDFromDD4hep(const std::string& name,
0132 const std::vector<int>& copyNos,
0133 const unsigned int copyNum,
0134 const bool isRun2) const;
0135 std::string computeSensorType(std::string_view name);
0136
0137 std::string m_name;
0138 int m_copy;
0139 bool m_isDD4hep;
0140 Translation m_trans;
0141 RotationMatrix m_rot;
0142 std::vector<double> m_params;
0143 bool m_isABox;
0144 DiamondDimensions m_diamondBoxParams;
0145 std::string m_sensorType;
0146 DetId m_geographicalID;
0147
0148 Container m_container;
0149 float m_z;
0150 };
0151
0152 struct DetGeomDescCompare {
0153 bool operator()(const DetGeomDesc& a, const DetGeomDesc& b) const {
0154 return (a.geographicalID() != b.geographicalID()
0155 ? a.geographicalID() < b.geographicalID()
0156
0157 : (a.name() != b.name() ? a.name() < b.name() : a.copyno() < b.copyno()));
0158 }
0159 };
0160
0161 #endif