Belle II Software prerelease-11-00-00a
RawTrackCandCleaner.icc.h
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/vxdHoughTracking/findlets/RawTrackCandCleaner.dcl.h>
9#include <tracking/vxdHoughTracking/utilities/SVDHoughTrackingHelpers.h>
10
11#include <framework/core/ModuleParamList.templateDetails.h>
12#include <tracking/spacePointCreation/SpacePointTrackCand.h>
13#include <tracking/vxdHoughTracking/filters/relations/LayerRelationFilter.icc.h>
14#include <tracking/vxdHoughTracking/findlets/SVDHoughTrackingTreeSearcher.icc.h>
15#include <tracking/trackingUtilities/filters/base/ChooseableFilter.icc.h>
16#include <tracking/trackingUtilities/utilities/StringManipulation.h>
17#include <tracking/trackingUtilities/utilities/Algorithms.h>
18#include <vxd/dataobjects/VxdID.h>
19#include <tracking/dbobjects/SVDHoughParameters.h>
20
21namespace Belle2::vxdHoughTracking {
22
23 template<class AHit>
25
26 template<class AHit>
33
34 template<class AHit>
35 void RawTrackCandCleaner<AHit>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
36 {
37 Super::exposeParameters(moduleParamList, prefix);
38 m_relationCreator.exposeParameters(moduleParamList, prefix);
39 m_treeSearcher.exposeParameters(moduleParamList, prefix);
40 m_resultRefiner.exposeParameters(moduleParamList, prefix);
42 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "maxRelations"), m_maxRelations,
43 "Maximum number of relations allowed for entering tree search.", m_maxRelations);
44 }
45
46 template<class AHit>
48 {
50 }
51
52 template<class AHit>
54 {
55
57
58 if (!m_SVDHoughParameters.isValid()) {
59 B2FATAL("SVDHough - RawTrackCandCleaner: SVDHoughParameter dbobject not found, using default parameters.");
60 } else {
61 m_maxRelations = m_SVDHoughParameters->getMaxRelations();
62 }
63
64 }
65
66 template<class AHit>
67 void RawTrackCandCleaner<AHit>::apply(std::vector<std::vector<AHit*>>& rawTrackCandidates,
68 std::vector<SpacePointTrackCand>& trackCandidates)
69 {
70
71 uint family = 0; // family of the SpacePointTrackCands
72 for (auto& rawTrackCand : rawTrackCandidates) {
73
74 // If the capacity of a std::vector is too large, start with a fresh one.
75 // Since std::vector.shrink() or std::vector.shrink_to_fit() not necessarily reduce the capacity in the desired way,
76 // create a temporary vector of the same type and swap them to use the vector at the new location afterwards.
77 checkResizeClear<TrackingUtilities::WeightedRelation<AHit>>(m_relations, 8192);
78 checkResizeClear<Result>(m_results, 8192);
79 checkResizeClear<SpacePointTrackCand>(m_unfilteredResults, 8192);
80 checkResizeClear<SpacePointTrackCand>(m_filteredResults, 8192);
81
82 m_relationCreator.apply(rawTrackCand, m_relations);
83
84 if (m_relations.size() > m_maxRelations) {
85 m_relations.clear();
86 continue;
87 }
88
89 m_treeSearcher.apply(rawTrackCand, m_relations, m_results);
90
91 m_unfilteredResults.reserve(m_results.size());
92 for (const std::vector<TrackingUtilities::WithWeight<const AHit*>>& result : m_results) {
93 std::vector<const SpacePoint*> spacePointsInResult;
94 spacePointsInResult.reserve(result.size());
95 for (const TrackingUtilities::WithWeight<const AHit*>& hit : result) {
96 spacePointsInResult.emplace_back(hit->getHit());
97 }
98 std::sort(spacePointsInResult.begin(), spacePointsInResult.end(), [](const SpacePoint * a, const SpacePoint * b) {
99 return
100 (a->getVxdID().getLayerNumber() < b->getVxdID().getLayerNumber()) or
101 (a->getVxdID().getLayerNumber() == b->getVxdID().getLayerNumber()
102 and a->getPosition().Perp() < b->getPosition().Perp());
103 });
104 m_unfilteredResults.emplace_back(spacePointsInResult);
105 }
106
107 for (auto aTC : m_unfilteredResults) {
108 aTC.setFamily(family);
109 }
110
112
113 for (const SpacePointTrackCand& trackCand : m_filteredResults) {
114 trackCandidates.emplace_back(trackCand);
115 }
116
117 family++;
118 }
119 }
120
121}
The Module parameter list class.
Storage for (VXD) SpacePoint-based track candidates.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition SpacePoint.h:42
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
A mixin class to attach a weight to an object.
Definition WithWeight.h:24
SVDHoughTrackingTreeSearcher< AHit, ChooseablePathFilter, Result > m_treeSearcher
perform a tree search using a cellular automaton for all the hits and relations of each raw track can...
void apply(std::vector< std::vector< AHit * > > &rawTrackCandidates, std::vector< SpacePointTrackCand > &trackCandidates) override
Reject bad SpacePointTrackCands and bad hits inside the remaining.
TrackCandidateResultRefiner m_resultRefiner
sort and refine the results for each raw track cand, performing a fit and a basic overlap check
void initialize() override
Create the store arrays.
TrackingUtilities::Findlet< std::vector< AHit * >, SpacePointTrackCand > Super
Parent class.
std::vector< TrackingUtilities::WeightedRelation< AHit > > m_relations
vector containing the relations between the hits in the raw track candidate
std::vector< SpacePointTrackCand > m_unfilteredResults
vector containing unfiltered results, i.e.
void beginRun() override
Check dbobject validity.
RelationCreator< AHit, ChooseableRelationFilter > m_relationCreator
create relations between the hits in each raw track candidate
RawTrackCandCleaner()
Find intercepts in the 2D Hough space.
std::vector< Result > m_results
vector containing track candidates after tree search
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
std::vector< SpacePointTrackCand > m_filteredResults
vector containing the filtered and pruned results the filtered results of each raw track candidate wi...
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.