CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GeometricDet.h
Go to the documentation of this file.
1 #ifndef Geometry_TrackerNumberingBuilder_GeometricDet_H
2 #define Geometry_TrackerNumberingBuilder_GeometricDet_H
3 
11 
12 #include <DD4hep/Shapes.h>
13 #include <Math/Rotation3D.h>
14 #include <Math/Vector3D.h>
15 
16 #include <vector>
17 #include <memory>
18 #include <ext/pool_allocator.h>
19 
20 class DDFilteredView;
21 
22 namespace cms {
23  class DDFilteredView;
24 }
25 
31 class GeometricDet {
32 public:
33  using NavRange = std::pair<int const*, size_t>;
34  using ConstGeometricDetContainer = std::vector<GeometricDet const*>;
35  using GeometricDetContainer = std::vector<GeometricDet*>;
36  using RotationMatrix = ROOT::Math::Rotation3D;
37  using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >;
38 
39 #ifdef PoolAlloc
40  using nav_type = std::vector<int, PoolAlloc<int> >;
41 #else
42  using nav_type = std::vector<int>;
43 #endif
44 
47 
48  typedef enum GDEnumType {
49  unknown = 100,
50  Tracker = 0,
53  TIB = 3,
54  TID = 4,
55  TOB = 5,
56  TEC = 6,
57  layer = 8,
58  wheel = 9,
59  strng = 10,
60  rod = 11,
61  petal = 12,
62  ring = 13,
63  ladder = 14,
64  mergedDet = 15,
65  DetUnit = 16,
66  disk = 17,
67  panel = 18,
82 
83  // Constructors from Filtered View (called while looping over DD).
86  // Constructors from persistent data (from DB)
88 
89  // ACCESS GENERAL INFO
90  const std::string& name() const { return ddname_; }
91  const GeometricEnumType& type() const { return type_; }
92 
93  // NAVIGATION related info
94  const nav_type& navType() const { return ddd_; }
95  NavRange navpos() const { return NavRange(&ddd_.front(), ddd_.size()); }
96  const DetId& geographicalId() const { return geographicalID_; }
98 
99  // VOLUME POSITION in CMS frame of reference
100  const Translation& translation() const { return trans_; } // in mm
101  double rho() const { return rho_; } // in mm
102  double phi() const { return phi_; }
103  const RotationMatrix& rotation() const { return rot_; }
104 
105  // BOUNDS
106  std::unique_ptr<Bounds> bounds() const;
107  Position positionBounds() const; // in cm
108  Rotation rotationBounds() const;
109 
110  // SOLID SHAPE
111  // old DD
113  // DD4hep
114  const cms::DDSolidShape& shape_dd4hep() const { return shape_; }
115  // solid shape parameters
116  const std::vector<double>& params() const {
119  edm::LogError("GeometricDet::params()")
120  << "Called on a shape which is neither a box, a trap, nor a tub. This is not supported!";
121  }
122  return params_;
123  } // in mm
124 
125  // RADIATION LENGTH AND ENERGY LOSS
126  double radLength() const { return radLength_; }
127  double xi() const { return xi_; }
128 
129  // SENSOR INFO
130  // Only return meaningful results for pixels.
131  bool isBricked() const { return isBricked_; }
132  double pixROCRows() const { return pixROCRows_; }
133  double pixROCCols() const { return pixROCCols_; }
134  double pixROCx() const { return pixROCx_; }
135  double pixROCy() const { return pixROCy_; }
136  // Only return meaningful results for Outer Trackers.
137  bool stereo() const { return stereo_; }
138  bool isLowerSensor() const { return isLowerSensor_; }
139  bool isUpperSensor() const { return isUpperSensor_; }
140  double siliconAPVNum() const { return siliconAPVNum_; }
141 
142  // DETECTOR DESCRIPTION ORIGIN INFO
143  bool isFromDD4hep() const { return isFromDD4hep_; }
144 
145  // CHILDREN INFO
146  GeometricDet* component(size_t index) { return const_cast<GeometricDet*>(container_[index]); }
147  bool isLeaf() const { return container_.empty(); }
148  // direct children only
149  // if the current GeometricDet is a leaf, it returns nothing.
152  // all descendants
153  // if the current GeometricDet is a leaf, it returns itself!
156 
157  // PUBLIC SETTERS (they should obviously be as few as possible!!)
160  void addComponent(GeometricDet*);
161  void clearComponents() { container_.clear(); } // only empties the container, THE CHILDREN ARE NOT DELETED!
162  void deleteComponents(); // EXPLICITLY DELETES THE CHILDREN
163 
164  // CUSTOM DESTRUCTOR
165  ~GeometricDet();
166 
167 private:
168  std::vector<double> computeLegacyShapeParameters(const cms::DDSolidShape& mySolidShape,
169  const dd4hep::Solid& mySolid) const;
170 
173 
176 
177  Translation trans_; // in mm
178  double rho_ = 0.; // in mm
179  double phi_ = 0.;
181 
183  std::vector<double> params_; // in mm
184 
185  double radLength_ = 0.;
186  double xi_ = 0.;
187  bool isBricked_ = false;
188  double pixROCRows_ = 0.;
189  double pixROCCols_ = 0.;
190  double pixROCx_ = 0.;
191  double pixROCy_ = 0.;
192  bool stereo_ = false;
193  bool isLowerSensor_ = false;
194  bool isUpperSensor_ = false;
195  double siliconAPVNum_ = 0.;
196 
197  bool isFromDD4hep_ = false;
198 
200 };
201 
202 #undef PoolAlloc
203 #endif
std::vector< GeometricDet * > GeometricDetContainer
Definition: GeometricDet.h:35
double pixROCy() const
Definition: GeometricDet.h:135
bool isFromDD4hep() const
Definition: GeometricDet.h:143
cms::DDSolidShape shape_
Definition: GeometricDet.h:182
double radLength() const
Definition: GeometricDet.h:126
bool isLowerSensor_
Definition: GeometricDet.h:193
double pixROCCols_
Definition: GeometricDet.h:189
bool isUpperSensor() const
Definition: GeometricDet.h:139
tuple cont
load Luminosity info ##
Definition: generateEDF.py:628
uint16_t *__restrict__ id
void addComponent(GeometricDet *)
std::vector< double > params_
Definition: GeometricDet.h:183
void clearComponents()
Definition: GeometricDet.h:161
void setGeographicalID(DetId id)
Definition: GeometricDet.h:97
bool isLeaf() const
Definition: GeometricDet.h:147
const ConstGeometricDetContainer & components() const
Definition: GeometricDet.h:151
DetId geographicalID_
Definition: GeometricDet.h:175
LegacySolidShape shape() const
Definition: GeometricDet.h:112
Log< level::Error, false > LogError
std::vector< int > nav_type
Definition: GeometricDet.h:42
enum GeometricDet::GDEnumType GeometricEnumType
bool isUpperSensor_
Definition: GeometricDet.h:194
nav_type ddd_
Definition: GeometricDet.h:174
std::vector< double > computeLegacyShapeParameters(const cms::DDSolidShape &mySolidShape, const dd4hep::Solid &mySolid) const
const std::vector< double > & params() const
Definition: GeometricDet.h:116
Mapping::value_type::value_type value(Mapping a, const std::string &name)
Definition: DDSolidShapes.h:42
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:150
ConstGeometricDetContainer container_
Definition: GeometricDet.h:199
Position positionBounds() const
const RotationMatrix & rotation() const
Definition: GeometricDet.h:103
double pixROCx_
Definition: GeometricDet.h:190
bool isFromDD4hep_
Definition: GeometricDet.h:197
const GeometricEnumType & type() const
Definition: GeometricDet.h:91
const nav_type & navType() const
Definition: GeometricDet.h:94
GeometricEnumType type_
Definition: GeometricDet.h:172
double radLength_
Definition: GeometricDet.h:185
GeometricDet(DDFilteredView *fv, GeometricEnumType dd)
Definition: GeometricDet.cc:73
std::unique_ptr< Bounds > bounds() const
double pixROCCols() const
Definition: GeometricDet.h:133
GeometricDet * component(size_t index)
Definition: GeometricDet.h:146
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:34
const std::array< const cms::dd::ValuePair< LegacySolidShape, cms::DDSolidShape >, 21 > LegacySolidShapeMap
void deleteComponents()
const cms::DDSolidShape & shape_dd4hep() const
Definition: GeometricDet.h:114
Point3DBase< float, GlobalTag > PositionType
Surface::RotationType Rotation
Definition: GeometricDet.h:46
double pixROCy_
Definition: GeometricDet.h:191
const DetId & geographicalId() const
Definition: GeometricDet.h:96
double pixROCRows_
Definition: GeometricDet.h:188
Definition: DetId.h:17
double xi() const
Definition: GeometricDet.h:127
DDSolidShape
Definition: DDSolidShapes.h:6
Translation trans_
Definition: GeometricDet.h:177
double pixROCx() const
Definition: GeometricDet.h:134
NavRange navpos() const
Definition: GeometricDet.h:95
double phi() const
Definition: GeometricDet.h:102
ConstGeometricDetContainer deepComponents() const
void addComponents(GeometricDetContainer const &cont)
Rotation rotationBounds() const
std::string ddname_
Definition: GeometricDet.h:171
std::pair< int const *, size_t > NavRange
Definition: GeometricDet.h:33
TkRotation< float > RotationType
ROOT::Math::Rotation3D RotationMatrix
Definition: GeometricDet.h:36
const Translation & translation() const
Definition: GeometricDet.h:100
const std::string & name() const
Definition: GeometricDet.h:90
double siliconAPVNum() const
Definition: GeometricDet.h:140
RotationMatrix rot_
Definition: GeometricDet.h:180
Surface::PositionType Position
Definition: GeometricDet.h:45
bool stereo() const
Definition: GeometricDet.h:137
double pixROCRows() const
Definition: GeometricDet.h:132
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: GeometricDet.h:37
bool isBricked() const
Definition: GeometricDet.h:131
bool isLowerSensor() const
Definition: GeometricDet.h:138
double siliconAPVNum_
Definition: GeometricDet.h:195
double rho() const
Definition: GeometricDet.h:101
DDSolidShape
Definition: DDSolidShapes.h:73