Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorSvgConverter.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorSvgConverter.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
13 #include "Acts/Detector/Portal.hpp"
17 
18 #include <map>
19 
22  const DetectorConverter::Options& detectorOptions) {
23  ProtoDetector pDetector;
24 
25  const auto volumes = detector.volumes();
26  // Create the index map vor volumes
27  std::map<const Experimental::DetectorVolume*, unsigned int> volumeIndices;
28  for (auto [iv, v] : enumerate(volumes)) {
29  volumeIndices[v] = iv;
30  }
31 
32  // Create the index map for portals
33  unsigned int ip = 0;
34  std::map<const Experimental::Portal*, unsigned int> portalIndices;
35  for (const auto& v : volumes) {
36  for (const auto& p : v->portals()) {
37  portalIndices[p] = ip++;
38  }
39  }
40 
41  DetectorVolumeConverter::Options volumeOptions =
42  detectorOptions.volumeOptions;
43  volumeOptions.portalIndices = portalIndices;
44  volumeOptions.portalOptions.volumeIndices = volumeIndices;
45 
46  // Loop over the list of volumes, remember internal ones
47  for (auto [iv, v] : enumerate(volumes)) {
48  auto [pVolume, pGrid] = convert(gctx, *v, volumeOptions);
49  pVolume._index = iv;
50  pDetector._volumes.push_back(pVolume);
51  }
52 
53  return pDetector;
54 }