Belle II Software development
RawCluster.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 <framework/logging/Logger.h>
10#include <svd/reconstruction/RawCluster.h>
11#include <vxd/geometry/GeoCache.h>
12#include <svd/geometry/SensorInfo.h>
13#include <framework/core/Environment.h>
14
15#include <framework/datastore/StoreArray.h>
16#include <svd/dataobjects/SVDShaperDigit.h>
17#include <svd/calibration/SVDPulseShapeCalibrations.h>
18#include <svd/reconstruction/SVDMaxSumAlgorithm.h>
19
20using namespace std;
21
22namespace Belle2 {
27
28 namespace SVD {
29
30 RawCluster::RawCluster(VxdID vxdID, bool isUside, double cutSeed, double cutAdjacent)
31 : m_storeShaperDigitsName("SVDShaperDigits")
32 , m_cutSeed(cutSeed)
33 , m_cutAdjacent(cutAdjacent)
34 , m_seedSNR(-1)
35 , m_seedMaxSample(-1)
36 , m_seedIndex(-1)
38 , m_vxdID(vxdID)
39 , m_isUside(isUside)
40 {m_strips.clear();};
41
42 RawCluster::RawCluster(VxdID vxdID, bool isUside, double cutSeed, double cutAdjacent, const std::string& storeShaperDigitsName)
43 : m_storeShaperDigitsName(storeShaperDigitsName)
44 , m_cutSeed(cutSeed)
45 , m_cutAdjacent(cutAdjacent)
46 , m_seedSNR(-1)
47 , m_seedMaxSample(-1)
48 , m_seedIndex(-1)
50 , m_vxdID(vxdID)
51 , m_isUside(isUside)
52 {m_strips.clear();};
53
54 bool RawCluster::add(VxdID vxdID, bool isUside, struct StripInRawCluster& aStrip)
55 {
56
57 bool added = false;
58
59 //do not add if you are on the wrong sensor or side
60 if ((m_vxdID != vxdID) || (m_isUside != isUside))
61 return false;
62
63 //do not add if its SNR is below the minimum SNR for adjacents strips
64 if ((float)aStrip.maxSample / aStrip.noise < m_cutAdjacent)
65 return false;
66
67 //add if it's the first strip
68 if (m_strips.size() == 0)
69 added = true;
70
71 //add if it is adjacent to the last strip added
72 //(we assume that SVDShaperDigits are ordered)
73 if ((m_strips.size() > 0 && (aStrip.cellID == m_strips.at(m_strips.size() - 1).cellID + 1)))
74 added = true;
75
76 //add it to the vector of strips, update the seed max sample and index:
77 if (added) {
78 m_strips.push_back(aStrip);
79
80 if (aStrip.maxSample > m_seedMaxSample) {
82 m_seedSNR = (float)aStrip.maxSample / (float)aStrip.noise;
83 m_seedInternalIndex = m_strips.size() - 1;
85 }
86 }
87 return added;
88
89 };
90
91
93 {
94
95 bool isGood = false;
96
98 isGood = true;
99
100 return isGood;
101 };
102
103
105 {
106
107 if (m_strips.size() == 0)
108 B2ERROR("oopps ... you are asking for the cluster samples of a cluster candidate with no strips");
109
110 //steps:
111 //1.loop on m_strips
112 //2. access the index of the shaperdigit from the element of m_strip
113 //3. sum each sample for each strip accessed in the loop
114 //4. you are done
115
116 Belle2::SVDShaperDigit::APVFloatSamples returnSamples = {0, 0, 0, 0, 0, 0};
117
118 const StoreArray<SVDShaperDigit> m_storeShaperDigits(m_storeShaperDigitsName.c_str());
119
120 SVDPulseShapeCalibrations pulseShapeCal;
121
122 for (auto istrip : m_strips) {
123 const SVDShaperDigit* shaperdigit = m_storeShaperDigits[istrip.shaperDigitIndex];
124 if (!shaperdigit) B2ERROR("No SVDShaperDigit for this strip! Are you sure you set the correct SVDShaperDigit StoreArray name?");
125 Belle2::SVDShaperDigit::APVFloatSamples APVsamples = shaperdigit->getSamples();
126 for (int iSample = 0; iSample < static_cast<int>(APVsamples.size()); ++iSample)
127 if (inElectrons)
128 returnSamples.at(iSample) += pulseShapeCal.getChargeFromADC(m_vxdID, m_isUside, shaperdigit->getCellID(), APVsamples.at(iSample));
129 else
130 returnSamples.at(iSample) += APVsamples.at(iSample);
131 }
132
133
134 return returnSamples;
135 }
136
137 std::pair<int, std::vector<float>> RawCluster::getMaxSum3Samples(bool inElectrons) const
138 {
139
140 //take the cluster samples
142
143 SVDMaxSumAlgorithm maxSum = SVDMaxSumAlgorithm(clsSamples);
144 return std::make_pair(maxSum.getFirstFrame(), maxSum.getSelectedSamples());
145
146 }
147
148 } //SVD namespace
150} //Belle2 namespace
This class defines the dbobject and the methods to access the SVD calibrations from the local runs pr...
double getChargeFromADC(const Belle2::VxdID &sensorID, const bool &isU, const unsigned short &strip, const double &pulseADC) const
Return the charge (number of electrons/holes) collected on a specific strip, given the number of ADC ...
The SVD ShaperDigit class.
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
array of APVFloatSampleType objects
APVFloatSamples getSamples() const
Get array of samples.
short int getCellID() const
Get strip ID.
RawCluster()
Default Constructor to create an empty RawCluster.
Definition RawCluster.h:40
std::pair< int, std::vector< float > > getMaxSum3Samples(bool inElectrons=false) const
std::string m_storeShaperDigitsName
Name of the collection to use for the SVDShaperDigits.
Definition RawCluster.h:138
Belle2::SVDShaperDigit::APVFloatSamples getClsSamples(bool inElectrons) const
int m_seedInternalIndex
stripsInRawCluster index of the seed strip of the cluster
Definition RawCluster.h:159
bool add(VxdID vxdID, bool isUside, struct StripInRawCluster &aStrip)
Add a Strip to the current cluster.
Definition RawCluster.cc:54
bool m_isUside
side of the cluster
Definition RawCluster.h:165
VxdID m_vxdID
VxdID of the cluster.
Definition RawCluster.h:162
float m_seedSNR
SNR (using MaxSample) of the seed strip.
Definition RawCluster.h:150
int m_seedMaxSample
ADC MaxSample of the seed strip.
Definition RawCluster.h:153
double m_cutSeed
SNR above which the strip can be considered as seed.
Definition RawCluster.h:144
int m_seedIndex
SVDShaperDigit index of the seed strip of the cluster.
Definition RawCluster.h:156
std::vector< StripInRawCluster > m_strips
vector containing the strips in the cluster
Definition RawCluster.h:141
double m_cutAdjacent
SNR above which the strip can be considered for clustering.
Definition RawCluster.h:147
Class implementing the MaxSum algorithm.
std::vector< float > getSelectedSamples()
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:33
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Abstract base class for different kinds of events.
STL namespace.
structure containing the relevant information of each strip of the raw cluster
Definition RawCluster.h:20
int shaperDigitIndex
index of the shaper digit
Definition RawCluster.h:21
int maxSample
ADC max of the acquired samples.
Definition RawCluster.h:23