Belle II Software  release-05-01-25
BestVXDFamilyCandidateSelectorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jonas Wagner *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include "tracking/modules/trackSetEvaluatorVXD/BestVXDFamilyCandidateSelectorModule.h"
12 #include <unordered_map>
13 
14 using namespace Belle2;
15 
16 
17 REG_MODULE(BestVXDFamilyCandidateSelector)
18 
20 {
21  setDescription("Module that selects the best candidate for each SPTC family");
22  setPropertyFlags(c_ParallelProcessingCertified);
23 
24 
25  addParam("NameSpacePointTrackCands", m_nameSpacePointTrackCands, "Name of expected StoreArray.", std::string(""));
26 }
27 
29 {
31 }
32 
34 {
35  /* family identifier -> (sptc array index, quality index) */
36  std::unordered_map<unsigned short, std::pair<int, float>> familyToCand;
38  if (not sptc.hasRefereeStatus(SpacePointTrackCand::c_isActive)) continue;
39 
40  float qi = sptc.getQualityIndicator();
41  unsigned short family = sptc.getFamily();
42  auto iter = familyToCand.find(family);
43  if (iter != familyToCand.end()) {
44  auto& entry = iter->second;
45  if (entry.second < qi) {
46  entry.first = sptc.getArrayIndex();
47  entry.second = qi;
48  }
49  } else {
50  familyToCand.emplace(std::piecewise_construct, std::forward_as_tuple(family), std::forward_as_tuple(sptc.getArrayIndex(), qi));
51  }
52  }
54  if (not sptc.hasRefereeStatus(SpacePointTrackCand::c_isActive)) continue;
55  int bestCandIndex = familyToCand.at(sptc.getFamily()).first;
56  if (sptc.getArrayIndex() != bestCandIndex) {
57  sptc.removeRefereeStatus(SpacePointTrackCand::c_isActive);
58  }
59  }
60 }
61 
Belle2::BestVXDFamilyCandidateSelectorModule::initialize
void initialize() override final
Requires SpacePointTrackCands.
Definition: BestVXDFamilyCandidateSelectorModule.cc:28
Belle2::BestVXDFamilyCandidateSelectorModule
Module that selects the best candidate for each SPTC family.
Definition: BestVXDFamilyCandidateSelectorModule.h:33
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::BestVXDFamilyCandidateSelectorModule::m_spacePointTrackCands
StoreArray< SpacePointTrackCand > m_spacePointTrackCands
StoreArray for input SpacePointTrackCands.
Definition: BestVXDFamilyCandidateSelectorModule.h:55
Belle2::SpacePointTrackCand::c_isActive
@ c_isActive
bit 11: SPTC is active (i.e.
Definition: SpacePointTrackCand.h:94
Belle2::BestVXDFamilyCandidateSelectorModule::m_nameSpacePointTrackCands
std::string m_nameSpacePointTrackCands
Name of input StoreArray containing SpacePointTrackCands.
Definition: BestVXDFamilyCandidateSelectorModule.h:49
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BestVXDFamilyCandidateSelectorModule::event
void event() override final
Application of the cut.
Definition: BestVXDFamilyCandidateSelectorModule.cc:33
Belle2::SpacePointTrackCand
Storage for (VXD) SpacePoint-based track candidates.
Definition: SpacePointTrackCand.h:51