Belle II Software development
TOPRawWaveform.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 <framework/datastore/RelationsObject.h>
12#include <vector>
13#include <algorithm>
14
15namespace Belle2 {
25 public:
26
30 enum {c_WindowSize = 64
31 };
32
37 int sampleRise = 0;
38 int samplePeak = 0;
39 int sampleFall = 0;
40 short vRise0 = 0;
41 short vRise1 = 0;
42 short vPeak = 0;
43 short vFall0 = 0;
44 short vFall1 = 0;
45 int integral = 0;
46 };
47
48
53 {}
54
55
66 TOPRawWaveform(int moduleID,
67 int pixelID,
68 unsigned channel,
69 unsigned scrodID,
70 unsigned window,
71 int startSample,
72 const std::vector<short>& data):
73 m_moduleID(moduleID), m_pixelID(pixelID), m_channel(channel), m_scrodID(scrodID),
74 m_window(window), m_startSample(startSample), m_data(data),
75 m_physicalWindow(window)
76 {}
77
82
86 void setPhysicalWindow(unsigned window) {m_physicalWindow = window;}
87
91 void setLastWriteAddr(unsigned lastWriteAddr) {m_lastWriteAddr = lastWriteAddr;}
92
96 void setStorageWindows(const std::vector<unsigned short>& windows)
97 {
98 m_windows = windows;
99 }
100
105 void setRevo9Counter(unsigned short revo9Counter) {m_revo9Counter = revo9Counter;}
106
111 void setOffsetWindows(int offsetWindows) {m_offsetWindows = offsetWindows;}
112
117 int getModuleID() const { return m_moduleID; }
118
123 int getPixelID() const { return m_pixelID; }
124
129 unsigned getChannel() const { return m_channel; }
130
135 unsigned getScrodID() const { return m_scrodID; }
136
141 unsigned getStorageWindow() const { return m_window; }
142
147 int getStartSample() const { return m_startSample;}
148
154
159 unsigned getPhysicalWindow() const {return m_physicalWindow;}
160
167 unsigned getReferenceWindow() const { return m_lastWriteAddr; }
168
173 const std::vector<unsigned short>& getStorageWindows() const { return m_windows; }
174
179 unsigned short getRevo9Counter() const {return m_revo9Counter;}
180
185 int getOffsetWindows() const {return m_offsetWindows;}
186
191 unsigned getASICChannel() const {return m_channel & 0x07;}
192
197 unsigned getASICNumber() const {return (m_channel >> 3) & 0x03;}
198
203 unsigned getCarrierNumber() const {return (m_channel >> 5) & 0x03;}
204
209 unsigned getBoardstackNumber() const {return (m_channel >> 7) & 0x03;}
210
215 unsigned getSize() const {return m_data.size();}
216
221 const std::vector<short>& getWaveform() const
222 {
223 return m_data;
224 }
225
233 bool areWindowsInOrder(unsigned lastSample = 0xFFFFFFFF,
234 unsigned short storageDepth = 508) const
235 {
236 unsigned last = lastSample / c_WindowSize + 1;
237 unsigned size = m_windows.size();
238 for (unsigned i = 1; i < std::min(last, size); i++) {
239 int diff = m_windows[i] - m_windows[i - 1];
240 if (diff < 0) diff += storageDepth;
241 if (diff != 1) return false;
242 }
243 return true;
244 }
245
253 int getIntegral(int sampleRise, int samplePeak, int sampleFall) const;
254
262 int featureExtraction(int threshold, int hysteresis, int thresholdCount) const;
263
268 const std::vector<FeatureExtraction>& getFeatureExtractionData() const
269 {
270 return m_features;
271 }
272
273
274 private:
275
283 int Integral(int sampleRise, int samplePeak, int sampleFall) const;
284
285 int m_moduleID = 0;
286 int m_pixelID = 0;
287 unsigned m_channel = 0;
288 unsigned short m_scrodID = 0;
289 unsigned short m_window = 0;
291 std::vector<short> m_data;
292 bool m_pedestalSubtracted = false;
294 unsigned short m_physicalWindow = 0;
295 unsigned short m_lastWriteAddr = 0;
296 std::vector<unsigned short> m_windows;
298 unsigned short m_revo9Counter = 0;
302 mutable std::vector<FeatureExtraction> m_features;
303
306 };
307
308
310} // end namespace Belle2
Defines interface for accessing relations of objects in StoreArray.
Class to store raw data waveforms.
unsigned short m_scrodID
SCROD ID.
unsigned getASICNumber() const
Returns ASIC number.
unsigned getCarrierNumber() const
Returns carrier board number.
void setRevo9Counter(unsigned short revo9Counter)
Sets number of global clock tics since last revo9 flag.
std::vector< unsigned short > m_windows
storage windows of waveform segments
int getOffsetWindows() const
Returns number of windows before the "first one" which defines the time origin.
unsigned short m_physicalWindow
hardware physical window number
unsigned short getRevo9Counter() const
Returns 127 MHz clock ticks since last revo9 marker.
unsigned short m_revo9Counter
number of clock ticks since last revo9 flag
unsigned m_channel
hardware channel number
const std::vector< unsigned short > & getStorageWindows() const
Returns storage window numbers of waveform segments.
@ c_WindowSize
number of samples per ASIC window
int m_startSample
sample number of the first waveform sample
void setLastWriteAddr(unsigned lastWriteAddr)
Sets current (reference) window number.
unsigned getSize() const
Returns waveform size.
TOPRawWaveform()
Default constructor.
int getPixelID() const
Returns pixel ID (1-based)
unsigned short m_lastWriteAddr
current (reference) window number
const std::vector< short > & getWaveform() const
Returns waveform.
int m_offsetWindows
number of offset windows (windows before "first one")
bool areWindowsInOrder(unsigned lastSample=0xFFFFFFFF, unsigned short storageDepth=508) const
Checks if storage windows come in the consecutive order before the last sample (no gaps in between be...
int getModuleID() const
Returns module ID.
void setPedestalSubtractedFlag(bool value)
Sets pedestal subtracted flag.
unsigned getASICChannel() const
Returns ASIC channel number.
void setStorageWindows(const std::vector< unsigned short > &windows)
Sets storage window numbers.
int getStartSample() const
Returns sample number of the first waveform sample.
bool isPedestalSubtracted() const
Tells whether pedestal already subtracted or not.
unsigned getChannel() const
Returns hardware channel number (0-based)
unsigned getBoardstackNumber() const
Returns boardstack number.
unsigned getStorageWindow() const
Returns hardware logic window number (storage window)
unsigned getScrodID() const
Returns SCROD ID.
void setPhysicalWindow(unsigned window)
Sets hardware physical window number.
unsigned short m_window
hardware logic window number (storage window)
std::vector< short > m_data
waveform ADC values
unsigned getReferenceWindow() const
Returns IRS reference analog storage window (last write address).
std::vector< FeatureExtraction > m_features
cache for feature extraction data
ClassDef(TOPRawWaveform, 9)
ClassDef.
unsigned getPhysicalWindow() const
Returns hardware physical window number.
bool m_pedestalSubtracted
true, if pedestals already subtracted
const std::vector< FeatureExtraction > & getFeatureExtractionData() const
Returns feature extraction data.
void setOffsetWindows(int offsetWindows)
Sets number of offset windows (windows before "first one") - MC only.
int m_pixelID
software channel ID
TOPRawWaveform(int moduleID, int pixelID, unsigned channel, unsigned scrodID, unsigned window, int startSample, const std::vector< short > &data)
Useful constructor.
int getIntegral(int sampleRise, int samplePeak, int sampleFall) const
Returns integral of a peak.
int Integral(int sampleRise, int samplePeak, int sampleFall) const
Returns integral of a peak.
int featureExtraction(int threshold, int hysteresis, int thresholdCount) const
Do feature extraction.
Abstract base class for different kinds of events.
short vFall0
ADC value at sampleFall.
short vRise1
ADC value at sampleRise + 1.
short vRise0
ADC value at sampleRise.
short vPeak
ADC value at samplePeak.
int integral
integral of a pulse (proportional to charge)
int samplePeak
sample number at maximum
int sampleRise
sample number just before 50% CFD crossing
short vFall1
ADC value at sampleFall + 1.