Belle II Software  release-05-02-19
AxialTrackMerger Class Referenceabstract

Findlet implementing the merging of axial tracks found in the legendre tree search. More...

#include <AxialTrackMerger.h>

Inheritance diagram for AxialTrackMerger:
Collaboration diagram for AxialTrackMerger:

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invokation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invokation.
 

Public Member Functions

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 (std::vector< CDCTrack > &axialTracks, const std::vector< const CDCWireHit * > &axialWireHits) final
 Merge tracks together. Allows for axial hits to be added as it may see fit.
 
template<class ACDCTracks >
WithWeight< MayBePtr< CDCTrack > > calculateBestTrackToMerge (CDCTrack &track, ACDCTracks &tracks)
 Determine the best track for merging with the candidate track.
 
virtual void exposeParameters (ModuleParamList *moduleParamList __attribute__((unused)), const std::string &prefix __attribute__((unused)))
 Forward prefixed parameters of this findlet to the module parameter list.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void initialize () override
 Receive and dispatch signal before the start of the event processing.
 
void beginRun () override
 Receive and dispatch signal for the beginning of a new run.
 
void beginEvent () override
 Receive and dispatch signal for the start of a new event.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector = typename ToVectorImpl< T >::Type
 Short hand for ToRangeImpl.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = Findlet< CDCTrack &, const CDCWireHit *const >
 Type of the base class.
 

Private Member Functions

void doTracksMerging (std::vector< CDCTrack > &axialTracks, const std::vector< const CDCWireHit * > &allAxialWireHits)
 The track finding often finds two curling tracks, originating from the same particle. More...
 

Static Private Member Functions

template<class ACDCTracks >
static WithWeight< MayBePtr< CDCTrack > > calculateBestTrackToMerge (CDCTrack &track, ACDCTracks &tracks)
 Searches for the best candidate to merge this track to. More...
 
static double doTracksFitTogether (CDCTrack &track1, CDCTrack &track2)
 Fits the hit content of both tracks in a common fit repeated with an annealing schedule removing far away hits. More...
 
static void removeStrangeHits (double factor, std::vector< const CDCWireHit * > &wireHits, CDCTrajectory2D &trajectory)
 Remove all hits that are further than factor * driftlength waay from the trajectory. More...
 
static void mergeTracks (CDCTrack &track1, CDCTrack &track2, const std::vector< const CDCWireHit * > &allAxialWireHits)
 Function to merge two track candidates. More...
 

Private Attributes

double m_param_minFitProb = 0.85
 Parameter : Minimal fit probability of the common fit of two tracks to be eligible for merging.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happend before.
 
bool m_terminated = false
 Flag to keep track whether termination happend before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Findlet implementing the merging of axial tracks found in the legendre tree search.

Definition at line 40 of file AxialTrackMerger.h.

Member Function Documentation

◆ calculateBestTrackToMerge()

static WithWeight<MayBePtr<CDCTrack> > calculateBestTrackToMerge ( CDCTrack track,
ACDCTracks &  tracks 
)
staticprivate

Searches for the best candidate to merge this track to.

Parameters
tracktrack for which we try to find merging partner
trackssearch range of tracks
Returns
a pointer to the best fit candidate including a fit probability
Return values
<tt>{nullptr,0}<

◆ doTracksFitTogether()

double doTracksFitTogether ( CDCTrack track1,
CDCTrack track2 
)
staticprivate

Fits the hit content of both tracks in a common fit repeated with an annealing schedule removing far away hits.

Returns
Some measure of fit probability

Definition at line 109 of file AxialTrackMerger.cc.

