File indexing completed on 2025-01-18 09:55:28
0001
0002
0003
0004 #ifndef EDM4EIC_UTILS_ANALYSIS_HH
0005 #define EDM4EIC_UTILS_ANALYSIS_HH
0006
0007 #include <algorithm>
0008 #include <cmath>
0009 #include <exception>
0010 #include <limits>
0011 #include <string>
0012 #include <vector>
0013
0014 #include <Math/Vector4D.h>
0015
0016 #include <edm4eic/ReconstructedParticleCollection.h>
0017 #include <edm4eic/ReconstructedParticleData.h>
0018 #include <edm4eic/TrackParametersCollection.h>
0019
0020 namespace edm4eic {
0021
0022
0023
0024
0025
0026 inline auto
0027 momenta_from_tracking(const std::vector<edm4eic::TrackParametersData>& tracks,
0028 const double mass) {
0029 std::vector<ROOT::Math::PxPyPzMVector> momenta{tracks.size()};
0030
0031 std::transform(tracks.begin(), tracks.end(), momenta.begin(),
0032 [mass](const auto& track) {
0033
0034 if (fabs(track.qOverP) < 1e-9) {
0035 return ROOT::Math::PxPyPzMVector{};
0036 }
0037 const double p = fabs(1. / track.qOverP);
0038 const double px = p * cos(track.phi) * sin(track.theta);
0039 const double py = p * sin(track.phi) * sin(track.theta);
0040 const double pz = p * cos(track.theta);
0041 return ROOT::Math::PxPyPzMVector{px, py, pz, mass};
0042 });
0043 return momenta;
0044 }
0045 }
0046 #endif