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