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 assert(std::is_sorted(wireHits.begin(), wireHits.end(), LessOf<Deref>()) &&
55 "Expected wire hits to be sorted");
56
57 const int nWireNeighbors = 8 + 10 * (m_param_degree - 1);
58 std::vector<const CDCWire*> m_wireNeighbors;
59 m_wireNeighbors.reserve(nWireNeighbors);
60
61 std::vector<CDCWireHit*> m_wireHitNeighbors;
62 m_wireHitNeighbors.reserve(2 * nWireNeighbors);
63
64 const CDCWireTopology& wireTopology = CDCWireTopology::getInstance();
65 const CDCWire& wire = from->getWire();
66
67 const CDCWire* ccwSixthSecondWireNeighbor = wireTopology.getSecondNeighborSixOClock(wire);
68 const CDCWire* ccwInWireNeighbor = wireTopology.getNeighborCCWInwards(wire);
69 const CDCWire* ccwWireNeighbor = wireTopology.getNeighborCCW(wire);
70 const CDCWire* ccwOutWireNeighbor = wireTopology.getNeighborCCWOutwards(wire);
71 const CDCWire* ccwTwelvethSecondWireNeighbor = wireTopology.getSecondNeighborTwelveOClock(wire);
72
73 const CDCWire* cwSixthSecondWireNeighbor = ccwSixthSecondWireNeighbor;
74 const CDCWire* cwInWireNeighbor = wireTopology.getNeighborCWInwards(wire);
75 const CDCWire* cwWireNeighbor = wireTopology.getNeighborCW(wire);
76 const CDCWire* cwOutWireNeighbor = wireTopology.getNeighborCWOutwards(wire);
77 const CDCWire* cwTwelvethSecondWireNeighbor = ccwTwelvethSecondWireNeighbor;
78
79 // Insert the neighbors such that they are most likely sorted.
80
81 // Degree 1 neighborhood - only add the six o'clock and the twelve o'clock neighbor once
82 if (m_param_degree > 1 and ccwSixthSecondWireNeighbor)
83 m_wireNeighbors.push_back(ccwSixthSecondWireNeighbor);
84
85 if (cwInWireNeighbor) m_wireNeighbors.push_back(cwInWireNeighbor);
86 if (ccwInWireNeighbor) m_wireNeighbors.push_back(ccwInWireNeighbor);
87
88 if (cwWireNeighbor) m_wireNeighbors.push_back(cwWireNeighbor);
89 if (ccwWireNeighbor) m_wireNeighbors.push_back(ccwWireNeighbor);
90
91 if (cwOutWireNeighbor) m_wireNeighbors.push_back(cwOutWireNeighbor);
92 if (ccwOutWireNeighbor) m_wireNeighbors.push_back(ccwOutWireNeighbor);
93
94 if (m_param_degree > 1 and ccwTwelvethSecondWireNeighbor)
95 m_wireNeighbors.push_back(ccwTwelvethSecondWireNeighbor);
96
97 for (int degree = 1; degree < m_param_degree; ++degree) {
98 if (cwSixthSecondWireNeighbor) {
99 cwSixthSecondWireNeighbor = cwSixthSecondWireNeighbor->getNeighborCW();
100 m_wireNeighbors.push_back(cwSixthSecondWireNeighbor);
101 }
102 if (ccwSixthSecondWireNeighbor) {
103 ccwSixthSecondWireNeighbor = ccwSixthSecondWireNeighbor->getNeighborCCW();
104 m_wireNeighbors.push_back(ccwSixthSecondWireNeighbor);
105 }
106
107 if (cwInWireNeighbor) {
108 cwInWireNeighbor = cwInWireNeighbor->getNeighborCW();
109 m_wireNeighbors.push_back(cwInWireNeighbor);
110 }
111 if (ccwInWireNeighbor) {
112 ccwInWireNeighbor = ccwInWireNeighbor->getNeighborCCW();
113 m_wireNeighbors.push_back(ccwInWireNeighbor);
114 }
115
116 if (cwWireNeighbor) {
117 cwWireNeighbor = cwWireNeighbor->getNeighborCW();
118 m_wireNeighbors.push_back(cwWireNeighbor);
119 }
120 if (ccwWireNeighbor) {
121 ccwWireNeighbor = ccwWireNeighbor->getNeighborCCW();
122 m_wireNeighbors.push_back(ccwWireNeighbor);
123 }
124
125 if (cwOutWireNeighbor) {
126 cwOutWireNeighbor = cwOutWireNeighbor->getNeighborCW();
127 m_wireNeighbors.push_back(cwOutWireNeighbor);
128 }
129 if (ccwOutWireNeighbor) {
130 ccwOutWireNeighbor = ccwOutWireNeighbor->getNeighborCCW();
131 m_wireNeighbors.push_back(ccwOutWireNeighbor);
132 }
133
134 if (cwTwelvethSecondWireNeighbor) {
135 cwTwelvethSecondWireNeighbor = cwTwelvethSecondWireNeighbor->getNeighborCW();
136 m_wireNeighbors.push_back(cwTwelvethSecondWireNeighbor);
137 }
138 if (ccwTwelvethSecondWireNeighbor) {
139 ccwTwelvethSecondWireNeighbor = ccwTwelvethSecondWireNeighbor->getNeighborCCW();
140 m_wireNeighbors.push_back(ccwTwelvethSecondWireNeighbor);
141 }
142 }
143
144 std::sort(std::begin(m_wireNeighbors), std::end(m_wireNeighbors));
145
146 for (const CDCWire* neighborWire : m_wireNeighbors) {
147 ConstVectorRange<CDCWireHit*> neighborWireHits{
148 std::equal_range(wireHits.begin(), wireHits.end(), neighborWire, LessOf<Deref>())};
149
150 m_wireHitNeighbors.insert(m_wireHitNeighbors.end(),
151 neighborWireHits.begin(),
152 neighborWireHits.end());
153 }
154
155 return m_wireHitNeighbors;
156}
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.
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:58
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.