Belle II Software development
TOPDigit.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/dataobjects/DigitBase.h>
12
13namespace Belle2 {
24 class TOPDigit : public DigitBase {
25 public:
26
34 c_Junk = 0, // invalid feature extraction, pedestal jump, width too narrow/too wide
35 c_Good = 1, // good photon hit
36 c_CrossTalk = 3, // cross-talk
37 c_CalPulse = 4, // calibration pulse
38 c_Uncalibrated = 5, // good photon hit, but no time-base or channel T0 calibration
39 c_Masked = 6 // good photon hit, but channel is masked as dead or hot
40 };
41
46 c_TimeBaseCalibrated = 1,
47 c_ChannelT0Calibrated = 2,
48 c_ModuleT0Calibrated = 4,
49 c_CommonT0Calibrated = 8,
50 c_FullyCalibrated = c_TimeBaseCalibrated | c_ChannelT0Calibrated | c_ModuleT0Calibrated | c_CommonT0Calibrated,
51 c_OffsetSubtracted = 16, // offset used in MC
52 c_EventT0Subtracted = 32,
53 c_BunchOffsetSubtracted = 64, // reconstructed average bunch offset
54 };
55
62 };
63
68 {}
69
76 TOPDigit(int moduleID, int pixelID, double rawTime):
77 m_moduleID(moduleID),
78 m_pixelID(pixelID),
79 m_rawTime(rawTime),
80 m_quality(c_Good)
81 {}
82
87 static void setDoubleHitResolution(double time) {s_doubleHitResolution = time;}
88
93 static void setPileupTime(double time) {s_pileupTime = time;}
94
99 void setModuleID(int moduleID) {m_moduleID = moduleID;}
100
105 void setPixelID(int pixelID) {m_pixelID = pixelID;}
106
111 void setChannel(unsigned int channel) {m_channel = channel;}
112
117 void setRawTime(double rawTime) {m_rawTime = rawTime;}
118
123 void setTime(double time) {m_time = time;}
124
129 void setTimeError(double timeError) {m_timeError = timeError;}
130
135 void setPulseHeight(int pulseHeight) {m_pulseHeight = pulseHeight;}
136
141 void setPulseWidth(double width) {m_pulseWidth = width;}
142
147 void setIntegral(int integral) {m_integral = integral;}
148
153 void setFirstWindow(unsigned window) { m_firstWindow = window;}
154
159 void setHitQuality(EHitQuality quality) {m_quality = quality;}
160
164 void setStatus(unsigned short status) { m_status = status; }
165
169 void addStatus(unsigned short bitmask) { m_status |= bitmask; }
170
174 void removeStatus(unsigned short bitmask) { m_status &= (~bitmask); }
175
180
185
190
195 void subtractT0(double t0) { m_time -= t0;}
196
202
207 unsigned short getStatus() const {return m_status;}
208
213 bool hasStatus(unsigned short bitmask) const
214 {
215 return (m_status & bitmask) == bitmask;
216 }
217
222 bool isCalibrated() const {return hasStatus(c_FullyCalibrated);}
223
228 bool isTimeBaseCalibrated() const {return hasStatus(c_TimeBaseCalibrated);}
229
234 bool isChannelT0Calibrated() const {return hasStatus(c_ChannelT0Calibrated);}
235
240 bool isModuleT0Calibrated() const {return hasStatus(c_ModuleT0Calibrated);}
241
246 bool isCommonT0Calibrated() const {return hasStatus(c_CommonT0Calibrated);}
247
252 bool isChargeShare() const {return m_chargeShare != 0;}
253
259
265
270 int getModuleID() const { return m_moduleID; }
271
276 int getPixelID() const { return m_pixelID; }
277
282 int getPixelRow() const { return (m_pixelID - 1) / 64 + 1;}
283
288 int getPixelCol() const { return (m_pixelID - 1) % 64 + 1;}
289
294 int getPMTRow() const {return (getPixelRow() - 1) / 4 + 1;}
295
300 int getPMTCol() const {return (getPixelCol() - 1) / 4 + 1;}
301
306 int getPMTNumber() const {return getPMTCol() + (getPMTRow() - 1) * 16;}
307
312 int getPMTPixelRow() const {return (getPixelRow() - 1) % 4 + 1;}
313
318 int getPMTPixelCol() const {return (getPixelCol() - 1) % 4 + 1;}
319
324 int getPMTPixel() const {return getPMTPixelCol() + (getPMTPixelRow() - 1) * 4;}
325
330 unsigned int getChannel() const { return m_channel; }
331
336 unsigned int getASICChannel() const {return m_channel & 0x07;}
337
342 unsigned int getASICNumber() const {return (m_channel >> 3) & 0x03;}
343
348 unsigned int getCarrierNumber() const {return (m_channel >> 5) & 0x03;}
349
354 unsigned int getBoardstackNumber() const {return (m_channel >> 7) & 0x03;}
355
360 double getRawTime() const { return m_rawTime; }
361
366 int getModulo256Sample() const;
367
372 double getTime() const { return m_time; }
373
378 double getTimeError() const {return m_timeError;}
379
384 int getPulseHeight() const { return m_pulseHeight; }
385
390 double getPulseWidth() const { return m_pulseWidth; }
391
396 int getIntegral() const {return m_integral;}
397
402 unsigned getFirstWindow() const { return m_firstWindow;}
403
409 unsigned int getUniqueChannelID() const override {return m_pixelID + (m_moduleID << 16);}
410
418
419
420 private:
421 int m_moduleID = 0;
422 int m_pixelID = 0;
423 unsigned m_channel = 0;
424 float m_rawTime = 0;
425 float m_time = 0;
426 float m_timeError = 0;
428 float m_pulseWidth = 0;
429 int m_integral = 0;
430 unsigned short m_firstWindow = 0;
432 unsigned short m_status = 0;
433 unsigned short m_chargeShare = 0;
436 static float s_pileupTime;
440 };
441
442
444} // end namespace Belle2
445
A common base for subdetector Digits.
Definition: DigitBase.h:26
EAppendStatus
Enum for return state of addBGDigit function.
Definition: DigitBase.h:32
Class to store TOP digitized hits (output of TOPDigitizer or raw data unpacker) relations to TOPSimHi...
Definition: TOPDigit.h:24
float m_time
calibrated time in [ns], t0-subtracted
Definition: TOPDigit.h:425
EHitQuality getHitQuality() const
Returns hit quality.
Definition: TOPDigit.h:201
unsigned short m_status
calibration status bits
Definition: TOPDigit.h:432
void setIntegral(int integral)
Sets pulse integral.
Definition: TOPDigit.h:147
static void setDoubleHitResolution(double time)
Sets double hit resolution.
Definition: TOPDigit.h:87
static void setPileupTime(double time)
Sets pile-up time.
Definition: TOPDigit.h:93
void setRawTime(double rawTime)
Sets raw detection time.
Definition: TOPDigit.h:117
float m_rawTime
raw time expressed in samples (TDC bins)
Definition: TOPDigit.h:424
int getPMTNumber() const
Returns PMT number (1-based)
Definition: TOPDigit.h:306
bool isSecondaryChargeShare() const
Returns charge share status.
Definition: TOPDigit.h:264
unsigned int getASICNumber() const
Returns ASIC number.
Definition: TOPDigit.h:342
int m_integral
pulse integral [ADC counts]
Definition: TOPDigit.h:429
void setModuleID(int moduleID)
Sets module ID.
Definition: TOPDigit.h:99
unsigned m_channel
hardware channel number (0-based)
Definition: TOPDigit.h:423
ClassDefOverride(TOPDigit, 15)
ClassDef.
double getTimeError() const
Returns calibrated time uncertainty.
Definition: TOPDigit.h:378
int getPMTPixelCol() const
Returns PMT pixel column number (1-based)
Definition: TOPDigit.h:318
int getPMTRow() const
Returns PMT row number (1-based)
Definition: TOPDigit.h:294
bool isModuleT0Calibrated() const
Returns calibration status.
Definition: TOPDigit.h:240
void resetChargeShare()
Remove charge share flag.
Definition: TOPDigit.h:189
int getPixelCol() const
Returns pixel column number (1-based)
Definition: TOPDigit.h:288
void setTime(double time)
Sets calibrated detection time.
Definition: TOPDigit.h:123
EHitQuality
hit quality enumerators
Definition: TOPDigit.h:33
TOPDigit()
Default constructor.
Definition: TOPDigit.h:67
unsigned short m_chargeShare
charge sharing flags
Definition: TOPDigit.h:433
int getPixelID() const
Returns pixel ID (1-based)
Definition: TOPDigit.h:276
unsigned int getChannel() const
Returns hardware channel number.
Definition: TOPDigit.h:330
void setPrimaryChargeShare()
Sets primary charge share flag.
Definition: TOPDigit.h:179
int m_moduleID
module ID (1-based)
Definition: TOPDigit.h:421
EStatusBits
calibration status enumerators
Definition: TOPDigit.h:45
float m_pulseWidth
pulse width (FWHM) in [ns]
Definition: TOPDigit.h:428
int getModuleID() const
Returns module ID.
Definition: TOPDigit.h:270
int getPMTPixelRow() const
Returns PMT pixel row number (1-based)
Definition: TOPDigit.h:312
unsigned int getUniqueChannelID() const override
Implementation of the base class function.
Definition: TOPDigit.h:409
int getPMTPixel() const
Returns PMT pixel number (1-based)
Definition: TOPDigit.h:324
int getPixelRow() const
Returns pixel row number (1-based)
Definition: TOPDigit.h:282
bool isPrimaryChargeShare() const
Returns charge share status.
Definition: TOPDigit.h:258
int getPMTCol() const
Returns PMT column number (1-based)
Definition: TOPDigit.h:300
void setFirstWindow(unsigned window)
Sets first ASIC window number of the merged waveform this hit is taken from.
Definition: TOPDigit.h:153
void addStatus(unsigned short bitmask)
Add calibration status.
Definition: TOPDigit.h:169
void setTimeError(double timeError)
Sets calibrated time uncertainty.
Definition: TOPDigit.h:129
void setPixelID(int pixelID)
Sets pixel ID.
Definition: TOPDigit.h:105
TOPDigit(int moduleID, int pixelID, double rawTime)
Usefull constructor.
Definition: TOPDigit.h:76
unsigned short m_firstWindow
first ASIC window of the merged waveform
Definition: TOPDigit.h:430
int m_pulseHeight
pulse height [ADC counts]
Definition: TOPDigit.h:427
double getPulseWidth() const
Returns pulse width.
Definition: TOPDigit.h:390
void setPulseHeight(int pulseHeight)
Sets pulse height.
Definition: TOPDigit.h:135
int getIntegral() const
Returns pulse integral.
Definition: TOPDigit.h:396
unsigned short getStatus() const
Returns calibration status bits.
Definition: TOPDigit.h:207
unsigned int getASICChannel() const
Returns ASIC channel number.
Definition: TOPDigit.h:336
int getPulseHeight() const
Returns pulse height.
Definition: TOPDigit.h:384
bool isCalibrated() const
Returns calibration status.
Definition: TOPDigit.h:222
unsigned int getBoardstackNumber() const
Returns boardstack number.
Definition: TOPDigit.h:354
unsigned int getCarrierNumber() const
Returns carrier board number.
Definition: TOPDigit.h:348
bool isChannelT0Calibrated() const
Returns calibration status.
Definition: TOPDigit.h:234
double getRawTime() const
Returns raw detection time.
Definition: TOPDigit.h:360
unsigned getFirstWindow() const
Returns first ASIC window number of the merged waveform this hit is taken from.
Definition: TOPDigit.h:402
float m_timeError
time uncertainty (r.m.s) in [ns]
Definition: TOPDigit.h:426
void setHitQuality(EHitQuality quality)
Sets hit quality flag.
Definition: TOPDigit.h:159
void setPulseWidth(double width)
Sets pulse width.
Definition: TOPDigit.h:141
bool isCommonT0Calibrated() const
Returns calibration status.
Definition: TOPDigit.h:246
void setChannel(unsigned int channel)
Sets hardware channel number (0-based)
Definition: TOPDigit.h:111
EHitQuality m_quality
hit quality
Definition: TOPDigit.h:431
bool hasStatus(unsigned short bitmask) const
Returns calibration status.
Definition: TOPDigit.h:213
void removeStatus(unsigned short bitmask)
Remove calibration status.
Definition: TOPDigit.h:174
bool isTimeBaseCalibrated() const
Returns calibration status.
Definition: TOPDigit.h:228
bool isChargeShare() const
Returns charge share status.
Definition: TOPDigit.h:252
void setStatus(unsigned short status)
Sets calibration status (overwrites previously set bits)
Definition: TOPDigit.h:164
void setSecondaryChargeShare()
Sets secondary charge share flag.
Definition: TOPDigit.h:184
int m_pixelID
software channel ID (1-based)
Definition: TOPDigit.h:422
EChargeShare
charge sharing enumerators
Definition: TOPDigit.h:59
@ c_PrimaryChargeShare
the largest one among hits sharing the same charge
Definition: TOPDigit.h:60
@ c_SecondaryChargeShare
others sharing the same charge
Definition: TOPDigit.h:61
double getTime() const
Returns t0-subtracted and calibrated time.
Definition: TOPDigit.h:372
void subtractT0(double t0)
Subtract start time from m_time.
Definition: TOPDigit.h:195
static float s_doubleHitResolution
double hit resolving time in [ns]
Definition: TOPDigit.h:435
DigitBase::EAppendStatus addBGDigit(const DigitBase *bg) override
Implementation of the base class function.
Definition: TOPDigit.cc:36
int getModulo256Sample() const
Returns sample number modulo 256.
Definition: TOPDigit.cc:26
static float s_pileupTime
pile-up time in [ns]
Definition: TOPDigit.h:436
Abstract base class for different kinds of events.