Belle II Software  release-08-01-10
TrackCreatorSegmentPairAutomaton.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/TrackCreatorSegmentPairAutomaton.h>
9 
10 #include <tracking/trackFindingCDC/fitting/CDCAxialStereoFusion.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
13 #include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentPair.h>
14 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
15 
16 #include <tracking/trackFindingCDC/ca/Path.h>
17 
18 #include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
19 
20 using namespace Belle2;
21 using namespace TrackFindingCDC;
22 
24 {
25  return "Constructs tracks by extraction of segment pair paths in a cellular automaton.";
26 }
27 
28 void TrackCreatorSegmentPairAutomaton::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
29 {
30  m_cellularPathFinder.exposeParameters(moduleParamList, prefix);
31 }
32 
34  const std::vector<CDCSegmentPair>& inputSegmentPairs,
35  const std::vector<WeightedRelation<const CDCSegmentPair>>& inputSegmentPairRelations,
36  std::vector<CDCTrack>& outputTracks)
37 {
38  // Obtain the segment pairs as pointers
39  std::vector<const CDCSegmentPair*> segmentPairPtrs =
40  as_pointers<const CDCSegmentPair>(inputSegmentPairs);
41 
42  m_segmentPairPaths.clear();
43  m_cellularPathFinder.apply(segmentPairPtrs, inputSegmentPairRelations, m_segmentPairPaths);
44 
45  // Reduce to plain tracks
46  CDCAxialStereoFusion fusionFitter;
47  for (const Path<const CDCSegmentPair>& segmentPairPath : m_segmentPairPaths) {
48  CDCTrajectory3D startTrajectory3D = segmentPairPath.front()->getTrajectory3D();
49  CDCTrajectory3D endTrajectory3D = segmentPairPath.back()->getTrajectory3D();
50 
51  // Work around for in stable fusion fits that reach over the apogee
52  auto saverStereoApogeePositions = [&fusionFitter](const CDCSegmentPair * lhs,
53  const CDCSegmentPair * rhs) {
54  // Segment pairs are at a turning point
55  if (lhs->getFromSegment()->getISuperLayer() != rhs->getToSegment()->getISuperLayer()) return false;
56 
57  // Only apply workaround if apogee is in a stereo superlayer
58  if (lhs->getToSegment()->isAxial()) return false;
59 
60  // Reset critical situation to simpler fit
61  fusionFitter.fusePreliminary(*lhs);
62  fusionFitter.fusePreliminary(*rhs);
63 
64  // Return false to continue looking
65  return false;
66  };
67  // return value is not needed here
68  // cppcheck-suppress ignoredReturnValue
69  std::adjacent_find(segmentPairPath.begin(), segmentPairPath.end(), saverStereoApogeePositions);
70 
71  // Compute the average recohits with the preliminary fits
72  outputTracks.push_back(CDCTrack::condense(segmentPairPath));
73  CDCTrack& track = outputTracks.back();
74 
75  // Set the start and end trajectory from the original fits
76  // Only necessary for the work around
77  {
78  Vector3D startPos = track.getStartTrajectory3D().getLocalOrigin();
79  startTrajectory3D.setLocalOrigin(startPos);
80  track.setStartTrajectory3D(startTrajectory3D);
81 
82  Vector3D endPos = track.getEndTrajectory3D().getLocalOrigin();
83  endTrajectory3D.setLocalOrigin(endPos);
84  track.setEndTrajectory3D(endTrajectory3D);
85  }
86  for (const CDCSegmentPair* segmentPair : segmentPairPath) {
87  segmentPair->getFromSegment()->getAutomatonCell().setTakenFlag();
88  segmentPair->getToSegment()->getAutomatonCell().setTakenFlag();
89  }
90  }
91 }
The Module parameter list class.
Utility class implementing the Kalmanesk combination of to two dimensional trajectories to one three ...
void fusePreliminary(const CDCSegmentPair &segmentPair)
Fit the given segment pair using the preliminary helix fit without proper covariance matrix.
Class representing a pair of one reconstructed axial segement and one stereo segment in adjacent supe...
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
const CDCSegment2D * getToSegment() const
Getter for the to segment.
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
static CDCTrack condense(const Path< const CDCTrack > &trackPath)
Concats several tracks from a path.
Definition: CDCTrack.cc:164
Particle full three dimensional trajectory.
double setLocalOrigin(const Vector3D &localOrigin)
Setter for the origin of the local coordinate system.
std::vector< Path< const CDCSegmentPair > > m_segmentPairPaths
Memory for the segment pair paths generated from the graph.
MultipassCellularPathFinder< const CDCSegmentPair > m_cellularPathFinder
Instance of the cellular automaton path finder.
std::string getDescription() final
Short description of the findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
void apply(const std::vector< CDCSegmentPair > &inputSegmentPairs, const std::vector< WeightedRelation< const CDCSegmentPair >> &inputSegmentPairRelations, std::vector< CDCTrack > &outputTracks) final
Main function of the segment finding by the cellular automaton.
A three dimensional vector.
Definition: Vector3D.h:33
Type for two related objects with a weight.
Abstract base class for different kinds of events.