File indexing completed on 2024-09-28 07:02:57
0001
0002
0003
0004 #include <Math/GenVector/LorentzVector.h>
0005 #include <Math/GenVector/PxPyPzM4D.h>
0006 #include <Math/Vector4Dfwd.h>
0007 #include <edm4eic/ReconstructedParticleCollection.h>
0008 #include <edm4hep/Vector3f.h>
0009 #include <fmt/core.h>
0010 #include <podio/ObjectID.h>
0011 #include <functional>
0012 #include <gsl/pointers>
0013 #include <map>
0014 #include <utility>
0015
0016 #include "algorithms/reco/ScatteredElectronsEMinusPz.h"
0017 #include "algorithms/reco/ScatteredElectronsEMinusPzConfig.h"
0018
0019 using ROOT::Math::PxPyPzEVector;
0020 using ROOT::Math::PxPyPzMVector;
0021
0022 namespace eicrecon {
0023
0024
0025
0026
0027 void ScatteredElectronsEMinusPz::init() { }
0028
0029
0030
0031
0032
0033
0034
0035
0036 void ScatteredElectronsEMinusPz::process(
0037 const ScatteredElectronsEMinusPz::Input& input,
0038 const ScatteredElectronsEMinusPz::Output& output
0039 ) const {
0040 auto [rcparts, rcele] = input;
0041 auto [out_electrons] = output;
0042
0043 static const auto m_electron = m_particleSvc.particle(11).mass;
0044 static const auto m_pion = m_particleSvc.particle(211).mass;
0045
0046
0047
0048
0049 std::map<double, edm4eic::ReconstructedParticle, std::greater<double>> scatteredElectronsMap;
0050
0051 out_electrons->setSubsetCollection();
0052
0053 trace("We have {} candidate electrons", rcele->size());
0054
0055
0056
0057
0058 PxPyPzMVector vScatteredElectron;
0059 PxPyPzMVector vHadronicFinalState;
0060 PxPyPzMVector vHadron;
0061
0062 for ( const auto& e: *rcele ) {
0063
0064
0065
0066 vHadronicFinalState.SetCoordinates(0, 0, 0, 0);
0067
0068
0069 vScatteredElectron.SetCoordinates(
0070 e.getMomentum().x,
0071 e.getMomentum().y,
0072 e.getMomentum().z,
0073 m_electron
0074 );
0075
0076
0077
0078 for (const auto& p: *rcparts) {
0079
0080
0081
0082 if (p.getObjectID() != e.getObjectID()) {
0083 vHadron.SetCoordinates(
0084 p.getMomentum().x,
0085 p.getMomentum().y,
0086 p.getMomentum().z,
0087 m_pion
0088 );
0089
0090
0091 vHadronicFinalState += vHadron;
0092 } else {
0093 trace("Skipping electron in hadronic final state");
0094 }
0095 }
0096
0097
0098
0099
0100
0101 double EPz=(vScatteredElectron+vHadronicFinalState).E()
0102 - (vScatteredElectron+vHadronicFinalState).Pz();
0103 trace("\tE-Pz={}", EPz);
0104 trace("\tScatteredElectron has Pxyz=( {}, {}, {} )", e.getMomentum().x, e.getMomentum().y, e.getMomentum().z);
0105
0106
0107 scatteredElectronsMap[ EPz ] = e;
0108 }
0109
0110 trace("Selecting candidates with {} < E-Pz < {}", m_cfg.minEMinusPz, m_cfg.maxEMinusPz);
0111
0112 bool first = true;
0113
0114 for (auto kv : scatteredElectronsMap) {
0115
0116 double EMinusPz = kv.first;
0117
0118
0119 if ( EMinusPz > m_cfg.maxEMinusPz
0120 || EMinusPz < m_cfg.minEMinusPz ){
0121 continue;
0122 }
0123
0124
0125
0126 if ( first ){
0127 trace("Max E-Pz Candidate:");
0128 trace("\tE-Pz={}", EMinusPz);
0129 trace("\tScatteredElectron has Pxyz=( {}, {}, {} )", kv.second.getMomentum().x, kv.second.getMomentum().y, kv.second.getMomentum().z);
0130 first = false;
0131 }
0132 out_electrons->push_back( kv.second );
0133 }
0134 }
0135
0136 }