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 }
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
DTGeometryBuilderFromDD4Hep::buildLayer
DTLayer * buildLayer(cms::DDFilteredView &, DTSuperLayer *, const MuonGeometryConstants &) const
Definition: DTGeometryBuilderFromDD4Hep.cc:138
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
DTGeometryBuilderFromDD4Hep::buildSuperLayer
DTSuperLayer * buildSuperLayer(cms::DDFilteredView &, DTChamber *, const MuonGeometryConstants &) const
Definition: DTGeometryBuilderFromDD4Hep.cc:114
MuonNumberingRecord.h
DTGeometryBuilderFromDD4Hep::buildGeometry
void buildGeometry(cms::DDFilteredView &, DTGeometry &, const MuonGeometryConstants &) const
Definition: DTGeometryBuilderFromDD4Hep.cc:50
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
DTNumberingScheme::baseNumberToUnitNumber
int baseNumberToUnitNumber(const MuonBaseNumber &num) const override
Definition: DTNumberingScheme.cc:38
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
DTGeometryBuilderFromDD4Hep.h
MuonBaseNumber.h
cms::DDDetector::worldVolume
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:48
cms::DDFilteredView::history
const ExpandedNodes & history()
The numbering history of the current node.
Definition: DDFilteredView.cc:683
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:34
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
DTGeometryBuilderFromDD4Hep::plane
RCPPlane plane(const cms::DDFilteredView &, Bounds *bounds) const
Definition: DTGeometryBuilderFromDD4Hep.cc:83
DTGeometryBuilderFromDD4Hep::build
void build(DTGeometry &, const cms::DDDetector *, const MuonGeometryConstants &, const dd4hep::SpecParRefs &)
Definition: DTGeometryBuilderFromDD4Hep.cc:181
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
DTGeometryBuilderFromDD4Hep::buildChamber
DTChamber * buildChamber(cms::DDFilteredView &, const MuonGeometryConstants &) const
Definition: DTGeometryBuilderFromDD4Hep.cc:94
DTChamberId
Definition: DTChamberId.h:14
MuonGeometryRecord.h
DTNumberingScheme
Definition: DTNumberingScheme.h:20