Belle II Software development
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// for std::ignore
21#include <utility>
22
23using namespace Belle2;
24using namespace TrackFindingCDC;
25
27{
28 return "Constructs tracks by extraction of segment pair paths in a cellular automaton.";
29}
30
31void TrackCreatorSegmentPairAutomaton::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
32{
33 m_cellularPathFinder.exposeParameters(moduleParamList, prefix);
34}
35
37 const std::vector<CDCSegmentPair>& inputSegmentPairs,
38 const std::vector<WeightedRelation<const CDCSegmentPair>>& inputSegmentPairRelations,
39 std::vector<CDCTrack>& outputTracks)
40{
41 // Obtain the segment pairs as pointers
42 std::vector<const CDCSegmentPair*> segmentPairPtrs =
43 as_pointers<const CDCSegmentPair>(inputSegmentPairs);
44
45 m_segmentPairPaths.clear();
46 m_cellularPathFinder.apply(segmentPairPtrs, inputSegmentPairRelations, m_segmentPairPaths);
47
48 // Reduce to plain tracks
49 CDCAxialStereoFusion fusionFitter;
50 for (const Path<const CDCSegmentPair>& segmentPairPath : m_segmentPairPaths) {
51 CDCTrajectory3D startTrajectory3D = segmentPairPath.front()->getTrajectory3D();
52 CDCTrajectory3D endTrajectory3D = segmentPairPath.back()->getTrajectory3D();
53
54 // Work around for in stable fusion fits that reach over the apogee
55 auto saverStereoApogeePositions = [&fusionFitter](const CDCSegmentPair * lhs,
56 const CDCSegmentPair * rhs) {
57 // Segment pairs are at a turning point
58 if (lhs->getFromSegment()->getISuperLayer() != rhs->getToSegment()->getISuperLayer()) return false;
59
60 // Only apply workaround if apogee is in a stereo superlayer
61 if (lhs->getToSegment()->isAxial()) return false;
62
63 // Reset critical situation to simpler fit
64 fusionFitter.fusePreliminary(*lhs);
65 fusionFitter.fusePreliminary(*rhs);
66
67 // Return false to continue looking
68 return false;
69 };
70 // return value is not needed here
71 std::ignore = std::adjacent_find(segmentPairPath.begin(), segmentPairPath.end(), saverStereoApogeePositions);
72
73 // Compute the average recohits with the preliminary fits
74 outputTracks.push_back(CDCTrack::condense(segmentPairPath));
75 CDCTrack& track = outputTracks.back();
76
77 // Set the start and end trajectory from the original fits
78 // Only necessary for the work around
79 {
80 Vector3D startPos = track.getStartTrajectory3D().getLocalOrigin();
81 startTrajectory3D.setLocalOrigin(startPos);
82 track.setStartTrajectory3D(startTrajectory3D);
83
84 Vector3D endPos = track.getEndTrajectory3D().getLocalOrigin();
85 endTrajectory3D.setLocalOrigin(endPos);
86 track.setEndTrajectory3D(endTrajectory3D);
87 }
88 for (const CDCSegmentPair* segmentPair : segmentPairPath) {
89 segmentPair->getFromSegment()->getAutomatonCell().setTakenFlag();
90 segmentPair->getToSegment()->getAutomatonCell().setTakenFlag();
91 }
92 }
93}
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 segment and one stereo segment in adjacent super...
const CDCSegment2D * getToSegment() const
Getter for the to segment.
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
static CDCTrack condense(const Path< const CDCTrack > &trackPath)
concatenates 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.
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.
std::string getDescription() final
Short description of the findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
A three dimensional vector.
Definition: Vector3D.h:33
Type for two related objects with a weight.
Abstract base class for different kinds of events.