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/trackFindingCDC/eventdata/hits/CDCWireHit.h>
11
12#include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
13#include <tracking/trackFindingCDC/topology/CDCWire.h>
14
15#include <tracking/trackFindingCDC/filters/base/RelationFilter.icc.h>
16
17#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
18#include <tracking/trackFindingCDC/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 TrackFindingCDC;
28
30
32 : m_param_degree(neighborhoodDegree)
33{
34}
35
37
39 const std::string& prefix)
40{
41 moduleParamList
42 ->addParameter(prefixed(prefix, "degree"),
44 "Neighbor degree which are included. 1 for primary, 2 for secondary, 3 ...",
46}
47
49 CDCWireHit* from,
50 const std::vector<CDCWireHit*>& wireHits) const
51{
52 assert(std::is_sorted(wireHits.begin(), wireHits.end(), LessOf<Deref>()) &&
53 "Expected wire hits to be sorted");
54
55 const int nWireNeighbors = 8 + 10 * (m_param_degree - 1);
56 std::vector<const CDCWire*> m_wireNeighbors;
57 m_wireNeighbors.reserve(nWireNeighbors);
58
59 std::vector<CDCWireHit*> m_wireHitNeighbors;
60 m_wireHitNeighbors.reserve(2 * nWireNeighbors);
61
62 const CDCWireTopology& wireTopology = CDCWireTopology::getInstance();
63 const CDCWire& wire = from->getWire();
64
65 const CDCWire* ccwSixthSecondWireNeighbor = wireTopology.getSecondNeighborSixOClock(wire);
66 const CDCWire* ccwInWireNeighbor = wireTopology.getNeighborCCWInwards(wire);
67 const CDCWire* ccwWireNeighbor = wireTopology.getNeighborCCW(wire);
68 const CDCWire* ccwOutWireNeighbor = wireTopology.getNeighborCCWOutwards(wire);
69 const CDCWire* ccwTwelvethSecondWireNeighbor = wireTopology.getSecondNeighborTwelveOClock(wire);
70
71 const CDCWire* cwSixthSecondWireNeighbor = ccwSixthSecondWireNeighbor;
72 const CDCWire* cwInWireNeighbor = wireTopology.getNeighborCWInwards(wire);
73 const CDCWire* cwWireNeighbor = wireTopology.getNeighborCW(wire);
74 const CDCWire* cwOutWireNeighbor = wireTopology.getNeighborCWOutwards(wire);
75 const CDCWire* cwTwelvethSecondWireNeighbor = ccwTwelvethSecondWireNeighbor;
76
77 // Insert the neighbors such that they are most likely sorted.
78
79 // Degree 1 neighborhood - only add the six o'clock and the twelve o'clock neighbor once
80 if (m_param_degree > 1 and ccwSixthSecondWireNeighbor)
81 m_wireNeighbors.push_back(ccwSixthSecondWireNeighbor);
82
83 if (cwInWireNeighbor) m_wireNeighbors.push_back(cwInWireNeighbor);
84 if (ccwInWireNeighbor) m_wireNeighbors.push_back(ccwInWireNeighbor);
85
86 if (cwWireNeighbor) m_wireNeighbors.push_back(cwWireNeighbor);
87 if (ccwWireNeighbor) m_wireNeighbors.push_back(ccwWireNeighbor);
88
89 if (cwOutWireNeighbor) m_wireNeighbors.push_back(cwOutWireNeighbor);
90 if (ccwOutWireNeighbor) m_wireNeighbors.push_back(ccwOutWireNeighbor);
91
92 if (m_param_degree > 1 and ccwTwelvethSecondWireNeighbor)
93 m_wireNeighbors.push_back(ccwTwelvethSecondWireNeighbor);
94
95 for (int degree = 1; degree < m_param_degree; ++degree) {
96 if (cwSixthSecondWireNeighbor) {
97 cwSixthSecondWireNeighbor = cwSixthSecondWireNeighbor->getNeighborCW();
98 m_wireNeighbors.push_back(cwSixthSecondWireNeighbor);
99 }
100 if (ccwSixthSecondWireNeighbor) {
101 ccwSixthSecondWireNeighbor = ccwSixthSecondWireNeighbor->getNeighborCCW();
102 m_wireNeighbors.push_back(ccwSixthSecondWireNeighbor);
103 }
104
105 if (cwInWireNeighbor) {
106 cwInWireNeighbor = cwInWireNeighbor->getNeighborCW();
107 m_wireNeighbors.push_back(cwInWireNeighbor);
108 }
109 if (ccwInWireNeighbor) {
110 ccwInWireNeighbor = ccwInWireNeighbor->getNeighborCCW();
111 m_wireNeighbors.push_back(ccwInWireNeighbor);
112 }
113
114 if (cwWireNeighbor) {
115 cwWireNeighbor = cwWireNeighbor->getNeighborCW();
116 m_wireNeighbors.push_back(cwWireNeighbor);
117 }
118 if (ccwWireNeighbor) {
119 ccwWireNeighbor = ccwWireNeighbor->getNeighborCCW();
120 m_wireNeighbors.push_back(ccwWireNeighbor);
121 }
122
123 if (cwOutWireNeighbor) {
124 cwOutWireNeighbor = cwOutWireNeighbor->getNeighborCW();
125 m_wireNeighbors.push_back(cwOutWireNeighbor);
126 }
127 if (ccwOutWireNeighbor) {
128 ccwOutWireNeighbor = ccwOutWireNeighbor->getNeighborCCW();
129 m_wireNeighbors.push_back(ccwOutWireNeighbor);
130 }
131
132 if (cwTwelvethSecondWireNeighbor) {
133 cwTwelvethSecondWireNeighbor = cwTwelvethSecondWireNeighbor->getNeighborCW();
134 m_wireNeighbors.push_back(cwTwelvethSecondWireNeighbor);
135 }
136 if (ccwTwelvethSecondWireNeighbor) {
137 ccwTwelvethSecondWireNeighbor = ccwTwelvethSecondWireNeighbor->getNeighborCCW();
138 m_wireNeighbors.push_back(ccwTwelvethSecondWireNeighbor);
139 }
140 }
141
142 std::sort(std::begin(m_wireNeighbors), std::end(m_wireNeighbors));
143
144 for (const CDCWire* neighborWire : m_wireNeighbors) {
145 ConstVectorRange<CDCWireHit*> neighborWireHits{
146 std::equal_range(wireHits.begin(), wireHits.end(), neighborWire, LessOf<Deref>())};
147
148 m_wireHitNeighbors.insert(m_wireHitNeighbors.end(),
149 neighborWireHits.begin(),
150 neighborWireHits.end());
151 }
152
153 return m_wireHitNeighbors;
154}
The Module parameter list class.
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
Class representing the sense wire arrangement in the whole of the central drift chamber.
MayBePtr< const CDCWire > getNeighborCCWInwards(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor in the next layer outwards.
MayBePtr< const CDCWire > getSecondNeighborSixOClock(const WireID &wireID) const
Getter for secondary neighbor at the six o'clock position.
MayBePtr< const CDCWire > getNeighborCCWOutwards(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor in the next layer outwards.
MayBePtr< const CDCWire > getSecondNeighborTwelveOClock(const WireID &wireID) const
Getter for secondary neighbor at the twelve o'clock position.
MayBePtr< const CDCWire > getNeighborCWInwards(const WireID &wireID) const
Getter for the nearest clockwise neighbor in the next layer outwards.
MayBePtr< const CDCWire > getNeighborCCW(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor.
MayBePtr< const CDCWire > getNeighborCWOutwards(const WireID &wireID) const
Getter for the nearest clockwise neighbor in the next layer outwards.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
MayBePtr< const CDCWire > getNeighborCW(const WireID &wireID) const
Getter for the nearest clockwise neighbor.
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
MayBePtr< const CDCWire > getNeighborCCW() const
Gives the closest neighbor in the counterclockwise direction - always exists.
Definition: CDCWire.cc:159
MayBePtr< const CDCWire > getNeighborCW() const
Gives the closest neighbor in the clockwise direction - always exists.
Definition: CDCWire.cc:164
A pair of iterators usable with the range base for loop.
Definition: Range.h:25
Base class for filtering the neighborhood of objects.
WholeWireHitRelationFilter(int neighborhoodDegree=2)
Constructor form the default neighborhood degree.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
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...
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.
Functor factory turning a binary functor and two functors into a new functor which executes the binar...
Definition: Functional.h:127