Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-07 08:04:09

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2026 Derek Anderson
0003 
0004 #include <edm4eic/Cluster.h>
0005 #include <edm4eic/Track.h>
0006 #include <map>
0007 #include <tuple>
0008 #include <utility>
0009 #include <vector>
0010 
0011 #include "ChargedCandidateMaker.h"
0012 #include "algorithms/interfaces/CompareObjectID.h"
0013 
0014 namespace eicrecon {
0015 
0016 /*! Construct a candidate charged particle via the
0017  *  following algorithm.
0018  *    1. Build map of tracks onto vectors of their
0019  *       matched clusters
0020  *    2. For each track, create a Reconstructed
0021  *       Particle with track and cluster relations
0022  *       filled
0023  */
0024 void ChargedCandidateMaker::process(const ChargedCandidateMaker::Input& input,
0025                                     const ChargedCandidateMaker::Output& output) const {
0026 
0027   // grab inputs/outputs
0028   const auto [in_matches] = input;
0029   auto [out_particles]    = output;
0030 
0031   // exit if no matches in collection
0032   if (in_matches->empty()) {
0033     debug("No track-cluster matches in collection");
0034     return;
0035   }
0036 
0037   std::map<edm4eic::Track, std::vector<edm4eic::Cluster>, CompareObjectID<edm4eic::Track>>
0038       mapTrackToClusters;
0039   for (const auto& match : *in_matches) {
0040     mapTrackToClusters[match.getTrack()].push_back(match.getCluster());
0041   }
0042 
0043   for (const auto& [track, clusters] : mapTrackToClusters) {
0044     edm4eic::MutableReconstructedParticle particle = out_particles->create();
0045     particle.addToTracks(track);
0046     for (const edm4eic::Cluster& cluster : clusters) {
0047       particle.addToClusters(cluster);
0048     }
0049   }
0050 } // end 'process(Input&, Output&)'
0051 } // namespace eicrecon