Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:18:31

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsTests/CommonHelpers/CubicTrackingGeometry.hpp"
0010 
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Geometry/CuboidVolumeBounds.hpp"
0013 #include "Acts/Geometry/LayerArrayCreator.hpp"
0014 #include "Acts/Geometry/PlaneLayer.hpp"
0015 #include "Acts/Geometry/TrackingVolume.hpp"
0016 #include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
0017 #include "Acts/Surfaces/RectangleBounds.hpp"
0018 #include "Acts/Surfaces/SurfaceArray.hpp"
0019 #include "Acts/Utilities/BinnedArrayXD.hpp"
0020 #include "ActsTests/CommonHelpers/DetectorElementStub.hpp"
0021 #include "ActsTests/CommonHelpers/PredefinedMaterials.hpp"
0022 
0023 #include <functional>
0024 #include <vector>
0025 
0026 using namespace Acts;
0027 using namespace Acts::UnitLiterals;
0028 
0029 ActsTests::CubicTrackingGeometry::CubicTrackingGeometry(
0030     const GeometryContext& gctx)
0031     : geoContext(gctx) {
0032   // Construct the rotation
0033   double rotationAngle = 90_degree;
0034   Vector3 xPos(cos(rotationAngle), 0., sin(rotationAngle));
0035   Vector3 yPos(0., 1., 0.);
0036   Vector3 zPos(-sin(rotationAngle), 0., cos(rotationAngle));
0037   rotation.col(0) = xPos;
0038   rotation.col(1) = yPos;
0039   rotation.col(2) = zPos;
0040 
0041   // Boundaries of the surfaces
0042   rBounds =
0043       std::make_shared<const RectangleBounds>(RectangleBounds(0.5_m, 0.5_m));
0044 
0045   // Material of the surfaces
0046   MaterialSlab matProp(makeBeryllium(), 0.5_mm);
0047   surfaceMaterial = std::make_shared<HomogeneousSurfaceMaterial>(matProp);
0048 }
0049 
0050 std::shared_ptr<const TrackingGeometry>
0051 ActsTests::CubicTrackingGeometry::operator()() {
0052   // Set translation vectors
0053   double eps = 1_mm;
0054   std::vector<Vector3> translations;
0055   translations.push_back({-2_m, 0., 0.});
0056   translations.push_back({-1_m, 0., 0.});
0057   translations.push_back({1_m - eps, 0., 0.});
0058   translations.push_back({1_m + eps, 0., 0.});
0059   translations.push_back({2_m - eps, 0., 0.});
0060   translations.push_back({2_m + eps, 0., 0.});
0061 
0062   std::vector<double> rotAngle;
0063   rotAngle.push_back(0.);
0064   rotAngle.push_back(0.);
0065   rotAngle.push_back(0.026);
0066   rotAngle.push_back(-0.026);
0067   rotAngle.push_back(0.026);
0068   rotAngle.push_back(-0.026);
0069 
0070   // Construct surfaces
0071   std::array<std::shared_ptr<const Surface>, 6> surfaces;
0072   for (unsigned int i = 0; i < translations.size(); i++) {
0073     RotationMatrix3 rotation_strip;
0074     double angle = rotAngle[i];
0075     Vector3 xPos(cos(angle), sin(angle), 0.);
0076     Vector3 yPos(-sin(angle), cos(angle), 0.);
0077     Vector3 zPos(0., 0., 1.);
0078     rotation_strip.col(0) = xPos;
0079     rotation_strip.col(1) = yPos;
0080     rotation_strip.col(2) = zPos;
0081 
0082     Transform3 trafo(Transform3::Identity() * rotation * rotation_strip);
0083     trafo.translation() = translations[i];
0084 
0085     // Create the detector element
0086     auto detElement = std::make_unique<const DetectorElementStub>(
0087         trafo, rBounds, 1._um, surfaceMaterial);
0088     // And remember the surface
0089     surfaces[i] = detElement->surface().getSharedPtr();
0090     // Add it to the event store
0091     detectorStore.push_back(std::move(detElement));
0092   }
0093 
0094   // Construct layers
0095   std::array<LayerPtr, 6> layers{};
0096   for (unsigned int i = 0; i < 6; i++) {
0097     Transform3 trafo(Transform3::Identity() * rotation);
0098     trafo.translation() = translations[i];
0099 
0100     std::unique_ptr<SurfaceArray> surArray(new SurfaceArray(surfaces[i]));
0101 
0102     layers[i] = PlaneLayer::create(trafo, rBounds, std::move(surArray), 1._mm);
0103 
0104     auto mutableSurface = const_cast<Surface*>(surfaces[i].get());
0105     mutableSurface->associateLayer(*layers[i]);
0106   }
0107 
0108   // Build volume for surfaces with negative x-values
0109   Transform3 trafoVol1(Transform3::Identity());
0110   trafoVol1.translation() = Vector3(-1.5_m, 0., 0.);
0111 
0112   auto boundsVol = std::make_shared<CuboidVolumeBounds>(1.5_m, 0.5_m, 0.5_m);
0113 
0114   LayerArrayCreator::Config lacConfig;
0115   LayerArrayCreator layArrCreator(
0116       lacConfig, getDefaultLogger("LayerArrayCreator", Logging::INFO));
0117 
0118   LayerVector layVec;
0119   layVec.push_back(layers[0]);
0120   layVec.push_back(layers[1]);
0121   std::unique_ptr<const LayerArray> layArr1(
0122       layArrCreator.layerArray(geoContext, layVec, -2_m - 1._mm, -1._m + 1._mm,
0123                                BinningType::arbitrary, AxisDirection::AxisX));
0124 
0125   auto trackVolume1 = std::make_shared<TrackingVolume>(
0126       trafoVol1, boundsVol, nullptr, std::move(layArr1), nullptr,
0127       MutableTrackingVolumeVector{}, "Volume 1");
0128 
0129   // Build volume for surfaces with positive x-values
0130   Transform3 trafoVol2(Transform3::Identity());
0131   trafoVol2.translation() = Vector3(1.5_m, 0., 0.);
0132 
0133   layVec.clear();
0134   for (unsigned int i = 2; i < 6; i++) {
0135     layVec.push_back(layers[i]);
0136   }
0137   std::unique_ptr<const LayerArray> layArr2(
0138       layArrCreator.layerArray(geoContext, layVec, 1._m - 2._mm, 2._m + 2._mm,
0139                                BinningType::arbitrary, AxisDirection::AxisX));
0140 
0141   auto trackVolume2 = std::make_shared<TrackingVolume>(
0142       trafoVol2, boundsVol, nullptr, std::move(layArr2), nullptr,
0143       MutableTrackingVolumeVector{}, "Volume 2");
0144 
0145   // Glue volumes
0146   trackVolume2->glueTrackingVolume(
0147       geoContext, BoundarySurfaceFace::negativeFaceYZ, trackVolume1.get(),
0148       BoundarySurfaceFace::positiveFaceYZ);
0149 
0150   trackVolume1->glueTrackingVolume(
0151       geoContext, BoundarySurfaceFace::positiveFaceYZ, trackVolume2.get(),
0152       BoundarySurfaceFace::negativeFaceYZ);
0153 
0154   // Build world volume
0155   Transform3 trafoWorld(Transform3::Identity());
0156   trafoWorld.translation() = Vector3(0., 0., 0.);
0157 
0158   auto worldVolBds = std::make_shared<CuboidVolumeBounds>(3._m, 0.5_m, 0.5_m);
0159 
0160   std::vector<std::pair<TrackingVolumePtr, Vector3>> tapVec;
0161 
0162   tapVec.push_back(std::make_pair(trackVolume1, Vector3(-1.5_m, 0., 0.)));
0163   tapVec.push_back(std::make_pair(trackVolume2, Vector3(1.5_m, 0., 0.)));
0164 
0165   std::vector<float> binBoundaries = {-3._m, 0., 3._m};
0166 
0167   BinningData binData(BinningOption::open, AxisDirection::AxisX, binBoundaries);
0168   std::unique_ptr<const BinUtility> bu(new BinUtility(binData));
0169 
0170   std::shared_ptr<const TrackingVolumeArray> trVolArr(
0171       new BinnedArrayXD<TrackingVolumePtr>(tapVec, std::move(bu)));
0172 
0173   MutableTrackingVolumePtr mtvpWorld(std::make_shared<TrackingVolume>(
0174       trafoWorld, worldVolBds, nullptr, nullptr, trVolArr,
0175       MutableTrackingVolumeVector{}, "World"));
0176 
0177   // Build and return tracking geometry
0178   return std::make_shared<TrackingGeometry>(mtvpWorld);
0179 }