forked from sPHENIX-Collaboration/acts
/
TrackingVolumeCreation.hpp
114 lines (103 loc) · 5.13 KB
/
TrackingVolumeCreation.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// This file is part of the Acts project.
//
// Copyright (C) 2016-2018 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "Acts/Geometry/CylinderLayer.hpp"
#include "Acts/Geometry/CylinderVolumeBounds.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/Geometry/TrackingVolume.hpp"
#include "Acts/Surfaces/CylinderBounds.hpp"
#include "Acts/Surfaces/CylinderSurface.hpp"
#include "Acts/Utilities/BinUtility.hpp"
#include "Acts/Utilities/BinnedArrayXD.hpp"
#include "Acts/Utilities/Definitions.hpp"
namespace Acts {
/// helper function to create a cylinder
TrackingVolumePtr constructCylinderVolume(
const GeometryContext& gctx, double surfaceHalfLengthZ, double surfaceR,
double surfaceRstagger, double surfaceZoverlap, double layerEnvelope,
double volumeEnvelope, double innerVolumeR, double outerVolumeR,
const std::string& name) {
/// the surface transforms
auto sfnPosition =
Vector3D(0., 0., -3 * surfaceHalfLengthZ - surfaceZoverlap);
auto sfnTransform = Transform3D(Translation3D(sfnPosition));
auto sfcTransform = Transform3D::Identity();
auto sfpPosition = Vector3D(0., 0., 3 * surfaceHalfLengthZ - surfaceZoverlap);
auto sfpTransform = Transform3D(Translation3D(sfpPosition));
/// the surfaces
auto sfnBounds = std::make_shared<CylinderBounds>(
surfaceR - 0.5 * surfaceRstagger, surfaceHalfLengthZ);
auto sfn = Surface::makeShared<CylinderSurface>(sfnTransform, sfnBounds);
auto sfcBounds = std::make_shared<CylinderBounds>(
surfaceR + 0.5 * surfaceRstagger, surfaceHalfLengthZ);
auto sfc = Surface::makeShared<CylinderSurface>(sfcTransform, sfcBounds);
auto sfpBounds = std::make_shared<CylinderBounds>(
surfaceR - 0.5 * surfaceRstagger, surfaceHalfLengthZ);
auto sfp = Surface::makeShared<CylinderSurface>(sfpTransform, sfpBounds);
/// prepare the surfaces
/// make the binned array
double bUmin = sfnPosition.z() - surfaceHalfLengthZ;
double bUmax = sfpPosition.z() + surfaceHalfLengthZ;
std::vector<std::shared_ptr<const Surface>> surfaces_only = {{sfn, sfc, sfp}};
std::vector<const Surface*> surfaces_only_raw = {
{sfn.get(), sfc.get(), sfp.get()}};
detail::Axis<detail::AxisType::Equidistant, detail::AxisBoundaryType::Bound>
axis(bUmin, bUmax, surfaces_only.size());
auto g2l = [](const Vector3D& glob) {
return std::array<double, 1>({{glob.z()}});
};
auto l2g = [](const std::array<double, 1>& loc) {
return Vector3D(0, 0, loc[0]);
};
auto sl = std::make_unique<SurfaceArray::SurfaceGridLookup<decltype(axis)>>(
g2l, l2g, std::make_tuple(axis));
sl->fill(gctx, surfaces_only_raw);
auto bArray = std::make_unique<SurfaceArray>(std::move(sl), surfaces_only);
/// now create the Layer
auto layer0bounds = std::make_shared<const CylinderBounds>(surfaceR, bUmax);
auto layer0 = CylinderLayer::create(Transform3D::Identity(), layer0bounds,
std::move(bArray),
surfaceRstagger + 2 * layerEnvelope);
std::unique_ptr<const LayerArray> layerArray =
std::make_unique<const BinnedArrayXD<LayerPtr>>(layer0);
/// create the volume
auto volumeBounds = std::make_shared<const CylinderVolumeBounds>(
innerVolumeR, outerVolumeR, bUmax + volumeEnvelope);
TrackingVolumePtr volume =
TrackingVolume::create(Transform3D::Identity(), volumeBounds, nullptr,
std::move(layerArray), nullptr, {}, name);
/// return the volume
return volume;
}
/// helper function to create a container
MutableTrackingVolumePtr constructContainerVolume(const GeometryContext& gctx,
TrackingVolumePtr iVolume,
TrackingVolumePtr oVolume,
double hVolumeR,
double hVolumeHalflength,
const std::string& name) {
/// create the volume array
using VAP = std::pair<TrackingVolumePtr, Vector3D>;
std::vector<VAP> volumes = {{iVolume, iVolume->binningPosition(gctx, binR)},
{oVolume, oVolume->binningPosition(gctx, binR)}};
/// the bounds for the container
auto hVolumeBounds = std::make_shared<const CylinderVolumeBounds>(
0., hVolumeR, hVolumeHalflength);
/// create the BinUtility & the BinnedArray
auto vUtility = std::make_unique<const BinUtility>(volumes.size(), 0.,
hVolumeR, open, binR);
std::shared_ptr<const TrackingVolumeArray> vArray =
std::make_shared<const BinnedArrayXD<TrackingVolumePtr>>(
volumes, std::move(vUtility));
/// create the container volume
auto hVolume = TrackingVolume::create(Transform3D::Identity(), hVolumeBounds,
vArray, name);
// return the container
return hVolume;
}
} // namespace Acts