Belle II Software  release-06-00-14
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/VXDHoughTrackingHelpers.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/VXDHoughTrackingTreeSearcher.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 using namespace Belle2;
23 using namespace TrackFindingCDC;
24 using namespace vxdHoughTracking;
25 
26 template<class AHit>
27 RawTrackCandCleaner<AHit>::~RawTrackCandCleaner() = default;
28 
29 template<class AHit>
31 {
35 }
36 
37 template<class AHit>
38 void RawTrackCandCleaner<AHit>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
39 {
40  Super::exposeParameters(moduleParamList, prefix);
41  m_relationCreator.exposeParameters(moduleParamList, prefix);
42  m_treeSearcher.exposeParameters(moduleParamList, prefix);
43  m_resultRefiner.exposeParameters(moduleParamList, prefix);
44 
45  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maxRelations"), m_param_maxRelations,
46  "Maximum number of relations allowed for entering tree search.", m_param_maxRelations);
47 }
48 
49 template<class AHit>
51 {
52  Super::initialize();
53 }
54 
55 template<class AHit>
56 void RawTrackCandCleaner<AHit>::apply(std::vector<std::vector<AHit*>>& rawTrackCandidates,
57  std::vector<SpacePointTrackCand>& trackCandidates)
58 {
59  uint family = 0; // family of the SpacePointTrackCands
60  for (auto& rawTrackCand : rawTrackCandidates) {
61 
62  // If the capacity of a std::vector is too large, start with a fresh one.
63  // Since std::vector.shrink() or std::vector.shrink_to_fit() not necessarily reduce the capacity in the desired way,
64  // create a temporary vector of the same type and swap them to use the vector at the new location afterwards.
65  checkResizeClear<TrackFindingCDC::WeightedRelation<AHit>>(m_relations, 8192);
66  checkResizeClear<Result>(m_results, 8192);
67  checkResizeClear<SpacePointTrackCand>(m_unfilteredResults, 8192);
68  checkResizeClear<SpacePointTrackCand>(m_filteredResults, 8192);
69 
70  m_relationCreator.apply(rawTrackCand, m_relations);
71 
72  if (m_relations.size() > m_param_maxRelations) {
73  m_relations.clear();
74  continue;
75  }
76 
77  m_treeSearcher.apply(rawTrackCand, m_relations, m_results);
78 
79  m_unfilteredResults.reserve(m_results.size());
80  for (const std::vector<TrackFindingCDC::WithWeight<const AHit*>>& result : m_results) {
81  std::vector<const SpacePoint*> spacePointsInResult;
82  spacePointsInResult.reserve(result.size());
83  for (const TrackFindingCDC::WithWeight<const AHit*>& hit : result) {
84  spacePointsInResult.emplace_back(hit->getHit());
85  }
86  std::sort(spacePointsInResult.begin(), spacePointsInResult.end(), [](const SpacePoint * a, const SpacePoint * b) {
87  return
88  (a->getVxdID().getLayerNumber() < b->getVxdID().getLayerNumber()) or
89  (a->getVxdID().getLayerNumber() == b->getVxdID().getLayerNumber()
90  and a->getPosition().Perp() < b->getPosition().Perp());
91  });
92  m_unfilteredResults.emplace_back(spacePointsInResult);
93  }
94 
95  for (auto aTC : m_unfilteredResults) {
96  aTC.setFamily(family);
97  }
98 
99  m_resultRefiner.apply(m_unfilteredResults, m_filteredResults);
100 
101  for (const SpacePointTrackCand& trackCand : m_filteredResults) {
102  trackCandidates.emplace_back(trackCand);
103  }
104 
105  family++;
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
Findlet for rejecting wrong SpacePointTrackCands and for removing bad hits.
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
VXDHoughTrackingTreeSearcher< 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 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.
Abstract base class for different kinds of events.