ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlanarHelper.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PlanarHelper.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 // PlanarHelper.hpp, Acts project
12 
13 #pragma once
14 
17 
18 namespace Acts {
19 
21 namespace PlanarHelper {
22 
29  const Vector3D& position,
30  const Vector3D& direction) {
31  // Get the matrix from the transform (faster access)
32  const auto& tMatrix = transform.matrix();
33  const Vector3D pnormal = tMatrix.block<3, 1>(0, 2).transpose();
34  const Vector3D pcenter = tMatrix.block<3, 1>(0, 3).transpose();
35  // It is solvable, so go on
36  double denom = direction.dot(pnormal);
37  if (denom != 0.0) {
38  // Translate that into a path
39  double path = (pnormal.dot((pcenter - position))) / (denom);
40  // Is valid hence either on surface or reachable
41  Intersection::Status status =
43  ? Intersection::Status::onSurface
44  : Intersection::Status::reachable;
45  // Return the intersection
46  return Intersection{(position + path * direction), path, status};
47  }
48  return Intersection();
49 }
50 
51 } // namespace PlanarHelper
52 } // namespace Acts