CMS 3D CMS Logo

DTGeometryBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DetectorDescription/DTGeometryBuilder
4 // Class: DTGeometryBuilder
5 //
14 //
15 // Original Author: Ianna Osborne
16 // Created: Wed, 16 Jan 2019 10:19:37 GMT
17 //
18 //
31 
40 #include "DTGeometryBuilder.h"
41 #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 using namespace cms;
50 
51 void
52 DTGeometryBuilder::buildGeometry(DDFilteredView& fview,
53  DTGeometry& geom, const MuonNumbering& num) const {
54 
55  bool doChamber = fview.firstChild();
56 
57  while(doChamber) {
58  DTChamber* chamber = buildChamber(fview, num);
59 
60  // Loop on SLs
61  bool doSL = fview.firstSibling();
62  while(doSL) {
63  DTSuperLayer* sl = buildSuperLayer(fview, chamber, num);
64 
65  // Loop on Layers
66  fview.down();
67  bool doLayers = fview.sibling();
68  while(doLayers) {
69  DTLayer* l = buildLayer(fview, sl, num);
70  fview.unCheckNode();
71  geom.add(l);
72 
73  doLayers = fview.sibling(); // go to next Layer
74  }
75  // Done with layers, go up
76  fview.up();
77 
78  geom.add(sl);
79  doSL = fview.nextSibling(); // go to next SL
80  }
81  geom.add(chamber);
82 
83  fview.parent(); // stop iterating current branch
84  doChamber = fview.firstChild(); // go to next chamber
85  }
86 }
87 
89 DTGeometryBuilder::plane(const DDFilteredView& fview,
90  Bounds* bounds) const {
91 
92  const Double_t *tr = fview.trans();
93  const Double_t *rot = fview.rot();
94 
95  return RCPPlane(new Plane(Surface::PositionType(tr[0], tr[1], tr[2]),
96  Surface::RotationType(rot[0], rot[3], rot[6],
97  rot[1], rot[4], rot[7],
98  rot[2], rot[5], rot[8]),
99  bounds));
100 }
101 
102 DTChamber*
103 DTGeometryBuilder::buildChamber(const DDFilteredView& fview,
104  const MuonNumbering& muonConstants) const {
105  int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history()));
106  DTChamberId detId(rawid);
107  auto const& par = fview.extractParameters();
108  // par[0] r-phi dimension - different in different chambers
109  // par[1] z dimension - constant 125.55 cm
110  // par[2] radial thickness - almost constant about 18 cm
111 
112  RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2])));
113 
114  DTChamber* chamber = new DTChamber(detId, surf);
115 
116  return chamber;
117 }
118 
120 DTGeometryBuilder::buildSuperLayer(const DDFilteredView& fview,
122  const MuonNumbering& muonConstants) const {
123  int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history()));
124  DTSuperLayerId slId(rawid);
125 
126  auto const& par = fview.extractParameters();
127  // par[0] r-phi dimension - changes in different chambers
128  // par[1] z dimension - constant 126.8 cm
129  // par[2] radial thickness - almost constant about 20 cm
130 
131  // Ok this is the slayer position...
132  RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2])));
133 
134  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
135 
136  // add to the chamber
137  chamber->add(slayer);
138 
139  return slayer;
140 }
141 
142 DTLayer*
143 DTGeometryBuilder::buildLayer(DDFilteredView& fview,
144  DTSuperLayer* sl,
145  const MuonNumbering& muonConstants) const {
146  int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history()));
147  DTLayerId layId(rawid);
148 
149  auto const& par = fview.extractParameters();
150  // Layer specific parameter (size)
151  // par[0] r-phi dimension - changes in different chambers
152  // par[1] z dimension - constant 126.8 cm
153  // par[2] radial thickness - almost constant about 20 cm
154  RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2])));
155 
156  // Loop on wires
157  fview.down();
158  bool doWire = fview.siblingNoCheck();
159  int firstWire = fview.volume()->GetNumber(); // copy no
160  auto const& wpar = fview.extractParameters();
161  float wireLength = wpar[1];
162 
163  int WCounter = 0;
164  while(doWire) {
165  doWire = fview.checkChild();
166  WCounter++;
167  }
168  fview.up();
169 
170  DTTopology topology(firstWire, WCounter, wireLength);
171 
172  DTLayerType layerType;
173 
174  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
175 
176  sl->add(layer);
177  return layer;
178 }
179 
180 void
181 DTGeometryBuilder::build(DTGeometry& geom,
182  const DDDetector* det,
183  const MuonNumbering& num,
184  const DDSpecParRefs& refs) {
185  Volume top = det->worldVolume();
186  DDFilteredView fview(det, top);
187  fview.mergedSpecifics(refs);
188  dtnum_ = make_unique<DTNumberingScheme>(num.values());
189  buildGeometry(fview, geom, num);
190 }
void up()
set current node to the parent node in the filtered tree
bool firstSibling()
set the current node to the first sibling
CaloTopology const * topology(0)
void mergedSpecifics(DDSpecParRefs const &)
User specific data.
void add(DTLayer *l)
Add layer to the SL which owns it.
Definition: DTSuperLayer.cc:59
Volume worldVolume() const
Definition: DDDetector.cc:34
const PlacedVolume volume() const
The physical volume of the current node.
bool sibling()
set the current node to the next sub sibling
const ExpandedNodes & history() const
The numbering history of the current node.
Definition: Plane.h:17
void down()
set current node to the child node in the filtered tree
bool nextSibling()
set the current node to the next sibling
const Double_t * rot() const
The absolute rotation of the current node.
const MuonBaseNumber geoHistoryToBaseNumber(const cms::ExpandedNodes &) const
bool parent()
set the current node to the parent node ...
bool firstChild()
set the current node to the first child
dd4hep::Volume Volume
Namespace of DDCMS conversion namespace.
std::vector< double > extractParameters() const
extract shape parameters
const Double_t * trans() const
The absolute translation of the current node.
const MuonConstants & values() const
HLT enums.
void add(DTSuperLayer *sl)
Add SL to the chamber which takes ownership.
Definition: DTChamber.cc:41
Definition: Bounds.h:22
std::vector< const DDSpecPar * > DDSpecParRefs
bool checkChild()
count the number of children matching selection
void unCheckNode()
pop current node
void add(DTChamber *ch)
Add a DTChamber to Geometry.
Definition: DTGeometry.cc:44