11 #include <framework/logging/Logger.h>
12 #include <framework/geometry/BFieldManager.h>
14 #include <tracking/modules/vxdtfRedesign/TrackFinderVXDCellOMatModule.h>
15 #include <tracking/trackFindingVXD/algorithms/NetworkPathConversion.h>
16 #include <tracking/trackFindingVXD/segmentNetwork/NodeNetworkHelperFunctions.h>
28 setDescription(
"The TrackFinderVXD Cell-O-Mat module."
29 "\n It uses the output produced by the SegmentNetworkProducerModule to create"
30 "SpacePointTrackCands using a Cellular Automaton algorithm implementation.");
31 setPropertyFlags(c_ParallelProcessingCertified);
34 addParam(
"NetworkName",
36 "name for StoreObjPtr< DirectedNodeNetwork> which contains the networks needed.",
39 addParam(
"SpacePointTrackCandArrayName",
40 m_PARAMSpacePointTrackCandArrayName,
41 "name for StoreArray< SpacePointTrackCand> to be filled.",
44 addParam(
"EventLevelTrackingInfoName",
45 m_PARAMEventLevelTrackingInfoName,
46 "Name of the EventLevelTrackingInfo that should be used (different one for ROI-finding).",
47 string(
"EventLevelTrackingInfo"));
49 addParam(
"printNetworks",
51 "If true for each event and each network created a file with a graph is created.",
bool(
false));
53 addParam(
"strictSeeding",
55 "Regulates if every node with enough notes below it is used as a seed or only the outermost nodes.",
58 addParam(
"storeSubsets",
60 "Regulates if every subset of sufficient length of a path shall be collected as separate path or not.",
63 addParam(
"setFamilies",
65 "Additionally assign a common family identifier to all Tracks that are share a node.",
68 addParam(
"selectBestPerFamily",
69 m_PARAMselectBestPerFamily,
70 "Select only the best track candidate for each family.",
73 addParam(
"xBestPerFamily",
74 m_PARAMxBestPerFamily,
75 "Number of best track candidates to be created per family.",
76 m_PARAMxBestPerFamily);
78 addParam(
"maxFamilies",
80 "Maximal number of families allowed in an event; if exceeded, the event execution will be skipped.",
85 "Maximal number of paths per an event; if exceeded, the event execution will be skipped.",
90 void TrackFinderVXDCellOMatModule::initialize()
92 m_network.isRequired(m_PARAMNetworkName);
93 m_TCs.registerInDataStore(m_PARAMSpacePointTrackCandArrayName, DataStore::c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered);
95 if (m_PARAMselectBestPerFamily) {
96 m_sptcSelector = std::make_unique<SPTCSelectorXBestPerFamily>(m_PARAMxBestPerFamily);
99 m_eventLevelTrackingInfo.isRequired(m_PARAMEventLevelTrackingInfoName);
103 void TrackFinderVXDCellOMatModule::beginRun()
105 if (m_PARAMselectBestPerFamily) {
107 double bFieldZ = BFieldManager::getFieldInTesla({0, 0, 0}).Z();
108 m_sptcSelector->setMagneticFieldForQE(bFieldZ);
113 void TrackFinderVXDCellOMatModule::event()
120 int nRounds = m_cellularAutomaton.apply(segmentNetwork);
122 B2ERROR(
"CA failed, skipping event!");
126 if (m_PARAMprintNetworks) {
127 std::string fileName = m_PARAMNetworkName +
"_CA_Ev" + std::to_string(m_eventCounter);
128 DNN::printCANetwork<Segment< Belle2::TrackNode>>(segmentNetwork, fileName);
132 unsigned int nSeeds = m_cellularAutomaton.findSeeds(segmentNetwork, m_PARAMstrictSeeding);
138 if (m_PARAMsetFamilies) {
139 unsigned short nFamilies = m_familyDefiner.defineFamilies(segmentNetwork);
140 if (nFamilies > m_PARAMmaxFamilies) {
141 B2WARNING(
"Maximal number of track canidates per event was exceeded: Number of Families = " << nFamilies);
142 m_eventLevelTrackingInfo->setVXDTF2AbortionFlag();
145 m_sptcSelector->prepareSelector(nFamilies);
149 m_collectedPaths.clear();
150 if (not m_pathCollector.findPaths(segmentNetwork, m_collectedPaths, m_PARAMmaxPaths, m_PARAMstoreSubsets)) {
151 B2WARNING(
"VXDCellOMat got signal to abort the event.");
152 m_eventLevelTrackingInfo->setVXDTF2AbortionFlag();
153 m_network->set_collectedPaths(m_collectedPaths.size());
157 m_network->set_collectedPaths(m_collectedPaths.size());
161 for (
auto& aPath : m_collectedPaths) {
164 if (m_PARAMselectBestPerFamily) {
165 m_sptcSelector->testNewSPTC(sptc);
167 std::vector<const SpacePoint*> path = sptc.
getHits();
168 m_sptcCreator.createSPTC(m_TCs, path, sptc.
getFamily());
173 if (m_PARAMselectBestPerFamily) {
174 std::vector<SpacePointTrackCand> bestPaths = m_sptcSelector->returnSelection();
175 for (
unsigned short iCand = 0; iCand < bestPaths.size(); iCand++) {
177 std::vector<const SpacePoint*> path = cand.
getHits();
178 m_sptcCreator.createSPTC(m_TCs, path, cand.
getFamily());