Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:39

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/AnnulusBounds.hpp"
0013 #include "Acts/Surfaces/DiscBounds.hpp"
0014 #include "Acts/Surfaces/DiscSurface.hpp"
0015 #include "Acts/Surfaces/DiscTrapezoidBounds.hpp"
0016 #include "Acts/Surfaces/PlaneSurface.hpp"
0017 #include "Acts/Surfaces/RadialBounds.hpp"
0018 #include "Acts/Surfaces/RectangleBounds.hpp"
0019 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0020 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0021 #include "Acts/Utilities/BinUtility.hpp"
0022 #include "Acts/Utilities/BinningType.hpp"
0023 
0024 #include <array>
0025 #include <tuple>
0026 #include <vector>
0027 
0028 #include "BoundRandomValues.hpp"
0029 
0030 namespace ActsFatras {
0031 
0032 using Randomizer = std::function<Acts::Vector2(double, double)>;
0033 
0034 using PlanarTestBed =
0035     std::tuple<std::string, std::shared_ptr<const Acts::Surface>,
0036                Acts::BinUtility, Randomizer>;
0037 
0038 /// Helper struct to create a testbed for Digitization steps
0039 struct PlanarSurfaceTestBeds {
0040   /// Call operator for creating a testbed of different surfaces.
0041   /// It returns a testbed for all planar surface types and the
0042   /// corresponding cartesian/polar segmentation.
0043   ///
0044   /// @param rScale is a parameter how far the random numbers
0045   /// should be generated (1 -> inside to boundary, 1.1 -> 10% outside)
0046   std::vector<PlanarTestBed> operator()(double rScale) const {
0047     double irScale = (2. - rScale);
0048 
0049     // Pixel test in Rectangle
0050     double xhalf = 3.;
0051     double yhalf = 6.5;
0052     auto rectangle = std::make_shared<Acts::RectangleBounds>(xhalf, yhalf);
0053     auto rSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(
0054         Acts::Transform3::Identity(), rectangle);
0055     Acts::BinUtility pixelated(15, -xhalf, xhalf, Acts::open, Acts::binX);
0056     pixelated += Acts::BinUtility(26, -yhalf, yhalf, Acts::open, Acts::binY);
0057     RectangleRandom rRandom(xhalf * rScale, yhalf * rScale);
0058 
0059     // Cartesian strip test in Trapezoid
0060     double xhalfminy = 2.;
0061     double xhalfmaxy = 3.5;
0062     yhalf = 4.;
0063     auto trapezoid =
0064         std::make_shared<Acts::TrapezoidBounds>(xhalfminy, xhalfmaxy, yhalf);
0065     auto tSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(
0066         Acts::Transform3::Identity(), trapezoid);
0067     Acts::BinUtility stripsX(35, -xhalfmaxy, xhalfmaxy, Acts::open, Acts::binX);
0068     stripsX += Acts::BinUtility(1, -yhalf, yhalf, Acts::open, Acts::binY);
0069     TrapezoidRandom tRandom(xhalfminy * rScale, xhalfmaxy * rScale,
0070                             yhalf * rScale);
0071 
0072     // Phi strip test in DiscTrapezoid
0073     double rmin = 2.;
0074     double rmax = 7.5;
0075     double xmin = 2.;
0076     double xmax = 3.5;
0077     double ymax = std::sqrt(rmax * rmax - xmax * xmax);
0078     double alpha = std::max(atan2(xmin, rmin), atan2(xmax, ymax));
0079 
0080     auto discTrapezoid =
0081         std::make_shared<Acts::DiscTrapezoidBounds>(xmin, xmax, rmin, rmax);
0082     auto dtSurface = Acts::Surface::makeShared<Acts::DiscSurface>(
0083         Acts::Transform3::Identity(), discTrapezoid);
0084     Acts::BinUtility stripsPhi(1, rmin, rmax, Acts::open, Acts::binR);
0085     stripsPhi += Acts::BinUtility(25, M_PI_2 - alpha, M_PI_2 + alpha,
0086                                   Acts::open, Acts::binPhi);
0087     TrapezoidRandom dtRandom(xmin * rScale, xmax * rScale, rmin * irScale,
0088                              ymax * rScale);
0089 
0090     // Raidal disc test
0091     auto discRadial =
0092         std::make_shared<Acts::RadialBounds>(rmin, rmax, M_PI_4, M_PI_2);
0093     auto dSurface = Acts::Surface::makeShared<Acts::DiscSurface>(
0094         Acts::Transform3::Identity(), discRadial);
0095     Acts::BinUtility rphiseg(10, rmin, rmax, Acts::open, Acts::binR);
0096     rphiseg += Acts::BinUtility(20, (M_PI_2 - M_PI_4), (M_PI_2 + M_PI_4),
0097                                 Acts::open, Acts::binPhi);
0098 
0099     DiscRandom dRandom(rmin * irScale, rmax * rScale,
0100                        (M_PI_2 - M_PI_4) * irScale, (M_PI_2 + M_PI_4) * rScale);
0101 
0102     // Annulus disc test
0103     rmin = 2.5;
0104     rmax = 5.5;
0105     Acts::Vector2 aorigin(0.1, -0.3);
0106     double phimin = -0.25;
0107     double phimax = 0.38;
0108     auto annulus = std::make_shared<Acts::AnnulusBounds>(rmin, rmax, phimin,
0109                                                          phimax, aorigin);
0110     auto aSurface = Acts::Surface::makeShared<Acts::DiscSurface>(
0111         Acts::Transform3::Identity() *
0112             Acts::Translation3(-aorigin.x(), -aorigin.y(), 0.),
0113         annulus);
0114 
0115     auto vertices = annulus->vertices(72);
0116     std::for_each(vertices.begin(), vertices.end(), [&](Acts::Vector2& v) {
0117       double r = Acts::VectorHelpers::perp(v);
0118       rmin = std::min(rmin, r);
0119       rmax = std::max(rmax, r);
0120     });
0121 
0122     Acts::BinUtility stripsPhiA(1, rmin, rmax, Acts::open, Acts::binR);
0123     stripsPhiA +=
0124         Acts::BinUtility(12, phimin, phimax, Acts::open, Acts::binPhi);
0125     AnnulusRandom aRandom(rmin * irScale, rmax * rScale, phimin * rScale,
0126                           phimax * rScale, aorigin.x(), aorigin.y());
0127 
0128     return {{"Rectangle", std::move(rSurface), pixelated, rRandom},
0129             {"Trapezoid", std::move(tSurface), stripsX, tRandom},
0130             {"DiscTrapezoid", std::move(dtSurface), stripsPhi, dtRandom},
0131             {"DiscRadial", std::move(dSurface), rphiseg, dRandom},
0132             {"Annulus", std::move(aSurface), stripsPhiA, aRandom}};
0133   }
0134 };
0135 
0136 }  // namespace ActsFatras