ECCE @ 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 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 
11 #include <functional>
12 #include <memory>
13 #include <vector>
18 
19 namespace Acts {
20 
21 class TrackingVolume;
22 class VolumeBounds;
23 class RectangleBounds;
24 class ISurfaceMaterial;
25 class IVolumeMaterial;
26 class DetectorElementBase;
27 class PlaneSurface;
28 
35  public:
38  struct SurfaceConfig {
39  // Center position
41  // Rotation
42  RotationMatrix3D rotation = RotationMatrix3D::Identity();
43  // Bounds
44  std::shared_ptr<const RectangleBounds> rBounds = nullptr;
45  // Attached material
46  std::shared_ptr<const ISurfaceMaterial> surMat = nullptr;
47  // Thickness
48  double thickness = 0.;
49  // Constructor function for optional detector elements
50  // Arguments are transform, rectangle bounds and thickness.
51  std::function<DetectorElementBase*(std::shared_ptr<const Transform3D>,
52  std::shared_ptr<const RectangleBounds>,
53  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