File indexing completed on 2026-04-10 07:50:41
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 <edm4eic/ReconstructedParticleCollection.h>
0009 #include <edm4hep/MCParticleCollection.h>
0010 #include <edm4hep/Vector3f.h>
0011 #include <cmath>
0012 #include <tuple>
0013
0014 #include "Beam.h"
0015 #include "Boost.h"
0016 #include "InclusiveKinematicsESigma.h"
0017
0018 using ROOT::Math::PxPyPzEVector;
0019
0020 namespace eicrecon {
0021
0022 void InclusiveKinematicsESigma::init() {}
0023
0024 void InclusiveKinematicsESigma::process(const InclusiveKinematicsESigma::Input& input,
0025 const InclusiveKinematicsESigma::Output& output) const {
0026
0027 const auto [mc_beam_electrons, mc_beam_protons, escat, hfs] = input;
0028 auto [out_kinematics] = output;
0029
0030
0031 if (mc_beam_electrons->empty()) {
0032 debug("No beam electron found");
0033 return;
0034 }
0035 const auto& ei_particle = (*mc_beam_electrons)[0];
0036 const PxPyPzEVector ei(round_beam_four_momentum(ei_particle.getMomentum(),
0037 m_particleSvc.particle(ei_particle.getPDG()).mass,
0038 electron_beam_pz_set, 0.0));
0039
0040
0041 if (mc_beam_protons->empty()) {
0042 debug("No beam hadron found");
0043 return;
0044 }
0045 const auto& pi_particle = (*mc_beam_protons)[0];
0046 const PxPyPzEVector pi(round_beam_four_momentum(pi_particle.getMomentum(),
0047 m_particleSvc.particle(pi_particle.getPDG()).mass,
0048 hadron_beam_pz_set, m_crossingAngle));
0049
0050
0051 auto boost = determine_boost(ei, pi);
0052
0053
0054 if (escat->empty()) {
0055 debug("No scattered electron found");
0056 return;
0057 }
0058 auto kf = escat->at(0);
0059 PxPyPzEVector e_lab(kf.getMomentum().x, kf.getMomentum().y, kf.getMomentum().z, kf.getEnergy());
0060 PxPyPzEVector e_boosted = apply_boost(boost, e_lab);
0061 auto pt_e = e_boosted.Pt();
0062 auto sigma_e = e_boosted.E() - e_boosted.Pz();
0063
0064
0065 if (hfs->empty()) {
0066 debug("No hadronic final state found");
0067 return;
0068 }
0069 auto sigma_h = hfs->at(0).getSigma();
0070
0071 if (sigma_h <= 0) {
0072 debug("No scattered electron found or sigma zero or negative");
0073 return;
0074 }
0075
0076 auto sigma_tot = sigma_e + sigma_h;
0077
0078
0079 const auto y_e = 1. - sigma_e / (2. * ei.energy());
0080 const auto Q2_e = (pt_e * pt_e) / (1. - y_e);
0081
0082 const auto y_sig = sigma_h / sigma_tot;
0083 const auto Q2_sig = (pt_e * pt_e) / (1. - y_sig);
0084 const auto x_sig = Q2_sig / (4. * ei.energy() * pi.energy() * y_sig);
0085
0086 static const auto m_proton = m_particleSvc.particle(2212).mass;
0087 const auto Q2_esig = Q2_e;
0088 const auto x_esig = x_sig;
0089 const auto y_esig = Q2_esig / (4. * ei.energy() * pi.energy() *
0090 x_esig);
0091 const auto nu_esig = Q2_esig / (2. * m_proton * x_esig);
0092 const auto W_esig = sqrt(m_proton * m_proton + 2 * m_proton * nu_esig - Q2_esig);
0093 auto kin = out_kinematics->create(x_esig, Q2_esig, W_esig, y_esig, nu_esig);
0094 kin.setScat(kf);
0095
0096
0097 debug("x,Q2,W,y,nu = {},{},{},{},{}", kin.getX(), kin.getQ2(), kin.getW(), kin.getY(),
0098 kin.getNu());
0099 }
0100
0101 }