Belle II Software  release-08-01-10
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");
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 
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
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
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.
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
Abstract base class for different kinds of events.