File indexing completed on 2024-09-27 07:02:59
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/InclusiveKinematicsCollection.h>
0011 #include <edm4eic/ReconstructedParticleCollection.h>
0012 #include <edm4hep/MCParticleCollection.h>
0013 #include <edm4hep/Vector3f.h>
0014 #include <fmt/core.h>
0015 #include <cmath>
0016 #include <gsl/pointers>
0017 #include <vector>
0018
0019 #include "Beam.h"
0020 #include "InclusiveKinematicsElectron.h"
0021
0022 using ROOT::Math::PxPyPzEVector;
0023
0024 namespace eicrecon {
0025
0026 void InclusiveKinematicsElectron::init() { }
0027
0028 void InclusiveKinematicsElectron::process(
0029 const InclusiveKinematicsElectron::Input& input,
0030 const InclusiveKinematicsElectron::Output& output) const {
0031
0032 const auto [mcparts, escat, hfs] = input;
0033 auto [kinematics] = output;
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
0081
0082
0083
0084 const auto ei_coll = find_first_beam_electron(mcparts);
0085 if (ei_coll.size() == 0) {
0086 debug("No beam electron found");
0087 return;
0088 }
0089 const PxPyPzEVector ei(
0090 round_beam_four_momentum(
0091 ei_coll[0].getMomentum(),
0092 m_particleSvc.particle(ei_coll[0].getPDG()).mass,
0093 {-5.0, -10.0, -18.0},
0094 0.0)
0095 );
0096
0097
0098 const auto pi_coll = find_first_beam_hadron(mcparts);
0099 if (pi_coll.size() == 0) {
0100 debug("No beam hadron found");
0101 return;
0102 }
0103 const PxPyPzEVector pi(
0104 round_beam_four_momentum(
0105 pi_coll[0].getMomentum(),
0106 m_particleSvc.particle(pi_coll[0].getPDG()).mass,
0107 {41.0, 100.0, 275.0},
0108 m_crossingAngle)
0109 );
0110
0111
0112 std::vector<PxPyPzEVector> electrons;
0113 for (const auto& p: *escat) {
0114 electrons.emplace_back(p.getMomentum().x, p.getMomentum().y, p.getMomentum().z, p.getEnergy());
0115 break;
0116 }
0117
0118
0119 if (electrons.size() == 0) {
0120 debug("No scattered electron found");
0121 return;
0122 }
0123
0124
0125 static const auto m_proton = m_particleSvc.particle(2212).mass;
0126 const auto ef = electrons.front();
0127 const auto q = ei - ef;
0128 const auto q_dot_pi = q.Dot(pi);
0129 const auto Q2 = -q.Dot(q);
0130 const auto y = q_dot_pi / ei.Dot(pi);
0131 const auto nu = q_dot_pi / m_proton;
0132 const auto x = Q2 / (2. * q_dot_pi);
0133 const auto W = sqrt(m_proton*m_proton + 2.*q_dot_pi - Q2);
0134 auto kin = kinematics->create(x, Q2, W, y, nu);
0135 kin.setScat(escat->at(0));
0136
0137 debug("x,Q2,W,y,nu = {},{},{},{},{}", kin.getX(),
0138 kin.getQ2(), kin.getW(), kin.getY(), kin.getNu());
0139 }
0140
0141 }
0142 #endif