CMS 3D CMS Logo

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 
20 
22 #include <Math/Rotation3D.h>
23 
25 
45  double xHalfWidth;
46  double yHalfWidth;
47  double zHalfWidth;
48 };
49 
50 class DetGeomDesc {
51 public:
52  using Container = std::vector<DetGeomDesc*>;
53  using RotationMatrix = ROOT::Math::Rotation3D;
54  using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
55 
56  // Constructor from old DD DDFilteredView
58  DetGeomDesc(const DDFilteredView& fv, const bool isRun2);
59  // Constructor from DD4Hep DDFilteredView
61  DetGeomDesc(const cms::DDFilteredView& fv, const bool isRun2);
62 
63  virtual ~DetGeomDesc();
64 
67 
68  // general info
69  const std::string& name() const { return m_name; }
70  int copyno() const { return m_copy; }
71 
72  // is DD4hep
73  bool isDD4hep() const { return m_isDD4hep; }
74 
75  // placement info
76  const Translation& translation() const { return m_trans; } // in mm
77  const RotationMatrix& rotation() const { return m_rot; }
78 
79  // shape info
80  // params() is left for general access to solid shape parameters (any shape, not only box!).
81  // Though, it should be used only with great care, for two reasons:
82  // 1. Order of shape parameters may possibly change from a version of DD4hep to another.
83  // 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.
84  const std::vector<double>& params() const { return m_params; } // default unit: mm for oldDD, DD4hep unit for DD4hep
85  bool isABox() const { return m_isABox; }
87  if (!isABox()) {
88  edm::LogError("DetGeomDesc::getDiamondDimensions is not called on a box, for solid ")
89  << name() << ", Id = " << geographicalID();
90  }
91  return m_diamondBoxParams;
92  } // in mm
93 
94  // sensor type
95  const std::string& sensorType() const { return m_sensorType; }
96 
97  // ID info
98  DetId geographicalID() const { return m_geographicalID; }
99 
100  // components (children) management
101  const Container& components() const { return m_container; }
102  float parentZPosition() const { return m_z; } // in mm
104  bool isLeaf() const { return m_container.empty(); }
105 
106  // alignment
108 
109  void print() const;
110 
111  void invertZSign() { m_trans.SetZ(-m_trans.z()); }
112 
113 private:
114  void deleteComponents(); // deletes just the first daughters
115  void deepDeleteComponents(); // traverses the tree and deletes all nodes.
116  void clearComponents() { m_container.resize(0); }
117 
118  std::string computeNameWithNoNamespace(std::string_view nameFromView) const;
119  std::vector<double> computeParameters(const cms::DDFilteredView& fv) const;
121  const bool isDD4hep,
122  const std::vector<double>& params) const;
124  const std::vector<int>& copyNos,
125  const unsigned int copyNum,
126  const bool isRun2) const;
128  const std::vector<int>& copyNos,
129  const unsigned int copyNum,
130  const bool isRun2) const;
131  std::string computeSensorType(std::string_view name);
132 
133  std::string m_name; // with no namespace
134  int m_copy;
138  std::vector<double> m_params; // default unit: mm from oldDD, DD4hep unit for DD4hep
139  bool m_isABox;
143 
145  float m_z; // in mm
146 };
147 
149  bool operator()(const DetGeomDesc& a, const DetGeomDesc& b) const {
150  return (a.geographicalID() != b.geographicalID()
151  ? a.geographicalID() < b.geographicalID() // Sort by DetId
152  // If DetIds are identical (== 0 for non-sensors), sort by name and copy number.
153  : (a.name() != b.name() ? a.name() < b.name() : a.copyno() < b.copyno()));
154  }
155 };
156 
157 #endif
DiamondDimensions
Geometrical description of a sensor.
Definition: DetGeomDesc.h:43
DiamondDimensions::zHalfWidth
double zHalfWidth
Definition: DetGeomDesc.h:46
DetGeomDesc::applyAlignment
void applyAlignment(const CTPPSRPAlignmentCorrectionData &)
Definition: DetGeomDesc.cc:81
DetGeomDesc::addComponent
void addComponent(DetGeomDesc *)
Definition: DetGeomDesc.cc:79
DetGeomDesc::translation
const Translation & translation() const
Definition: DetGeomDesc.h:75
DetGeomDesc::m_isABox
bool m_isABox
Definition: DetGeomDesc.h:138
DetGeomDesc::Container
std::vector< DetGeomDesc * > Container
Definition: DetGeomDesc.h:51
DetGeomDesc::deepDeleteComponents
void deepDeleteComponents()
Definition: DetGeomDesc.cc:116
DetGeomDesc::m_copy
int m_copy
Definition: DetGeomDesc.h:133
DetGeomDesc::m_sensorType
std::string m_sensorType
Definition: DetGeomDesc.h:140
DetGeomDesc::computeDiamondDimensions
DiamondDimensions computeDiamondDimensions(const bool isABox, const bool isDD4hep, const std::vector< double > &params) const
Definition: DetGeomDesc.cc:144
DetGeomDesc::m_container
Container m_container
Definition: DetGeomDesc.h:143
DetGeomDesc::~DetGeomDesc
virtual ~DetGeomDesc()
Definition: DetGeomDesc.cc:77
DetGeomDesc::m_name
std::string m_name
Definition: DetGeomDesc.h:132
DetGeomDesc::sensorType
const std::string & sensorType() const
Definition: DetGeomDesc.h:94
cms::DDFilteredView
Definition: DDFilteredView.h:70
DetGeomDesc::parentZPosition
float parentZPosition() const
Definition: DetGeomDesc.h:101
RotationMatrix
ROOT::Math::Rotation3D RotationMatrix
Definition: PGeometricDetBuilder.cc:21
DetGeomDesc::m_params
std::vector< double > m_params
Definition: DetGeomDesc.h:137
DetGeomDesc::clearComponents
void clearComponents()
Definition: DetGeomDesc.h:115
DetGeomDesc::m_z
float m_z
Definition: DetGeomDesc.h:144
DetGeomDesc::CopyMode
CopyMode
Definition: DetGeomDesc.h:64
DetId
Definition: DetId.h:17
DetGeomDesc::isLeaf
bool isLeaf() const
Definition: DetGeomDesc.h:103
DDFilteredView.h
DetGeomDesc::geographicalID
DetId geographicalID() const
Definition: DetGeomDesc.h:97
DetGeomDesc::computeDetID
DetId computeDetID(const std::string &name, const std::vector< int > &copyNos, const unsigned int copyNum, const bool isRun2) const
Definition: DetGeomDesc.cc:164
DetGeomDesc::getDiamondDimensions
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:85
DDFilteredView.h
geometryPPS_CMSxz_fromDD_2016_cfi.isRun2
isRun2
Definition: geometryPPS_CMSxz_fromDD_2016_cfi.py:14
DiamondDimensions::xHalfWidth
double xHalfWidth
Definition: DetGeomDesc.h:44
b
double b
Definition: hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DetGeomDesc::isDD4hep
bool isDD4hep() const
Definition: DetGeomDesc.h:72
DetGeomDesc::m_diamondBoxParams
DiamondDimensions m_diamondBoxParams
Definition: DetGeomDesc.h:139
DetGeomDesc::cmWithoutChildren
Definition: DetGeomDesc.h:64
a
double a
Definition: hdecay.h:119
DetGeomDesc::components
const Container & components() const
Definition: DetGeomDesc.h:100
DetGeomDescCompare
Definition: DetGeomDesc.h:147
DetGeomDesc::isABox
bool isABox() const
Definition: DetGeomDesc.h:84
DetGeomDesc::name
const std::string & name() const
Definition: DetGeomDesc.h:68
DetGeomDesc
Definition: DetGeomDesc.h:49
DiamondDimensions::yHalfWidth
double yHalfWidth
Definition: DetGeomDesc.h:45
DetGeomDesc::print
void print() const
Definition: DetGeomDesc.cc:86
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DetGeomDesc::m_isDD4hep
bool m_isDD4hep
Definition: DetGeomDesc.h:134
DetGeomDesc::deleteComponents
void deleteComponents()
Definition: DetGeomDesc.cc:114
DetGeomDesc::Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: DetGeomDesc.h:53
DetId.h
DetGeomDesc::computeSensorType
std::string computeSensorType(std::string_view name)
Definition: DetGeomDesc.cc:301
DetGeomDesc::invertZSign
void invertZSign()
Definition: DetGeomDesc.h:110
DetGeomDesc::params
const std::vector< double > & params() const
Definition: DetGeomDesc.h:83
DetGeomDesc::computeParameters
std::vector< double > computeParameters(const cms::DDFilteredView &fv) const
Definition: DetGeomDesc.cc:132
DetGeomDesc::cmWithChildren
Definition: DetGeomDesc.h:64
DDFilteredView
Definition: DDFilteredView.h:20
DetGeomDesc::m_geographicalID
DetId m_geographicalID
Definition: DetGeomDesc.h:141
CTPPSRPAlignmentCorrectionData
Alignment correction for an element of the CT-PPS detector. Within the geometry description,...
Definition: CTPPSRPAlignmentCorrectionData.h:58
DetGeomDesc::DetGeomDesc
DetGeomDesc(const DDFilteredView &fv, const bool isRun2)
Definition: DetGeomDesc.cc:28
DetGeomDesc::RotationMatrix
ROOT::Math::Rotation3D RotationMatrix
Definition: DetGeomDesc.h:52
DetGeomDesc::computeNameWithNoNamespace
std::string computeNameWithNoNamespace(std::string_view nameFromView) const
Definition: DetGeomDesc.cc:123
DetGeomDesc::copyno
int copyno() const
Definition: DetGeomDesc.h:69
DetGeomDesc::rotation
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:76
DetGeomDesc::computeDetIDFromDD4hep
DetId computeDetIDFromDD4hep(const std::string &name, const std::vector< int > &copyNos, const unsigned int copyNum, const bool isRun2) const
Definition: DetGeomDesc.cc:288
DetGeomDescCompare::operator()
bool operator()(const DetGeomDesc &a, const DetGeomDesc &b) const
Definition: DetGeomDesc.h:148
DetGeomDesc::m_trans
Translation m_trans
Definition: DetGeomDesc.h:135
DetGeomDesc::m_rot
RotationMatrix m_rot
Definition: DetGeomDesc.h:136