Belle II Software development
WholeWireHitRelationFilter.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/filters/wireHitRelation/WholeWireHitRelationFilter.h>
9
10#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
11
12#include <cdc/topology/CDCWireTopology.h>
13#include <cdc/topology/CDCWire.h>
14
15#include <tracking/trackingUtilities/filters/base/RelationFilter.icc.h>
16
17#include <tracking/trackingUtilities/utilities/StringManipulation.h>
18#include <tracking/trackingUtilities/utilities/Functional.h>
19
20#include <framework/core/ModuleParamList.templateDetails.h>
21
22#include <vector>
23#include <string>
24#include <cassert>
25
26using namespace Belle2;
27using namespace CDC;
28using namespace TrackFindingCDC;
29using namespace TrackingUtilities;
30
32
34 : m_param_degree(neighborhoodDegree)
35{
36}
37
39
41 const std::string& prefix)
42{
43 moduleParamList
44 ->addParameter(prefixed(prefix, "degree"),
46 "Neighbor degree which are included. 1 for primary, 2 for secondary, 3 ...",
48}
49
51 CDCWireHit* from,
52 const std::vector<CDCWireHit*>& wireHits) const
53{
54 const int nWireNeighbors = 8 + 10 * (m_param_degree - 1);
55 std::vector<const CDCWire*> m_wireNeighbors;
56 m_wireNeighbors.reserve(nWireNeighbors);
57
58 std::vector<CDCWireHit*> m_wireHitNeighbors;
59 m_wireHitNeighbors.reserve(2 * nWireNeighbors);
60
61 const CDCWireTopology& wireTopology = CDCWireTopology::getInstance();
62 const CDCWire& wire = from->getWire();
63
64 const CDCWire* ccwSixthSecondWireNeighbor = wireTopology.getSecondNeighborSixOClock(wire);
65 const CDCWire* ccwInWireNeighbor = wireTopology.getNeighborCCWInwards(wire);
66 const CDCWire* ccwWireNeighbor = wireTopology.getNeighborCCW(wire);
67 const CDCWire* ccwOutWireNeighbor = wireTopology.getNeighborCCWOutwards(wire);
68 const CDCWire* ccwTwelvethSecondWireNeighbor = wireTopology.getSecondNeighborTwelveOClock(wire);
69
70 const CDCWire* cwSixthSecondWireNeighbor = ccwSixthSecondWireNeighbor;
71 const CDCWire* cwInWireNeighbor = wireTopology.getNeighborCWInwards(wire);
72 const CDCWire* cwWireNeighbor = wireTopology.getNeighborCW(wire);
73 const CDCWire* cwOutWireNeighbor = wireTopology.getNeighborCWOutwards(wire);
74 const CDCWire* cwTwelvethSecondWireNeighbor = ccwTwelvethSecondWireNeighbor;
75
76 // Insert the neighbors such that they are most likely sorted.
77
78 // Degree 1 neighborhood - only add the six o'clock and the twelve o'clock neighbor once
79 if (m_param_degree > 1 and ccwSixthSecondWireNeighbor)
80 m_wireNeighbors.push_back(ccwSixthSecondWireNeighbor);
81
82 if (cwInWireNeighbor) m_wireNeighbors.push_back(cwInWireNeighbor);
83 if (ccwInWireNeighbor) m_wireNeighbors.push_back(ccwInWireNeighbor);
84
85 // cppcheck-suppress knownConditionTrueFalse ; defensive null check on the wire neighbour lookup
86 if (cwWireNeighbor) m_wireNeighbors.push_back(cwWireNeighbor);
87 // cppcheck-suppress knownConditionTrueFalse ; defensive null check on the wire neighbour lookup
88 if (ccwWireNeighbor) m_wireNeighbors.push_back(ccwWireNeighbor);
89
90 if (cwOutWireNeighbor) m_wireNeighbors.push_back(cwOutWireNeighbor);
91 if (ccwOutWireNeighbor) m_wireNeighbors.push_back(ccwOutWireNeighbor);
92
93 if (m_param_degree > 1 and ccwTwelvethSecondWireNeighbor)
94 m_wireNeighbors.push_back(ccwTwelvethSecondWireNeighbor);
95
96 for (int degree = 1; degree < m_param_degree; ++degree) {
97 if (cwSixthSecondWireNeighbor) {
98 cwSixthSecondWireNeighbor = cwSixthSecondWireNeighbor->getNeighborCW();
99 m_wireNeighbors.push_back(cwSixthSecondWireNeighbor);
100 }
101 if (ccwSixthSecondWireNeighbor) {
102 ccwSixthSecondWireNeighbor = ccwSixthSecondWireNeighbor->getNeighborCCW();
103 m_wireNeighbors.push_back(ccwSixthSecondWireNeighbor);
104 }
105
106 if (cwInWireNeighbor) {
107 cwInWireNeighbor = cwInWireNeighbor->getNeighborCW();
108 m_wireNeighbors.push_back(cwInWireNeighbor);
109 }
110 if (ccwInWireNeighbor) {
111 ccwInWireNeighbor = ccwInWireNeighbor->getNeighborCCW();
112 m_wireNeighbors.push_back(ccwInWireNeighbor);
113 }
114
115 if (cwWireNeighbor) {
116 cwWireNeighbor = cwWireNeighbor->getNeighborCW();
117 m_wireNeighbors.push_back(cwWireNeighbor);
118 }
119 if (ccwWireNeighbor) {
120 ccwWireNeighbor = ccwWireNeighbor->getNeighborCCW();
121 m_wireNeighbors.push_back(ccwWireNeighbor);
122 }
123
124 if (cwOutWireNeighbor) {
125 cwOutWireNeighbor = cwOutWireNeighbor->getNeighborCW();
126 m_wireNeighbors.push_back(cwOutWireNeighbor);
127 }
128 if (ccwOutWireNeighbor) {
129 ccwOutWireNeighbor = ccwOutWireNeighbor->getNeighborCCW();
130 m_wireNeighbors.push_back(ccwOutWireNeighbor);
131 }
132
133 if (cwTwelvethSecondWireNeighbor) {
134 cwTwelvethSecondWireNeighbor = cwTwelvethSecondWireNeighbor->getNeighborCW();
135 m_wireNeighbors.push_back(cwTwelvethSecondWireNeighbor);
136 }
137 if (ccwTwelvethSecondWireNeighbor) {
138 ccwTwelvethSecondWireNeighbor = ccwTwelvethSecondWireNeighbor->getNeighborCCW();
139 m_wireNeighbors.push_back(ccwTwelvethSecondWireNeighbor);
140 }
141 }
142
143 std::sort(std::begin(m_wireNeighbors), std::end(m_wireNeighbors));
144
145 for (const CDCWire* neighborWire : m_wireNeighbors) {
146 ConstVectorRange<CDCWireHit*> neighborWireHits{
147 std::equal_range(wireHits.begin(), wireHits.end(), neighborWire, LessOf<Deref>())};
148
149 m_wireHitNeighbors.insert(m_wireHitNeighbors.end(),
150 neighborWireHits.begin(),
151 neighborWireHits.end());
152 }
153
154 return m_wireHitNeighbors;
155}
Class representing the sense wire arrangement in the whole of the central drift chamber.
TrackingUtilities::MayBePtr< const CDCWire > getNeighborCCW(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor.
TrackingUtilities::MayBePtr< const CDCWire > getSecondNeighborSixOClock(const WireID &wireID) const
Getter for secondary neighbor at the six o'clock position.
TrackingUtilities::MayBePtr< const CDCWire > getNeighborCW(const WireID &wireID) const
Getter for the nearest clockwise neighbor.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
TrackingUtilities::MayBePtr< const CDCWire > getNeighborCWOutwards(const WireID &wireID) const
Getter for the nearest clockwise neighbor in the next layer outwards.
TrackingUtilities::MayBePtr< const CDCWire > getNeighborCCWInwards(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor in the next layer outwards.
TrackingUtilities::MayBePtr< const CDCWire > getNeighborCCWOutwards(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor in the next layer outwards.
TrackingUtilities::MayBePtr< const CDCWire > getSecondNeighborTwelveOClock(const WireID &wireID) const
Getter for secondary neighbor at the twelve o'clock position.
TrackingUtilities::MayBePtr< const CDCWire > getNeighborCWInwards(const WireID &wireID) const
Getter for the nearest clockwise neighbor in the next layer outwards.
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
TrackingUtilities::MayBePtr< const CDCWire > getNeighborCCW() const
Gives the closest neighbor in the counterclockwise direction - always exists.
Definition CDCWire.cc:159
TrackingUtilities::MayBePtr< const CDCWire > getNeighborCW() const
Gives the closest neighbor in the clockwise direction - always exists.
Definition CDCWire.cc:164
The Module parameter list class.
WholeWireHitRelationFilter(int neighborhoodDegree=2)
Constructor form the default neighborhood degree.
~WholeWireHitRelationFilter() override
Default destructor.
std::vector< TrackingUtilities::CDCWireHit * > getPossibleTos(TrackingUtilities::CDCWireHit *from, const std::vector< TrackingUtilities::CDCWireHit * > &wireHits) const final
Returns a vector containing the neighboring wire hits of the given wire hit out of the sorted range g...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:56
Base class for filtering the neighborhood of objects.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.