Analysis Software
Documentation for sPHENIX simulation 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 Vector3& position,
28  const Vector3& direction,
30  // Get the matrix from the transform (faster access)
31  const auto& tMatrix = transform.matrix();
32  const Vector3 pnormal = tMatrix.block<3, 1>(0, 2).transpose();
33  const Vector3 pcenter = tMatrix.block<3, 1>(0, 3).transpose();
34  // It is solvable, so go on
35  ActsScalar denom = direction.dot(pnormal);
36  if (denom != 0.0) {
37  // Translate that into a path
38  ActsScalar path = (pnormal.dot((pcenter - position))) / (denom);
39  // Is valid hence either on surface or reachable
40  Intersection3D::Status status = std::abs(path) < std::abs(tolerance)
41  ? Intersection3D::Status::onSurface
42  : Intersection3D::Status::reachable;
43  // Return the intersection
44  return Intersection3D{(position + path * direction), path, status};
45  }
46  return Intersection3D::invalid();
47 }
48 
49 } // namespace PlanarHelper
50 } // namespace Acts