CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DetGeomDesc.h
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * Authors:
4 * Jan Kašpar (jan.kaspar@gmail.com)
5 * CMSSW developpers (based on class GeometricDet)
6 *
7 * Rewritten + Moved out common functionalities to DetGeomDesc(Builder) by Gabrielle Hugo.
8 * Migrated to DD4hep by Gabrielle Hugo and Wagner Carvalho.
9 *
10 ****************************************************************************/
11 
12 #ifndef Geometry_VeryForwardGeometryBuilder_DetGeomDesc
13 #define Geometry_VeryForwardGeometryBuilder_DetGeomDesc
14 
15 #include <utility>
16 #include <vector>
17 
21 
23 #include <Math/Rotation3D.h>
24 
26 
46  double xHalfWidth;
47  double yHalfWidth;
48  double zHalfWidth;
49 };
50 
51 class DetGeomDesc {
52 public:
53  using Container = std::vector<DetGeomDesc*>;
54  using RotationMatrix = ROOT::Math::Rotation3D;
55  using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
56 
57  // Constructor from old DD DDFilteredView
59  DetGeomDesc(const DDFilteredView& fv, const bool isRun2);
60  // Constructor from DD4hep DDFilteredView
62  DetGeomDesc(const cms::DDFilteredView& fv, const bool isRun2);
63  // Constructor from DB object PDetGeomDesc
64  DetGeomDesc(const PDetGeomDesc& gd);
65  // Constructor from DB object PDetGeomDesc::Item
67  virtual ~DetGeomDesc();
68 
71 
72  // general info
73  const std::string& name() const { return m_name; }
74  int copyno() const { return m_copy; }
75 
76  // is DD4hep
77  bool isDD4hep() const { return m_isDD4hep; }
78 
79  // placement info
80  const Translation& translation() const { return m_trans; } // in mm
81  const RotationMatrix& rotation() const { return m_rot; }
82 
83  // shape info
84  // params() is left for general access to solid shape parameters (any shape, not only box!).
85  // Though, it should be used only with great care, for two reasons:
86  // 1. Order of shape parameters may possibly change from a version of DD4hep to another.
87  // 2. Among all parameters, those representing a length are expressed in mm (for old DD) or the DD4hep-configured unit (for DD4hep), while PPS uses mm.
88  const std::vector<double>& params() const { return m_params; } // default unit: mm for oldDD, DD4hep unit for DD4hep
89  bool isABox() const { return m_isABox; }
91  if (!isABox()) {
92  edm::LogError("DetGeomDesc::getDiamondDimensions is not called on a box, for solid ")
93  << name() << ", Id = " << geographicalID();
94  }
95  return m_diamondBoxParams;
96  } // in mm
97 
98  // sensor type
99  const std::string& sensorType() const { return m_sensorType; }
100 
101  // ID info
103 
104  // components (children) management
105  const Container& components() const { return m_container; }
106  float parentZPosition() const { return m_z; } // in mm
107  void addComponent(DetGeomDesc*);
108  bool isLeaf() const { return m_container.empty(); }
109 
110  // alignment
112 
113  void print() const;
114 
115  void invertZSign() { m_trans.SetZ(-m_trans.z()); }
116 
117 private:
118  void deleteComponents(); // deletes just the first daughters
119  void deepDeleteComponents(); // traverses the tree and deletes all nodes.
120  void clearComponents() { m_container.resize(0); }
121 
122  std::string computeNameWithNoNamespace(std::string_view nameFromView) const;
123  std::vector<double> computeParameters(const cms::DDFilteredView& fv) const;
125  const bool isDD4hep,
126  const std::vector<double>& params) const;
128  const std::vector<int>& copyNos,
129  const unsigned int copyNum,
130  const bool isRun2) const;
132  const std::vector<int>& copyNos,
133  const unsigned int copyNum,
134  const bool isRun2) const;
135  std::string computeSensorType(std::string_view name);
136 
137  std::string m_name; // with no namespace
138  int m_copy;
142  std::vector<double> m_params; // default unit: mm from oldDD, DD4hep unit for DD4hep
143  bool m_isABox;
147 
149  float m_z; // in mm
150 };
151 
153  bool operator()(const DetGeomDesc& a, const DetGeomDesc& b) const {
154  return (a.geographicalID() != b.geographicalID()
155  ? a.geographicalID() < b.geographicalID() // Sort by DetId
156  // If DetIds are identical (== 0 for non-sensors), sort by name and copy number.
157  : (a.name() != b.name() ? a.name() < b.name() : a.copyno() < b.copyno()));
158  }
159 };
160 
161 #endif
Translation m_trans
Definition: DetGeomDesc.h:140
const std::vector< double > & params() const
Definition: DetGeomDesc.h:88
DetId geographicalID() const
Definition: DetGeomDesc.h:102
const Translation & translation() const
Definition: DetGeomDesc.h:80
const std::string & sensorType() const
Definition: DetGeomDesc.h:99
Container m_container
Definition: DetGeomDesc.h:148
std::string m_name
Definition: DetGeomDesc.h:137
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:90
void applyAlignment(const CTPPSRPAlignmentCorrectionData &)
Definition: DetGeomDesc.cc:114
std::string computeNameWithNoNamespace(std::string_view nameFromView) const
Definition: DetGeomDesc.cc:156
void clearComponents()
Definition: DetGeomDesc.h:120
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> Translation
Definition: DetGeomDesc.h:55
std::string m_sensorType
Definition: DetGeomDesc.h:145
std::vector< DetGeomDesc * > Container
Definition: DetGeomDesc.h:53
Log< level::Error, false > LogError
void deepDeleteComponents()
Definition: DetGeomDesc.cc:149
std::vector< double > m_params
Definition: DetGeomDesc.h:142
virtual ~DetGeomDesc()
Definition: DetGeomDesc.cc:110
DiamondDimensions m_diamondBoxParams
Definition: DetGeomDesc.h:144
DiamondDimensions computeDiamondDimensions(const bool isABox, const bool isDD4hep, const std::vector< double > &params) const
Definition: DetGeomDesc.cc:177
Geometrical description of a sensor.
Definition: DetGeomDesc.h:45
DetId computeDetIDFromDD4hep(const std::string &name, const std::vector< int > &copyNos, const unsigned int copyNum, const bool isRun2) const
Definition: DetGeomDesc.cc:321
const Container & components() const
Definition: DetGeomDesc.h:105
bool operator()(const DetGeomDesc &a, const DetGeomDesc &b) const
Definition: DetGeomDesc.h:153
std::string computeSensorType(std::string_view name)
Definition: DetGeomDesc.cc:334
const std::string & name() const
Definition: DetGeomDesc.h:73
Definition: DetId.h:17
void deleteComponents()
Definition: DetGeomDesc.cc:147
DetId computeDetID(const std::string &name, const std::vector< int > &copyNos, const unsigned int copyNum, const bool isRun2) const
Definition: DetGeomDesc.cc:197
void invertZSign()
Definition: DetGeomDesc.h:115
bool isABox() const
Definition: DetGeomDesc.h:89
int copyno() const
Definition: DetGeomDesc.h:74
double b
Definition: hdecay.h:118
bool isDD4hep() const
Definition: DetGeomDesc.h:77
bool m_isDD4hep
Definition: DetGeomDesc.h:139
float parentZPosition() const
Definition: DetGeomDesc.h:106
double a
Definition: hdecay.h:119
void print() const
Definition: DetGeomDesc.cc:119
DetId m_geographicalID
Definition: DetGeomDesc.h:146
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:81
std::vector< double > computeParameters(const cms::DDFilteredView &fv) const
Definition: DetGeomDesc.cc:165
void addComponent(DetGeomDesc *)
Definition: DetGeomDesc.cc:112
DetGeomDesc(const DDFilteredView &fv, const bool isRun2)
Definition: DetGeomDesc.cc:29
RotationMatrix m_rot
Definition: DetGeomDesc.h:141
ROOT::Math::Rotation3D RotationMatrix
Definition: DetGeomDesc.h:54
Alignment correction for an element of the CT-PPS detector. Within the geometry description, every sensor (more generally every element) is given its translation and rotation. These two quantities shall be understood in local-to-global coordinate transform. That is, if r_l is a point in local coordinate system and x_g in global, then it holds.
bool isLeaf() const
Definition: DetGeomDesc.h:108