File indexing completed on 2026-11-28 09:20:46
0001
0002
0003
0004 #include <Math/GenVector/LorentzVector.h>
0005 #include <Math/GenVector/PxPyPzE4D.h>
0006 #include <Math/Vector4Dfwd.h>
0007 #include <edm4eic/InclusiveKinematicsCollection.h>
0008 #include <edm4hep/MCParticleCollection.h>
0009 #include <cstdlib>
0010 #include <optional>
0011 #include <tuple>
0012
0013 #include "InclusiveKinematicsTruthBare.h"
0014 #include "TruthLeptonLine.h"
0015
0016 using ROOT::Math::PxPyPzEVector;
0017
0018 namespace eicrecon {
0019
0020 void InclusiveKinematicsTruthBare::init() {}
0021
0022 void InclusiveKinematicsTruthBare::process(
0023 const InclusiveKinematicsTruthBare::Input& input,
0024 const InclusiveKinematicsTruthBare::Output& output) const {
0025
0026 const auto [mcparts] = input;
0027 auto [kinematics] = output;
0028
0029
0030
0031
0032
0033
0034
0035 const auto truth = find_lepton_line_truth(*mcparts);
0036 if (!truth.has_value()) {
0037 debug("No beam electron with a final-state scattered lepton found");
0038 return;
0039 }
0040
0041
0042 static const auto ei_mass = m_particleSvc.particle(11).mass;
0043 const PxPyPzEVector ei = four_momentum(truth->beam_lepton(), ei_mass);
0044
0045
0046 if (!truth->beam_hadron.has_value()) {
0047 debug("No beam hadron found");
0048 return;
0049 }
0050 const auto& pi_particle = *truth->beam_hadron;
0051 const auto pi_beam = beam_per_nucleon(
0052 pi_particle,
0053 is_ion(pi_particle.getPDG()) ? 0. : m_particleSvc.particle(pi_particle.getPDG()).mass);
0054 const PxPyPzEVector pi = pi_beam.momentum;
0055
0056
0057
0058 const auto& ef_particle = truth->scattered_lepton();
0059 const auto ef_mass = m_particleSvc.particle(std::abs(ef_particle.getPDG())).mass;
0060 const PxPyPzEVector ef = four_momentum(ef_particle, ef_mass);
0061
0062
0063 const auto q = ei - ef;
0064 const auto dis = dis_variables(ei, pi, pi_beam.mass, q);
0065 auto kin = kinematics->create(dis.x, dis.Q2, dis.W, dis.y, dis.nu);
0066
0067 debug("x,Q2,W,y,nu = {},{},{},{},{}", kin.getX(), kin.getQ2(), kin.getW(), kin.getY(),
0068 kin.getNu());
0069 }
0070
0071 }