CMS 3D CMS Logo

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,
85 
86  // Constructors from Filtered View (called while looping over DD).
89  // Constructors from persistent data (from DB)
91 
92  // ACCESS GENERAL INFO
93  const std::string& name() const { return ddname_; }
94  const GeometricEnumType& type() const { return type_; }
95 
96  // NAVIGATION related info
97  const nav_type& navType() const { return ddd_; }
98  NavRange navpos() const { return NavRange(&ddd_.front(), ddd_.size()); }
99  const DetId& geographicalId() const { return geographicalID_; }
101 
102  // VOLUME POSITION in CMS frame of reference
103  const Translation& translation() const { return trans_; } // in mm
104  double rho() const { return rho_; } // in mm
105  double phi() const { return phi_; }
106  const RotationMatrix& rotation() const { return rot_; }
107 
108  // BOUNDS
109  std::unique_ptr<Bounds> bounds() const;
110  Position positionBounds() const; // in cm
111  Rotation rotationBounds() const;
112 
113  // SOLID SHAPE
114  // old DD
116  // DD4hep
117  const cms::DDSolidShape& shape_dd4hep() const { return shape_; }
118  // solid shape parameters
119  const std::vector<double>& params() const {
122  edm::LogError("GeometricDet::params()")
123  << "Called on a shape which is neither a box, a trap, nor a tub. This is not supported!";
124  }
125  return params_;
126  } // in mm
127 
128  // RADIATION LENGTH AND ENERGY LOSS
129  double radLength() const { return radLength_; }
130  double xi() const { return xi_; }
131 
132  // SENSOR INFO
133  // Only return meaningful results for pixels.
134  double pixROCRows() const { return pixROCRows_; }
135  double pixROCCols() const { return pixROCCols_; }
136  double pixROCx() const { return pixROCx_; }
137  double pixROCy() const { return pixROCy_; }
138  int bigPixelsx() const { return bigPixelsx_; }
139  int bigPixelsy() const { return bigPixelsy_; }
140  float bigPixelsPitchx() const { return bigPixelsPitchx_; }
141  float bigPixelsPitchy() const { return bigPixelsPitchy_; }
142  bool isFirstSensor() const { return isFirstSensor_; }
143  bool isSecondSensor() const { return isSecondSensor_; }
144  // Only return meaningful results for Outer Trackers.
145  bool stereo() const { return stereo_; }
146  bool isLowerSensor() const { return isLowerSensor_; }
147  bool isUpperSensor() const { return isUpperSensor_; }
148  double siliconAPVNum() const { return siliconAPVNum_; }
149 
150  // DETECTOR DESCRIPTION ORIGIN INFO
151  bool isFromDD4hep() const { return isFromDD4hep_; }
152 
153  // CHILDREN INFO
154  GeometricDet* component(size_t index) { return const_cast<GeometricDet*>(container_[index]); }
155  bool isLeaf() const { return container_.empty(); }
156  // direct children only
157  // if the current GeometricDet is a leaf, it returns nothing.
160  // all descendants
161  // if the current GeometricDet is a leaf, it returns itself!
164 
165  // PUBLIC SETTERS (they should obviously be as few as possible!!)
168  void addComponent(GeometricDet*);
169  void clearComponents() { container_.clear(); } // only empties the container, THE CHILDREN ARE NOT DELETED!
170  void deleteComponents(); // EXPLICITLY DELETES THE CHILDREN
171 
172  // CUSTOM DESTRUCTOR
173  ~GeometricDet();
174 
175  // Utility function
176  static std::string printNavType(int const* n, size_t sz);
177 
178 private:
179  std::vector<double> computeLegacyShapeParameters(const cms::DDSolidShape& mySolidShape,
180  const dd4hep::Solid& mySolid) const;
181 
184 
187 
188  Translation trans_; // in mm
189  double rho_ = 0.; // in mm
190  double phi_ = 0.;
192 
194  std::vector<double> params_; // in mm
195 
196  double radLength_ = 0.;
197  double xi_ = 0.;
198  double pixROCRows_ = 0.;
199  double pixROCCols_ = 0.;
200  double pixROCx_ = 0.;
201  double pixROCy_ = 0.;
202  int bigPixelsx_ = 0;
203  int bigPixelsy_ = 0;
204  float bigPixelsPitchx_ = 0.;
205  float bigPixelsPitchy_ = 0.;
206  bool isFirstSensor_ = false;
207  bool isSecondSensor_ = false;
208  bool stereo_ = false;
209  bool isLowerSensor_ = false;
210  bool isUpperSensor_ = false;
211  double siliconAPVNum_ = 0.;
212 
213  bool isFromDD4hep_ = false;
214 
216 };
217 
218 namespace geometric_det_ns {
219  inline std::ostream& operator<<(std::ostream& os, const GeometricDet::NavRange& n) {
220  os << GeometricDet::printNavType(n.first, n.second);
221  return os;
222  }
223 } // namespace geometric_det_ns
224 
225 #undef PoolAlloc
226 #endif
double siliconAPVNum() const
Definition: GeometricDet.h:148
std::vector< GeometricDet * > GeometricDetContainer
Definition: GeometricDet.h:35
float bigPixelsPitchy_
Definition: GeometricDet.h:205
cms::DDSolidShape shape_
Definition: GeometricDet.h:193
double pixROCy() const
Definition: GeometricDet.h:137
bool isLowerSensor_
Definition: GeometricDet.h:209
double pixROCCols_
Definition: GeometricDet.h:199
int bigPixelsy() const
Definition: GeometricDet.h:139
void addComponent(GeometricDet *)
std::vector< double > params_
Definition: GeometricDet.h:194
double phi() const
Definition: GeometricDet.h:105
const std::vector< double > & params() const
Definition: GeometricDet.h:119
void clearComponents()
Definition: GeometricDet.h:169
const cms::DDSolidShape & shape_dd4hep() const
Definition: GeometricDet.h:117
bool isUpperSensor() const
Definition: GeometricDet.h:147
void setGeographicalID(DetId id)
Definition: GeometricDet.h:100
Position positionBounds() const
DetId geographicalID_
Definition: GeometricDet.h:186
Log< level::Error, false > LogError
bool isLowerSensor() const
Definition: GeometricDet.h:146
std::vector< int > nav_type
Definition: GeometricDet.h:42
bool stereo() const
Definition: GeometricDet.h:145
enum GeometricDet::GDEnumType GeometricEnumType
string dd
Definition: createTree.py:154
bool isUpperSensor_
Definition: GeometricDet.h:210
nav_type ddd_
Definition: GeometricDet.h:185
float bigPixelsPitchy() const
Definition: GeometricDet.h:141
Mapping::value_type::value_type value(Mapping a, const std::string &name)
Definition: DDSolidShapes.h:42
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:158
ConstGeometricDetContainer container_
Definition: GeometricDet.h:215
bool isFromDD4hep() const
Definition: GeometricDet.h:151
const Translation & translation() const
Definition: GeometricDet.h:103
double pixROCx_
Definition: GeometricDet.h:200
float bigPixelsPitchx() const
Definition: GeometricDet.h:140
bool isFromDD4hep_
Definition: GeometricDet.h:213
static std::string printNavType(int const *n, size_t sz)
GeometricEnumType type_
Definition: GeometricDet.h:183
double radLength_
Definition: GeometricDet.h:196
std::ostream & operator<<(std::ostream &os, const GeometricDet::NavRange &n)
Definition: GeometricDet.h:219
LegacySolidShape shape() const
Definition: GeometricDet.h:115
Rotation rotationBounds() const
const ConstGeometricDetContainer & components() const
Definition: GeometricDet.h:159
GeometricDet(DDFilteredView *fv, GeometricEnumType dd)
Definition: GeometricDet.cc:73
GeometricDet * component(size_t index)
Definition: GeometricDet.h:154
double rho() const
Definition: GeometricDet.h:104
bool isFirstSensor_
Definition: GeometricDet.h:206
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:34
const std::string & name() const
Definition: GeometricDet.h:93
const std::array< const cms::dd::ValuePair< LegacySolidShape, cms::DDSolidShape >, 21 > LegacySolidShapeMap
int bigPixelsx() const
Definition: GeometricDet.h:138
void deleteComponents()
Point3DBase< float, GlobalTag > PositionType
Surface::RotationType Rotation
Definition: GeometricDet.h:46
const RotationMatrix & rotation() const
Definition: GeometricDet.h:106
double xi() const
Definition: GeometricDet.h:130
double pixROCy_
Definition: GeometricDet.h:201
Namespace of DDCMS conversion namespace.
std::vector< double > computeLegacyShapeParameters(const cms::DDSolidShape &mySolidShape, const dd4hep::Solid &mySolid) const
bool isLeaf() const
Definition: GeometricDet.h:155
double pixROCRows_
Definition: GeometricDet.h:198
float bigPixelsPitchx_
Definition: GeometricDet.h:204
Definition: DetId.h:17
const DetId & geographicalId() const
Definition: GeometricDet.h:99
double radLength() const
Definition: GeometricDet.h:129
const GeometricEnumType & type() const
Definition: GeometricDet.h:94
bool isSecondSensor() const
Definition: GeometricDet.h:143
DDSolidShape
Definition: DDSolidShapes.h:6
bool isSecondSensor_
Definition: GeometricDet.h:207
double pixROCRows() const
Definition: GeometricDet.h:134
Translation trans_
Definition: GeometricDet.h:188
void addComponents(GeometricDetContainer const &cont)
std::string ddname_
Definition: GeometricDet.h:182
double pixROCx() const
Definition: GeometricDet.h:136
std::pair< int const *, size_t > NavRange
Definition: GeometricDet.h:33
TkRotation< float > RotationType
ROOT::Math::Rotation3D RotationMatrix
Definition: GeometricDet.h:36
ConstGeometricDetContainer deepComponents() const
const nav_type & navType() const
Definition: GeometricDet.h:97
NavRange navpos() const
Definition: GeometricDet.h:98
RotationMatrix rot_
Definition: GeometricDet.h:191
Surface::PositionType Position
Definition: GeometricDet.h:45
bool isFirstSensor() const
Definition: GeometricDet.h:142
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: GeometricDet.h:37
cont
load Luminosity info ##
Definition: generateEDF.py:620
double siliconAPVNum_
Definition: GeometricDet.h:211
double pixROCCols() const
Definition: GeometricDet.h:135
std::unique_ptr< Bounds > bounds() const
DDSolidShape
Definition: DDSolidShapes.h:73