Belle II Software  release-08-01-10
CKFToSVDFindlet.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 
9 #include <tracking/ckf/svd/findlets/CKFToSVDFindlet.h>
10 
11 #include <tracking/ckf/general/findlets/SpacePointTagger.icc.h>
12 #include <tracking/ckf/general/findlets/StateCreatorWithReversal.icc.h>
13 #include <tracking/ckf/general/findlets/StateCreator.icc.h>
14 #include <tracking/ckf/general/findlets/CKFRelationCreator.icc.h>
15 #include <tracking/ckf/general/findlets/TreeSearcher.icc.h>
16 #include <tracking/ckf/general/findlets/OverlapResolver.icc.h>
17 #include <tracking/ckf/general/findlets/StateRejecter.icc.h>
18 #include <tracking/ckf/general/findlets/ResultStorer.icc.h>
19 #include <tracking/ckf/general/utilities/Helpers.h>
20 
21 #include <tracking/trackFindingCDC/filters/base/ChooseableFilter.icc.h>
22 #include <tracking/ckf/svd/filters/relations/LayerSVDRelationFilter.icc.h>
23 
24 #include <framework/core/ModuleParamList.h>
25 
26 using namespace Belle2;
27 using namespace TrackFindingCDC;
28 
30 
32 {
33  addProcessingSignalListener(&m_dataHandler);
34  addProcessingSignalListener(&m_hitsLoader);
35  addProcessingSignalListener(&m_stateCreatorFromTracks);
36  addProcessingSignalListener(&m_stateCreatorFromHits);
37  addProcessingSignalListener(&m_relationCreator);
38  addProcessingSignalListener(&m_treeSearchFindlet);
39  addProcessingSignalListener(&m_overlapResolver);
40  addProcessingSignalListener(&m_spacePointTagger);
41  addProcessingSignalListener(&m_resultStorer);
42 }
43 
44 void CKFToSVDFindlet::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
45 {
46  Super::exposeParameters(moduleParamList, prefix);
47 
48  m_dataHandler.exposeParameters(moduleParamList, prefix);
49  m_hitsLoader.exposeParameters(moduleParamList, prefix);
50  m_stateCreatorFromTracks.exposeParameters(moduleParamList, prefix);
51  m_stateCreatorFromHits.exposeParameters(moduleParamList, prefix);
52  m_relationCreator.exposeParameters(moduleParamList, prefix);
53  m_treeSearchFindlet.exposeParameters(moduleParamList, prefix);
54  m_overlapResolver.exposeParameters(moduleParamList, prefix);
55  m_spacePointTagger.exposeParameters(moduleParamList, prefix);
56  m_resultStorer.exposeParameters(moduleParamList, prefix);
57 
58  moduleParamList->addParameter("minimalHitRequirement", m_param_minimalHitRequirement,
59  "Minimal Hit requirement for the results (counted in space points)",
60  m_param_minimalHitRequirement);
61 
62  moduleParamList->getParameter<std::string>("firstHighFilter").setDefaultValue("mva_with_direction_check");
63  moduleParamList->getParameter<std::string>("advanceHighFilter").setDefaultValue("advance");
64  moduleParamList->getParameter<std::string>("secondHighFilter").setDefaultValue("mva");
65  moduleParamList->getParameter<std::string>("updateHighFilter").setDefaultValue("fit");
66  moduleParamList->getParameter<std::string>("thirdHighFilter").setDefaultValue("mva");
67 
68  moduleParamList->getParameter<std::string>("filter").setDefaultValue("mva");
69 
70  moduleParamList->getParameter<std::string>("hitFilter").setDefaultValue("sensor");
71  moduleParamList->getParameter<std::string>("seedFilter").setDefaultValue("all");
72  moduleParamList->getParameter<std::string>("preSeedFilter").setDefaultValue("loose");
73  moduleParamList->getParameter<std::string>("preHitFilter").setDefaultValue("loose");
74 
75  moduleParamList->getParameter<std::string>("hitsSpacePointsStoreArrayName").setDefaultValue("SVDSpacePoints");
76 
77  moduleParamList->getParameter<bool>("useAssignedHits").setDefaultValue(false);
78 }
79 
81 {
82  Super::beginEvent();
83 
84  // If the capacity of a std::vector is very large without being used, it just allocates RAM for no reason, increasing the RAM
85  // usage unnecessarily. In this case, start with a fresh one.
86  // Since std::vector.shrink() or std::vector.shrink_to_fit() not necessarily reduce the capacity in the desired way, create a
87  // temporary vector of the same type, swap them to use the vector at the new location afterwards, and clear the tempoary vector.
88  m_cdcRecoTrackVector.clear();
89  checkResizeClear<const SpacePoint*>(m_spacePointVector, 40000);
90 
91  m_seedStates.clear();
92  checkResizeClear<CKFToSVDState>(m_states, 40000);
93 
94  checkResizeClear<TrackFindingCDC::WeightedRelation<CKFToSVDState>>(m_relations, 100000);
95 
96  m_results.clear();
97  m_filteredResults.clear();
98 }
99 
101 {
102  m_dataHandler.apply(m_cdcRecoTrackVector);
103  m_hitsLoader.apply(m_spacePointVector);
104 
105  B2DEBUG(29, "Now have " << m_spacePointVector.size() << " hits.");
106 
107  if (m_spacePointVector.empty() or m_cdcRecoTrackVector.empty()) {
108  return;
109  }
110 
111  m_stateCreatorFromTracks.apply(m_cdcRecoTrackVector, m_seedStates);
112  m_stateCreatorFromHits.apply(m_spacePointVector, m_states);
113  m_relationCreator.apply(m_seedStates, m_states, m_relations);
114 
115  B2DEBUG(29, "Created " << m_relations.size() << " relations.");
116  m_treeSearchFindlet.apply(m_seedStates, m_states, m_relations, m_results);
117 
118  B2DEBUG(29, "Having found " << m_results.size() << " results before overlap check");
119 
120  const auto hasLowHitNumber = [this](const CKFResult<RecoTrack, SpacePoint>& result) {
121  return result.getHits().size() < m_param_minimalHitRequirement;
122  };
123  TrackFindingCDC::erase_remove_if(m_results, hasLowHitNumber);
124 
125  m_overlapResolver.apply(m_results, m_filteredResults);
126 
127  B2DEBUG(29, "Having found " << m_filteredResults.size() << " results");
128 
129  m_resultStorer.apply(m_filteredResults);
130  m_spacePointTagger.apply(m_filteredResults, m_spacePointVector);
131 }
~CKFToSVDFindlet() override
Default desctructor.
void beginEvent() override
Clear the object pools.
CKFToSVDFindlet()
Constructor, for setting module description and parameters.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
void apply() override
Do the track/hit finding/merging.
The Module parameter list class.
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.