Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:02

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/Geometry/GeometryContext.hpp"
0013 
0014 #include <array>
0015 #include <utility>
0016 #include <vector>
0017 
0018 namespace Acts {
0019 class BinUtility;
0020 class Surface;
0021 }  // namespace Acts
0022 
0023 namespace ActsFatras {
0024 
0025 /// The Segmentizer splits a surface segment, i.e. after projection
0026 /// onto the readout surface into channel segments.
0027 ///
0028 struct Segmentizer {
0029   /// Shorthand for a 2D segment
0030   using Segment2D = std::array<Acts::Vector2, 2>;
0031   /// Shorthand for a 2D bin
0032   using Bin2D = std::array<unsigned int, 2>;
0033   /// shorthand for a 2D bin delta
0034   using BinDelta2D = std::array<int, 2>;
0035 
0036   /// Nested struct for stepping from one channel to the next.
0037   struct ChannelStep {
0038     /// This is the delta to the last step in bins
0039     BinDelta2D delta = {0, 0};
0040     /// The intersection with the channel boundary
0041     Acts::Vector2 intersect;
0042     /// The patlength from the start
0043     double path = 0.;
0044 
0045     /// Constructor with arguments for a ChannelStep.
0046     ///
0047     /// @param delta_ The bin delta for this step
0048     /// @param intersect_ The intersect with the channel boundary
0049     /// @param start The start of the surface segment, for path from origin
0050     ChannelStep(BinDelta2D delta_, Acts::Vector2 intersect_,
0051                 const Acts::Vector2& start)
0052         : delta(delta_),
0053           intersect(std::move(intersect_)),
0054           path((intersect - start).norm()) {}
0055 
0056     /// Smaller operator for sorting the ChannelStep objects.
0057     ///
0058     /// @param cstep The other ChannelStep to be compared
0059     ///
0060     /// The ChannelStep objects can be compared with its path distance
0061     /// from the start (surface segment origin)
0062     bool operator<(const ChannelStep& cstep) const { return path < cstep.path; }
0063   };
0064 
0065   /// Nested struct for representing channel steps.
0066   struct ChannelSegment {
0067     /// The bin of this segment
0068     Bin2D bin = {0, 0};
0069     /// The segment start, end points
0070     Segment2D path2D;
0071     /// The (clipped) value (uncorrected: path length)
0072     double activation = 0.;
0073 
0074     /// Constructor with arguments
0075     ///
0076     /// @param bin_ The bin corresponding to this step
0077     /// @param path2D_ The start/end 2D position of the segement
0078     /// @param activation_ The segment activation (clean: length) for this bin
0079     ChannelSegment(Bin2D bin_, Segment2D path2D_, double activation_)
0080         : bin(bin_), path2D(std::move(path2D_)), activation(activation_) {}
0081   };
0082 
0083   /// Divide the surface segment into channel segments.
0084   ///
0085   /// @note Channelizing is done in cartesian coordinates (start/end)
0086   /// @note The start and end cartesian vector is supposed to be inside
0087   /// the surface bounds (pre-run through the SurfaceMasker)
0088   /// @note The segmentation has to be 2-dimensional, even if the
0089   /// actual readout is 1-dimensional, in latter case one bin in the
0090   /// second coordinate direction is required.
0091   ///
0092   /// @param geoCtx The geometry context for the localToGlobal, etc.
0093   /// @param surface The surface for the channelizing
0094   /// @param segmentation The segmentation for the channelizing
0095   /// @param segment The surface segment (cartesian coordinates)
0096   ///
0097   /// @return a vector of ChannelSegment objects
0098   std::vector<ChannelSegment> segments(const Acts::GeometryContext& geoCtx,
0099                                        const Acts::Surface& surface,
0100                                        const Acts::BinUtility& segmentation,
0101                                        const Segment2D& segment) const;
0102 };
0103 
0104 }  // namespace ActsFatras