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