Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlanarSurfaceDrift.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PlanarSurfaceDrift.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
12 
13 #include <cmath>
14 
17  const Acts::Surface& surface,
18  double thickness,
19  const Acts::Vector3& pos,
20  const Acts::Vector3& dir,
21  const Acts::Vector3& driftDir) const {
22  // Transform the hit & direction into the local surface frame
23  const auto& invTransform = surface.transform(gctx).inverse();
24  Acts::Vector2 pos2Local = (invTransform * pos).segment<2>(0);
25  Acts::Vector3 seg3Local = invTransform.linear() * dir;
26  // Scale unit direction to the actual segment in the (depletion/drift) zone
27  seg3Local *= thickness / std::cos(Acts::VectorHelpers::theta(seg3Local));
28  // Calulate local entry/exit before drift
29  Acts::Vector2 entry = pos2Local - 0.5 * seg3Local.segment<2>(0);
30  Acts::Vector2 exit = pos2Local + 0.5 * seg3Local.segment<2>(0);
31  // Actually apply a drift
32  // - dirftDir is assumed in local coordinates
33  if (not driftDir.segment<2>(0).isApprox(Acts::Vector2(0., 0.))) {
34  // Apply the scaled drift
35  auto applyDrift = [&](Acts::Vector2& local) {
36  auto scaledDriftDir =
37  driftDir * thickness / std::cos(Acts::VectorHelpers::theta(driftDir));
38  local += scaledDriftDir.segment<2>(0);
39  };
40 
41  if (driftDir.z() > 0.) {
42  applyDrift(entry);
43  }
44  if (driftDir.z() < 0.) {
45  applyDrift(exit);
46  }
47  }
48 
49  return {entry, exit};
50 }