File indexing completed on 2025-01-18 10:10:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef ROOT_Math_GenVector_eta
0018 #define ROOT_Math_GenVector_eta 1
0019
0020 #include "Math/GenVector/etaMax.h"
0021
0022
0023 #include <limits>
0024 #include <cmath>
0025
0026
0027 namespace ROOT {
0028
0029 namespace Math {
0030
0031 namespace Impl {
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 template<typename Scalar>
0048 inline Scalar Eta_FromRhoZ(Scalar rho, Scalar z) {
0049 if (rho > 0) {
0050
0051
0052 static const Scalar big_z_scaled = pow(std::numeric_limits<Scalar>::epsilon(), static_cast<Scalar>(-.25));
0053
0054 Scalar z_scaled = z/rho;
0055 using std::fabs;
0056 if (std::fabs(z_scaled) < big_z_scaled) {
0057 using std::sqrt;
0058 using std::log;
0059 return log(z_scaled + std::sqrt(z_scaled * z_scaled + 1.0));
0060 } else {
0061
0062 using std::log;
0063 return z > 0 ? log(2.0 * z_scaled + 0.5 / z_scaled) : -log(-2.0 * z_scaled);
0064 }
0065 }
0066
0067 else if (z==0) {
0068 return 0;
0069 }
0070 else if (z>0) {
0071 return z + etaMax<Scalar>();
0072 }
0073 else {
0074 return z - etaMax<Scalar>();
0075 }
0076
0077 }
0078
0079
0080
0081
0082
0083
0084 template<typename Scalar>
0085 inline Scalar Eta_FromTheta(Scalar theta, Scalar r) {
0086 Scalar tanThetaOver2 = tan(theta / 2.);
0087 if (tanThetaOver2 == 0) {
0088 return r + etaMax<Scalar>();
0089 }
0090 else if (tanThetaOver2 > std::numeric_limits<Scalar>::max()) {
0091 return -r - etaMax<Scalar>();
0092 }
0093 else {
0094 using std::log;
0095 return -log(tanThetaOver2);
0096 }
0097
0098 }
0099
0100 }
0101
0102 }
0103
0104 }
0105
0106
0107 #endif