File indexing completed on 2025-01-18 09:10:53
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/BoundarySurfaceFace.hpp"
0013 #include "Acts/Geometry/BoundarySurfaceT.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/GeometryIdentifier.hpp"
0016 #include "Acts/Geometry/Layer.hpp"
0017 #include "Acts/Geometry/Portal.hpp"
0018 #include "Acts/Geometry/TrackingVolumeVisitorConcept.hpp"
0019 #include "Acts/Geometry/Volume.hpp"
0020 #include "Acts/Material/IVolumeMaterial.hpp"
0021 #include "Acts/Navigation/NavigationDelegate.hpp"
0022 #include "Acts/Navigation/NavigationStream.hpp"
0023 #include "Acts/Surfaces/Surface.hpp"
0024 #include "Acts/Surfaces/SurfaceArray.hpp"
0025 #include "Acts/Surfaces/SurfaceVisitorConcept.hpp"
0026 #include "Acts/Utilities/BinnedArray.hpp"
0027 #include "Acts/Utilities/Logger.hpp"
0028 #include "Acts/Utilities/TransformRange.hpp"
0029 #include "Acts/Visualization/ViewConfig.hpp"
0030
0031 #include <cstddef>
0032 #include <memory>
0033 #include <string>
0034 #include <unordered_map>
0035 #include <utility>
0036 #include <vector>
0037
0038 #include <boost/container/container_fwd.hpp>
0039
0040 namespace Acts {
0041
0042 class GlueVolumesDescriptor;
0043 class VolumeBounds;
0044 template <typename object_t>
0045 struct NavigationOptions;
0046 class IMaterialDecorator;
0047 class ISurfaceMaterial;
0048 class IVolumeMaterial;
0049 class Surface;
0050 class TrackingVolume;
0051 struct GeometryIdentifierHook;
0052 class Portal;
0053 class INavigationPolicy;
0054
0055
0056
0057
0058
0059
0060 using TrackingVolumePtr = std::shared_ptr<const TrackingVolume>;
0061 using MutableTrackingVolumePtr = std::shared_ptr<TrackingVolume>;
0062
0063 using TrackingVolumeBoundaryPtr =
0064 std::shared_ptr<const BoundarySurfaceT<TrackingVolume>>;
0065 using TrackingVolumeBoundaries = std::vector<TrackingVolumeBoundaryPtr>;
0066
0067
0068 using TrackingVolumeArray = BinnedArray<TrackingVolumePtr>;
0069 using TrackingVolumeVector = std::vector<TrackingVolumePtr>;
0070 using MutableTrackingVolumeVector = std::vector<MutableTrackingVolumePtr>;
0071 using LayerArray = BinnedArray<LayerPtr>;
0072 using LayerVector = std::vector<LayerPtr>;
0073
0074
0075 using LayerIntersection = std::pair<SurfaceIntersection, const Layer*>;
0076
0077 using LayerMultiIntersection =
0078 std::pair<SurfaceMultiIntersection, const Layer*>;
0079
0080
0081 using BoundarySurface = BoundarySurfaceT<TrackingVolume>;
0082
0083 using BoundaryIntersection =
0084 std::pair<SurfaceIntersection, const BoundarySurface*>;
0085
0086 using BoundaryMultiIntersection =
0087 std::pair<SurfaceMultiIntersection, const BoundarySurface*>;
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112 class TrackingVolume : public Volume {
0113 friend class TrackingGeometry;
0114
0115 public:
0116 TrackingVolume() = delete;
0117 ~TrackingVolume() override;
0118 TrackingVolume(const TrackingVolume&) = delete;
0119 TrackingVolume& operator=(const TrackingVolume&) = delete;
0120 TrackingVolume(TrackingVolume&&) noexcept;
0121 TrackingVolume& operator=(TrackingVolume&&) noexcept;
0122
0123
0124
0125
0126
0127
0128
0129
0130 TrackingVolume(const Transform3& transform,
0131 std::shared_ptr<VolumeBounds> volbounds,
0132 const std::string& volumeName = "undefined");
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145 TrackingVolume(
0146 const Transform3& transform, std::shared_ptr<VolumeBounds> volumeBounds,
0147 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
0148 std::unique_ptr<const LayerArray> staticLayerArray = nullptr,
0149 std::shared_ptr<const TrackingVolumeArray> containedVolumeArray = nullptr,
0150 MutableTrackingVolumeVector denseVolumeVector = {},
0151 const std::string& volumeName = "undefined");
0152
0153
0154
0155
0156 TrackingVolume(Volume& volume, const std::string& volumeName = "undefined");
0157
0158
0159
0160
0161
0162
0163
0164 const TrackingVolume* lowestTrackingVolume(const GeometryContext& gctx,
0165 const Vector3& position,
0166 const double tol = 0.) const;
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 template <SurfaceVisitor visitor_t>
0179 void visitSurfaces(visitor_t&& visitor, bool restrictToSensitives) const {
0180 if (!restrictToSensitives) {
0181
0182 for (const auto& bs : m_boundarySurfaces) {
0183 visitor(&(bs->surfaceRepresentation()));
0184 }
0185
0186 for (const auto& portal : portals()) {
0187 visitor(&portal.surface());
0188 }
0189 }
0190
0191
0192 if (m_confinedVolumes == nullptr) {
0193
0194 if (m_confinedLayers != nullptr) {
0195 for (const auto& layer : m_confinedLayers->arrayObjects()) {
0196
0197 if (layer->surfaceArray() != nullptr) {
0198 for (const auto& srf : layer->surfaceArray()->surfaces()) {
0199 visitor(srf);
0200 continue;
0201 }
0202 }
0203 if (!restrictToSensitives) {
0204
0205 visitor(&layer->surfaceRepresentation());
0206
0207 if (layer->approachDescriptor() != nullptr) {
0208 for (const auto& srf :
0209 layer->approachDescriptor()->containedSurfaces()) {
0210 visitor(srf);
0211 }
0212 }
0213 }
0214 }
0215 }
0216 } else {
0217
0218 for (const auto& volume : m_confinedVolumes->arrayObjects()) {
0219 volume->visitSurfaces(visitor, restrictToSensitives);
0220 }
0221 }
0222
0223 for (const auto& surface : surfaces()) {
0224 visitor(&surface);
0225 }
0226
0227 for (const auto& volume : volumes()) {
0228 volume.visitSurfaces(visitor, restrictToSensitives);
0229 }
0230 }
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241 template <SurfaceVisitor visitor_t>
0242 void visitSurfaces(visitor_t&& visitor) const {
0243 visitSurfaces(std::forward<visitor_t>(visitor), true);
0244 }
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255 template <TrackingVolumeVisitor visitor_t>
0256 void visitVolumes(visitor_t&& visitor) const {
0257 visitor(this);
0258 if (m_confinedVolumes != nullptr) {
0259
0260 for (const auto& volume : m_confinedVolumes->arrayObjects()) {
0261 volume->visitVolumes(visitor);
0262 }
0263 }
0264
0265 for (const auto& volume : m_volumes) {
0266 volume->visitVolumes(visitor);
0267 }
0268 }
0269
0270
0271 const std::string& volumeName() const;
0272
0273
0274
0275 void setVolumeName(const std::string& volumeName);
0276
0277
0278 const IVolumeMaterial* volumeMaterial() const;
0279
0280
0281 const std::shared_ptr<const IVolumeMaterial>& volumeMaterialPtr() const;
0282
0283
0284
0285
0286
0287
0288
0289
0290 void assignVolumeMaterial(std::shared_ptr<const IVolumeMaterial> material);
0291
0292
0293 const TrackingVolume* motherVolume() const;
0294
0295
0296 TrackingVolume* motherVolume();
0297
0298
0299
0300
0301 void setMotherVolume(TrackingVolume* mvol);
0302
0303 using MutableVolumeRange =
0304 detail::TransformRange<detail::Dereference,
0305 std::vector<std::unique_ptr<TrackingVolume>>>;
0306 using VolumeRange = detail::TransformRange<
0307 detail::ConstDereference,
0308 const std::vector<std::unique_ptr<TrackingVolume>>>;
0309
0310
0311
0312 VolumeRange volumes() const;
0313
0314
0315
0316 MutableVolumeRange volumes();
0317
0318 using MutablePortalRange =
0319 detail::TransformRange<detail::Dereference,
0320 std::vector<std::shared_ptr<Portal>>>;
0321
0322 using PortalRange =
0323 detail::TransformRange<detail::ConstDereference,
0324 const std::vector<std::shared_ptr<Portal>>>;
0325
0326
0327
0328 PortalRange portals() const;
0329
0330
0331
0332 MutablePortalRange portals();
0333
0334
0335
0336 void addPortal(std::shared_ptr<Portal> portal);
0337
0338 using MutableSurfaceRange =
0339 detail::TransformRange<detail::Dereference,
0340 std::vector<std::shared_ptr<Surface>>>;
0341 using SurfaceRange =
0342 detail::TransformRange<detail::ConstDereference,
0343 const std::vector<std::shared_ptr<Surface>>>;
0344
0345
0346
0347 SurfaceRange surfaces() const;
0348
0349
0350
0351 MutableSurfaceRange surfaces();
0352
0353
0354
0355 void addSurface(std::shared_ptr<Surface> surface);
0356
0357
0358
0359
0360
0361
0362 TrackingVolume& addVolume(std::unique_ptr<TrackingVolume> volume);
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375 const Layer* associatedLayer(const GeometryContext& gctx,
0376 const Vector3& position) const;
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389 boost::container::small_vector<LayerIntersection, 10> compatibleLayers(
0390 const GeometryContext& gctx, const Vector3& position,
0391 const Vector3& direction, const NavigationOptions<Layer>& options) const;
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405 boost::container::small_vector<BoundaryIntersection, 4> compatibleBoundaries(
0406 const GeometryContext& gctx, const Vector3& position,
0407 const Vector3& direction, const NavigationOptions<Surface>& options,
0408 const Logger& logger = getDummyLogger()) const;
0409
0410
0411
0412 const LayerArray* confinedLayers() const;
0413
0414
0415 std::shared_ptr<const TrackingVolumeArray> confinedVolumes() const;
0416
0417
0418 const MutableTrackingVolumeVector denseVolumes() const;
0419
0420
0421 const TrackingVolumeBoundaries& boundarySurfaces() const;
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431 void assignBoundaryMaterial(
0432 std::shared_ptr<const ISurfaceMaterial> surfaceMaterial,
0433 BoundarySurfaceFace bsFace);
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443 void glueTrackingVolume(const GeometryContext& gctx,
0444 BoundarySurfaceFace bsfMine, TrackingVolume* neighbor,
0445 BoundarySurfaceFace bsfNeighbor);
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455 void glueTrackingVolumes(
0456 const GeometryContext& gctx, BoundarySurfaceFace bsfMine,
0457 const std::shared_ptr<TrackingVolumeArray>& neighbors,
0458 BoundarySurfaceFace bsfNeighbor);
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468 void updateBoundarySurface(
0469 BoundarySurfaceFace bsf,
0470 std::shared_ptr<const BoundarySurfaceT<TrackingVolume>> bs,
0471 bool checkmaterial = true);
0472
0473
0474
0475
0476
0477
0478
0479
0480 void registerGlueVolumeDescriptor(std::unique_ptr<GlueVolumesDescriptor> gvd);
0481
0482
0483
0484
0485
0486
0487 GlueVolumesDescriptor& glueVolumesDescriptor();
0488
0489
0490
0491
0492
0493
0494
0495 void visualize(IVisualization3D& helper, const GeometryContext& gctx,
0496 const ViewConfig& viewConfig,
0497 const ViewConfig& portalViewConfig,
0498 const ViewConfig& sensitiveViewConfig) const;
0499
0500
0501
0502
0503 void setNavigationPolicy(std::unique_ptr<INavigationPolicy> policy);
0504
0505
0506
0507
0508
0509
0510
0511 void initializeNavigationCandidates(const NavigationArguments& args,
0512 AppendOnlyNavigationStream& stream,
0513 const Logger& logger) const;
0514
0515 private:
0516 void connectDenseBoundarySurfaces(
0517 MutableTrackingVolumeVector& confinedDenseVolumes);
0518
0519
0520 void interlinkLayers();
0521
0522
0523 void createBoundarySurfaces();
0524
0525
0526
0527
0528
0529 void synchronizeLayers(double envelope = 1.) const;
0530
0531
0532 std::vector<TrackingVolumeBoundaryPtr> m_boundarySurfaces;
0533
0534
0535
0536 std::unique_ptr<const LayerArray> m_confinedLayers = nullptr;
0537
0538
0539 std::shared_ptr<const TrackingVolumeArray> m_confinedVolumes = nullptr;
0540
0541
0542 MutableTrackingVolumeVector m_confinedDenseVolumes;
0543
0544
0545 std::unique_ptr<GlueVolumesDescriptor> m_glueVolumeDescriptor{nullptr};
0546
0547
0548
0549 private:
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560 void closeGeometry(
0561 const IMaterialDecorator* materialDecorator,
0562 std::unordered_map<GeometryIdentifier, const TrackingVolume*>& volumeMap,
0563 std::size_t& vol, const GeometryIdentifierHook& hook,
0564 const Logger& logger = getDummyLogger());
0565
0566
0567 std::shared_ptr<const IVolumeMaterial> m_volumeMaterial{nullptr};
0568
0569
0570 TrackingVolume* m_motherVolume{nullptr};
0571
0572
0573 std::string m_name;
0574
0575 std::vector<std::unique_ptr<TrackingVolume>> m_volumes;
0576 std::vector<std::shared_ptr<Portal>> m_portals;
0577 std::vector<std::shared_ptr<Surface>> m_surfaces;
0578
0579 std::unique_ptr<INavigationPolicy> m_navigationPolicy;
0580
0581 NavigationDelegate m_navigationDelegate{};
0582 };
0583
0584 }