8#include <tracking/trackFindingCDC/filters/wireHitRelation/BridgingWireHitRelationFilter.h>
10#include <tracking/trackFindingCDC/filters/base/RelationFilter.icc.h>
12#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
14#include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
15#include <tracking/trackFindingCDC/topology/CDCWire.h>
17#include <tracking/trackFindingCDC/utilities/Relation.h>
18#include <tracking/trackFindingCDC/utilities/VectorRange.h>
19#include <tracking/trackFindingCDC/utilities/Functional.h>
20#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
22#include <framework/core/ModuleParamList.templateDetails.h>
29using namespace TrackFindingCDC;
38 const std::string& prefix)
41 ->
addParameter(prefixed(prefix,
"missingPrimaryNeighborThresholds"),
43 "Map of o'clock directions to number of missing drift cells "
44 "in the primary neighborhood to trigger the inclusion of secondary neighbors "
45 "in that very o'clock direction",
52 for (
short oClockDirection = 0; oClockDirection < 12; oClockDirection++) {
61 for (
short oClockDirection : {5, 6, 7, 4, 8, 3, 9, 2, 10, 1, 0, 11}) {
70 const std::vector<CDCWireHit*>& wireHits)
const
72 assert(std::is_sorted(wireHits.begin(), wireHits.end(),
LessOf<Deref>()) &&
73 "Expected wire hits to be sorted");
75 std::vector<std::pair<const CDCWire*, int>> wireNeighbors;
76 wireNeighbors.reserve(8);
78 std::vector<CDCWireHit*> wireHitNeighbors;
79 wireHitNeighbors.reserve(12);
81 std::array<short, 12> missingPrimaryNeighbor = {0};
85 const CDCWire& wire = from->getWire();
88 for (
short oClockDirection : {5, 7, 3, 9, 1, 11}) {
89 MayBePtr<const CDCWire> neighborWire = wireTopology.
getPrimaryNeighbor(oClockDirection, wire);
90 if (neighborWire) wireNeighbors.emplace_back(neighborWire, oClockDirection);
93 std::sort(std::begin(wireNeighbors), std::end(wireNeighbors));
95 for (std::pair<const CDCWire*, int> wireAndOClockDirection : wireNeighbors) {
96 const CDCWire* neighborWire = wireAndOClockDirection.first;
97 int oClockDirection = wireAndOClockDirection.second;
100 std::equal_range(wireHits.begin(), wireHits.end(), neighborWire,
LessOf<Deref>())};
101 if (wireHitRange.empty()) {
102 int ccwOClockDirection = oClockDirection - 1;
103 int cwOClockDirection = oClockDirection == 11 ? 0 : oClockDirection + 1;
104 ++missingPrimaryNeighbor[ccwOClockDirection];
105 ++missingPrimaryNeighbor[oClockDirection];
106 ++missingPrimaryNeighbor[cwOClockDirection];
108 wireHitNeighbors.insert(wireHitNeighbors.end(), wireHitRange.begin(), wireHitRange.end());
111 size_t nPrimaryWireHitNeighbors = wireHitNeighbors.
size();
112 wireNeighbors.clear();
116 MayBePtr<const CDCWire> neighborWire = wireTopology.
getSecondaryNeighbor(oClockDirection, wire);
117 if (not neighborWire)
continue;
118 if (missingPrimaryNeighbor[oClockDirection] <
121 wireNeighbors.emplace_back(neighborWire, oClockDirection);
124 std::sort(std::begin(wireNeighbors), std::end(wireNeighbors));
126 for (std::pair<const CDCWire*, int> wireAndOClockDirection : wireNeighbors) {
127 const CDCWire* neighborWire = wireAndOClockDirection.first;
129 std::equal_range(wireHits.begin(), wireHits.end(), neighborWire,
LessOf<Deref>())};
130 wireHitNeighbors.insert(wireHitNeighbors.end(), wireHitRange.begin(), wireHitRange.end());
134 std::inplace_merge(wireHitNeighbors.begin(),
135 wireHitNeighbors.begin() + nPrimaryWireHitNeighbors,
136 wireHitNeighbors.end(),
137 std::less<CDCWireHit*>());
139 return wireHitNeighbors;
The Module parameter list class.
std::map< int, int > m_param_missingPrimaryNeighborThresholdMap
Parameter: A map from o'clock direction to the number of missing primary drift cells.
void initialize() override
Receive signal at the begin of the event processing and prepare some parameters.
~BridgingWireHitRelationFilter()
Default destructor.
BridgingWireHitRelationFilter()
Default constructor.
std::vector< CDCWireHit * > getPossibleTos(CDCWireHit *from, const std::vector< CDCWireHit * > &wireHits) const final
Returns a vector containing the neighboring wire hits of the given wire hit out of the sorted range g...
std::array< short, 12 > m_missingPrimaryNeighborThresholds
Array for the number of primary drift cells to be included for the o'clock position at each index.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the set of parameters of the filter to the module parameter list.
std::vector< short > m_consideredSecondaryNeighbors
Indices of the considered o'clock positions of the secondary neighborhood.
Class representing a hit wire in the central drift chamber.
Class representing the sense wire arrangement in the whole of the central drift chamber.
MayBePtr< const CDCWire > getSecondaryNeighbor(short oClockDirection, const WireID &wireID) const
Getter for the secondary neighbor of the given wire id.
MayBePtr< const CDCWire > getPrimaryNeighbor(short oClockDirection, const WireID &wireID) const
Getter for the primary neighbor of the given wire id.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
Class representing a sense wire in the central drift chamber.
void initialize() override
Receive and dispatch signal before the start of the event processing.
A pair of iterators usable with the range base for loop.
std::size_t size() const
Returns the total number of objects in this range.
Base class for filtering the neighborhood of objects.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.
Functor factory turning a binary functor and two functors into a new functor which executes the binar...