Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:25

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/Geometry/TrackingVolumeArrayCreator.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/GeometryObjectSorter.hpp"
0013 #include "Acts/Geometry/TrackingVolume.hpp"
0014 #include "Acts/Geometry/VolumeBounds.hpp"
0015 #include "Acts/Utilities/BinUtility.hpp"
0016 #include "Acts/Utilities/BinnedArrayXD.hpp"
0017 
0018 #include <algorithm>
0019 #include <vector>
0020 
0021 std::shared_ptr<const Acts::TrackingVolumeArray>
0022 Acts::TrackingVolumeArrayCreator::trackingVolumeArray(
0023     const GeometryContext& gctx, const TrackingVolumeVector& tVolumes,
0024     AxisDirection aDir) const {
0025   // MSG_VERBOSE("Create VolumeArray of "<< tVolumes.size() << " TrackingVolumes
0026   // with binning in : " << axisDirectionName(aDir) );
0027   // let's copy and sort
0028   TrackingVolumeVector volumes(tVolumes);
0029   // sort it accordingly to the binning value
0030   GeometryObjectSorterT<std::shared_ptr<const TrackingVolume>> volumeSorter(
0031       gctx, aDir);
0032   std::ranges::sort(volumes, volumeSorter);
0033 
0034   // prepare what we need :
0035   // (1) arbitrary binning for volumes is fast enough
0036   std::vector<float> boundaries;
0037   boundaries.reserve(tVolumes.size() + 1);
0038   // (2) the vector needed for the BinnedArray
0039   std::vector<TrackingVolumeOrderPosition> tVolumesOrdered;
0040 
0041   // let's loop over the (sorted) volumes
0042   for (auto& tVolume : volumes) {
0043     // get the binning position
0044     Vector3 referencePosition = tVolume->referencePosition(gctx, aDir);
0045     double referenceBorder = tVolume->volumeBounds().referenceBorder(aDir);
0046     // get the center value according to the bin
0047     double value = tVolume->referencePositionValue(gctx, aDir);
0048     // for the first one take low and high boundary
0049     if (boundaries.empty()) {
0050       boundaries.push_back(value - referenceBorder);
0051     }
0052     // always take the high boundary
0053     boundaries.push_back(value + referenceBorder);
0054     // record the volume to be ordered
0055     tVolumesOrdered.push_back(
0056         TrackingVolumeOrderPosition(tVolume, referencePosition));
0057   }
0058 
0059   // now create the bin utility
0060   auto binUtility = std::make_unique<const BinUtility>(boundaries, open, aDir);
0061 
0062   // and return the newly created binned array
0063   return std::make_shared<const BinnedArrayXD<TrackingVolumePtr>>(
0064       tVolumesOrdered, std::move(binUtility));
0065 }