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 "ActsFatras/Digitization/PlanarSurfaceDrift.hpp"
0012 #include "ActsFatras/Digitization/PlanarSurfaceMask.hpp"
0013 #include "ActsFatras/Digitization/Segmentizer.hpp"
0014 #include "ActsFatras/EventData/Hit.hpp"
0015 
0016 #include <numeric>
0017 
0018 namespace ActsFatras {
0019 
0020 /// @brief Class that ties the digitization modules together and produces the channels
0021 class Channelizer {
0022   PlanarSurfaceDrift m_surfaceDrift;
0023   PlanarSurfaceMask m_surfaceMask;
0024   Segmentizer m_segmentizer;
0025 
0026  public:
0027   /// Do the geometric channelizing
0028   ///
0029   /// @param hit The hit we want to channelize
0030   /// @param surface the surface on which the hit is
0031   /// @param gctx the Geometry context
0032   /// @param driftDir the drift direction
0033   /// @param segmentation the segmentation of the surface
0034   /// @param thickness the thickness of the surface
0035   ///
0036   /// @return the list of channels
0037   Acts::Result<std::vector<Segmentizer::ChannelSegment>> channelize(
0038       const Hit& hit, const Acts::Surface& surface,
0039       const Acts::GeometryContext& gctx, const Acts::Vector3& driftDir,
0040       const Acts::BinUtility& segmentation, double thickness) const {
0041     auto driftedSegment = m_surfaceDrift.toReadout(
0042         gctx, surface, thickness, hit.position(), hit.direction(), driftDir);
0043 
0044     auto maskedSegmentRes = m_surfaceMask.apply(surface, driftedSegment);
0045 
0046     if (!maskedSegmentRes.ok()) {
0047       return maskedSegmentRes.error();
0048     }
0049 
0050     // Now Channelize
0051     auto segments =
0052         m_segmentizer.segments(gctx, surface, segmentation, *maskedSegmentRes);
0053 
0054     // Go from 2D-path to 3D-path by applying thickness
0055     const auto path2D = std::accumulate(
0056         segments.begin(), segments.end(), 0.0,
0057         [](double sum, const auto& seg) { return sum + seg.activation; });
0058 
0059     for (auto& seg : segments) {
0060       auto r = path2D != 0.0 ? (seg.activation / path2D) : 1.0;
0061       auto segThickness = r * thickness;
0062 
0063       seg.activation = std::hypot(segThickness, seg.activation);
0064     }
0065 
0066     return segments;
0067   }
0068 };
0069 
0070 }  // namespace ActsFatras