Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CuboidVolumeBuilder.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CuboidVolumeBuilder.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2020 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 
9 #pragma once
10 
15 
16 #include <array>
17 #include <cstddef>
18 #include <functional>
19 #include <iosfwd>
20 #include <memory>
21 #include <optional>
22 #include <string>
23 #include <utility>
24 #include <vector>
25 
26 namespace Acts {
27 
28 class TrackingVolume;
29 class VolumeBounds;
30 class RectangleBounds;
31 class ISurfaceMaterial;
32 class IVolumeMaterial;
33 class DetectorElementBase;
34 class Surface;
35 class Layer;
36 
43  public:
46  struct SurfaceConfig {
47  // Center position
49  // Rotation
50  RotationMatrix3 rotation = RotationMatrix3::Identity();
51  // Bounds
52  std::shared_ptr<const RectangleBounds> rBounds = nullptr;
53  // Attached material
54  std::shared_ptr<const ISurfaceMaterial> surMat = nullptr;
55  // Thickness
56  double thickness = 0.;
57  // Constructor function for optional detector elements
58  // Arguments are transform, rectangle bounds and thickness.
59  std::function<DetectorElementBase*(
60  const Transform3&, std::shared_ptr<const RectangleBounds>, double)>
62  };
63 
65  struct LayerConfig {
66  // Configuration of the surface
67  std::vector<SurfaceConfig> surfaceCfg;
68  // Encapsulated surface
69  std::vector<std::shared_ptr<const Surface>> surfaces;
70  // Boolean flag if layer is active
71  bool active = false;
72  // Bins in Y direction
73  size_t binsY = 1;
74  // Bins in Z direction
75  size_t binsZ = 1;
76  // Envelope in X
77  std::array<ActsScalar, 2u> envelopeX{0, 0};
78  // Envelope in Y
79  std::array<ActsScalar, 2u> envelopeY{0, 0};
80  // Envelope in Z
81  std::array<ActsScalar, 2u> envelopeZ{0, 0};
82  // An optional rotation for this
83  std::optional<RotationMatrix3> rotation{std::nullopt};
84  };
85 
88  struct VolumeConfig {
89  // Center position
91  // Lengths in x,y,z
93  // Configurations of its layers
94  std::vector<LayerConfig> layerCfg;
95  // Stored layers
96  std::vector<std::shared_ptr<const Layer>> layers;
97  // Configurations of confined volumes
98  std::vector<VolumeConfig> volumeCfg;
99  // Stored confined volumes
100  std::vector<std::shared_ptr<TrackingVolume>> trackingVolumes;
101  // Name of the volume
102  std::string name = "Volume";
103  // Material
104  std::shared_ptr<const IVolumeMaterial> volumeMaterial = nullptr;
105  };
106 
108  struct Config {
109  // Center position
110  Vector3 position = Vector3(0., 0., 0.);
111  // Length in x,y,z
112  Vector3 length = Vector3(0., 0., 0.);
113  // Configuration of its volumes
114  std::vector<VolumeConfig> volumeCfg = {};
115  };
116 
118  CuboidVolumeBuilder() = default;
119 
124 
128  void setConfig(Config& cfg) { m_cfg = cfg; }
129 
137  std::shared_ptr<const Surface> buildSurface(const GeometryContext& gctx,
138  const SurfaceConfig& cfg) const;
139 
148  std::shared_ptr<const Layer> buildLayer(const GeometryContext& gctx,
149  LayerConfig& cfg) const;
150 
159  std::shared_ptr<TrackingVolume> buildVolume(const GeometryContext& gctx,
160  VolumeConfig& cfg) const;
161 
171  std::pair<double, double> binningRange(const GeometryContext& gctx,
172  const VolumeConfig& cfg) const;
173 
174  void sortVolumes(std::vector<std::pair<TrackingVolumePtr, Vector3>>& tapVec,
175  BinningValue bValue) const;
176 
183  std::shared_ptr<TrackingVolume> trackingVolume(
184  const GeometryContext& gctx,
185  std::shared_ptr<const TrackingVolume> /*oppositeVolume*/,
186  std::shared_ptr<const VolumeBounds> /*outsideBounds*/) const override;
187 
188  private:
191 };
192 } // namespace Acts