Belle II Software  release-08-01-10
SVDMaxSumAlgorithm.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 <vxd/dataobjects/VxdID.h>
12 #include <svd/dataobjects/SVDShaperDigit.h>
13 #include <vector>
14 
15 namespace Belle2::SVD {
16 
21 
22  public:
23 
24 
29  : m_samples(samples)
30  {
32  };
33 
34 
38  virtual ~SVDMaxSumAlgorithm() {};
39 
43  int getFirstFrame() {return m_result.first;}
44 
48  std::vector<float> getSelectedSamples() {return m_result.second;}
49 
50 
51  protected:
52 
57  std::pair<int, std::vector<float>> m_result;
58 
63  {
64 
65  //Max Sum selection
66  if (m_samples.size() < 3)
67  B2ERROR("APV25 samples less than 3!?");
68 
69  std::vector<float> Sum2bin(m_samples.size() - 1, 0);
70 
71  for (int iBin = 0; iBin < static_cast<int>(m_samples.size()) - 1; ++iBin)
72  Sum2bin.at(iBin) = m_samples.at(iBin) + m_samples.at(iBin + 1);
73 
74  auto itSum = std::max_element(std::begin(Sum2bin), std::end(Sum2bin));
75 
76  int ctrFrame = std::distance(std::begin(Sum2bin), itSum);
77 
78  if (ctrFrame == 0) ctrFrame = 1;
79 
80  std::vector<float> selectedSamples = {m_samples.at(ctrFrame - 1), m_samples.at(ctrFrame), m_samples.at(ctrFrame + 1)};
81 
82  m_result.first = ctrFrame - 1;
83  m_result.second = selectedSamples;
84 
85  };
86 
87  };
88 
89 }
90 
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
array of APVFloatSampleType objects
Class implementing the MaxSum algorithm.
virtual ~SVDMaxSumAlgorithm()
virtual destructor
Belle2::SVDShaperDigit::APVFloatSamples m_samples
strip samples
std::vector< float > getSelectedSamples()
void applyAlgorithm()
applies the algorithm
SVDMaxSumAlgorithm(const Belle2::SVDShaperDigit::APVFloatSamples samples)
Constructor with the APVFloatSamples.
std::pair< int, std::vector< float > > m_result
ADC of the acquired samples.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Definition: GeoSVDCreator.h:23