Belle II Software development
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/trackFindingCDC/filters/base/ChooseableFilter.icc.h>
16#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
17#include <tracking/trackFindingCDC/utilities/Algorithms.h>
18#include <vxd/dataobjects/VxdID.h>
19
20namespace Belle2::vxdHoughTracking {
21
22 template<class AHit>
24
25 template<class AHit>
32
33 template<class AHit>
34 void RawTrackCandCleaner<AHit>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
35 {
36 Super::exposeParameters(moduleParamList, prefix);
37 m_relationCreator.exposeParameters(moduleParamList, prefix);
38 m_treeSearcher.exposeParameters(moduleParamList, prefix);
39 m_resultRefiner.exposeParameters(moduleParamList, prefix);
40
41 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maxRelations"), m_maxRelations,
42 "Maximum number of relations allowed for entering tree search.", m_maxRelations);
43 }
44
45 template<class AHit>
50
51 template<class AHit>
52 void RawTrackCandCleaner<AHit>::apply(std::vector<std::vector<AHit*>>& rawTrackCandidates,
53 std::vector<SpacePointTrackCand>& trackCandidates)
54 {
55 uint family = 0; // family of the SpacePointTrackCands
56 for (auto& rawTrackCand : rawTrackCandidates) {
57
58 // If the capacity of a std::vector is too large, start with a fresh one.
59 // Since std::vector.shrink() or std::vector.shrink_to_fit() not necessarily reduce the capacity in the desired way,
60 // create a temporary vector of the same type and swap them to use the vector at the new location afterwards.
61 checkResizeClear<TrackFindingCDC::WeightedRelation<AHit>>(m_relations, 8192);
62 checkResizeClear<Result>(m_results, 8192);
63 checkResizeClear<SpacePointTrackCand>(m_unfilteredResults, 8192);
64 checkResizeClear<SpacePointTrackCand>(m_filteredResults, 8192);
65
66 m_relationCreator.apply(rawTrackCand, m_relations);
67
68 if (m_relations.size() > m_maxRelations) {
69 m_relations.clear();
70 continue;
71 }
72
73 m_treeSearcher.apply(rawTrackCand, m_relations, m_results);
74
75 m_unfilteredResults.reserve(m_results.size());
76 for (const std::vector<TrackFindingCDC::WithWeight<const AHit*>>& result : m_results) {
77 std::vector<const SpacePoint*> spacePointsInResult;
78 spacePointsInResult.reserve(result.size());
79 for (const TrackFindingCDC::WithWeight<const AHit*>& hit : result) {
80 spacePointsInResult.emplace_back(hit->getHit());
81 }
82 std::sort(spacePointsInResult.begin(), spacePointsInResult.end(), [](const SpacePoint * a, const SpacePoint * b) {
83 return
84 (a->getVxdID().getLayerNumber() < b->getVxdID().getLayerNumber()) or
85 (a->getVxdID().getLayerNumber() == b->getVxdID().getLayerNumber()
86 and a->getPosition().Perp() < b->getPosition().Perp());
87 });
88 m_unfilteredResults.emplace_back(spacePointsInResult);
89 }
90
91 for (auto aTC : m_unfilteredResults) {
92 aTC.setFamily(family);
93 }
94
96
97 for (const SpacePointTrackCand& trackCand : m_filteredResults) {
98 trackCandidates.emplace_back(trackCand);
99 }
100
101 family++;
102 }
103 }
104
105}
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.
TrackFindingCDC::Findlet< std::vector< AHit * >, SpacePointTrackCand > Super
Parent class.
std::vector< SpacePointTrackCand > m_unfilteredResults
vector containing unfiltered results, i.e.
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< TrackFindingCDC::WeightedRelation< AHit > > m_relations
vector containing the relations between the hits in the raw track candidate
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.