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 // Modified by Sergio Lo Meo (sergio.lo.meo@cern.ch) Mon, 31 August 2020
18 //
19 //
41 #include "DTGeometryBuilder.h"
42 #include "DD4hep/Detector.h"
44 
45 #include <memory>
46 #include <string>
47 #include <string_view>
48 
49 using namespace edm;
50 using namespace std;
51 using namespace cms;
52 
53 void DTGeometryBuilder::buildGeometry(DDFilteredView& fview, DTGeometry& geom, const MuonGeometryConstants& num) const {
54  edm::LogVerbatim("DTGeometryBuilder") << "(0) DTGeometryBuilder - DD4Hep ";
55 
56  bool doChamber = fview.firstChild();
57 
58  while (doChamber) {
59  DTChamber* chamber = buildChamber(fview, num);
60 
61  bool doSL = fview.nextSibling();
62  while (doSL) {
63  DTSuperLayer* sl = buildSuperLayer(fview, chamber, num);
64 
65  fview.down();
66  bool doLayers = fview.sibling();
67  while (doLayers) {
68  DTLayer* l = buildLayer(fview, sl, num);
69  geom.add(l);
70 
71  doLayers = fview.sibling();
72  }
73 
74  geom.add(sl);
75  doSL = fview.nextSibling();
76  }
77  geom.add(chamber);
78 
79  fview.parent();
80  doChamber = fview.firstChild();
81  }
82 }
83 
84 DTGeometryBuilder::RCPPlane DTGeometryBuilder::plane(const DDFilteredView& fview, 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 
94 DTChamber* DTGeometryBuilder::buildChamber(DDFilteredView& fview, const MuonGeometryConstants& muonConstants) const {
95  MuonGeometryNumbering mdddnum(muonConstants);
96  DTNumberingScheme dtnum(muonConstants);
97  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fview.history()));
98 
99  DTChamberId detId(rawid);
100  auto const& par = fview.parameters();
101 
102  edm::LogVerbatim("DTGeometryBuilder") << "(1) detId: " << rawid << " par[0]: " << par[0] / dd4hep::cm
103  << " par[1]: " << par[1] / dd4hep::cm << " par[2]: " << par[2] / dd4hep::cm;
104 
105  RCPPlane surf(
106  plane(fview, new RectangularPlaneBounds(par[0] / dd4hep::cm, par[1] / dd4hep::cm, par[2] / dd4hep::cm)));
107 
108  DTChamber* chamber = new DTChamber(detId, surf);
109 
110  return chamber;
111 }
112 
113 DTSuperLayer* DTGeometryBuilder::buildSuperLayer(DDFilteredView& fview,
115  const MuonGeometryConstants& muonConstants) const {
116  MuonGeometryNumbering mdddnum(muonConstants);
117  DTNumberingScheme dtnum(muonConstants);
118  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fview.history()));
119 
120  DTSuperLayerId slId(rawid);
121 
122  auto const& par = fview.parameters();
123 
124  edm::LogVerbatim("DTGeometryBuilder") << "(2) detId: " << rawid << " par[0]: " << par[0] / dd4hep::cm
125  << " par[1]: " << par[1] / dd4hep::cm << " par[2]: " << par[2] / dd4hep::cm;
126 
127  RCPPlane surf(
128  plane(fview, new RectangularPlaneBounds(par[0] / dd4hep::cm, par[1] / dd4hep::cm, par[2] / dd4hep::cm)));
129 
130  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
131 
132  chamber->add(slayer);
133 
134  return slayer;
135 }
136 
137 DTLayer* DTGeometryBuilder::buildLayer(DDFilteredView& fview,
138  DTSuperLayer* sl,
139  const MuonGeometryConstants& muonConstants) const {
140  MuonGeometryNumbering mdddnum(muonConstants);
141  DTNumberingScheme dtnum(muonConstants);
142  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fview.history()));
143 
144  DTLayerId layId(rawid);
145 
146  auto const& par = fview.parameters();
147 
148  edm::LogVerbatim("DTGeometryBuilder") << "(3) detId: " << rawid << " par[0]: " << par[0] / dd4hep::cm
149  << " par[1]: " << par[1] / dd4hep::cm << " par[2]: " << par[2] / dd4hep::cm;
150 
151  RCPPlane surf(
152  plane(fview, new RectangularPlaneBounds(par[0] / dd4hep::cm, par[1] / dd4hep::cm, par[2] / dd4hep::cm)));
153 
154  fview.down();
155  bool doWire = fview.sibling();
156  int firstWire = fview.volume()->GetNumber();
157  auto const& wpar = fview.parameters();
158  float wireLength = wpar[1] / dd4hep::cm;
159 
160  edm::LogVerbatim("DTGeometryBuilder") << "(4) detId: " << rawid << " wpar[1]: " << wpar[1] / dd4hep::cm
161  << " firstWire: " << firstWire;
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 
181  const DDDetector* det,
182  const MuonGeometryConstants& num,
183  const dd4hep::SpecParRefs& refs) {
184  Volume top = det->worldVolume();
185  DDFilteredView fview(det, top);
186  fview.mergedSpecifics(refs);
187  buildGeometry(fview, geom, num);
188 }
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
MuonGeometryConstants
Definition: MuonGeometryConstants.h:20
GlobalPositionRcd.h
cms::DDFilteredView::parameters
const std::vector< double > parameters() const
extract shape parameters
Definition: DDFilteredView.cc:536
MessageLogger.h
cms::DDFilteredView::sibling
bool sibling()
set the current node to the next sub sibling
Definition: DDFilteredView.cc:450
MuonGeometryNumbering::geoHistoryToBaseNumber
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history) const
Definition: MuonGeometryNumbering.cc:38
DTRecoGeometryRcd.h
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:481
Bounds
Definition: Bounds.h:18
DetectorGlobalPosition.h
MuonGeometryNumbering.h
ReferenceCountingPointer< Plane >
DTSuperLayer
Definition: DTSuperLayer.h:24
cms::DDFilteredView
Definition: DDFilteredView.h:70
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:427
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
cms::DDFilteredView::firstChild
bool firstChild()
set the current node to the first child
Definition: DDFilteredView.cc:268
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
DTNumberingScheme::baseNumberToUnitNumber
int baseNumberToUnitNumber(const MuonBaseNumber &num) const override
Definition: DTNumberingScheme.cc:37
cms::DDFilteredView::down
void down()
set current node to the child node in the filtered tree
Definition: DDFilteredView.cc:505
Bounds.h
Point3DBase< float, GlobalTag >
DTLayerId
Definition: DTLayerId.h:12
RecoIdealGeometry.h
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
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:47
DTAlignmentErrorRcd.h
MuonBaseNumber.h
cms::DDDetector::worldVolume
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:60
cms::DDFilteredView::history
const ExpandedNodes & history()
The numbering history of the current node.
Definition: DDFilteredView.cc:686
cms::DDFilteredView::up
void up()
set current node to the parent node in the filtered tree
Definition: DDFilteredView.cc:516
DTAlignmentRcd.h
DTNumberingScheme.h
DTLayer
Definition: DTLayer.h:25
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:33
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
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:466
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DTLayerType
Definition: DTLayerType.h:15
cms::DDDetector
Definition: DDDetector.h:12
Plane
Definition: Plane.h:16
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
MuonGeometryNumbering
Definition: MuonGeometryNumbering.h:24
DTGeometryBuilder.h
DTChamberId
Definition: DTChamberId.h:14
MuonGeometryRecord.h
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
DTNumberingScheme
Definition: DTNumberingScheme.h:20