Belle II Software  release-08-01-10
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.h>
12 #include <framework/core/ModuleParamList.templateDetails.h>
13 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
14 #include <tracking/vxdHoughTracking/entities/VXDHoughState.h>
15 #include <tracking/vxdHoughTracking/filters/relations/LayerRelationFilter.icc.h>
16 #include <tracking/vxdHoughTracking/findlets/SVDHoughTrackingTreeSearcher.icc.h>
17 #include <tracking/trackFindingCDC/filters/base/ChooseableFilter.icc.h>
18 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
19 #include <tracking/trackFindingCDC/utilities/Algorithms.h>
20 #include <vxd/dataobjects/VxdID.h>
21 
22 namespace Belle2::vxdHoughTracking {
23 
24  template<class AHit>
26 
27  template<class AHit>
29  {
33  }
34 
35  template<class AHit>
36  void RawTrackCandCleaner<AHit>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
37  {
38  Super::exposeParameters(moduleParamList, prefix);
39  m_relationCreator.exposeParameters(moduleParamList, prefix);
40  m_treeSearcher.exposeParameters(moduleParamList, prefix);
41  m_resultRefiner.exposeParameters(moduleParamList, prefix);
42 
43  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maxRelations"), m_maxRelations,
44  "Maximum number of relations allowed for entering tree search.", m_maxRelations);
45  }
46 
47  template<class AHit>
49  {
50  Super::initialize();
51  }
52 
53  template<class AHit>
54  void RawTrackCandCleaner<AHit>::apply(std::vector<std::vector<AHit*>>& rawTrackCandidates,
55  std::vector<SpacePointTrackCand>& trackCandidates)
56  {
57  uint family = 0; // family of the SpacePointTrackCands
58  for (auto& rawTrackCand : rawTrackCandidates) {
59 
60  // If the capacity of a std::vector is too large, start with a fresh one.
61  // Since std::vector.shrink() or std::vector.shrink_to_fit() not necessarily reduce the capacity in the desired way,
62  // create a temporary vector of the same type and swap them to use the vector at the new location afterwards.
63  checkResizeClear<TrackFindingCDC::WeightedRelation<AHit>>(m_relations, 8192);
64  checkResizeClear<Result>(m_results, 8192);
65  checkResizeClear<SpacePointTrackCand>(m_unfilteredResults, 8192);
66  checkResizeClear<SpacePointTrackCand>(m_filteredResults, 8192);
67 
68  m_relationCreator.apply(rawTrackCand, m_relations);
69 
70  if (m_relations.size() > m_maxRelations) {
71  m_relations.clear();
72  continue;
73  }
74 
75  m_treeSearcher.apply(rawTrackCand, m_relations, m_results);
76 
77  m_unfilteredResults.reserve(m_results.size());
78  for (const std::vector<TrackFindingCDC::WithWeight<const AHit*>>& result : m_results) {
79  std::vector<const SpacePoint*> spacePointsInResult;
80  spacePointsInResult.reserve(result.size());
81  for (const TrackFindingCDC::WithWeight<const AHit*>& hit : result) {
82  spacePointsInResult.emplace_back(hit->getHit());
83  }
84  std::sort(spacePointsInResult.begin(), spacePointsInResult.end(), [](const SpacePoint * a, const SpacePoint * b) {
85  return
86  (a->getVxdID().getLayerNumber() < b->getVxdID().getLayerNumber()) or
87  (a->getVxdID().getLayerNumber() == b->getVxdID().getLayerNumber()
88  and a->getPosition().Perp() < b->getPosition().Perp());
89  });
90  m_unfilteredResults.emplace_back(spacePointsInResult);
91  }
92 
93  for (auto aTC : m_unfilteredResults) {
94  aTC.setFamily(family);
95  }
96 
97  m_resultRefiner.apply(m_unfilteredResults, m_filteredResults);
98 
99  for (const SpacePointTrackCand& trackCand : m_filteredResults) {
100  trackCandidates.emplace_back(trackCand);
101  }
102 
103  family++;
104  }
105  }
106 
107 }
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
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Interface for an algorithm part that needs to receive the module processing signals.
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...
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.
RelationCreator< AHit, ChooseableRelationFilter > m_relationCreator
create relations between the hits in each raw track candidate
RawTrackCandCleaner()
Find intercepts in the 2D Hough space.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
void apply(std::vector< std::vector< AHit * >> &rawTrackCandidates, std::vector< SpacePointTrackCand > &trackCandidates) override
Reject bad SpacePointTrackCands and bad hits inside the remaining.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.