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