Belle II Software development
AxialSegmentPairCreator.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/AxialSegmentPairCreator.h>
9
10#include <tracking/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
11#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
12
13#include <vector>
14#include <algorithm>
15
16using namespace Belle2;
17using namespace TrackFindingCDC;
18
20{
22}
23
25{
26 return "Creates axial axial segment pairs from a set of segments filtered by some acceptance criterion";
27}
28
29void AxialSegmentPairCreator::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
30{
31 m_axialSegmentPairFilter.exposeParameters(moduleParamList, prefix);
32}
33
34void AxialSegmentPairCreator::apply(const std::vector<CDCSegment2D>& inputSegments,
35 std::vector<CDCAxialSegmentPair>& axialSegmentPairs)
36{
37 // Group the segments by their super layer id
38 for (std::vector<const CDCSegment2D*>& segementsInSuperLayer : m_segmentsBySuperLayer) {
39 segementsInSuperLayer.clear();
40 }
41
42 for (const CDCSegment2D& segment : inputSegments) {
43 ISuperLayer iSuperLayer = segment.getISuperLayer();
44 const CDCSegment2D* ptrSegment = &segment;
45 m_segmentsBySuperLayer[iSuperLayer].push_back(ptrSegment);
46 }
47
48 // Make pairs of closeby superlayers
49 for (ISuperLayer iSuperLayer = 0; iSuperLayer < ISuperLayerUtil::c_N; ++iSuperLayer) {
50 if (not ISuperLayerUtil::isAxial(iSuperLayer)) continue;
51
52 const std::vector<const CDCSegment2D*>& startSegments = m_segmentsBySuperLayer[iSuperLayer];
53
54 // Make pairs of this superlayer and the superlayer more to the inside
55 {
56 ISuperLayer iStereoSuperLayerIn = ISuperLayerUtil::getNextInwards(iSuperLayer);
57 ISuperLayer iAxialSuperLayerIn = ISuperLayerUtil::getNextInwards(iStereoSuperLayerIn);
58 if (ISuperLayerUtil::isInCDC(iAxialSuperLayerIn)) {
59 const std::vector<const CDCSegment2D*>& endSegments = m_segmentsBySuperLayer[iAxialSuperLayerIn];
60 create(startSegments, endSegments, axialSegmentPairs);
61 }
62 }
63
64 // Make pairs with the same super layer
65 create(startSegments, startSegments, axialSegmentPairs);
66
67 // Make pairs of this superlayer and the superlayer more to the outside
68 {
69 ISuperLayer iStereoSuperLayerOut = ISuperLayerUtil::getNextOutwards(iSuperLayer);
70 ISuperLayer iAxialSuperLayerOut = ISuperLayerUtil::getNextOutwards(iStereoSuperLayerOut);
71 if (ISuperLayerUtil::isInCDC(iAxialSuperLayerOut)) {
72 const std::vector<const CDCSegment2D*>& endSegments = m_segmentsBySuperLayer[iAxialSuperLayerOut];
73 create(startSegments, endSegments, axialSegmentPairs);
74 }
75 }
76
77 } // end for iSuperLayer
78
79 std::sort(axialSegmentPairs.begin(), axialSegmentPairs.end());
80}
81
82void AxialSegmentPairCreator::create(const std::vector<const CDCSegment2D*>& startSegments,
83 const std::vector<const CDCSegment2D*>& endSegments,
84 std::vector<CDCAxialSegmentPair>& axialSegmentPairs)
85{
86 CDCAxialSegmentPair axialSegmentPair;
87 for (const CDCSegment2D* ptrStartSegment : startSegments) {
88 for (const CDCSegment2D* ptrEndSegment : endSegments) {
89
90 if (ptrStartSegment == ptrEndSegment) continue; // Just for safety
91 axialSegmentPair.setSegments(ptrStartSegment, ptrEndSegment);
92 axialSegmentPair.clearTrajectory2D();
93
94 Weight pairWeight = m_axialSegmentPairFilter(axialSegmentPair);
95 if (not std::isnan(pairWeight)) {
96 axialSegmentPair.getAutomatonCell().setCellWeight(pairWeight);
97 axialSegmentPairs.push_back(axialSegmentPair);
98 }
99 }
100 }
101}
The Module parameter list class.
void setCellWeight(Weight weight)
Setter for the cell weight.
AxialSegmentPairCreator()
Constructor adding the filter as a subordinary processing signal listener.
std::string getDescription() final
Short description of the findlet.
void create(const std::vector< const CDCSegment2D * > &startSegments, const std::vector< const CDCSegment2D * > &endSegments, std::vector< CDCAxialSegmentPair > &axialSegmentPairs)
Creates segment pairs from a combination of start segments and end segments.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
void apply(const std::vector< CDCSegment2D > &inputSegments, std::vector< CDCAxialSegmentPair > &axialSegmentPairs) final
Main method constructing pairs in adjacent super layers.
std::array< std::vector< const CDCSegment2D * >, ISuperLayerUtil::c_N > m_segmentsBySuperLayer
Structure for the segments grouped by super layer id.
ChooseableAxialSegmentPairFilter m_axialSegmentPairFilter
The filter to be used for the segment pair generation.
Class representing a pair of reconstructed axial segements in adjacent superlayer.
void clearTrajectory2D() const
Invalides the currently stored trajectory information.
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
void setSegments(const CDCSegment2D *startSegment, const CDCSegment2D *endSegment)
Setter for both segments simultaniously.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Abstract base class for different kinds of events.
static bool isAxial(ISuperLayer iSuperLayer)
Returns if the super layer with the given id is axial.
Definition: ISuperLayer.cc:21
static const ISuperLayer c_N
Constant representing the total number of cdc superlayers.
Definition: ISuperLayer.h:56
static ISuperLayer getNextInwards(ISuperLayer iSuperLayer)
Returns the super layer that is inside of the given super layer.
Definition: ISuperLayer.cc:63
static ISuperLayer getNextOutwards(ISuperLayer iSuperLayer)
Returns the super layer that is outside of the given super layer.
Definition: ISuperLayer.cc:72
static bool isInCDC(ISuperLayer iSuperLayer)
Indicates if the given number corresponds to a true cdc superlayer - excludes the logic ids for inner...
Definition: ISuperLayer.cc:43