File indexing completed on 2025-07-01 07:56:26
0001
0002
0003
0004 #include <edm4eic/EDM4eicVersion.h>
0005 #if EDM4EIC_VERSION_MAJOR >= 6
0006
0007 #include <Math/GenVector/LorentzVector.h>
0008 #include <Math/GenVector/PxPyPzE4D.h>
0009 #include <Math/Vector4Dfwd.h>
0010 #include <edm4eic/HadronicFinalStateCollection.h>
0011 #include <edm4eic/InclusiveKinematicsCollection.h>
0012 #include <fmt/core.h>
0013 #include <cmath>
0014 #include <gsl/pointers>
0015
0016 #include "Beam.h"
0017 #include "InclusiveKinematicsJB.h"
0018
0019 using ROOT::Math::PxPyPzEVector;
0020
0021 namespace eicrecon {
0022
0023 void InclusiveKinematicsJB::init() {}
0024
0025 void InclusiveKinematicsJB::process(const InclusiveKinematicsJB::Input& input,
0026 const InclusiveKinematicsJB::Output& output) const {
0027
0028 const auto [mcparts, escat, hfs] = input;
0029 auto [kinematics] = output;
0030
0031
0032 const auto ei_coll = find_first_beam_electron(mcparts);
0033 if (ei_coll.empty()) {
0034 debug("No beam electron found");
0035 return;
0036 }
0037 const PxPyPzEVector ei(round_beam_four_momentum(ei_coll[0].getMomentum(),
0038 m_particleSvc.particle(ei_coll[0].getPDG()).mass,
0039 {-5.0, -10.0, -18.0}, 0.0));
0040
0041
0042 const auto pi_coll = find_first_beam_hadron(mcparts);
0043 if (pi_coll.empty()) {
0044 debug("No beam hadron found");
0045 return;
0046 }
0047 const PxPyPzEVector pi(round_beam_four_momentum(pi_coll[0].getMomentum(),
0048 m_particleSvc.particle(pi_coll[0].getPDG()).mass,
0049 {41.0, 100.0, 275.0}, m_crossingAngle));
0050
0051
0052 if (hfs->empty()) {
0053 debug("No hadronic final state found");
0054 return;
0055 }
0056 auto sigma_h = hfs->at(0).getSigma();
0057 auto ptsum = hfs->at(0).getPT();
0058
0059
0060 if (sigma_h <= 0) {
0061 debug("Sigma zero or negative");
0062 return;
0063 }
0064
0065
0066 static const auto m_proton = m_particleSvc.particle(2212).mass;
0067 const auto y_jb = sigma_h / (2. * ei.energy());
0068 const auto Q2_jb = ptsum * ptsum / (1. - y_jb);
0069 const auto x_jb = Q2_jb / (4. * ei.energy() * pi.energy() * y_jb);
0070 const auto nu_jb = Q2_jb / (2. * m_proton * x_jb);
0071 const auto W_jb = sqrt(m_proton * m_proton + 2 * m_proton * nu_jb - Q2_jb);
0072 auto kin = kinematics->create(x_jb, Q2_jb, W_jb, y_jb, nu_jb);
0073 if (escat->empty()) {
0074 debug("No scattered electron found");
0075 } else {
0076 kin.setScat(escat->at(0));
0077 }
0078
0079 debug("x,Q2,W,y,nu = {},{},{},{},{}", kin.getX(), kin.getQ2(), kin.getW(), kin.getY(),
0080 kin.getNu());
0081 }
0082
0083 }
0084 #endif