Belle II Software development
SegmentTripleCreator.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/SegmentTripleCreator.h>
9
10#include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentTriple.h>
11#include <tracking/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
12#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13
14#include <tracking/trackFindingCDC/topology/ISuperLayer.h>
15
16#include <framework/logging/Logger.h>
17
18#include <vector>
19#include <array>
20#include <string>
21#include <algorithm>
22
23using namespace Belle2;
24using namespace TrackFindingCDC;
25
27{
29}
30
32{
33 return "Creates segment triples from a set of middle segments and already combined axial "
34 "segment pairs filtered by some acceptance criterion";
35}
36
37void SegmentTripleCreator::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
38{
39 m_segmentTripleFilter.exposeParameters(moduleParamList, prefix);
40}
41
42void SegmentTripleCreator::apply(const std::vector<CDCSegment2D>& inputSegments,
43 const std::vector<CDCAxialSegmentPair>& inputAxialSegmentPairs,
44 std::vector<CDCSegmentTriple>& segmentTriples)
45{
46 // Group the segments by their super layer id
47 for (std::vector<const CDCSegment2D*>& segementsInSuperLayer : m_segmentsBySuperLayer) {
48 segementsInSuperLayer.clear();
49 }
50
51 for (const CDCSegment2D& segment : inputSegments) {
52 ISuperLayer iSuperLayer = segment.getISuperLayer();
53 const CDCSegment2D* ptrSegment = &segment;
54 m_segmentsBySuperLayer[iSuperLayer].push_back(ptrSegment);
55 }
56
57 for (const CDCAxialSegmentPair& axialSegmentPair : inputAxialSegmentPairs) {
58 const CDCSegment2D* startSegment = axialSegmentPair.getStartSegment();
59 const CDCSegment2D* endSegment = axialSegmentPair.getEndSegment();
60
61 ISuperLayer startISuperLayer = startSegment->getISuperLayer();
62 ISuperLayer endISuperLayer = endSegment->getISuperLayer();
63
64 B2ASSERT("Invalid start ISuperLayer", ISuperLayerUtil::isAxial(startISuperLayer));
65 B2ASSERT("Invalid end ISuperLayer", ISuperLayerUtil::isAxial(endISuperLayer));
66
67 if (startISuperLayer != endISuperLayer) {
68 ISuperLayer middleISuperLayer = (startISuperLayer + endISuperLayer) / 2;
69
70 B2ASSERT("Middle ISuperLayer is not stereo", not ISuperLayerUtil::isAxial(middleISuperLayer));
71
72 const std::vector<const CDCSegment2D*>& middleSegments = m_segmentsBySuperLayer[middleISuperLayer];
73 create(axialSegmentPair, middleSegments, segmentTriples);
74 } else {
75 // Case where start and end super layer are the same
76 // Look for stereo segments in the adjacent super layer
77 ISuperLayer middleISuperLayerIn = ISuperLayerUtil::getNextInwards(startISuperLayer);
78 ISuperLayer middleISuperLayerOut = ISuperLayerUtil::getNextOutwards(startISuperLayer);
79 for (ISuperLayer middleISuperLayer : {middleISuperLayerIn, middleISuperLayerOut}) {
80 if (ISuperLayerUtil::isInCDC(middleISuperLayer)) {
81 const std::vector<const CDCSegment2D*>& middleSegments = m_segmentsBySuperLayer[middleISuperLayer];
82 create(axialSegmentPair, middleSegments, segmentTriples);
83 }
84 }
85 }
86 }
87 std::sort(segmentTriples.begin(), segmentTriples.end());
88}
89
91 const std::vector<const CDCSegment2D*>& middleSegments,
92 std::vector<CDCSegmentTriple>& segmentTriples)
93{
94 CDCSegmentTriple segmentTriple(axialSegmentPair);
95 for (const CDCSegment2D* middleSegment : middleSegments) {
96 segmentTriple.setMiddleSegment(middleSegment);
97 segmentTriple.clearTrajectory3D();
98
99 // Ask the filter to assess this triple
100 Weight weight = m_segmentTripleFilter(segmentTriple);
101
102 if (not std::isnan(weight)) {
103 segmentTriple.getAutomatonCell().setCellWeight(weight);
104 segmentTriples.insert(segmentTriples.end(), segmentTriple);
105 }
106 }
107}
The Module parameter list class.
void setCellWeight(Weight weight)
Setter for the cell weight.
Class representing a pair of reconstructed axial segments in adjacent superlayer.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a triple of reconstructed segments in adjacent superlayer.
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
void setMiddleSegment(const CDCStereoSegment2D *middleSegment)
Setter for the middle stereo segment.
void clearTrajectory3D() const
Clears the three dimensional helix trajectory.
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.
void apply(const std::vector< CDCSegment2D > &inputSegments, const std::vector< CDCAxialSegmentPair > &inputAxialSegmentPairs, std::vector< CDCSegmentTriple > &segmentTriples) final
Main method constructing pairs in adjacent super layers.
void create(const CDCAxialSegmentPair &axialSegmentPair, const std::vector< const CDCSegment2D * > &middleSegments, std::vector< CDCSegmentTriple > &segmentTriples)
Creates segment triples by adding the middle segment to the axial segments and filter out the valuabl...
std::string getDescription() final
Short description of the findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
SegmentTripleCreator()
Constructor adding the filter as a subordinary processing signal listener.
ChooseableSegmentTripleFilter m_segmentTripleFilter
The filter to be used for the segment triple generation.
std::array< std::vector< const CDCSegment2D * >, ISuperLayerUtil::c_N > m_segmentsBySuperLayer
Structure for the segments grouped by super layer id.
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 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