Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-17 07:50:47

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2026 Derek Anderson
0003 
0004 #include <edm4eic/Track.h>
0005 #include <podio/detail/LinkCollectionImpl.h>
0006 #include <podio/detail/LinkCollectionIterator.h>
0007 #include <cstddef>
0008 #include <tuple>
0009 
0010 #include "TrackProtoClusterMatchPromoter.h"
0011 
0012 namespace eicrecon {
0013 
0014 /*! For each track-protocluster match, create
0015  *  a corresponding track-cluster match.
0016  *
0017  *  \note Input protocluster and cluster collections
0018  *    are assumed to be 1-to-1, i.e. that the Nth
0019  *    cluster was reconstructed from the Nth
0020  *    protocluster.
0021  */
0022 void TrackProtoClusterMatchPromoter::process(
0023     const TrackProtoClusterMatchPromoter::Input& input,
0024     const TrackProtoClusterMatchPromoter::Output& output) const {
0025 
0026   // grab inputs/outputs
0027 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0028   const auto [in_links, in_protos, in_clusts] = input;
0029 #elif EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 4, 0)
0030   const auto [in_matches, in_protos, in_clusts] = input;
0031 #else
0032   const auto [in_protos, in_clusts] = input;
0033 #endif
0034   auto [out_matches] = output;
0035 
0036 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0037   // exit if no links in input collection
0038   if (in_links->size() == 0) {
0039     debug("No track-protocluster links in collection.");
0040     return;
0041   }
0042 #elif EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 4, 0)
0043   // exit if no matches in input collection
0044   if (in_matches->size() == 0) {
0045     debug("No track-protocluster matches in collection.");
0046     return;
0047   }
0048 #endif
0049 
0050   // exit if protocluster/cluster collection
0051   // sizes are different
0052   //   --> 1-to-1 ordering can't be assumed!
0053   if (in_protos->size() != in_clusts->size()) {
0054     error("Number of input protoclusters ({}) not the same as number of input clusters ({})",
0055           in_protos->size(), in_clusts->size());
0056     return;
0057   }
0058 
0059 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0060   for (std::size_t icl = 0; const auto& proto : *in_protos) {
0061     for (const auto& pr_match : *in_links) {
0062       if (pr_match.getTo() == proto) {
0063         edm4eic::MutableTrackClusterMatch cl_match = out_matches->create();
0064         cl_match.setCluster((*in_clusts)[icl]);
0065         cl_match.setTrack(pr_match.getFrom());
0066         cl_match.setWeight(pr_match.getWeight());
0067       }
0068     }
0069     ++icl;
0070   }
0071 #elif EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 4, 0)
0072   for (std::size_t icl = 0; const auto& proto : *in_protos) {
0073     for (const auto& pr_match : *in_matches) {
0074       if (pr_match.getTo() == proto) {
0075         edm4eic::MutableTrackClusterMatch cl_match = out_matches->create();
0076         cl_match.setCluster((*in_clusts)[icl]);
0077         cl_match.setTrack(pr_match.getFrom());
0078         cl_match.setWeight(pr_match.getWeight());
0079       }
0080     }
0081     ++icl;
0082   }
0083 #endif
0084 } // end 'process(Input&, Output&)'
0085 } // namespace eicrecon