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
57  DetGeomDesc(const DDFilteredView& fv);
58  // Constructor from DD4Hep DDFilteredView
60 
61  virtual ~DetGeomDesc();
62 
65 
66  // general info
67  const std::string& name() const { return m_name; }
68  int copyno() const { return m_copy; }
69 
70  // is DD4hep
71  bool isDD4hep() const { return m_isDD4hep; }
72 
73  // placement info
74  const Translation& translation() const { return m_trans; } // in mm
75  const RotationMatrix& rotation() const { return m_rot; }
76 
77  // shape info
78  // params() is left for general access to solid shape parameters, but should be used
79  // only with great care, for two reasons: 1. order of parameters may possibly change from
80  // a version to another of DD4hep; 2. length parameters unit is cm while PPS uses mm.
81  const std::vector<double>& params() const { return m_params; } // default unit: mm from oldDD, cm from DD4hep
82  bool isABox() const { return m_isABox; }
84  if (!isABox()) {
85  edm::LogError("DetGeomDesc::getDiamondDimensions is not called on a box, for solid ")
86  << name() << ", Id = " << geographicalID();
87  }
88  return m_diamondBoxParams;
89  } // in mm
90 
91  // sensor type
92  const std::string& sensorType() const { return m_sensorType; }
93 
94  // ID info
95  DetId geographicalID() const { return m_geographicalID; }
96 
97  // components (children) management
98  const Container& components() const { return m_container; }
99  float parentZPosition() const { return m_z; } // in mm
101  bool isLeaf() const { return m_container.empty(); }
102 
103  // alignment
105 
106  void print() const;
107 
108 private:
109  void deleteComponents(); // deletes just the first daughters
110  void deepDeleteComponents(); // traverses the tree and deletes all nodes.
111  void clearComponents() { m_container.resize(0); }
112 
113  std::string computeNameWithNoNamespace(std::string_view nameFromView) const;
114  std::vector<double> computeParameters(const cms::DDFilteredView& fv) const;
116  const bool isDD4hep,
117  const std::vector<double>& params) const;
118  DetId computeDetID(const std::string& name, const std::vector<int>& copyNos, unsigned int copyNum) const;
119  DetId computeDetIDFromDD4hep(const std::string& name, const std::vector<int>& copyNos, unsigned int copyNum) const;
120  std::string computeSensorType(std::string_view name);
121 
122  std::string m_name; // with no namespace
123  int m_copy;
127  std::vector<double> m_params; // default unit: mm from oldDD, cm from DD4hep
128  bool m_isABox;
132 
134  float m_z; // in mm
135 };
136 
138  bool operator()(const DetGeomDesc& a, const DetGeomDesc& b) const {
139  return (a.geographicalID() != b.geographicalID()
140  ? a.geographicalID() < b.geographicalID() // Sort by DetId
141  // If DetIds are identical (== 0 for non-sensors), sort by name and copy number.
142  : (a.name() != b.name() ? a.name() < b.name() : a.copyno() < b.copyno()));
143  }
144 };
145 
146 #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:73
DetGeomDesc::m_isABox
bool m_isABox
Definition: DetGeomDesc.h:127
DetGeomDesc::Container
std::vector< DetGeomDesc * > Container
Definition: DetGeomDesc.h:51
DetGeomDesc::computeDetID
DetId computeDetID(const std::string &name, const std::vector< int > &copyNos, unsigned int copyNum) const
Definition: DetGeomDesc.cc:166
DetGeomDesc::deepDeleteComponents
void deepDeleteComponents()
Definition: DetGeomDesc.cc:116
DetGeomDesc::m_copy
int m_copy
Definition: DetGeomDesc.h:122
DetGeomDesc::m_sensorType
std::string m_sensorType
Definition: DetGeomDesc.h:129
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:132
DetGeomDesc::~DetGeomDesc
virtual ~DetGeomDesc()
Definition: DetGeomDesc.cc:77
DetGeomDesc::m_name
std::string m_name
Definition: DetGeomDesc.h:121
DetGeomDesc::sensorType
const std::string & sensorType() const
Definition: DetGeomDesc.h:91
cms::DDFilteredView
Definition: DDFilteredView.h:70
DetGeomDesc::parentZPosition
float parentZPosition() const
Definition: DetGeomDesc.h:98
RotationMatrix
ROOT::Math::Rotation3D RotationMatrix
Definition: PGeometricDetBuilder.cc:21
DetGeomDesc::m_params
std::vector< double > m_params
Definition: DetGeomDesc.h:126
DetGeomDesc::clearComponents
void clearComponents()
Definition: DetGeomDesc.h:110
DetGeomDesc::m_z
float m_z
Definition: DetGeomDesc.h:133
DetGeomDesc::CopyMode
CopyMode
Definition: DetGeomDesc.h:62
DetId
Definition: DetId.h:17
DetGeomDesc::isLeaf
bool isLeaf() const
Definition: DetGeomDesc.h:100
DDFilteredView.h
DetGeomDesc::geographicalID
DetId geographicalID() const
Definition: DetGeomDesc.h:94
DetGeomDesc::getDiamondDimensions
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:82
DetGeomDesc::computeDetIDFromDD4hep
DetId computeDetIDFromDD4hep(const std::string &name, const std::vector< int > &copyNos, unsigned int copyNum) const
Definition: DetGeomDesc.cc:269
DDFilteredView.h
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:70
DetGeomDesc::m_diamondBoxParams
DiamondDimensions m_diamondBoxParams
Definition: DetGeomDesc.h:128
DetGeomDesc::cmWithoutChildren
Definition: DetGeomDesc.h:62
a
double a
Definition: hdecay.h:119
DetGeomDesc::components
const Container & components() const
Definition: DetGeomDesc.h:97
DetGeomDescCompare
Definition: DetGeomDesc.h:136
DetGeomDesc::isABox
bool isABox() const
Definition: DetGeomDesc.h:81
DetGeomDesc::name
const std::string & name() const
Definition: DetGeomDesc.h:66
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:123
DetGeomDesc::deleteComponents
void deleteComponents()
Definition: DetGeomDesc.cc:114
DetGeomDesc::DetGeomDesc
DetGeomDesc(const DDFilteredView &fv)
Definition: DetGeomDesc.cc:28
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:281
DetGeomDesc::params
const std::vector< double > & params() const
Definition: DetGeomDesc.h:80
DetGeomDesc::computeParameters
std::vector< double > computeParameters(const cms::DDFilteredView &fv) const
Definition: DetGeomDesc.cc:132
DetGeomDesc::cmWithChildren
Definition: DetGeomDesc.h:62
DDFilteredView
Definition: DDFilteredView.h:20
DetGeomDesc::m_geographicalID
DetId m_geographicalID
Definition: DetGeomDesc.h:130
CTPPSRPAlignmentCorrectionData
Alignment correction for an element of the CT-PPS detector. Within the geometry description,...
Definition: CTPPSRPAlignmentCorrectionData.h:58
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:67
DetGeomDesc::rotation
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:74
DetGeomDescCompare::operator()
bool operator()(const DetGeomDesc &a, const DetGeomDesc &b) const
Definition: DetGeomDesc.h:137
DetGeomDesc::m_trans
Translation m_trans
Definition: DetGeomDesc.h:124
DetGeomDesc::m_rot
RotationMatrix m_rot
Definition: DetGeomDesc.h:125