Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-20 07:59:30

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 "ActsPlugins/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/Utilities/Enumerate.hpp"
0016 #include "ActsPlugins/ActSVG/DetectorVolumeSvgConverter.hpp"
0017 
0018 #include <map>
0019 
0020 using namespace Acts;
0021 
0022 ActsPlugins::Svg::ProtoDetector ActsPlugins::Svg::DetectorConverter::convert(
0023     const GeometryContext& gctx, const Experimental::Detector& detector,
0024     const DetectorConverter::Options& detectorOptions) {
0025   ProtoDetector pDetector;
0026 
0027   const auto volumes = detector.volumes();
0028   // Create the index map vor volumes
0029   std::map<const Experimental::DetectorVolume*, unsigned int> volumeIndices;
0030   for (auto [iv, v] : enumerate(volumes)) {
0031     volumeIndices[v] = iv;
0032   }
0033 
0034   // Create the index map for portals
0035   unsigned int ip = 0;
0036   std::map<const Experimental::Portal*, unsigned int> portalIndices;
0037   for (const auto& v : volumes) {
0038     for (const auto& p : v->portals()) {
0039       portalIndices[p] = ip++;
0040     }
0041   }
0042 
0043   DetectorVolumeConverter::Options volumeOptions =
0044       detectorOptions.volumeOptions;
0045   volumeOptions.portalIndices = portalIndices;
0046   volumeOptions.portalOptions.volumeIndices = volumeIndices;
0047 
0048   // Loop over the list of volumes, remember internal ones
0049   for (auto [iv, v] : enumerate(volumes)) {
0050     auto [pVolume, pGrid] = convert(gctx, *v, volumeOptions);
0051     pVolume._index = iv;
0052     pDetector._volumes.push_back(pVolume);
0053   }
0054 
0055   return pDetector;
0056 }