9 #include <framework/logging/Logger.h>
11 #include <framework/geometry/BFieldManager.h>
13 #include <tracking/modules/vxdtfRedesign/TrackFinderVXDBasicPathFinderModule.h>
14 #include <tracking/trackFindingVXD/algorithms/NetworkPathConversion.h>
15 #include <tracking/trackFindingVXD/segmentNetwork/NodeNetworkHelperFunctions.h>
27 setDescription(
"The TrackFinderVXD BasicPathFinder module."
28 "\n It uses the output produced by the SegmentNetworkProducerModule to create"
29 "SpacePointTrackCands by simply storing all possible paths stored in the SegmentNetwork.");
30 setPropertyFlags(c_ParallelProcessingCertified);
33 addParam(
"NetworkName",
35 "name for StoreObjPtr< DirectedNodeNetwork> which contains the networks needed.",
38 addParam(
"EventLevelTrackingInfoName",
39 m_PARAMEventLevelTrackingInfoName,
40 "Name of the EventLevelTrackingInfo that should be used (different one for ROI-finding).",
41 string(
"EventLevelTrackingInfo"));
43 addParam(
"SpacePointTrackCandArrayName",
44 m_PARAMSpacePointTrackCandArrayName,
45 "name for StoreArray< SpacePointTrackCand> to be filled.",
48 addParam(
"printNetworks",
50 "If true for each event and each network created a file with a graph is created.",
bool(
false));
52 addParam(
"strictSeeding",
54 "Regulates if every node with enough notes below it is used as a seed or only the outermost nodes.",
57 addParam(
"storeSubsets",
59 "Regulates if every subset of sufficient length of a path shall be collected as separate path or not.",
62 addParam(
"setFamilies",
64 "Additionally assign a common family identifier to all Tracks that are share a node.",
67 addParam(
"selectBestPerFamily",
68 m_PARAMselectBestPerFamily,
69 "Select only the best track candidates for each family.",
72 addParam(
"xBestPerFamily",
73 m_PARAMxBestPerFamily,
74 "Number of best track candidates to be created per family.",
75 m_PARAMxBestPerFamily);
77 addParam(
"maxFamilies",
79 "Maximal number of families allowed in an event; if exceeded, the event execution will be skipped.",
84 "Maximal number of paths per an event; if exceeded, the event execution will be skipped.",
89 void TrackFinderVXDBasicPathFinderModule::initialize()
91 m_network.isRequired(m_PARAMNetworkName);
92 m_TCs.registerInDataStore(m_PARAMSpacePointTrackCandArrayName, DataStore::c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered);
94 if (m_PARAMselectBestPerFamily) {
95 m_sptcSelector = std::make_unique<SPTCSelectorXBestPerFamily>(m_PARAMxBestPerFamily);
98 m_eventLevelTrackingInfo.isRequired(m_PARAMEventLevelTrackingInfoName);
102 void TrackFinderVXDBasicPathFinderModule::beginRun()
104 if (m_PARAMselectBestPerFamily) {
106 double bFieldZ = BFieldManager::getFieldInTesla({0, 0, 0}).Z();
107 m_sptcSelector->setMagneticFieldForQE(bFieldZ);
112 void TrackFinderVXDBasicPathFinderModule::event()
118 if (m_PARAMprintNetworks) {
119 std::string fileName = m_PARAMsecMapName +
"_BasicPF_Ev" + std::to_string(m_eventCounter);
120 DNN::printCANetwork<Segment< Belle2::TrackNode>>(segmentNetwork, fileName);
124 int nRounds = m_cellularAutomaton.apply(segmentNetwork);
126 B2WARNING(
"Basic Path Finder failed, skipping event!");
127 m_eventLevelTrackingInfo->setVXDTF2AbortionFlag();
132 unsigned int nSeeds = 0;
133 for (
auto* aNode : segmentNetwork) {
134 if (m_PARAMstrictSeeding && !(aNode->getOuterNodes().empty())) {
137 if (aNode->getInnerNodes().empty()) {
142 aNode->getMetaInfo().setSeed(
true);
147 B2WARNING(
"In Event: " << m_eventCounter <<
" no seed could be found -> no TCs created!");
152 if (m_PARAMsetFamilies) {
153 unsigned short nFamilies = m_familyDefiner.defineFamilies(segmentNetwork);
154 B2DEBUG(10,
"Number of families in the network: " << nFamilies);
155 if (nFamilies > m_PARAMmaxFamilies) {
156 B2WARNING(
"Maximal number of track canidates per event was exceeded: " <<
LogVar(
" Number of Families", nFamilies)
157 <<
LogVar(
"Max number of families", m_PARAMmaxFamilies));
158 m_eventLevelTrackingInfo->setVXDTF2AbortionFlag();
161 m_sptcSelector->prepareSelector(nFamilies);
164 m_collectedPaths.clear();
165 if (not m_pathCollector.findPaths(segmentNetwork, m_collectedPaths, m_PARAMmaxPaths, m_PARAMstoreSubsets)) {
166 B2WARNING(
"VXDBasicPathFinder got signal to abort the event.");
167 m_eventLevelTrackingInfo->setVXDTF2AbortionFlag();
168 m_network->set_collectedPaths(m_collectedPaths.size());
172 m_network->set_collectedPaths(m_collectedPaths.size());
176 for (
auto& aPath : m_collectedPaths) {
179 if (m_PARAMselectBestPerFamily) {
180 m_sptcSelector->testNewSPTC(sptc);
182 std::vector<const SpacePoint*> path = sptc.
getHits();
183 m_sptcCreator.createSPTC(m_TCs, path, sptc.
getFamily());
188 if (m_PARAMselectBestPerFamily) {
189 std::vector<SpacePointTrackCand> bestPaths = m_sptcSelector->returnSelection();
190 for (
unsigned short iCand = 0; iCand < bestPaths.size(); iCand++) {
192 std::vector<const SpacePoint*> path = cand.
getHits();
193 m_sptcCreator.createSPTC(m_TCs, path, cand.
getFamily());
The CACell class This Class stores all relevant information one wants to have stored in a cell for a ...
Network of directed nodes of the type EntryType.
Storage for (VXD) SpacePoint-based track candidates.
short getFamily() const
return family identifier
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
The TrackFinderVXDBasicPathFinder is a low momentum Si-only trackfinder.
Class to store variables with their name which were sent to the logging service.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
SpacePointTrackCand convertNetworkPath(NetworkPath networkPath)
Create new SPTC from network path.
Abstract base class for different kinds of events.