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