Belle II Software  release-08-01-10
VectorUtil.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 /* ROOT headers. */
12 #include <Math/Vector3D.h>
13 #include <TVector3.h>
14 
15 namespace Belle2 {
24  static constexpr auto XYZToTVector = [](const ROOT::Math::XYZVector& a)
25  {
26  return TVector3(a.X(), a.Y(), a.Z());
27  };
28 
29  namespace VectorUtil {
30 
38  inline void setMagThetaPhi(ROOT::Math::XYZVector& vector,
39  double mag, double theta, double phi)
40  {
41  const double amag = std::abs(mag);
42  const double sinTheta = std::sin(theta);
43  const double x = amag * sinTheta * std::cos(phi);
44  const double y = amag * sinTheta * std::sin(phi);
45  const double z = amag * std::cos(theta);
46  vector.SetXYZ(x, y, z);
47  }
48 
49  }
50 
52 }
static constexpr auto XYZToTVector
Helper function to convert XYZVector to TVector3.
Definition: VectorUtil.h:24
Abstract base class for different kinds of events.