ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingVolumeArrayCreator.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackingVolumeArrayCreator.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 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 // TrackingVolumeArrayCreator.cpp, Acts project
12 
20 
21 std::shared_ptr<const Acts::TrackingVolumeArray>
23  const GeometryContext& gctx, const TrackingVolumeVector& tVolumes,
24  BinningValue bValue) const {
25  // MSG_VERBOSE("Create VolumeArray of "<< tVolumes.size() << " TrackingVolumes
26  // with binning in : " << binningValueNames[bValue] );
27  // let's copy and sort
28  TrackingVolumeVector volumes(tVolumes);
29  // sort it accordingly to the binning value
31  gctx, bValue);
32  std::sort(volumes.begin(), volumes.end(), volumeSorter);
33 
34  // prepare what we need :
35  // (1) arbitrary binning for volumes is fast enough
36  std::vector<float> boundaries;
37  boundaries.reserve(tVolumes.size() + 1);
38  // (2) the vector needed for the BinnedArray
39  std::vector<TrackingVolumeOrderPosition> tVolumesOrdered;
40 
41  // let's loop over the (sorted) volumes
42  for (auto& tVolume : volumes) {
43  // get the binning position
44  Vector3D binningPosition = tVolume->binningPosition(gctx, bValue);
45  double binningBorder = tVolume->volumeBounds().binningBorder(bValue);
46  // get the center value according to the bin
47  double value = tVolume->binningPositionValue(gctx, bValue);
48  // for the first one take low and high boundary
49  if (boundaries.empty()) {
50  boundaries.push_back(value - binningBorder);
51  }
52  // always take the high boundary
53  boundaries.push_back(value + binningBorder);
54  // record the volume to be ordered
55  tVolumesOrdered.push_back(
56  TrackingVolumeOrderPosition(tVolume, binningPosition));
57  }
58 
59  // now create the bin utility
60  auto binUtility =
61  std::make_unique<const BinUtility>(boundaries, open, bValue);
62 
63  // and return the newly created binned array
64  return std::make_shared<const BinnedArrayXD<TrackingVolumePtr>>(
65  tVolumesOrdered, std::move(binUtility));
66 }