Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:51

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 "ActsFatras/Digitization/Channelizer.hpp"
0010 
0011 namespace ActsFatras {
0012 
0013 Acts::Result<std::vector<Segmentizer::ChannelSegment>> Channelizer::channelize(
0014     const Hit& hit, const Acts::Surface& surface,
0015     const Acts::GeometryContext& gctx, const Acts::Vector3& driftDir,
0016     const Acts::BinUtility& segmentation, double thickness,
0017     double minRelPerpDrift) const {
0018   // Drifted surface and scalor 2D to 3D segment
0019   // SurfaceDrift handles the surface-type-specific local frame internally
0020   // (plane/disc Cartesian, cylinder unrolled (rPhi, z))
0021   const auto atReadoutPlane = m_surfaceDrift.toReadout(
0022       gctx, surface, thickness, hit.position(), hit.direction(), driftDir);
0023   if (!atReadoutPlane.ok()) {
0024     return atReadoutPlane.error();
0025   }
0026   // The drifted and the full segment
0027   const auto& [driftedSegment, fullSegment] = *atReadoutPlane;
0028 
0029   // Applies the surface mask (also surface-type agnostic)
0030   const auto maskedSegmentRes = m_surfaceMask.apply(surface, driftedSegment);
0031   if (!maskedSegmentRes.ok()) {
0032     return maskedSegmentRes.error();
0033   }
0034 
0035   // Now Channelize, i.e. segments are mapped to the readout grid
0036   auto segments =
0037       m_segmentizer.segments(gctx, surface, segmentation, *maskedSegmentRes);
0038 
0039   const double driftedPathLength =
0040       (driftedSegment[1] - driftedSegment[0]).norm();
0041   // In case we have close-to-nominal incident, we could run into numerical
0042   // problems
0043   if (std::abs(driftedPathLength) < minRelPerpDrift * thickness &&
0044       segments.size() == 1) {
0045     segments[0].activation = thickness;
0046     return segments;
0047   }
0048 
0049   const double fullPathLength = (fullSegment[1] - fullSegment[0]).norm();
0050   const double scale2Dto3D = fullPathLength / driftedPathLength;
0051   // scale the activations
0052   for (auto& segment : segments) {
0053     segment.activation *= scale2Dto3D;
0054   }
0055 
0056   return segments;
0057 }
0058 
0059 }  // namespace ActsFatras