Belle II Software development
TrackSelector.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/eventTimeExtraction/findlets/TrackSelector.h>
9#include <tracking/trackFindingCDC/utilities/Algorithms.h>
10#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
11#include <tracking/dataobjects/RecoTrack.h>
12#include <framework/core/ModuleParamList.h>
13
14using namespace Belle2;
15using namespace TrackFindingCDC;
16
17void TrackSelector::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
18{
19 moduleParamList->addParameter(prefixed(prefix, "minNumberCDCHits"), m_param_minNumberCDCHits,
20 "Minimal number of CDC hits for a track", m_param_minNumberCDCHits);
21 moduleParamList->addParameter(prefixed(prefix, "maximumNumberOfTracks"), m_param_maximumNumberOfTracks,
22 "Maximal number of tracks in an event", m_param_maximumNumberOfTracks);
23 moduleParamList->addParameter(prefixed(prefix, "minimumTrackPt"), m_param_minimumTrackPt,
24 "Minimal pt for a track", m_param_minimumTrackPt);
25}
26
27void TrackSelector::apply(std::vector<RecoTrack*>& tracks)
28{
29 const auto trackHasEnoughPtAndHits = [this](RecoTrack * rt) {
30 return (rt->getNumberOfCDCHits() < m_param_minNumberCDCHits) or
31 (rt->getMomentumSeed().Rho() < m_param_minimumTrackPt);
32 };
33 TrackFindingCDC::erase_remove_if(tracks, trackHasEnoughPtAndHits);
34
35 // this lambda will sort in reverse order, meaning the tracks with the most CDC hits first
36 const auto greaterHits = [](RecoTrack * lhs, RecoTrack * rhs) {
37 return lhs->getNumberOfCDCHits() > rhs->getNumberOfCDCHits();
38 };
39 // sort by the amount of CDC hits
40 std::sort(tracks.begin(), tracks.end(), greaterHits);
41
42 const unsigned int maximalNumberOfElements = std::min(static_cast<unsigned int>(tracks.size()),
43 m_param_maximumNumberOfTracks);
44 // limit to the maximum number of tracks
45 tracks.resize(maximalNumberOfElements);
46
47 B2DEBUG(25, "Limited number of selected tracks: " << tracks.size());
48}
The Module parameter list class.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
Definition: RecoTrack.h:427
void apply(std::vector< RecoTrack * > &) override final
Timing extraction for this findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override final
Expose the parameters for this module.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.