CMS 3D CMS Logo

DTGeometryBuilderFromDD4hep.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Geometry/DTGeometryBuilder
4 // Class: DTGeometryBuilderFromDD4hep
5 //
14 //
15 // Original Author: Ianna Osborne
16 // Created: Wed, 16 Jan 2019 10:19:37 GMT
17 // Modified by Sergio Lo Meo (sergio.lo.meo@cern.ch) Mon, 31 August 2020
18 //
19 //
40 #include "DD4hep/Detector.h"
42 
43 #include <memory>
44 #include <string>
45 #include <string_view>
46 
47 using namespace edm;
48 using namespace std;
49 
52  const MuonGeometryConstants& num) const {
53  edm::LogVerbatim("DTGeometryBuilder") << "(0) DTGeometryBuilder - DD4hep ";
54 
55  bool doChamber = fview.firstChild();
56 
57  while (doChamber) {
58  DTChamber* chamber = buildChamber(fview, num);
59 
60  bool doSL = fview.nextSibling();
61  while (doSL) {
62  DTSuperLayer* sl = buildSuperLayer(fview, chamber, num);
63 
64  fview.down();
65  bool doLayers = fview.sibling();
66  while (doLayers) {
67  DTLayer* l = buildLayer(fview, sl, num);
68  geom.add(l);
69 
70  doLayers = fview.sibling();
71  }
72 
73  geom.add(sl);
74  doSL = fview.nextSibling();
75  }
76  geom.add(chamber);
77 
78  fview.parent();
79  doChamber = fview.firstChild();
80  }
81 }
82 
84  Bounds* bounds) const {
85  const Double_t* tr = fview.trans();
86  const Double_t* rot = fview.rot();
87 
88  return RCPPlane(
89  new Plane(Surface::PositionType(tr[0] / dd4hep::cm, tr[1] / dd4hep::cm, tr[2] / dd4hep::cm),
90  Surface::RotationType(rot[0], rot[3], rot[6], rot[1], rot[4], rot[7], rot[2], rot[5], rot[8]),
91  bounds));
92 }
93 
95  const MuonGeometryConstants& muonConstants) const {
96  MuonGeometryNumbering mdddnum(muonConstants);
97  DTNumberingScheme dtnum(muonConstants);
98  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fview.history()));
99 
100  DTChamberId detId(rawid);
101  auto const& par = fview.parameters();
102 
103  RCPPlane surf(
104  plane(fview, new RectangularPlaneBounds(par[0] / dd4hep::cm, par[1] / dd4hep::cm, par[2] / dd4hep::cm)));
105 
106  edm::LogVerbatim("DTGeometryBuilder") << "(1) detId: " << rawid << " par[0]: " << par[0] / dd4hep::cm
107  << " par[1]: " << par[1] / dd4hep::cm << " par[2]: " << par[2] / dd4hep::cm;
108 
109  DTChamber* chamber = new DTChamber(detId, surf);
110 
111  return chamber;
112 }
113 
116  const MuonGeometryConstants& muonConstants) const {
117  MuonGeometryNumbering mdddnum(muonConstants);
118  DTNumberingScheme dtnum(muonConstants);
119  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fview.history()));
120 
121  DTSuperLayerId slId(rawid);
122 
123  auto const& par = fview.parameters();
124 
125  RCPPlane surf(
126  plane(fview, new RectangularPlaneBounds(par[0] / dd4hep::cm, par[1] / dd4hep::cm, par[2] / dd4hep::cm)));
127 
128  edm::LogVerbatim("DTGeometryBuilder") << "(2) detId: " << rawid << " par[0]: " << par[0] / dd4hep::cm
129  << " par[1]: " << par[1] / dd4hep::cm << " par[2]: " << par[2] / dd4hep::cm;
130 
131  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
132 
133  chamber->add(slayer);
134 
135  return slayer;
136 }
137 
139  DTSuperLayer* sl,
140  const MuonGeometryConstants& muonConstants) const {
141  MuonGeometryNumbering mdddnum(muonConstants);
142  DTNumberingScheme dtnum(muonConstants);
143  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fview.history()));
144 
145  DTLayerId layId(rawid);
146 
147  auto const& par = fview.parameters();
148 
149  RCPPlane surf(
150  plane(fview, new RectangularPlaneBounds(par[0] / dd4hep::cm, par[1] / dd4hep::cm, par[2] / dd4hep::cm)));
151 
152  edm::LogVerbatim("DTGeometryBuilder") << "(3) detId: " << rawid << " par[0]: " << par[0] / dd4hep::cm
153  << " par[1]: " << par[1] / dd4hep::cm << " par[2]: " << par[2] / dd4hep::cm;
154 
155  fview.down();
156  bool doWire = fview.sibling();
157  int firstWire = fview.volume()->GetNumber();
158  auto const& wpar = fview.parameters();
159  float wireLength = wpar[1] / dd4hep::cm;
160 
161  edm::LogVerbatim("DTGeometryBuilder") << "(4) detId: " << rawid << " wpar[1]: " << wpar[1] / dd4hep::cm
162  << " firstWire: " << firstWire;
163 
164  int WCounter = 0;
165  while (doWire) {
166  doWire = fview.checkChild();
167  WCounter++;
168  }
169  fview.up();
170 
171  DTTopology topology(firstWire, WCounter, wireLength);
172 
173  DTLayerType layerType;
174 
175  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
176 
177  sl->add(layer);
178  return layer;
179 }
180 
182  const cms::DDDetector* det,
183  const MuonGeometryConstants& num,
184  const dd4hep::SpecParRefs& refs) {
185  cms::Volume top = det->worldVolume();
186  cms::DDFilteredView fview(det, top);
187  fview.mergedSpecifics(refs);
188  buildGeometry(fview, geom, num);
189 }
Log< level::Info, true > LogVerbatim
void up()
set current node to the parent node in the filtered tree
void mergedSpecifics(DDSpecParRefs const &)
User specific data.
const Double_t * rot() const
The absolute rotation of the current node.
void buildGeometry(cms::DDFilteredView &, DTGeometry &, const MuonGeometryConstants &) const
void add(DTLayer *l)
Add layer to the SL which owns it.
Definition: DTSuperLayer.cc:47
bool sibling()
set the current node to the next sub sibling
DTChamber * buildChamber(cms::DDFilteredView &, const MuonGeometryConstants &) const
Definition: Plane.h:16
void down()
set current node to the child node in the filtered tree
constexpr std::array< uint8_t, layerIndexSize > layer
const Double_t * trans() const
The absolute translation of the current node.
int baseNumberToUnitNumber(const MuonBaseNumber &num) const override
bool nextSibling()
set the current node to the next sibling
DTLayer * buildLayer(cms::DDFilteredView &, DTSuperLayer *, const MuonGeometryConstants &) const
const ExpandedNodes & history()
The numbering history of the current node.
DTSuperLayer * buildSuperLayer(cms::DDFilteredView &, DTChamber *, const MuonGeometryConstants &) const
bool parent()
set the current node to the parent node ...
bool firstChild()
set the current node to the first child
dd4hep::Volume Volume
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:62
HLT enums.
const PlacedVolume volume() const
The physical volume of the current node.
void build(DTGeometry &, const cms::DDDetector *, const MuonGeometryConstants &, const dd4hep::SpecParRefs &)
Definition: Bounds.h:18
bool checkChild()
count the number of children matching selection
const std::vector< double > parameters() const
extract shape parameters
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history) const
RCPPlane plane(const cms::DDFilteredView &, Bounds *bounds) const