Belle II Software development
CDCCKFPathMerger.h
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#pragma once
9
10#include <tracking/trackFindingCDC/findlets/base/Findlet.h>
11#include <tracking/ckf/cdc/entities/CDCCKFPath.h>
12
13#include <boost/range/adaptor/reversed.hpp>
14#include <boost/functional/hash.hpp>
15
16namespace Belle2 {
22 class CDCCKFPathMerger : public TrackFindingCDC::Findlet<CDCCKFPath> {
23 public:
25 void apply(std::vector<CDCCKFPath>& newPaths) override
26 {
28 std::unordered_map<size_t, CDCCKFPath> hashToPathList;
29 for (const CDCCKFPath& path : newPaths) {
30 const auto lastHitsHash = lastThreeHitHash(path);
31 if (hashToPathList.find(lastHitsHash) != hashToPathList.end()) {
32 if (hashToPathList[lastHitsHash].size() < path.size()) {
33 hashToPathList[lastHitsHash] = path;
34 }
35 } else {
36 hashToPathList[lastHitsHash] = path;
37 }
38 }
39
40 newPaths.clear();
41 for (const auto& hashAndPathList : hashToPathList) {
42 const CDCCKFPath& path = hashAndPathList.second;
43 newPaths.push_back(path);
44 }
45 }
46
47 private:
49 size_t lastThreeHitHash(const CDCCKFPath& path)
50 {
51 size_t seed = 0;
52 unsigned int counter = 0;
53
54 for (const CDCCKFState& state : boost::adaptors::reverse(path)) {
55 if (counter >= 3) {
56 break;
57 }
58 if (not state.isSeed()) {
59 boost::hash_combine(seed, state.getWireHit());
60 }
61 counter++;
62 }
63 return seed;
64 };
65
66 };
68}
Merge similar paths.
void apply(std::vector< CDCCKFPath > &newPaths) override
main method of the findlet, reads/returns merged paths
size_t lastThreeHitHash(const CDCCKFPath &path)
helper function, returns has of the last 3 wire hits on the path
Define states for CKF algorithm, which can be seed track or CDC wire hit.
Definition: CDCCKFState.h:25
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition: Findlet.h:26
std::vector< CDCCKFState > CDCCKFPath
Shortcut for the collection of CDC CKF-algorithm states.
Definition: CDCCKFPath.h:19
Abstract base class for different kinds of events.