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 
9 #pragma once
10 
13 
14 namespace Acts {
15 
17 namespace PlanarHelper {
18 
27  const Vector3D& position,
28  const Vector3D& direction) {
29  // Get the matrix from the transform (faster access)
30  const auto& tMatrix = transform.matrix();
31  const Vector3D pnormal = tMatrix.block<3, 1>(0, 2).transpose();
32  const Vector3D pcenter = tMatrix.block<3, 1>(0, 3).transpose();
33  // It is solvable, so go on
34  double denom = direction.dot(pnormal);
35  if (denom != 0.0) {
36  // Translate that into a path
37  double path = (pnormal.dot((pcenter - position))) / (denom);
38  // Is valid hence either on surface or reachable
39  Intersection3D::Status status =
41  ? Intersection3D::Status::onSurface
42  : Intersection3D::Status::reachable;
43  // Return the intersection
44  return Intersection3D{(position + path * direction), path, status};
45  }
46  return Intersection3D();
47 }
48 
49 } // namespace PlanarHelper
50 } // namespace Acts