Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:14

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Plugins/ActSVG/DetectorSvgConverter.hpp"
0010 
0011 #include "Acts/Detector/Detector.hpp"
0012 #include "Acts/Detector/DetectorVolume.hpp"
0013 #include "Acts/Detector/Portal.hpp"
0014 #include "Acts/Geometry/VolumeBounds.hpp"
0015 #include "Acts/Plugins/ActSVG/DetectorVolumeSvgConverter.hpp"
0016 #include "Acts/Utilities/Enumerate.hpp"
0017 
0018 #include <map>
0019 
0020 Acts::Svg::ProtoDetector Acts::Svg::DetectorConverter::convert(
0021     const GeometryContext& gctx, const Experimental::Detector& detector,
0022     const DetectorConverter::Options& detectorOptions) {
0023   ProtoDetector pDetector;
0024 
0025   const auto volumes = detector.volumes();
0026   // Create the index map vor volumes
0027   std::map<const Experimental::DetectorVolume*, unsigned int> volumeIndices;
0028   for (auto [iv, v] : enumerate(volumes)) {
0029     volumeIndices[v] = iv;
0030   }
0031 
0032   // Create the index map for portals
0033   unsigned int ip = 0;
0034   std::map<const Experimental::Portal*, unsigned int> portalIndices;
0035   for (const auto& v : volumes) {
0036     for (const auto& p : v->portals()) {
0037       portalIndices[p] = ip++;
0038     }
0039   }
0040 
0041   DetectorVolumeConverter::Options volumeOptions =
0042       detectorOptions.volumeOptions;
0043   volumeOptions.portalIndices = portalIndices;
0044   volumeOptions.portalOptions.volumeIndices = volumeIndices;
0045 
0046   // Loop over the list of volumes, remember internal ones
0047   for (auto [iv, v] : enumerate(volumes)) {
0048     auto [pVolume, pGrid] = convert(gctx, *v, volumeOptions);
0049     pVolume._index = iv;
0050     pDetector._volumes.push_back(pVolume);
0051   }
0052 
0053   return pDetector;
0054 }