EICrecon
JANA based reconstruction for the EPIC detector
Loading...
Searching...
No Matches
FilterMatching.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Copyright (C) 2024 Simon Gardner
3
4#pragma once
5
6#include <spdlog/spdlog.h>
7#include <algorithms/algorithm.h>
8#include <string>
9#include <string_view>
10
13
14namespace eicrecon {
15
16template <class ToFilterObjectT, class FilterByObjectT>
18 algorithms::Algorithm<typename algorithms::Input<typename ToFilterObjectT::collection_type,
19 typename FilterByObjectT::collection_type>,
20 typename algorithms::Output<typename ToFilterObjectT::collection_type,
21 typename ToFilterObjectT::collection_type>>;
22
28template <typename ToFilterObjectT, auto ToFilterFunction, typename FilterByObjectT,
29 auto FilterByFunction>
30class FilterMatching : public FilterMatchingAlgorithm<ToFilterObjectT, FilterByObjectT>,
31 public WithPodConfig<NoConfig> {
32
33public:
34 FilterMatching(std::string_view name)
35 : FilterMatchingAlgorithm<ToFilterObjectT, FilterByObjectT>{
36 name,
37 {"inputCollection", "inputMatchedCollection"},
38 {"outputMatchedAssociations", "outputUnmatchedAssociations"},
39 "Filter by matching to a collection"} {};
40
41 void init() final {};
42
43 void
46 const final {
47
48 const auto [toFilterEntries, filterByEntries] = input;
49 auto [is_matched, is_not_matched] = output;
50
51 is_matched->setSubsetCollection();
52 is_not_matched->setSubsetCollection();
53
54 for (const auto& matchedEntry : *toFilterEntries) {
55
56 auto ref_value = ToFilterFunction(&matchedEntry);
57
58 bool found_match = false;
59
60 // Tries to find the association in the entries
61 for (const auto& entry : *filterByEntries) {
62 auto other_value = FilterByFunction(&entry);
63 if (other_value == ref_value) {
64 is_matched->push_back(matchedEntry);
65 found_match = true;
66 break;
67 }
68 }
69
70 if (!found_match) {
71 is_not_matched->push_back(matchedEntry);
72 }
73 }
74 };
75};
76
77} // namespace eicrecon
Definition FilterMatching.h:31
void process(const typename FilterMatchingAlgorithm< ToFilterObjectT, FilterByObjectT >::Input &input, const typename FilterMatchingAlgorithm< ToFilterObjectT, ToFilterObjectT >::Output &output) const final
Definition FilterMatching.h:44
void init() final
Definition FilterMatching.h:41
FilterMatching(std::string_view name)
Definition FilterMatching.h:34
Definition WithPodConfig.h:22
-client
Definition CalorimeterClusterRecoCoG.cc:37
algorithms::Algorithm< typename algorithms::Input< typename ToFilterObjectT::collection_type, typename FilterByObjectT::collection_type >, typename algorithms::Output< typename ToFilterObjectT::collection_type, typename ToFilterObjectT::collection_type > > FilterMatchingAlgorithm
Definition FilterMatching.h:21