10#include <tracking/trackFindingCDC/collectors/matchers/MatcherInterface.h>
12#include <tracking/trackFindingCDC/ca/AutomatonCell.h>
22 namespace TrackFindingCDC {
31 template <
class ACollectorItem,
class ACollectionItem>
45 void apply(std::vector<ACollectorItem>& collectorItems,
const std::vector<ACollectionItem>& collectionItems,
46 std::vector<typename Super::WeightedRelationItem>& weightedRelations)
override
49 for (
const ACollectionItem& collectionItem : collectionItems) {
50 const AutomatonCell& automatonCell = collectionItem.getAutomatonCell();
52 if (automatonCell.
hasTakenFlag() or collectionItem.empty()) {
56 for (
const auto& hit : collectionItem) {
60 m_hitLookup.insert(std::make_pair(&wireHit, &collectionItem));
64 Super::apply(collectorItems, collectionItems, weightedRelations);
72 void match(ACollectorItem& collectorItem,
const std::vector<ACollectionItem>& collectionItems,
73 std::vector<typename Super::WeightedRelationItem>& relationsForCollector)
override
75 std::map<const ACollectionItem*, unsigned int> numberOfIntersectionsMap;
78 for (
const ACollectionItem& collectionItem : collectionItems) {
79 numberOfIntersectionsMap[&collectionItem] = 0;
83 for (
const auto& hit : collectorItem) {
87 const auto& relatedCollectionItems =
m_hitLookup.equal_range(&wireHit);
89 for (
auto& relatedCollectionItemIterator : asRange(relatedCollectionItems)) {
90 const ACollectionItem* collectionItem = relatedCollectionItemIterator.second;
91 numberOfIntersectionsMap[collectionItem] += 1;
96 for (
const auto& collectionWithIntersections : numberOfIntersectionsMap) {
97 const ACollectionItem* collectionItem = collectionWithIntersections.first;
98 unsigned int numberOfIntersections = collectionWithIntersections.second;
100 relationsForCollector.emplace_back(&collectorItem, numberOfIntersections, collectionItem);
105 std::multimap<const CDCWireHit*, const ACollectionItem*>
m_hitLookup;
Cell used by the cellular automata.
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
Class representing a hit wire in the central drift chamber.
Base class for a findlet, which outputs a list of weighted relations between elements in a list of Co...
void apply(std::vector< ACollectorItem > &collectorItems, const std::vector< ACollectionItem > &collectionItems, std::vector< WeightedRelationItem > &weightedRelations) override
Main function: create weighted relations between collectors and collection items using the implemente...
A generic matcher algorithm which outputs all combinations of elements with the number of shared hits...
void match(ACollectorItem &collectorItem, const std::vector< ACollectionItem > &collectionItems, std::vector< typename Super::WeightedRelationItem > &relationsForCollector) override
Output the number of shared hits - the rest of the logic (relation creation etc.) is handled by the p...
std::multimap< const CDCWireHit *, const ACollectionItem * > m_hitLookup
association of CDCWireHits with a generic collection item
void beginEvent() override
Clear the hit lookup in every event.
void apply(std::vector< ACollectorItem > &collectorItems, const std::vector< ACollectionItem > &collectionItems, std::vector< typename Super::WeightedRelationItem > &weightedRelations) override
Call the apply function of the super class - but before fill the hit lookup.
Abstract base class for different kinds of events.