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 
14 
21 
22 std::shared_ptr<const Acts::TrackingVolumeArray>
24  const GeometryContext& gctx, const TrackingVolumeVector& tVolumes,
25  BinningValue bValue) const {
26  // MSG_VERBOSE("Create VolumeArray of "<< tVolumes.size() << " TrackingVolumes
27  // with binning in : " << binningValueNames[bValue] );
28  // let's copy and sort
29  TrackingVolumeVector volumes(tVolumes);
30  // sort it accordingly to the binning value
32  gctx, bValue);
33  std::sort(volumes.begin(), volumes.end(), volumeSorter);
34 
35  // prepare what we need :
36  // (1) arbitrary binning for volumes is fast enough
37  std::vector<float> boundaries;
38  boundaries.reserve(tVolumes.size() + 1);
39  // (2) the vector needed for the BinnedArray
40  std::vector<TrackingVolumeOrderPosition> tVolumesOrdered;
41 
42  // let's loop over the (sorted) volumes
43  for (auto& tVolume : volumes) {
44  // get the binning position
45  Vector3D binningPosition = tVolume->binningPosition(gctx, bValue);
46  double binningBorder = tVolume->volumeBounds().binningBorder(bValue);
47  // get the center value according to the bin
48  double value = tVolume->binningPositionValue(gctx, bValue);
49  // for the first one take low and high boundary
50  if (boundaries.empty()) {
51  boundaries.push_back(value - binningBorder);
52  }
53  // always take the high boundary
54  boundaries.push_back(value + binningBorder);
55  // record the volume to be ordered
56  tVolumesOrdered.push_back(
57  TrackingVolumeOrderPosition(tVolume, binningPosition));
58  }
59 
60  // now create the bin utility
61  auto binUtility =
62  std::make_unique<const BinUtility>(boundaries, open, bValue);
63 
64  // and return the newly created binned array
65  return std::make_shared<const BinnedArrayXD<TrackingVolumePtr>>(
66  tVolumesOrdered, std::move(binUtility));
67 }