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