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 
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
102  DetId geographicalID() const { return m_geographicalID; }
103 
104  // components (children) management
105  const Container& components() const { return m_container; }
106  float parentZPosition() const { return m_z; } // in mm
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
DiamondDimensions
Geometrical description of a sensor.
Definition: DetGeomDesc.h:44
DiamondDimensions::zHalfWidth
double zHalfWidth
Definition: DetGeomDesc.h:47
DetGeomDesc::applyAlignment
void applyAlignment(const CTPPSRPAlignmentCorrectionData &)
Definition: DetGeomDesc.cc:113
DetGeomDesc::addComponent
void addComponent(DetGeomDesc *)
Definition: DetGeomDesc.cc:111
DetGeomDesc::translation
const Translation & translation() const
Definition: DetGeomDesc.h:79
DetGeomDesc::m_isABox
bool m_isABox
Definition: DetGeomDesc.h:142
DetGeomDesc::Container
std::vector< DetGeomDesc * > Container
Definition: DetGeomDesc.h:52
PDetGeomDesc::Item
Definition: PDetGeomDesc.h:11
DetGeomDesc::deepDeleteComponents
void deepDeleteComponents()
Definition: DetGeomDesc.cc:148
DetGeomDesc::m_copy
int m_copy
Definition: DetGeomDesc.h:137
DetGeomDesc::m_sensorType
std::string m_sensorType
Definition: DetGeomDesc.h:144
DetGeomDesc::computeDiamondDimensions
DiamondDimensions computeDiamondDimensions(const bool isABox, const bool isDD4hep, const std::vector< double > &params) const
Definition: DetGeomDesc.cc:176
DetGeomDesc::m_container
Container m_container
Definition: DetGeomDesc.h:147
DetGeomDesc::~DetGeomDesc
virtual ~DetGeomDesc()
Definition: DetGeomDesc.cc:109
DetGeomDesc::m_name
std::string m_name
Definition: DetGeomDesc.h:136
DetGeomDesc::sensorType
const std::string & sensorType() const
Definition: DetGeomDesc.h:98
cms::DDFilteredView
Definition: DDFilteredView.h:70
DetGeomDesc::parentZPosition
float parentZPosition() const
Definition: DetGeomDesc.h:105
RotationMatrix
ROOT::Math::Rotation3D RotationMatrix
Definition: PGeometricDetBuilder.cc:22
DetGeomDesc::m_params
std::vector< double > m_params
Definition: DetGeomDesc.h:141
DetGeomDesc::clearComponents
void clearComponents()
Definition: DetGeomDesc.h:119
DetGeomDesc::m_z
float m_z
Definition: DetGeomDesc.h:148
DetGeomDesc::CopyMode
CopyMode
Definition: DetGeomDesc.h:68
DetId
Definition: DetId.h:17
DetGeomDesc::isLeaf
bool isLeaf() const
Definition: DetGeomDesc.h:107
DDFilteredView.h
DetGeomDesc::geographicalID
DetId geographicalID() const
Definition: DetGeomDesc.h:101
PDetGeomDesc.h
DetGeomDesc::computeDetID
DetId computeDetID(const std::string &name, const std::vector< int > &copyNos, const unsigned int copyNum, const bool isRun2) const
Definition: DetGeomDesc.cc:196
DetGeomDesc::getDiamondDimensions
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:89
DDFilteredView.h
geometryPPS_CMSxz_fromDD_2016_cfi.isRun2
isRun2
Definition: geometryPPS_CMSxz_fromDD_2016_cfi.py:14
DiamondDimensions::xHalfWidth
double xHalfWidth
Definition: DetGeomDesc.h:45
b
double b
Definition: hdecay.h:118
DetGeomDesc::isDD4hep
bool isDD4hep() const
Definition: DetGeomDesc.h:76
DetGeomDesc::m_diamondBoxParams
DiamondDimensions m_diamondBoxParams
Definition: DetGeomDesc.h:143
DetGeomDesc::cmWithoutChildren
Definition: DetGeomDesc.h:68
a
double a
Definition: hdecay.h:119
DetGeomDesc::components
const Container & components() const
Definition: DetGeomDesc.h:104
DetGeomDescCompare
Definition: DetGeomDesc.h:151
DetGeomDesc::isABox
bool isABox() const
Definition: DetGeomDesc.h:88
DetGeomDesc::name
const std::string & name() const
Definition: DetGeomDesc.h:72
DetGeomDesc
Definition: DetGeomDesc.h:50
DiamondDimensions::yHalfWidth
double yHalfWidth
Definition: DetGeomDesc.h:46
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
DetGeomDesc::print
void print() const
Definition: DetGeomDesc.cc:118
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
PDetGeomDesc
Definition: PDetGeomDesc.h:9
DetGeomDesc::m_isDD4hep
bool m_isDD4hep
Definition: DetGeomDesc.h:138
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DetGeomDesc::deleteComponents
void deleteComponents()
Definition: DetGeomDesc.cc:146
DetGeomDesc::Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: DetGeomDesc.h:54
DetId.h
DetGeomDesc::computeSensorType
std::string computeSensorType(std::string_view name)
Definition: DetGeomDesc.cc:333
DetGeomDesc::invertZSign
void invertZSign()
Definition: DetGeomDesc.h:114
DetGeomDesc::params
const std::vector< double > & params() const
Definition: DetGeomDesc.h:87
DetGeomDesc::computeParameters
std::vector< double > computeParameters(const cms::DDFilteredView &fv) const
Definition: DetGeomDesc.cc:164
DetGeomDesc::cmWithChildren
Definition: DetGeomDesc.h:68
DDFilteredView
Definition: DDFilteredView.h:20
DetGeomDesc::m_geographicalID
DetId m_geographicalID
Definition: DetGeomDesc.h:145
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:53
DetGeomDesc::computeNameWithNoNamespace
std::string computeNameWithNoNamespace(std::string_view nameFromView) const
Definition: DetGeomDesc.cc:155
DetGeomDesc::copyno
int copyno() const
Definition: DetGeomDesc.h:73
DetGeomDesc::rotation
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:80
DetGeomDesc::computeDetIDFromDD4hep
DetId computeDetIDFromDD4hep(const std::string &name, const std::vector< int > &copyNos, const unsigned int copyNum, const bool isRun2) const
Definition: DetGeomDesc.cc:320
DetGeomDescCompare::operator()
bool operator()(const DetGeomDesc &a, const DetGeomDesc &b) const
Definition: DetGeomDesc.h:152
DetGeomDesc::m_trans
Translation m_trans
Definition: DetGeomDesc.h:139
DetGeomDesc::m_rot
RotationMatrix m_rot
Definition: DetGeomDesc.h:140