9 #include <framework/logging/Logger.h>
10 #include <framework/geometry/BFieldManager.h>
12 #include <tracking/modules/vxdtfRedesign/TrackFinderVXDCellOMatModule.h>
13 #include <tracking/trackFindingVXD/algorithms/NetworkPathConversion.h>
14 #include <tracking/trackFindingVXD/segmentNetwork/NodeNetworkHelperFunctions.h>
26 setDescription(
"The TrackFinderVXD Cell-O-Mat module."
27 "\n It uses the output produced by the SegmentNetworkProducerModule to create"
28 "SpacePointTrackCands using a Cellular Automaton algorithm implementation.");
29 setPropertyFlags(c_ParallelProcessingCertified);
32 addParam(
"NetworkName",
34 "name for StoreObjPtr< DirectedNodeNetwork> which contains the networks needed.",
37 addParam(
"SpacePointTrackCandArrayName",
38 m_PARAMSpacePointTrackCandArrayName,
39 "name for StoreArray< SpacePointTrackCand> to be filled.",
42 addParam(
"EventLevelTrackingInfoName",
43 m_PARAMEventLevelTrackingInfoName,
44 "Name of the EventLevelTrackingInfo that should be used (different one for ROI-finding).",
45 string(
"EventLevelTrackingInfo"));
47 addParam(
"printNetworks",
49 "If true for each event and each network created a file with a graph is created.",
bool(
false));
51 addParam(
"strictSeeding",
53 "Regulates if every node with enough notes below it is used as a seed or only the outermost nodes.",
56 addParam(
"storeSubsets",
58 "Regulates if every subset of sufficient length of a path shall be collected as separate path or not.",
61 addParam(
"setFamilies",
63 "Additionally assign a common family identifier to all Tracks that are share a node.",
66 addParam(
"selectBestPerFamily",
67 m_PARAMselectBestPerFamily,
68 "Select only the best track candidate for each family.",
71 addParam(
"xBestPerFamily",
72 m_PARAMxBestPerFamily,
73 "Number of best track candidates to be created per family.",
74 m_PARAMxBestPerFamily);
76 addParam(
"maxFamilies",
78 "Maximal number of families allowed in an event; if exceeded, the event execution will be skipped.",
83 "Maximal number of paths per an event; if exceeded, the event execution will be skipped.",
88 void TrackFinderVXDCellOMatModule::initialize()
90 m_network.isRequired(m_PARAMNetworkName);
91 m_TCs.registerInDataStore(m_PARAMSpacePointTrackCandArrayName, DataStore::c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered);
93 if (m_PARAMselectBestPerFamily) {
94 m_sptcSelector = std::make_unique<SPTCSelectorXBestPerFamily>(m_PARAMxBestPerFamily);
97 m_eventLevelTrackingInfo.isRequired(m_PARAMEventLevelTrackingInfoName);
101 void TrackFinderVXDCellOMatModule::beginRun()
103 if (m_PARAMselectBestPerFamily) {
105 double bFieldZ = BFieldManager::getFieldInTesla({0, 0, 0}).Z();
106 m_sptcSelector->setMagneticFieldForQE(bFieldZ);
111 void TrackFinderVXDCellOMatModule::event()
118 int nRounds = m_cellularAutomaton.apply(segmentNetwork);
120 B2ERROR(
"Cellular Automaton failed, skipping event!");
124 if (m_PARAMprintNetworks) {
125 std::string fileName = m_PARAMNetworkName +
"_CA_Ev" + std::to_string(m_eventCounter);
126 DNN::printCANetwork<Segment< Belle2::TrackNode>>(segmentNetwork, fileName);
130 unsigned int nSeeds = m_cellularAutomaton.findSeeds(segmentNetwork, m_PARAMstrictSeeding);
136 if (m_PARAMsetFamilies) {
137 unsigned short nFamilies = m_familyDefiner.defineFamilies(segmentNetwork);
138 if (nFamilies > m_PARAMmaxFamilies) {
139 B2WARNING(
"Maximal number of track canidates per event was exceeded: Number of Families = " << nFamilies);
140 m_eventLevelTrackingInfo->setVXDTF2AbortionFlag();
143 m_sptcSelector->prepareSelector(nFamilies);
147 m_collectedPaths.clear();
148 if (not m_pathCollector.findPaths(segmentNetwork, m_collectedPaths, m_PARAMmaxPaths, m_PARAMstoreSubsets)) {
149 B2WARNING(
"Received signal to skip the event and not processing it.");
150 m_eventLevelTrackingInfo->setVXDTF2AbortionFlag();
151 m_network->set_collectedPaths(m_collectedPaths.size());
155 m_network->set_collectedPaths(m_collectedPaths.size());
159 for (
auto& aPath : m_collectedPaths) {
162 if (m_PARAMselectBestPerFamily) {
163 m_sptcSelector->testNewSPTC(sptc);
165 std::vector<const SpacePoint*> path = sptc.
getHits();
166 m_sptcCreator.createSPTC(m_TCs, path, sptc.
getFamily());
171 if (m_PARAMselectBestPerFamily) {
172 std::vector<SpacePointTrackCand> bestPaths = m_sptcSelector->returnSelection();
173 for (
unsigned short iCand = 0; iCand < bestPaths.size(); iCand++) {
175 std::vector<const SpacePoint*> path = cand.
getHits();
176 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 TrackFinderVXDCellOMatModule is a low momentum Si-only trackfinder.
#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.