Belle II Software  release-06-02-00
BestVXDFamilyCandidateSelectorModule.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/modules/trackSetEvaluatorVXD/BestVXDFamilyCandidateSelectorModule.h"
10 #include <unordered_map>
11 
12 using namespace Belle2;
13 
14 
15 REG_MODULE(BestVXDFamilyCandidateSelector)
16 
18 {
19  setDescription("Module that selects the best candidate for each SPTC family");
20  setPropertyFlags(c_ParallelProcessingCertified);
21 
22 
23  addParam("NameSpacePointTrackCands", m_nameSpacePointTrackCands, "Name of expected StoreArray.", std::string(""));
24 }
25 
27 {
29 }
30 
32 {
33  /* family identifier -> (sptc array index, quality index) */
34  std::unordered_map<unsigned short, std::pair<int, float>> familyToCand;
36  if (not sptc.hasRefereeStatus(SpacePointTrackCand::c_isActive)) continue;
37 
38  float qi = sptc.getQualityIndicator();
39  unsigned short family = sptc.getFamily();
40  auto iter = familyToCand.find(family);
41  if (iter != familyToCand.end()) {
42  auto& entry = iter->second;
43  if (entry.second < qi) {
44  entry.first = sptc.getArrayIndex();
45  entry.second = qi;
46  }
47  } else {
48  familyToCand.emplace(std::piecewise_construct, std::forward_as_tuple(family), std::forward_as_tuple(sptc.getArrayIndex(), qi));
49  }
50  }
52  if (not sptc.hasRefereeStatus(SpacePointTrackCand::c_isActive)) continue;
53  int bestCandIndex = familyToCand.at(sptc.getFamily()).first;
54  if (sptc.getArrayIndex() != bestCandIndex) {
55  sptc.removeRefereeStatus(SpacePointTrackCand::c_isActive);
56  }
57  }
58 }
59 
Module that selects the best candidate for each SPTC family.
void initialize() override final
Requires SpacePointTrackCands.
void event() override final
Application of the cut.
StoreArray< SpacePointTrackCand > m_spacePointTrackCands
StoreArray for input SpacePointTrackCands.
std::string m_nameSpacePointTrackCands
Name of input StoreArray containing SpacePointTrackCands.
Base class for Modules.
Definition: Module.h:72
Storage for (VXD) SpacePoint-based track candidates.
@ c_isActive
bit 11: SPTC is active (i.e.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.