diff --git a/src/algorithms/fardetectors/FarDetectorTransportationPostML.cc b/src/algorithms/fardetectors/FarDetectorTransportationPostML.cc index b854fe459d..d742c12bf8 100644 --- a/src/algorithms/fardetectors/FarDetectorTransportationPostML.cc +++ b/src/algorithms/fardetectors/FarDetectorTransportationPostML.cc @@ -28,8 +28,8 @@ void FarDetectorTransportationPostML::process( const FarDetectorTransportationPostML::Input& input, const FarDetectorTransportationPostML::Output& output) const { - const auto [prediction_tensors, track_associations, beamElectrons] = input; - auto [out_particles, out_links, out_associations] = output; + const auto [prediction_tensors, tracks, track_associations, beamElectrons] = input; + auto [out_particles, out_links, out_associations] = output; //Set beam energy from first MCBeamElectron, using std::call_once if (beamElectrons != nullptr) { @@ -111,6 +111,13 @@ void FarDetectorTransportationPostML::process( particle.setMass(m_mass); particle.setPDG(m_cfg.pdg_value); + if (i >= tracks->size()) { + error("Prediction tensor row {} has no corresponding track (tracks size={})", i, + tracks->size()); + throw std::runtime_error("Prediction tensor/track size mismatch"); + } + particle.addToTracks(tracks->at(i)); + //Check if both association collections are set and copy the MCParticle association if ((track_associations != nullptr) && (track_associations->size() > i)) { // Copy the association from the input to the output @@ -125,8 +132,6 @@ void FarDetectorTransportationPostML::process( out_association.setWeight(association.getWeight()); } } - - // TODO: Implement the association of the reconstructed particles with the tracks } } // namespace eicrecon diff --git a/src/algorithms/fardetectors/FarDetectorTransportationPostML.h b/src/algorithms/fardetectors/FarDetectorTransportationPostML.h index 6b74a2f608..5346c34f01 100644 --- a/src/algorithms/fardetectors/FarDetectorTransportationPostML.h +++ b/src/algorithms/fardetectors/FarDetectorTransportationPostML.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -21,7 +22,7 @@ namespace eicrecon { using FarDetectorTransportationPostMLAlgorithm = algorithms::Algorithm< - algorithms::Input, std::optional>, algorithms::Output::epsilon(); diff --git a/src/algorithms/tracking/TracksToParticles.cc b/src/algorithms/tracking/TracksToParticles.cc index ed1593b81b..cabd2258fa 100644 --- a/src/algorithms/tracking/TracksToParticles.cc +++ b/src/algorithms/tracking/TracksToParticles.cc @@ -28,6 +28,9 @@ void TracksToParticles::process(const TracksToParticles::Input& input, for (const auto& track : *tracks) { auto trajectory = track.getTrajectory(); + if (!trajectory.isAvailable()) { + continue; + } for (const auto& trk : trajectory.getTrackParameters()) { const auto mom = edm4hep::utils::sphericalToVector(1.0 / std::abs(trk.getQOverP()), trk.getTheta(), trk.getPhi()); diff --git a/src/detectors/LOWQ2/LOWQ2.cc b/src/detectors/LOWQ2/LOWQ2.cc index 1a82cca322..6c59c2028a 100644 --- a/src/detectors/LOWQ2/LOWQ2.cc +++ b/src/detectors/LOWQ2/LOWQ2.cc @@ -210,7 +210,8 @@ void InitPlugin(JApplication* app) { app)); app->Add(new JOmniFactoryGeneratorT( "TaggerTrackerTransportationPostML", - {"TaggerTrackerPredictionTensor", "TaggerTrackerLocalTrackAssociations", "MCBeamElectrons"}, + {"TaggerTrackerPredictionTensor", "TaggerTrackerLocalTracks", + "TaggerTrackerLocalTrackAssociations", "MCBeamElectrons"}, {"TaggerTrackerReconstructedParticles", "TaggerTrackerReconstructedParticleLinks", "TaggerTrackerReconstructedParticleAssociations"}, { diff --git a/src/factories/fardetectors/FarDetectorTransportationPostML_factory.h b/src/factories/fardetectors/FarDetectorTransportationPostML_factory.h index a0e831d445..209db52434 100644 --- a/src/factories/fardetectors/FarDetectorTransportationPostML_factory.h +++ b/src/factories/fardetectors/FarDetectorTransportationPostML_factory.h @@ -7,6 +7,7 @@ #include "algorithms/fardetectors/FarDetectorTransportationPostML.h" #include "services/algorithms_init/AlgorithmsInit_service.h" #include "extensions/jana/JOmniFactory.h" +#include namespace eicrecon { @@ -21,6 +22,7 @@ class FarDetectorTransportationPostML_factory std::unique_ptr m_algo; PodioInput m_prediction_tensor_input{this}; + PodioInput m_tracks_input{this}; PodioInput m_association_input{this}; PodioInput m_beamelectrons_input{this}; @@ -47,7 +49,8 @@ class FarDetectorTransportationPostML_factory void Process(int32_t /* run_number */, uint64_t /* event_number */) { m_algo->process( - {m_prediction_tensor_input(), m_association_input(), m_beamelectrons_input()}, + {m_prediction_tensor_input(), m_tracks_input(), m_association_input(), + m_beamelectrons_input()}, {m_particle_output().get(), m_links_output().get(), m_association_output().get()}); } };