File indexing completed on 2025-07-11 07:53:36
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 <edm4hep/Vector3f.h>
0010 #include <fmt/core.h>
0011 #include <cmath>
0012 #include <gsl/pointers>
0013
0014 #include "Beam.h"
0015 #include "Boost.h"
0016 #include "InclusiveKinematicsSigma.h"
0017
0018 using ROOT::Math::PxPyPzEVector;
0019
0020 namespace eicrecon {
0021
0022 void InclusiveKinematicsSigma::init() {}
0023
0024 void InclusiveKinematicsSigma::process(const InclusiveKinematicsSigma::Input& input,
0025 const InclusiveKinematicsSigma::Output& output) const {
0026
0027 const auto [mcparts, escat, hfs] = input;
0028 auto [kinematics] = output;
0029
0030
0031 const auto ei_coll = find_first_beam_electron(mcparts);
0032 if (ei_coll.empty()) {
0033 debug("No beam electron found");
0034 return;
0035 }
0036 const PxPyPzEVector ei(round_beam_four_momentum(ei_coll[0].getMomentum(),
0037 m_particleSvc.particle(ei_coll[0].getPDG()).mass,
0038 {-5.0, -10.0, -18.0}, 0.0));
0039
0040
0041 const auto pi_coll = find_first_beam_hadron(mcparts);
0042 if (pi_coll.empty()) {
0043 debug("No beam hadron found");
0044 return;
0045 }
0046 const PxPyPzEVector pi(round_beam_four_momentum(pi_coll[0].getMomentum(),
0047 m_particleSvc.particle(pi_coll[0].getPDG()).mass,
0048 {41.0, 100.0, 275.0}, 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 static const auto m_proton = m_particleSvc.particle(2212).mass;
0080 const auto y_sig = sigma_h / sigma_tot;
0081 const auto Q2_sig = (pt_e * pt_e) / (1. - y_sig);
0082 const auto x_sig = Q2_sig / (4. * ei.energy() * pi.energy() * y_sig);
0083 const auto nu_sig = Q2_sig / (2. * m_proton * x_sig);
0084 const auto W_sig = sqrt(m_proton * m_proton + 2 * m_proton * nu_sig - Q2_sig);
0085 auto kin = kinematics->create(x_sig, Q2_sig, W_sig, y_sig, nu_sig);
0086 kin.setScat(kf);
0087
0088 debug("x,Q2,W,y,nu = {},{},{},{},{}", kin.getX(), kin.getQ2(), kin.getW(), kin.getY(),
0089 kin.getNu());
0090 }
0091
0092 }