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 DTGeometryBuilder::buildGeometry(DDFilteredView& fview, DTGeometry& geom, const MuonNumbering& num) const {
52  bool doChamber = fview.firstChild();
53 
54  while (doChamber) {
55  DTChamber* chamber = buildChamber(fview, num);
56 
57  // Loop on SLs
58  bool doSL = fview.nextSibling();
59  while (doSL) {
60  DTSuperLayer* sl = buildSuperLayer(fview, chamber, num);
61 
62  // Loop on Layers
63  fview.down();
64  bool doLayers = fview.sibling();
65  while (doLayers) {
66  DTLayer* l = buildLayer(fview, sl, num);
67  geom.add(l);
68 
69  doLayers = fview.sibling(); // go to next Layer
70  }
71  // Done with layers
72 
73  geom.add(sl);
74  doSL = fview.nextSibling(); // go to next SL
75  }
76  geom.add(chamber);
77 
78  fview.parent(); // stop iterating current branch
79  doChamber = fview.firstChild(); // go to next chamber
80  }
81 }
82 
83 DTGeometryBuilder::RCPPlane DTGeometryBuilder::plane(const DDFilteredView& fview, Bounds* bounds) const {
84  const Double_t* tr = fview.trans();
85  const Double_t* rot = fview.rot();
86 
87  return RCPPlane(
88  new Plane(Surface::PositionType(tr[0], tr[1], tr[2]),
89  Surface::RotationType(rot[0], rot[3], rot[6], rot[1], rot[4], rot[7], rot[2], rot[5], rot[8]),
90  bounds));
91 }
92 
93 DTChamber* DTGeometryBuilder::buildChamber(DDFilteredView& fview, const MuonNumbering& muonConstants) const {
94  int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history()));
95  DTChamberId detId(rawid);
96  auto const& par = fview.parameters();
97  // par[0] r-phi dimension - different in different chambers
98  // par[1] z dimension - constant 125.55 cm
99  // par[2] radial thickness - almost constant about 18 cm
100 
101  RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2])));
102 
103  DTChamber* chamber = new DTChamber(detId, surf);
104 
105  return chamber;
106 }
107 
108 DTSuperLayer* DTGeometryBuilder::buildSuperLayer(DDFilteredView& fview,
110  const MuonNumbering& muonConstants) const {
111  int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history()));
112  DTSuperLayerId slId(rawid);
113 
114  auto const& par = fview.parameters();
115  // par[0] r-phi dimension - changes in different chambers
116  // par[1] z dimension - constant 126.8 cm
117  // par[2] radial thickness - almost constant about 20 cm
118 
119  // Ok this is the slayer position...
120  RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2])));
121 
122  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
123 
124  // add to the chamber
125  chamber->add(slayer);
126 
127  return slayer;
128 }
129 
130 DTLayer* DTGeometryBuilder::buildLayer(DDFilteredView& fview,
131  DTSuperLayer* sl,
132  const MuonNumbering& muonConstants) const {
133  int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history()));
134  DTLayerId layId(rawid);
135 
136  auto const& par = fview.parameters();
137  // Layer specific parameter (size)
138  // par[0] r-phi dimension - changes in different chambers
139  // par[1] z dimension - constant 126.8 cm
140  // par[2] radial thickness - almost constant about 20 cm
141  RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2])));
142 
143  // Loop on wires
144  fview.down();
145  bool doWire = fview.sibling();
146  int firstWire = fview.volume()->GetNumber(); // copy no
147  auto const& wpar = fview.parameters();
148  float wireLength = wpar[1];
149 
150  int WCounter = 0;
151  while (doWire) {
152  doWire = fview.checkChild();
153  WCounter++;
154  }
155  fview.up();
156 
157  DTTopology topology(firstWire, WCounter, wireLength);
158 
159  DTLayerType layerType;
160 
161  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
162 
163  sl->add(layer);
164  return layer;
165 }
166 
168  const DDDetector* det,
169  const MuonNumbering& num,
170  const DDSpecParRefs& refs) {
171  Volume top = det->worldVolume();
172  DDFilteredView fview(det, top);
173  fview.mergedSpecifics(refs);
174  dtnum_ = make_unique<DTNumberingScheme>(num.values());
175  buildGeometry(fview, geom, num);
176 }
AlignmentErrorsExtended.h
cms::DDFilteredView::rot
const Double_t * rot() const
The absolute rotation of the current node.
Definition: DDFilteredView.cc:120
cms::DDFilteredView::volume
const PlacedVolume volume() const
The physical volume of the current node.
Definition: DDFilteredView.cc:68
DTGeometry
Definition: DTGeometry.h:28
TkRotation< float >
DTSuperLayerId
Definition: DTSuperLayerId.h:12
cms::MuonNumbering::geoHistoryToBaseNumber
const MuonBaseNumber geoHistoryToBaseNumber(const cms::ExpandedNodes &) const
Definition: DD4hep_MuonNumbering.cc:8
GlobalPositionRcd.h
cms::DDFilteredView::parameters
const std::vector< double > parameters() const
extract shape parameters
Definition: DDFilteredView.cc:448
cms::DDFilteredView::sibling
bool sibling()
set the current node to the next sub sibling
Definition: DDFilteredView.cc:371
DTRecoGeometryRcd.h
cms::DTGeometryBuilder::DDSpecParRefs
std::vector< const DDSpecPar * > DDSpecParRefs
Definition: DTGeometryBuilder.h:31
DTAlignmentErrorExtendedRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
DTChamber
Definition: DTChamber.h:24
cms::DDFilteredView::parent
bool parent()
set the current node to the parent node ...
Definition: DDFilteredView.cc:398
Bounds
Definition: Bounds.h:18
DetectorGlobalPosition.h
ReferenceCountingPointer< Plane >
DTSuperLayer
Definition: DTSuperLayer.h:24
cms::DDFilteredView
Definition: DDFilteredView.h:65
newFWLiteAna.build
build
Definition: newFWLiteAna.py:126
MuonNumberingRecord.h
DDDetector.h
cms::DDFilteredView::nextSibling
bool nextSibling()
set the current node to the next sibling
Definition: DDFilteredView.cc:350
DTTopology
Definition: DTTopology.h:28
Plane.h
GeometryFileRcd.h
cms::DDFilteredView::trans
const Double_t * trans() const
The absolute translation of the current node.
Definition: DDFilteredView.cc:101
ecaldqm::topology
const CaloTopology * topology(nullptr)
cms::DDFilteredView::firstChild
bool firstChild()
set the current node to the first child
Definition: DDFilteredView.cc:218
RectangularPlaneBounds.h
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
cms::DDFilteredView::mergedSpecifics
void mergedSpecifics(DDSpecParRefs const &)
User specific data.
Definition: DDFilteredView.cc:159
DDFilteredView.h
cms::DDFilteredView::down
void down()
set current node to the child node in the filtered tree
Definition: DDFilteredView.cc:419
Bounds.h
Point3DBase< float, GlobalTag >
DTLayerId
Definition: DTLayerId.h:12
RecoIdealGeometry.h
DTSuperLayer::add
void add(DTLayer *l)
Add layer to the SL which owns it.
Definition: DTSuperLayer.cc:47
DTGeometry.h
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
DTAlignmentErrorRcd.h
cms::DDFilteredView::history
const ExpandedNodes & history()
The numbering history of the current node.
Definition: DDFilteredView.cc:573
cms::MuonNumbering
Definition: DD4hep_MuonNumbering.h:37
cms::DDFilteredView::up
void up()
set current node to the parent node in the filtered tree
Definition: DDFilteredView.cc:428
DD4hep_DTNumberingScheme.h
DTAlignmentRcd.h
DTLayer
Definition: DTLayer.h:25
DD4hep_MuonNumbering.h
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
std
Definition: JetResolutionObject.h:76
RectangularPlaneBounds
Definition: RectangularPlaneBounds.h:12
GeometryAligner.h
cms::DDFilteredView::checkChild
bool checkChild()
count the number of children matching selection
Definition: DDFilteredView.cc:385
DTLayerType
Definition: DTLayerType.h:15
cms::DDDetector
Definition: DDDetector.h:11
Plane
Definition: Plane.h:16
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
DTGeometryBuilder.h
DTChamberId
Definition: DTChamberId.h:14
MuonGeometryRecord.h
cms::DDDetector::worldVolume
Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:41
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21