File indexing completed on 2025-10-31 08:20:43
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 "InclusiveKinematicsElectron.h"
0018 
0019 using ROOT::Math::PxPyPzEVector;
0020 
0021 namespace eicrecon {
0022 
0023 void InclusiveKinematicsElectron::init() {}
0024 
0025 void InclusiveKinematicsElectron::process(const InclusiveKinematicsElectron::Input& input,
0026                                           const InclusiveKinematicsElectron::Output& output) const {
0027 
0028   const auto [mcparts, escat, hfs] = input;
0029   auto [kinematics]                = output;
0030 
0031   
0032   
0033   
0034   
0035   
0036 
0037   
0038   
0039   
0040   
0041   
0042   
0043   
0044   
0045   
0046   
0047   
0048   
0049   
0050   
0051   
0052   
0053 
0054   
0055   
0056   
0057   
0058   
0059   
0060   
0061 
0062   
0063   
0064   
0065   
0066   
0067   
0068   
0069   
0070   
0071   
0072 
0073   
0074   
0075   
0076   
0077   
0078 
0079   
0080   const auto ei_coll = find_first_beam_electron(mcparts);
0081   if (ei_coll.empty()) {
0082     debug("No beam electron found");
0083     return;
0084   }
0085   const PxPyPzEVector ei(round_beam_four_momentum(ei_coll[0].getMomentum(),
0086                                                   m_particleSvc.particle(ei_coll[0].getPDG()).mass,
0087                                                   {-5.0, -10.0, -18.0}, 0.0));
0088 
0089   
0090   const auto pi_coll = find_first_beam_hadron(mcparts);
0091   if (pi_coll.empty()) {
0092     debug("No beam hadron found");
0093     return;
0094   }
0095   const PxPyPzEVector pi(round_beam_four_momentum(pi_coll[0].getMomentum(),
0096                                                   m_particleSvc.particle(pi_coll[0].getPDG()).mass,
0097                                                   {41.0, 100.0, 275.0}, m_crossingAngle));
0098 
0099   
0100   std::vector<PxPyPzEVector> electrons;
0101   for (const auto& p : *escat) {
0102     electrons.emplace_back(p.getMomentum().x, p.getMomentum().y, p.getMomentum().z, p.getEnergy());
0103     break;
0104   }
0105 
0106   
0107   if (electrons.empty()) {
0108     debug("No scattered electron found");
0109     return;
0110   }
0111 
0112   
0113   static const auto m_proton = m_particleSvc.particle(2212).mass;
0114   const auto ef              = electrons.front();
0115   const auto q               = ei - ef;
0116   const auto q_dot_pi        = q.Dot(pi);
0117   const auto Q2              = -q.Dot(q);
0118   const auto y               = q_dot_pi / ei.Dot(pi);
0119   const auto nu              = q_dot_pi / m_proton;
0120   const auto x               = Q2 / (2. * q_dot_pi);
0121   const auto W               = sqrt(m_proton * m_proton + 2. * q_dot_pi - Q2);
0122   auto kin                   = kinematics->create(x, Q2, W, y, nu);
0123   kin.setScat(escat->at(0));
0124 
0125   debug("x,Q2,W,y,nu = {},{},{},{},{}", kin.getX(), kin.getQ2(), kin.getW(), kin.getY(),
0126         kin.getNu());
0127 }
0128 
0129 }