Belle II Software development
SegmentLinker.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/findlets/minimal/SegmentLinker.h>
9
10#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
11
12#include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
13#include <tracking/trackFindingCDC/utilities/Algorithms.h>
14
15#include <framework/core/ModuleParamList.templateDetails.h>
16
17#include <vector>
18#include <string>
19
20using namespace Belle2;
21using namespace TrackFindingCDC;
22
24{
26}
27
29{
30 return "Links segments by extraction of segment paths in a cellular automaton.";
31}
32
33void SegmentLinker::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
34{
35 m_segment2DRelationCreator.exposeParameters(moduleParamList, prefix);
36
37 moduleParamList->addParameter(prefixed(prefix, "wholeSuperLayer"),
39 "Link segment in the whole superlayer instead of inside the super cluster.",
41
42 moduleParamList->addParameter(prefixed(prefix, "dealiasLinked"),
44 "Block hits that appear in linked segments such that unlinked reverse and aliases are excluded.",
46
47 moduleParamList->addParameter(prefixed(prefix, "onlyLinked"),
49 "Switch to construct only segments that have a linked partner.",
51}
52
53void SegmentLinker::apply(const std::vector<CDCSegment2D>& inputSegment2Ds,
54 std::vector<CDCSegment2D>& outputSegment2Ds)
55{
57 for (const CDCSegment2D& segment2D : inputSegment2Ds) {
58 segment2D.setISuperCluster(-1);
59 }
60 }
61
62 // Obtain the segments as pointers
63 std::vector<const CDCSegment2D*> segment2DPtrs = as_pointers<const CDCSegment2D>(inputSegment2Ds);
64
65 // Create linking relations
68
69 // Find linking paths
70 m_segment2DPaths.clear();
72
73 // Unmasked hits in case the blocking logic is requested
74 const bool toHits = true;
75 for (const CDCSegment2D& segment : inputSegment2Ds) {
76 segment.unsetAndForwardMaskedFlag(toHits);
77 }
78
79 // Put the linked segments together
80 std::vector<CDCSegment2D> tempOutputSegment2Ds;
81 tempOutputSegment2Ds.reserve(m_segment2DPaths.size());
82 for (const Path<const CDCSegment2D>& segment2DPath : m_segment2DPaths) {
83 if (m_param_onlyLinked and segment2DPath.size() == 1) continue;
84
85 // Do not use the single segments blocked in the dealiasing
86 if (m_param_dealiasLinked and segment2DPath.size() == 1 and
87 (*segment2DPath[0])->hasMaskedFlag()) {
88 continue;
89 }
90
91 tempOutputSegment2Ds.push_back(CDCSegment2D::condense(segment2DPath));
92
93 // If two segments are linked odds are that it is the correct alias
94 // Block the used hits.
95 if (m_param_dealiasLinked and segment2DPath.size() > 1) {
96 tempOutputSegment2Ds.back().setAndForwardMaskedFlag(toHits);
97 for (const CDCSegment2D& otherSegment : inputSegment2Ds) {
98 otherSegment.receiveMaskedFlag(toHits);
99 }
100 }
101
102 }
103 outputSegment2Ds = std::move(tempOutputSegment2Ds);
104}
The Module parameter list class.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
static CDCSegment2D condense(const CDCTangentSegment &tangentSegment)
Averages the reconstructed positions from hits that overlap in adjacent tangents in the given tangent...
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
std::vector< WeightedRelation< const CDCSegment2D > > m_segment2DRelations
Memory for the relations between segments to be followed on linking.
Definition: SegmentLinker.h:70
WeightedRelationCreator< const CDCSegment2D, ChooseableSegmentRelationFilter > m_segment2DRelationCreator
Creator of the segment relations for linking.
Definition: SegmentLinker.h:64
MultipassCellularPathFinder< const CDCSegment2D > m_cellularPathFinder
Instance of the cellular automaton path finder.
Definition: SegmentLinker.h:67
bool m_param_wholeSuperLayer
Parameter : Switch to activate segment linking in the whole superlayer instead of only the super clus...
Definition: SegmentLinker.h:54
bool m_param_dealiasLinked
Parameter : Switch to block hits that appear in linked segments such that unlinked reverse and aliase...
Definition: SegmentLinker.h:57
std::string getDescription() final
Short description of the findlet.
bool m_param_onlyLinked
Parameter : Switch to construct only segments that have a linked partner.
Definition: SegmentLinker.h:60
void apply(const std::vector< CDCSegment2D > &inputSegment2Ds, std::vector< CDCSegment2D > &outputSegment2Ds) final
Main algorithm.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
SegmentLinker()
Constructor adding the filter as a subordinary processing signal listener.
std::vector< Path< const CDCSegment2D > > m_segment2DPaths
Memory for the segment paths generated from the graph.
Definition: SegmentLinker.h:73
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.