14 #include "Acts/ActsVersion.hpp"
15 #include "Acts/Geometry/CutoutCylinderVolumeBounds.hpp"
16 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
17 #include "Acts/Geometry/TrapezoidVolumeBounds.hpp"
18 #include "Acts/Visualization/GeometryView3D.hpp"
19 #include "Acts/Detector/DetectorVolume.hpp"
20 #include "Acts/Detector/PortalGenerators.hpp"
21 #include "Acts/Navigation/DetectorVolumeFinders.hpp"
22 #include "Acts/Navigation/InternalNavigation.hpp"
23 #include "Acts/Navigation/NavigationDelegates.hpp"
24 #include "Acts/Navigation/NavigationState.hpp"
25 #include "Acts/Visualization/ObjVisualization3D.hpp"
26 #include "Acts/Detector/MultiWireStructureBuilder.hpp"
27 #include "Acts/Geometry/GeometryIdentifier.hpp"
36 using volumePtr= std::shared_ptr<Acts::Experimental::DetectorVolume>;
42 declareInterface<IDetectorVolumeBuilderTool>(
this);
48 ATH_MSG_DEBUG(
"ACTS version is: v"<< Acts::VersionMajor <<
"." << Acts::VersionMinor <<
"." << Acts::VersionPatch <<
" [" << Acts::CommitHash <<
"]");
50 return StatusCode::SUCCESS;
56 using ChamberIdKey = std::pair<Muon::MuonStationIndex::ChIndex, unsigned int>;
57 using EnvelopeIdentifierMap = std::map<ChamberIdKey, unsigned int>;
58 using ChamberIdentifierMap = std::map<unsigned int, unsigned int>;
59 EnvelopeIdentifierMap volIds{};
60 ChamberIdentifierMap chamberIds{};
62 std::vector< std::shared_ptr< Acts::Experimental::DetectorVolume > > detectorVolumeBoundingVolumes{};
63 detectorVolumeBoundingVolumes.reserve(chambers.size());
64 std::vector<surfacePtr> surfaces = {};
65 std::pair<std::vector<volumePtr>, std::vector<surfacePtr>> readoutElements;
67 auto portalGenerator = Acts::Experimental::defaultPortalGenerator();
70 unsigned int volNumb = volIds[std::make_pair(
chamber->chamberIndex(),
chamber->stationPhi())];
71 if (!volNumb) volNumb = volIds.size();
73 unsigned int chNumb = (++chamberIds[volNumb]);
75 std::shared_ptr<Acts::TrapezoidVolumeBounds> bounds =
chamber->bounds();
77 volumePtr detectorVolume = Acts::Experimental::DetectorVolumeFactory::construct(
79 bounds, readoutElements.second, readoutElements.first, Acts::Experimental::tryAllSubVolumes(), Acts::Experimental::tryAllPortalsAndSurfaces());
80 detectorVolume->assignGeometryId(Acts::GeometryIdentifier{}.setLayer(volNumb).setVolume(chNumb));
85 Acts::ObjVisualization3D
helper;
86 Acts::GeometryView3D::drawDetectorVolume(
helper, *detectorVolume, gctx->
context());
90 detectorVolumeBoundingVolumes.push_back(std::move(detectorVolume));
91 readoutElements.first.clear();
92 readoutElements.second.clear();
94 std::unique_ptr<Acts::CutoutCylinderVolumeBounds> msBounds = std::make_unique<Acts::CutoutCylinderVolumeBounds>(0, 4000, 145000, 220000, 3200);
95 volumePtr msDetectorVolume = Acts::Experimental::DetectorVolumeFactory::construct(
96 portalGenerator, gctx->
context(),
"Envelope",
97 Acts::Transform3::Identity(), std::move(msBounds), surfaces,
98 detectorVolumeBoundingVolumes, Acts::Experimental::tryAllSubVolumes(),
99 Acts::Experimental::tryAllPortalsAndSurfaces());
100 msDetectorVolume->assignGeometryId(Acts::GeometryIdentifier{}.setVolume(15));
104 Acts::ObjVisualization3D
helper;
105 Acts::GeometryView3D::drawDetectorVolume(
helper, *msDetectorVolume, gctx->
context());
106 helper.write(
"detector.obj");
111 Acts::Experimental::DetectorComponent::PortalContainer portalContainer;
112 for (
auto [
ip,
p] : Acts::enumerate(msDetectorVolume->portalPtrs())) {
113 portalContainer[
ip] =
p;
116 return Acts::Experimental::DetectorComponent{
119 {{msDetectorVolume}, Acts::Experimental::tryRootVolumes()}};
124 std::vector<volumePtr> readoutDetectorVolumes = {};
125 std::vector<surfacePtr> readoutSurfaces = {};
126 std::pair<std::vector<volumePtr>, std::vector<surfacePtr>> pairElements;
127 Acts::GeometryIdentifier::Value surfId{1};
128 Acts::GeometryIdentifier::Value mdtId{1};
139 std::vector<surfacePtr> surfaces = {};
142 for(
unsigned int lay=1; lay<=mdtReadoutEle->
numLayers(); ++lay){
145 if (!mdtReadoutEle->
isValid(measHash))
continue;
147 surface->assignGeometryId(Acts::GeometryIdentifier{}.setLayer(chId.first).setVolume(chId.second).setBoundary(mdtId).setSensitive(++surfId));
148 surfaces.push_back(surface);
160 Acts::Experimental::MultiWireStructureBuilder::Config mlCfg;
163 mlCfg.mlSurfaces = surfaces;
164 mlCfg.transform = mdtTransform;
166 mlCfg.mlBounds= mdtBounds->values();
167 mlCfg.mlBinning = {Acts::Experimental::ProtoBinning(
Acts::binY, Acts::detail::AxisBoundaryType::Bound,
168 -mdtBounds->values()[1], mdtBounds->values()[1], std::lround(2*mdtBounds->values()[1]/
parameters.tubePitch), 0
u), Acts::Experimental::ProtoBinning(
Acts::binZ, Acts::detail::AxisBoundaryType::Bound,
169 -mdtBounds->values()[2], mdtBounds->values()[2], std::lround(2*mdtBounds->values()[2]/
parameters.tubePitch), 0
u)};
171 Acts::Experimental::MultiWireStructureBuilder mdtBuilder(mlCfg);
173 mdtVolume->assignGeometryId(Acts::GeometryIdentifier{}.setLayer(chId.first).setVolume(chId.second).setBoundary(mdtId++));
176 readoutDetectorVolumes.push_back(mdtVolume);
185 if (!
layer)
continue;
188 rpcSurface->assignGeometryId(Acts::GeometryIdentifier{}.setLayer(chId.first).setVolume(chId.second).setSensitive(++surfId));
189 readoutSurfaces.push_back(rpcSurface);
200 if (!layerPtr)
continue;
203 tgcSurface->assignGeometryId(Acts::GeometryIdentifier{}.setLayer(chId.first).setVolume(chId.second).setSensitive(++surfId));
205 readoutSurfaces.push_back(tgcSurface);
218 stgcSurface->assignGeometryId(Acts::GeometryIdentifier{}.setLayer(chId.first).setVolume(chId.second).setSensitive(++surfId));
220 readoutSurfaces.push_back(stgcSurface);
230 mmSurface->assignGeometryId(Acts::GeometryIdentifier{}.setLayer(chId.first).setVolume(chId.second).setSensitive(++surfId));
232 readoutSurfaces.push_back(mmSurface);
242 pairElements = std::make_pair(readoutDetectorVolumes, readoutSurfaces);