110 {
111  // First check whether most of the hits from the tracks lie in the backward direction
112  // even if though track is not curling -> tracks should not be merged
113  const CDCTrajectory3D& trajectory3D1 = track1.getStartTrajectory3D();
114  const CDCTrajectory3D& trajectory3D2 = track2.getStartTrajectory3D();
115 
116  const Vector2D& phi0Vec1 = trajectory3D1.getFlightDirection3DAtSupport().xy();
117  const Vector2D& phi0Vec2 = trajectory3D2.getFlightDirection3DAtSupport().xy();
118 
119  int fbVote12 = 0;
120  int fbVote21 = 0;
121 
122  for (const CDCRecoHit3D& recoHit3D : track1) {
123  EForwardBackward fbInfo = phi0Vec2.isForwardOrBackwardOf(recoHit3D.getRecoPos2D());
124  if (not isValid(fbInfo)) continue;
125  fbVote12 += fbInfo;
126  }
127 
128  for (const CDCRecoHit3D& recoHit3D : track2) {
129  EForwardBackward fbInfo = phi0Vec1.isForwardOrBackwardOf(recoHit3D.getRecoPos2D());
130  if (not isValid(fbInfo)) continue;
131  fbVote21 += fbInfo;
132  }
133 
134  if (not trajectory3D1.isCurler() and fbVote12 < 0) return NAN;
135  if (not trajectory3D2.isCurler() and fbVote21 < 0) return NAN;
136 
137  // Build common hit list by copying the wire hits into one large list
138  // We use the wire hits here as we do not want them to bring
139  // their "old" reconstructed position when fitting.
140  std::vector<const CDCWireHit*> combinedWireHits;
141  combinedWireHits.reserve(track1.size() + track2.size());
142  for (const CDCRecoHit3D& hit : track1) {
143  // cppcheck-suppress useStlAlgorithm
144  combinedWireHits.push_back(&(hit.getWireHit()));
145  }
146  for (const CDCRecoHit3D& hit : track2) {
147  // cppcheck-suppress useStlAlgorithm
148  combinedWireHits.push_back(&(hit.getWireHit()));
149  }
150 
151  // Sorting is done via pointer addresses (!!).
152  // This is not very stable and also not very meaningful (in terms of ordering in the track),
153  // but it does the job for unique.
154  // (the ordering is still outwards though since the wire hits are ordered like that in continuous memory)
155  std::sort(combinedWireHits.begin(), combinedWireHits.end());
156  erase_unique(combinedWireHits);
157 
158  // Calculate track parameters
159  CDCTrajectory2D commonTrajectory2D;
160  const CDCKarimakiFitter& fitter = CDCKarimakiFitter::getNoDriftVarianceFitter();
161 
162  // Approach the best fit
163  commonTrajectory2D = fitter.fit(combinedWireHits);
164  removeStrangeHits(5, combinedWireHits, commonTrajectory2D);
165  commonTrajectory2D = fitter.fit(combinedWireHits);
166  removeStrangeHits(3, combinedWireHits, commonTrajectory2D);
167  commonTrajectory2D = fitter.fit(combinedWireHits);
168  removeStrangeHits(1, combinedWireHits, commonTrajectory2D);
169  commonTrajectory2D = fitter.fit(combinedWireHits);
170  removeStrangeHits(1, combinedWireHits, commonTrajectory2D);
171  commonTrajectory2D = fitter.fit(combinedWireHits);
172 
173  // Dismiss this possibility if the hit list size after all the removing of hits is even smaller
174  // than the two lists before or if the list is too small
175  if (combinedWireHits.size() <= std::max(track1.size(), track2.size())
176  or combinedWireHits.size() < 15) {
177  return NAN;
178  }
179 
180  return commonTrajectory2D.getPValue();
181 }

◆ doTracksMerging()

void doTracksMerging ( std::vector< CDCTrack > &  axialTracks,
const std::vector< const CDCWireHit * > &  allAxialWireHits 
)
private

The track finding often finds two curling tracks, originating from the same particle.

This function merges them.

Definition at line 70 of file AxialTrackMerger.cc.

◆ mergeTracks()

void mergeTracks ( CDCTrack track1,
CDCTrack track2,
const std::vector< const CDCWireHit * > &  allAxialWireHits 
)
staticprivate

Function to merge two track candidates.

The hits of track2 are deleted and transfered to track1 and the track1 is resorted. The method also applys some postprocessing and splits the track1 in case it appears to contain two back-to-back arms,

Definition at line 196 of file AxialTrackMerger.cc.

◆ removeStrangeHits()

void removeStrangeHits ( double  factor,
std::vector< const CDCWireHit * > &  wireHits,
CDCTrajectory2D trajectory 
)
staticprivate

Remove all hits that are further than factor * driftlength waay from the trajectory.

Parameters
factorgives a number how far the hit is allowed to be.

Definition at line 183 of file AxialTrackMerger.cc.


The documentation for this class was generated from the following files:
Belle2::TrackFindingCDC::NForwardBackward::isValid
bool isValid(EForwardBackward eForwardBackward)
Check whether the given enum instance is one of the valid values.
Definition: EForwardBackward.h:55
Belle2::TrackFindingCDC::NForwardBackward::EForwardBackward
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Definition: EForwardBackward.h:35
Belle2::TrackFindingCDC::CDCKarimakiFitter::getNoDriftVarianceFitter
static const CDCKarimakiFitter & getNoDriftVarianceFitter()
Static getter for a general fitter that does not use the drift length variances.
Definition: CDCKarimakiFitter.cc:35
Belle2::TrackFindingCDC::AxialTrackMerger::removeStrangeHits
static void removeStrangeHits(double factor, std::vector< const CDCWireHit * > &wireHits, CDCTrajectory2D &trajectory)
Remove all hits that are further than factor * driftlength waay from the trajectory.
Definition: AxialTrackMerger.cc:183