EIC 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 <functional>
17 #include <memory>
18 #include <vector>
19 
20 namespace Acts {
21 
22 class TrackingVolume;
23 class VolumeBounds;
24 class RectangleBounds;
25 class ISurfaceMaterial;
26 class IVolumeMaterial;
27 class DetectorElementBase;
28 class PlaneSurface;
29 
36  public:
39  struct SurfaceConfig {
40  // Center position
42  // Rotation
43  RotationMatrix3D rotation = RotationMatrix3D::Identity();
44  // Bounds
45  std::shared_ptr<const RectangleBounds> rBounds = nullptr;
46  // Attached material
47  std::shared_ptr<const ISurfaceMaterial> surMat = nullptr;
48  // Thickness
49  double thickness = 0.;
50  // Constructor function for optional detector elements
51  // Arguments are transform, rectangle bounds and thickness.
52  std::function<DetectorElementBase*(
53  const Transform3D&, std::shared_ptr<const RectangleBounds>, double)>
55  };
56 
59  struct LayerConfig {
60  // Configuration of the surface
62  // Encapsulated surface
63  std::shared_ptr<const PlaneSurface> surface = nullptr;
64  // Boolean flag if layer is active
65  bool active = false;
66  // Bins in Y direction
67  size_t binsY = 1;
68  // Bins in Z direction
69  size_t binsZ = 1;
70  };
71 
74  struct VolumeConfig {
75  // Center position
77  // Lengths in x,y,z
79  // Configurations of its layers
80  std::vector<LayerConfig> layerCfg;
81  // Stored layers
82  std::vector<std::shared_ptr<const Layer>> layers;
83  // Configurations of confined volumes
84  std::vector<VolumeConfig> volumeCfg;
85  // Stored confined volumes
86  std::vector<std::shared_ptr<TrackingVolume>> trackingVolumes;
87  // Name of the volume
88  std::string name = "Volume";
89  // Material
90  std::shared_ptr<const IVolumeMaterial> volumeMaterial = nullptr;
91  };
92 
94  struct Config {
95  // Center position
96  Vector3D position = Vector3D(0., 0., 0.);
97  // Length in x,y,z
98  Vector3D length = Vector3D(0., 0., 0.);
99  // Configuration of its volumes
100  std::vector<VolumeConfig> volumeCfg = {};
101  };
102 
104  CuboidVolumeBuilder() = default;
105 
110 
114  void setConfig(Config& cfg) { m_cfg = cfg; }
115 
123  std::shared_ptr<const PlaneSurface> buildSurface(
124  const GeometryContext& gctx, const SurfaceConfig& cfg) const;
125 
134  std::shared_ptr<const Layer> buildLayer(const GeometryContext& gctx,
135  LayerConfig& cfg) const;
136 
145  std::shared_ptr<TrackingVolume> buildVolume(const GeometryContext& gctx,
146  VolumeConfig& cfg) const;
147 
157  std::pair<double, double> binningRange(const GeometryContext& gctx,
158  const VolumeConfig& cfg) const;
159 
160  void sortVolumes(std::vector<std::pair<TrackingVolumePtr, Vector3D>>& tapVec,
161  BinningValue bValue) const;
162 
169  std::shared_ptr<TrackingVolume> trackingVolume(
170  const GeometryContext& gctx,
171  std::shared_ptr<const TrackingVolume> /*unused*/,
172  std::shared_ptr<const VolumeBounds> /*unused*/) const override;
173 
174  private:
177 };
178 } // namespace Acts