Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:13

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/PlanarSurfaceDrift.hpp"
0010 
0011 #include "Acts/Utilities/Helpers.hpp"
0012 
0013 #include <cmath>
0014 
0015 ActsFatras::PlanarSurfaceDrift::Segment2D
0016 ActsFatras::PlanarSurfaceDrift::toReadout(const Acts::GeometryContext& gctx,
0017                                           const Acts::Surface& surface,
0018                                           double thickness,
0019                                           const Acts::Vector3& pos,
0020                                           const Acts::Vector3& dir,
0021                                           const Acts::Vector3& driftDir) const {
0022   // Transform the hit & direction into the local surface frame
0023   const auto& invTransform = surface.transform(gctx).inverse();
0024   Acts::Vector2 pos2Local = (invTransform * pos).segment<2>(0);
0025   Acts::Vector3 seg3Local = invTransform.linear() * dir;
0026   // Scale unit direction to the actual segment in the (depletion/drift) zone
0027   seg3Local *= thickness / std::cos(Acts::VectorHelpers::theta(seg3Local));
0028   // Calculate local entry/exit before drift
0029   Acts::Vector2 entry = pos2Local - 0.5 * seg3Local.segment<2>(0);
0030   Acts::Vector2 exit = pos2Local + 0.5 * seg3Local.segment<2>(0);
0031   // Actually apply a drift
0032   // - dirftDir is assumed in local coordinates
0033   if (!driftDir.segment<2>(0).isApprox(Acts::Vector2(0., 0.))) {
0034     // Apply the scaled drift
0035     auto applyDrift = [&](Acts::Vector2& local) {
0036       auto scaledDriftDir =
0037           driftDir * thickness / std::cos(Acts::VectorHelpers::theta(driftDir));
0038       local += scaledDriftDir.segment<2>(0);
0039     };
0040 
0041     if (driftDir.z() > 0.) {
0042       applyDrift(entry);
0043     }
0044     if (driftDir.z() < 0.) {
0045       applyDrift(exit);
0046     }
0047   }
0048 
0049   return {entry, exit};
0050 }