Belle II Software development
NDFinderPeakFinder.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
9#pragma once
10
11#include <vector>
12#include <utility>
13#include <array>
14#include <boost/multi_array.hpp>
15
16#define BOOST_MULTI_ARRAY_NO_GENERATORS
17
18namespace Belle2 {
23
24 // Typedefs for the Hough space
25 typedef boost::multi_array<unsigned short, 3> c3array;
26 typedef c3array::index c3index;
27 typedef std::array<c3index, 3> cell_index;
28
29 // Struct containing the parameters for the peak finding
31 // Number of iterations of the peak searching for each Hough space quadrant
32 unsigned short iterations;
33 // Number of deleted cells in omega in each direction of the peak
34 unsigned short omegaTrim;
35 // Number of deleted cells in phi in each direction of the peak
36 unsigned short phiTrim;
37 // The Hough space dimensions
38 unsigned short nOmega;
39 unsigned short nPhi;
40 unsigned short nCot;
41 };
42
43 // Struct for a found peak and its hits
44 struct HoughPeak {
45 std::vector<unsigned short> hits;
46 cell_index cell{0, 0, 0};
47 unsigned int weight{0};
48 };
49
50
51 // Peak finding module
52 class NDFinderPeakFinder {
53 public:
54 // Struct containing the deletion bounds of a omega row
56 c3index phiLowerBound;
57 c3index phiUpperBound;
58 c3index omega;
59 c3index cot;
60 };
61
62 // Default constructor
63 NDFinderPeakFinder() = default;
64
65 // To set custom peak finding parameters
66 explicit NDFinderPeakFinder(const PeakFindingParameters& parameters): m_peakFindingParams(parameters) {}
67
68 // Set a new Hough space for peak and track finding
69 void setNewPlane(c3array& houghSpace) { m_houghSpace = &houghSpace; }
70 // Create all the peaks in the Hough space
71 std::vector<HoughPeak> findPeaks();
72
73 private:
74 // Get the phi bounds of one quadrant section
75 std::array<c3index, 2> getSectionBounds(const unsigned short quadrant, const unsigned section);
76 // Iterate m_peakFindingParams.iterations times over one section
77 void iterateOverSection(const std::array<c3index, 2>& sectionBounds, std::vector<HoughPeak>& candidatePeaks);
78 // Finds the global section peak index
79 HoughPeak getSectionPeak(const std::array<c3index, 2>& sectionBounds);
80 // Deletes the surroundings of such a peak (if iterations > 1)
81 void deletePeakSurroundings(const HoughPeak& peak);
82 // Method to delete a omega row for the peak cluster deletion in deletePeakSurroundings method
83 void clearHoughSpaceRow(const DeletionBounds& bounds);
84 // The struct holding the peak finding parameters
85 PeakFindingParameters m_peakFindingParams;
86 // Pointer to the Hough space
87 c3array* m_houghSpace{0};
88 };
89
90}
Abstract base class for different kinds of events.