Belle II Software development
CKFToPXDFindlet.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/pxd/findlets/CKFToPXDFindlet.h>
10
11#include <tracking/ckf/general/findlets/StateCreator.icc.h>
12#include <tracking/ckf/general/findlets/CKFRelationCreator.icc.h>
13#include <tracking/ckf/general/findlets/StateCreatorWithReversal.icc.h>
14#include <tracking/ckf/general/findlets/TreeSearcher.icc.h>
15#include <tracking/ckf/general/findlets/OverlapResolver.icc.h>
16#include <tracking/ckf/general/findlets/SpacePointTagger.icc.h>
17#include <tracking/ckf/general/findlets/ResultStorer.icc.h>
18#include <tracking/ckf/general/utilities/Helpers.h>
19
20#include <tracking/ckf/pxd/entities/CKFToPXDResult.h>
21#include <tracking/ckf/pxd/entities/CKFToPXDState.h>
22
23#include <tracking/dataobjects/RecoTrack.h>
24#include <tracking/spacePointCreation/SpacePoint.h>
25#include <pxd/dataobjects/PXDCluster.h>
26
27#include <framework/core/ModuleParamList.h>
28
29using namespace Belle2;
30using namespace TrackFindingCDC;
31
33
35{
45}
46
47void CKFToPXDFindlet::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
48{
49 Super::exposeParameters(moduleParamList, prefix);
50
51 m_dataHandler.exposeParameters(moduleParamList, prefix);
52 m_hitsLoader.exposeParameters(moduleParamList, prefix);
53 m_stateCreatorFromTracks.exposeParameters(moduleParamList, prefix);
54 m_stateCreatorFromHits.exposeParameters(moduleParamList, prefix);
55 m_relationCreator.exposeParameters(moduleParamList, prefix);
56 m_treeSearchFindlet.exposeParameters(moduleParamList, prefix);
57 m_overlapResolver.exposeParameters(moduleParamList, prefix);
58 m_spacePointTagger.exposeParameters(moduleParamList, prefix);
59 m_resultStorer.exposeParameters(moduleParamList, prefix);
60
61 moduleParamList->addParameter("minimalHitRequirement", m_param_minimalHitRequirement,
62 "Minimal Hit requirement for the results (counted in space points)",
64 moduleParamList->addParameter("onlyUseTracksWithSVD", m_param_onlyUseTracksWithSVD,
65 "Only use tracks which have an SVD hit associated.",
67 moduleParamList->addParameter("reverseSeedState", m_param_reverseSeed, "Reverse the seed.", m_param_reverseSeed);
68
69 // Default values
70 moduleParamList->getParameter<std::string>("advanceHighFilter").setDefaultValue("advance");
71 moduleParamList->getParameter<std::string>("updateHighFilter").setDefaultValue("fit");
72
73 moduleParamList->getParameter<std::string>("firstHighFilter").setDefaultValue("mva_with_direction_check");
74 moduleParamList->getParameter<std::string>("secondHighFilter").setDefaultValue("mva");
75 moduleParamList->getParameter<std::string>("thirdHighFilter").setDefaultValue("mva");
76
77 moduleParamList->getParameter<bool>("useAssignedHits").setDefaultValue(false);
78
79 moduleParamList->getParameter<std::string>("hitFilter").setDefaultValue("sensor");
80 moduleParamList->getParameter<std::string>("seedFilter").setDefaultValue("sensor");
81 moduleParamList->getParameter<std::string>("preSeedFilter").setDefaultValue("loose");
82 moduleParamList->getParameter<std::string>("preHitFilter").setDefaultValue("loose");
83
84 moduleParamList->getParameter<std::string>("hitsSpacePointsStoreArrayName").setDefaultValue("PXDSpacePoints");
85
86 moduleParamList->getParameter<std::string>("filter").setDefaultValue("mva");
87}
88
90{
92
93 // If the capacity of a std::vector is very large without being used, it just allocates RAM for no reason, increasing the RAM
94 // usage unnecessarily. In this case, start with a fresh one.
95 // Since std::vector.shrink() or std::vector.shrink_to_fit() not necessarily reduce the capacity in the desired way, create a
96 // temporary vector of the same type, swap them to use the vector at the new location afterwards, and clear the tempoary vector.
97 m_recoTracksVector.clear();
98 checkResizeClear<const SpacePoint*>(m_spacePointVector, 2000);
99
100 m_seedStates.clear();
101 checkResizeClear<CKFToPXDState>(m_states, 2000);
102
103 checkResizeClear<TrackFindingCDC::WeightedRelation<CKFToPXDState>>(m_relations, 2000);
104
105 m_results.clear();
106 m_filteredResults.clear();
107}
108
110{
113
114 if (m_spacePointVector.empty() or m_recoTracksVector.empty()) {
115 return;
116 }
117
118 // Delete stuff not from the PXD
119 const auto notFromPXD = [](const SpacePoint * spacePoint) {
120 return spacePoint->getType() != VXD::SensorInfoBase::PXD;
121 };
122 TrackFindingCDC::erase_remove_if(m_spacePointVector, notFromPXD);
123
125 const auto hasNoSVD = [this](const RecoTrack * recoTrack) {
126 const auto& svdHitList = recoTrack->getSortedSVDHitList();
127 if (svdHitList.empty()) return true;
128 // Require at least one hit in layer 3 or 4
129 return m_param_reverseSeed ? svdHitList.back()->getSensorID().getLayerNumber() > 4
130 : svdHitList.front()->getSensorID().getLayerNumber() > 4;
131 };
132 TrackFindingCDC::erase_remove_if(m_recoTracksVector, hasNoSVD);
133 }
134
135 B2DEBUG(29, "Now have " << m_spacePointVector.size() << " hits.");
136
140
141 B2DEBUG(29, "Created " << m_relations.size() << " relations.");
142
144
145 B2DEBUG(29, "Having found " << m_results.size() << " results before overlap check");
146
147 const auto hasLowHitNumber = [this](const CKFResult<RecoTrack, SpacePoint>& result) {
148 return result.getHits().size() < m_param_minimalHitRequirement;
149 };
150 TrackFindingCDC::erase_remove_if(m_results, hasLowHitNumber);
151
153
154 B2DEBUG(29, "Having found " << m_filteredResults.size() << " results");
155
158}
Object for temporary storage of a CKF tree search result.
Definition: CKFResult.h:30
std::vector< CKFToPXDResult > m_results
Vector for storing the results.
std::vector< CKFToPXDResult > m_filteredResults
Vector for storing the filtered results.
std::vector< TrackFindingCDC::WeightedRelation< CKFToPXDState > > m_relations
Relations between states.
CKFRelationCreator< CKFToPXDState, ChooseablePXDRelationFilter > m_relationCreator
Findlet for creating relations between states.
unsigned int m_param_minimalHitRequirement
Minimal hit requirement for the results (counted in number of space points)
TrackLoader m_dataHandler
Findlet for retrieving the cdc tracks and writing the result out.
StateCreatorWithReversal< CKFToPXDState > m_stateCreatorFromTracks
Findlet for creating states out of tracks.
std::vector< const SpacePoint * > m_spacePointVector
Pointers to the (const) SpacePoints as a vector.
TreeSearcher< CKFToPXDState, PXDStateRejecter, CKFToPXDResult > m_treeSearchFindlet
Findlet doing the main work: the tree finding.
SpacePointLoader m_hitsLoader
Findlet for loading the space points.
bool m_param_onlyUseTracksWithSVD
Cut away tracks without SVD hits or not.
std::vector< CKFToPXDState > m_states
States for the hits.
ResultStorer< CKFToPXDResult > m_resultStorer
Findlet for storing the results.
SpacePointTagger< CKFToPXDResult, PXDCluster > m_spacePointTagger
Findlet for tagging the used space points.
CKFToPXDFindlet()
Constructor, for setting module description and parameters.
StateCreator< const SpacePoint, CKFToPXDState > m_stateCreatorFromHits
Findlet for creating states out of hits.
void beginEvent() override
Clear the object pools.
~CKFToPXDFindlet()
Default destructor.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
OverlapResolver< ChooseablePXDResultFilter > m_overlapResolver
Findlet for resolving overlaps.
bool m_param_reverseSeed
Reverse the seed.
void apply() override
Do the tree search.
std::vector< CKFToPXDState > m_seedStates
States for the tracks.
std::vector< RecoTrack * > m_recoTracksVector
Pointers to the Reco tracks as a vector.
The Module parameter list class.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
void apply(std::vector< const SpacePoint * > &spacePoints) final
Do the space point retrieval.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
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.
void beginEvent() override
Receive and dispatch signal for the start of a new event.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Forward prefixed parameters of this findlet to the module parameter list.
Definition: Findlet.h:69
void apply(std::vector< RecoTrack * > &seeds) override
Load in the reco tracks and the hits.
Definition: TrackLoader.cc:68
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: TrackLoader.cc:24
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.