Belle II Software  release-08-01-10
SVDHoughTracking.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/vxdHoughTracking/findlets/SVDHoughTracking.h>
9 #include <tracking/vxdHoughTracking/findlets/RawTrackCandCleaner.icc.h>
10 #include <tracking/vxdHoughTracking/utilities/SVDHoughTrackingHelpers.h>
11 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
12 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
13 #include <framework/logging/Logger.h>
14 #include <framework/core/ModuleParamList.h>
15 
16 using namespace Belle2;
17 using namespace TrackFindingCDC;
18 using namespace vxdHoughTracking;
19 
20 SVDHoughTracking::~SVDHoughTracking() = default;
21 
22 SVDHoughTracking::SVDHoughTracking()
23 {
24  addProcessingSignalListener(&m_spacePointLoaderAndPreparer);
25  addProcessingSignalListener(&m_multiHouthSpaceInterceptFinder);
26  addProcessingSignalListener(&m_singleHouthSpaceInterceptFinder);
27  addProcessingSignalListener(&m_rawTCCleaner);
28  addProcessingSignalListener(&m_overlapResolver);
29  addProcessingSignalListener(&m_recoTrackStorer);
30  addProcessingSignalListener(&m_roiFinder);
31 }
32 
33 void SVDHoughTracking::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
34 {
35  Super::exposeParameters(moduleParamList, prefix);
36 
37  m_spacePointLoaderAndPreparer.exposeParameters(moduleParamList, prefix);
38  m_multiHouthSpaceInterceptFinder.exposeParameters(moduleParamList, prefix);
39  m_singleHouthSpaceInterceptFinder.exposeParameters(moduleParamList, TrackFindingCDC::prefixed(prefix, "simple"));
40  m_rawTCCleaner.exposeParameters(moduleParamList, prefix);
41  m_overlapResolver.exposeParameters(moduleParamList, TrackFindingCDC::prefixed(prefix, "finalOverlapResolver"));
42  m_recoTrackStorer.exposeParameters(moduleParamList, prefix);
43  m_roiFinder.exposeParameters(moduleParamList, prefix);
44 
45  moduleParamList->getParameter<std::string>("relationFilter").setDefaultValue("angleAndTime");
46  moduleParamList->getParameter<std::string>("twoHitFilter").setDefaultValue("twoHitVirtualIPQI");
47  moduleParamList->getParameter<std::string>("threeHitFilter").setDefaultValue("qualityIndicator");
48  moduleParamList->getParameter<std::string>("fourHitFilter").setDefaultValue("qualityIndicator");
49  moduleParamList->getParameter<std::string>("fiveHitFilter").setDefaultValue("qualityIndicator");
50 
51  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "useMultiHoughSpaceInterceptFinding"),
52  m_useMultiHoughSpaceInterceptFinding,
53  "Use Hough spaces working on a subset of hits (=true), or just one Hough space working on all hits at the same time (=false)?",
54  m_useMultiHoughSpaceInterceptFinding);
55 }
56 
57 void SVDHoughTracking::beginEvent()
58 {
59  Super::beginEvent();
60 
61  // If the capacity of a std::vector is too large, start with a fresh one.
62  // Since std::vector.shrink() or std::vector.shrink_to_fit() not necessarily reduce the capacity in the desired way,
63  // create a temporary vector of the same type and swap them to use the vector at the new location afterwards.
64  checkResizeClear<const SpacePoint*>(m_spacePointVector, 5000);
65  checkResizeClear<VXDHoughState>(m_vxdHoughStates, 5000);
66  checkResizeClear<std::vector<VXDHoughState*>>(m_rawTrackCandidates, 500);
67  checkResizeClear<SpacePointTrackCand>(m_trackCandidates, 500);
68 
69 }
70 
71 void SVDHoughTracking::apply()
72 {
73  m_spacePointLoaderAndPreparer.apply(m_spacePointVector, m_vxdHoughStates);
74  B2DEBUG(29, "m_vxdHoughStates.size(): " << m_vxdHoughStates.size());
75 
76  if (m_useMultiHoughSpaceInterceptFinding) {
77  m_multiHouthSpaceInterceptFinder.apply(m_vxdHoughStates, m_rawTrackCandidates);
78  } else {
79  m_singleHouthSpaceInterceptFinder.apply(m_vxdHoughStates, m_rawTrackCandidates);
80  }
81  B2DEBUG(29, "m_rawTrackCandidates.size: " << m_rawTrackCandidates.size());
82 
83  m_rawTCCleaner.apply(m_rawTrackCandidates, m_trackCandidates);
84 
85  // sort by number of hits in the track candidate and by the QI
86  std::sort(m_trackCandidates.begin(), m_trackCandidates.end(),
87  [](const SpacePointTrackCand & a, const SpacePointTrackCand & b) {
88  return ((a.getNHits() > b.getNHits()) or
89  (a.getNHits() == b.getNHits() and a.getQualityIndicator() > b.getQualityIndicator()));
90  });
91 
92  m_overlapResolver.apply(m_trackCandidates);
93 
94  m_recoTrackStorer.apply(m_trackCandidates, m_spacePointVector);
95 
96  // A check if or if not ROIs shall be calculated is performed within the m_roiFinder findlet to
97  // avoid creation and registration of the ROIs and PXDIntercept StoreArrays
98  // such that StoreArrays with the same name can be registered elsewhere.
99  m_roiFinder.apply(m_trackCandidates);
100 }
The Module parameter list class.
Storage for (VXD) SpacePoint-based track candidates.
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
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.