Belle II Software development
DATCONSVDDigit.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 <vxd/dataobjects/VxdID.h>
11
12#include <algorithm>
13#include <limits>
14
15namespace Belle2 {
31
32 public:
33
35 static const std::size_t c_nAPVSamples = 6;
36
38 typedef uint8_t APVRawSampleType;
40 typedef std::array<APVRawSampleType, c_nAPVSamples> APVRawSamples;
41
43 typedef float APVFloatSampleType;
45 typedef std::array<APVFloatSampleType, c_nAPVSamples> APVFloatSamples;
46
53 DATCONSVDDigit(VxdID sensorID, bool isU, short cellID, APVFloatSampleType samples[c_nAPVSamples]):
54 m_sensorID(sensorID), m_isU(isU), m_cellID(cellID), m_totalCharge(0), m_maxSampleIndex(0)
55 {
56 std::transform(samples, samples + c_nAPVSamples, m_samples.begin(),
57 [](APVFloatSampleType x)->APVRawSampleType { return trimToSampleRange(x); });
58 }
59
66 DATCONSVDDigit(VxdID sensorID, bool isU, short cellID, APVFloatSamples samples) :
67 m_sensorID(sensorID), m_isU(isU), m_cellID(cellID), m_totalCharge(0), m_maxSampleIndex(0)
68 {
69 std::transform(samples.begin(), samples.end(), m_samples.begin(),
70 [](typename APVFloatSamples::value_type x)->APVRawSampleType { return trimToSampleRange(x); });
71 }
72
74 VxdID getSensorID() const { return m_sensorID; }
75
78
80 bool isUStrip() const { return m_isU; }
81
83 short int getCellID() const { return m_cellID; }
84
87 {
88 APVFloatSamples returnSamples;
89 std::transform(m_samples.begin(), m_samples.end(), returnSamples.begin(),
90 [](APVRawSampleType x) { return static_cast<APVFloatSampleType>(x); });
91 return returnSamples;
92 }
93
96 {
97 return m_samples;
98 }
99
101 unsigned short getTotalCharge()
102 {
103 if (m_totalCharge > 0)
104 return m_totalCharge;
105 else {
106 m_totalCharge = 0;
107 for (unsigned int i = 0; i < c_nAPVSamples; i++) {
109 }
110 }
111 return m_totalCharge;
112 }
113
115 unsigned short getMaxSampleCharge() const
116 {
117 unsigned short maxCharge = 0;
118 for (unsigned int i = 0; i < c_nAPVSamples; i++) {
119 if (m_samples[i] > maxCharge) {
120 maxCharge = m_samples[i];
121 }
122 }
123 return maxCharge;
124 }
125
127 unsigned short getMaxSampleIndex()
128 {
129 if (m_maxSampleIndex > 0)
130 return m_maxSampleIndex;
131 else {
132 unsigned short maxCharge = 0;
133 for (unsigned int i = 0; i < c_nAPVSamples; i++) {
134 if (m_samples[i] > maxCharge) {
135 maxCharge = m_samples[i];
137 }
138 }
139 }
140 return m_maxSampleIndex;
141 }
142
149 {
150 T trimmedX = std::min(
151 static_cast<T>(std::numeric_limits<DATCONSVDDigit::APVRawSampleType>::max()),
152 std::max(
153 static_cast<T>(std::numeric_limits<DATCONSVDDigit::APVRawSampleType>::lowest()),
154 x));
155 return static_cast<DATCONSVDDigit::APVRawSampleType>(trimmedX);
156 }
157
158
160 void setSensorID(VxdID sensorid) { m_sensorID = sensorid; }
161
163 void setUStrip(bool isU) { m_isU = isU; }
164
166 void setCellID(short cellID) { m_cellID = cellID; }
167
169 void setAPVRawSamples(APVFloatSamples apvInputSamples)
170 {
171 // m_samples = apvSamples;
172 std::transform(apvInputSamples.begin(), apvInputSamples.end(), m_samples.begin(),
173 [](APVFloatSampleType x) { return static_cast<APVRawSampleType>(x); });
174 }
175
176 private:
177
179 bool m_isU;
180 short m_cellID;
182 unsigned short m_totalCharge;
183 unsigned short m_maxSampleIndex;
185 }; // class DATCONSVDDigit
186
188} // end namespace Belle2
The DATCONSVDDigit class.
static DATCONSVDDigit::APVRawSampleType trimToSampleRange(T x)
Convert a value to sample range.
unsigned short m_maxSampleIndex
Index of charge of sample max.
void setCellID(short cellID)
Setter for the stripID / cellID.
unsigned short getTotalCharge()
Getter for the total charge of the array in ADUs.
bool m_isU
True if U, false if V.
void setAPVRawSamples(APVFloatSamples apvInputSamples)
Setter for the raw samples array.
static const std::size_t c_nAPVSamples
Number of APV samples stored.
VxdID::baseType m_sensorID
Compressed sensor identifier.
unsigned short getMaxSampleIndex()
Getter for the index of the biggest sample inside the cluster (0...6)
unsigned short m_totalCharge
Total charge of this DATCONSVDDigit.
VxdID::baseType getRawSensorID() const
Getter for the raw sensor ID.
APVRawSamples getRawSamples() const
Get int-array of of 6 APV25 samples.
DATCONSVDDigit(VxdID sensorID, bool isU, short cellID, APVFloatSampleType samples[c_nAPVSamples])
Constructor using c-array of samples.
APVFloatSamples getFloatSamples() const
Get float-array of 6 APV25 samples.
std::array< APVRawSampleType, c_nAPVSamples > APVRawSamples
Type for array of samples received from DAQ.
uint8_t APVRawSampleType
Type of samples received from DAQ.
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
Types for array of samples for processing.
float APVFloatSampleType
Types of samples for processing.
void setSensorID(VxdID sensorid)
Setter for the sensorID.
short m_cellID
Strip coordinate in pitch units.
DATCONSVDDigit(VxdID sensorID, bool isU, short cellID, APVFloatSamples samples)
Constructor using a stl container of samples.
VxdID getSensorID() const
Getter for the sensor ID.
unsigned short getMaxSampleCharge() const
Getter for the charge of the biggest sample of the array in ADUs.
short int getCellID() const
Getter for the strip ID.
bool isUStrip() const
Getter for the strip direction (u or v)
APVRawSamples m_samples
6 APV signals from the strip.
void setUStrip(bool isU)
Setter for the strip direction (u or v).
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
unsigned short baseType
The base integer type for VxdID.
Definition: VxdID.h:36
Abstract base class for different kinds of events.