Belle II Software  release-05-02-19
TOPDigit.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Petric, Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/dataobjects/DigitBase.h>
14 
15 namespace Belle2 {
26  class TOPDigit : public DigitBase {
27  public:
28 
35  enum EHitQuality {
36  c_Junk = 0, // invalid feature extraction, pedestal jump, width too narrow/too wide
37  c_Good = 1, // good photon hit
38  c_CrossTalk = 3, // cross-talk
39  c_CalPulse = 4, // calibration pulse
40  c_Uncalibrated = 5, // good photon hit, but no time-base or channel T0 calibration
41  c_Masked = 6 // good photon hit, but channel is masked as dead or hot
42  };
43 
47  enum EStatusBits {
48  c_TimeBaseCalibrated = 1,
49  c_ChannelT0Calibrated = 2,
50  c_ModuleT0Calibrated = 4,
51  c_CommonT0Calibrated = 8,
52  c_FullyCalibrated = c_TimeBaseCalibrated | c_ChannelT0Calibrated | c_ModuleT0Calibrated | c_CommonT0Calibrated,
53  c_OffsetSubtracted = 16, // offset used in MC
54  c_EventT0Subtracted = 32,
55  c_BunchOffsetSubtracted = 64, // reconstructed average bunch offset
56  };
57 
61  enum EChargeShare {
64  };
65 
70  {}
71 
78  TOPDigit(int moduleID, int pixelID, double rawTime):
79  m_moduleID(moduleID),
80  m_pixelID(pixelID),
81  m_rawTime(rawTime),
82  m_quality(c_Good)
83  {}
84 
89  static void setDoubleHitResolution(double time) {s_doubleHitResolution = time;}
90 
95  static void setPileupTime(double time) {s_pileupTime = time;}
96 
101  void setModuleID(int moduleID) {m_moduleID = moduleID;}
102 
107  void setPixelID(int pixelID) {m_pixelID = pixelID;}
108 
113  void setChannel(unsigned int channel) {m_channel = channel;}
114 
119  void setRawTime(double rawTime) {m_rawTime = rawTime;}
120 
125  void setTime(double time) {m_time = time;}
126 
131  void setTimeError(double timeError) {m_timeError = timeError;}
132 
137  void setPulseHeight(int pulseHeight) {m_pulseHeight = pulseHeight;}
138 
143  void setPulseWidth(double width) {m_pulseWidth = width;}
144 
149  void setIntegral(int integral) {m_integral = integral;}
150 
155  void setFirstWindow(unsigned window) { m_firstWindow = window;}
156 
161  void setHitQuality(EHitQuality quality) {m_quality = quality;}
162 
166  void setStatus(unsigned short status) { m_status = status; }
167 
171  void addStatus(unsigned short bitmask) { m_status |= bitmask; }
172 
176  void removeStatus(unsigned short bitmask) { m_status &= (~bitmask); }
177 
182 
187 
191  void resetChargeShare() {m_chargeShare = 0;}
192 
197  void subtractT0(double t0) { m_time -= t0;}
198 
203  EHitQuality getHitQuality() const {return m_quality; }
204 
209  unsigned short getStatus() const {return m_status;}
210 
215  bool hasStatus(unsigned short bitmask) const
216  {
217  return (m_status & bitmask) == bitmask;
218  }
219 
224  bool isCalibrated() const {return hasStatus(c_FullyCalibrated);}
225 
230  bool isTimeBaseCalibrated() const {return hasStatus(c_TimeBaseCalibrated);}
231 
236  bool isChannelT0Calibrated() const {return hasStatus(c_ChannelT0Calibrated);}
237 
242  bool isModuleT0Calibrated() const {return hasStatus(c_ModuleT0Calibrated);}
243 
248  bool isCommonT0Calibrated() const {return hasStatus(c_CommonT0Calibrated);}
249 
254  bool isChargeShare() const {return m_chargeShare != 0;}
255 
261 
267 
272  int getModuleID() const { return m_moduleID; }
273 
278  int getPixelID() const { return m_pixelID; }
279 
284  int getPixelRow() const { return (m_pixelID - 1) / 64 + 1;}
285 
290  int getPixelCol() const { return (m_pixelID - 1) % 64 + 1;}
291 
296  int getPMTRow() const {return (getPixelRow() - 1) / 4 + 1;}
297 
302  int getPMTCol() const {return (getPixelCol() - 1) / 4 + 1;}
303 
308  int getPMTNumber() const {return getPMTCol() + (getPMTRow() - 1) * 16;}
309 
314  int getPMTPixelRow() const {return (getPixelRow() - 1) % 4 + 1;}
315 
320  int getPMTPixelCol() const {return (getPixelCol() - 1) % 4 + 1;}
321 
326  int getPMTPixel() const {return getPMTPixelCol() + (getPMTPixelRow() - 1) * 4;}
327 
332  unsigned int getChannel() const { return m_channel; }
333 
338  unsigned int getASICChannel() const {return m_channel & 0x07;}
339 
344  unsigned int getASICNumber() const {return (m_channel >> 3) & 0x03;}
345 
350  unsigned int getCarrierNumber() const {return (m_channel >> 5) & 0x03;}
351 
356  unsigned int getBoardstackNumber() const {return (m_channel >> 7) & 0x03;}
357 
362  double getRawTime() const { return m_rawTime; }
363 
368  int getModulo256Sample() const;
369 
374  double getTime() const { return m_time; }
375 
380  double getTimeError() const {return m_timeError;}
381 
386  int getPulseHeight() const { return m_pulseHeight; }
387 
392  double getPulseWidth() const { return m_pulseWidth; }
393 
398  int getIntegral() const {return m_integral;}
399 
404  unsigned getFirstWindow() const { return m_firstWindow;}
405 
411  unsigned int getUniqueChannelID() const override {return m_pixelID + (m_moduleID << 16);}
412 
420 
421 
422  private:
423  int m_moduleID = 0;
424  int m_pixelID = 0;
425  unsigned m_channel = 0;
426  float m_rawTime = 0;
427  float m_time = 0;
428  float m_timeError = 0;
429  int m_pulseHeight = 0;
430  float m_pulseWidth = 0;
431  int m_integral = 0;
432  unsigned short m_firstWindow = 0;
434  unsigned short m_status = 0;
435  unsigned short m_chargeShare = 0;
437  static float s_doubleHitResolution;
438  static float s_pileupTime;
442  };
443 
444 
446 } // end namespace Belle2
447 
Belle2::TOPDigit::s_doubleHitResolution
static float s_doubleHitResolution
double hit resolving time in [ns]
Definition: TOPDigit.h:445
Belle2::TOPDigit::m_pulseHeight
int m_pulseHeight
pulse height [ADC counts]
Definition: TOPDigit.h:437
Belle2::TOPDigit::hasStatus
bool hasStatus(unsigned short bitmask) const
Returns calibration status.
Definition: TOPDigit.h:223
Belle2::TOPDigit::m_pixelID
int m_pixelID
software channel ID (1-based)
Definition: TOPDigit.h:432
Belle2::DigitBase::EAppendStatus
EAppendStatus
Enum for return state of addBGDigit function.
Definition: DigitBase.h:42
Belle2::TOPDigit::setHitQuality
void setHitQuality(EHitQuality quality)
Sets hit quality flag.
Definition: TOPDigit.h:169
Belle2::TOPDigit::resetChargeShare
void resetChargeShare()
Remove charge share flag.
Definition: TOPDigit.h:199
Belle2::TOPDigit::setSecondaryChargeShare
void setSecondaryChargeShare()
Sets secondary charge share flag.
Definition: TOPDigit.h:194
Belle2::TOPDigit::getPMTNumber
int getPMTNumber() const
Returns PMT number (1-based)
Definition: TOPDigit.h:316
Belle2::TOPDigit::m_status
unsigned short m_status
calibration status bits
Definition: TOPDigit.h:442
Belle2::TOPDigit::m_moduleID
int m_moduleID
module ID (1-based)
Definition: TOPDigit.h:431
Belle2::TOPDigit::EChargeShare
EChargeShare
charge sharing enumerators
Definition: TOPDigit.h:69
Belle2::TOPDigit::m_chargeShare
unsigned short m_chargeShare
charge sharing flags
Definition: TOPDigit.h:443
Belle2::TOPDigit::setStatus
void setStatus(unsigned short status)
Sets calibration status (overwrites previously set bits)
Definition: TOPDigit.h:174
Belle2::TOPDigit::EStatusBits
EStatusBits
calibration status enumerators
Definition: TOPDigit.h:55
Belle2::TOPDigit::setModuleID
void setModuleID(int moduleID)
Sets module ID.
Definition: TOPDigit.h:109
Belle2::TOPDigit::getRawTime
double getRawTime() const
Returns raw detection time.
Definition: TOPDigit.h:370
Belle2::TOPDigit::c_SecondaryChargeShare
@ c_SecondaryChargeShare
others sharing the same charge
Definition: TOPDigit.h:71
Belle2::TOPDigit::setPileupTime
static void setPileupTime(double time)
Sets pile-up time.
Definition: TOPDigit.h:103
Belle2::TOPDigit::getHitQuality
EHitQuality getHitQuality() const
Returns hit quality.
Definition: TOPDigit.h:211
Belle2::TOPDigit::isChannelT0Calibrated
bool isChannelT0Calibrated() const
Returns calibration status.
Definition: TOPDigit.h:244
Belle2::TOPDigit::s_pileupTime
static float s_pileupTime
pile-up time in [ns]
Definition: TOPDigit.h:446
Belle2::TOPDigit::m_quality
EHitQuality m_quality
hit quality
Definition: TOPDigit.h:441
Belle2::TOPDigit::c_PrimaryChargeShare
@ c_PrimaryChargeShare
the largest one among hits sharing the same charge
Definition: TOPDigit.h:70
Belle2::TOPDigit::getASICNumber
unsigned int getASICNumber() const
Returns ASIC number.
Definition: TOPDigit.h:352
Belle2::TOPDigit::isTimeBaseCalibrated
bool isTimeBaseCalibrated() const
Returns calibration status.
Definition: TOPDigit.h:238
Belle2::TOPDigit::m_firstWindow
unsigned short m_firstWindow
first ASIC window of the merged waveform
Definition: TOPDigit.h:440
Belle2::TOPDigit::getPMTPixel
int getPMTPixel() const
Returns PMT pixel number (1-based)
Definition: TOPDigit.h:334
Belle2::TOPDigit::getPixelRow
int getPixelRow() const
Returns pixel row number (1-based)
Definition: TOPDigit.h:292
Belle2::TOPDigit::isCommonT0Calibrated
bool isCommonT0Calibrated() const
Returns calibration status.
Definition: TOPDigit.h:256
Belle2::TOPDigit::getStatus
unsigned short getStatus() const
Returns calibration status bits.
Definition: TOPDigit.h:217
Belle2::TOPDigit::getChannel
unsigned int getChannel() const
Returns hardware channel number.
Definition: TOPDigit.h:340
Belle2::TOPDigit::m_pulseWidth
float m_pulseWidth
pulse width (FWHM) in [ns]
Definition: TOPDigit.h:438
Belle2::TOPDigit::ClassDefOverride
ClassDefOverride(TOPDigit, 15)
ClassDef.
Belle2::TOPDigit::getFirstWindow
unsigned getFirstWindow() const
Returns first ASIC window number of the merged waveform this hit is taken from.
Definition: TOPDigit.h:412
Belle2::TOPDigit
Class to store TOP digitized hits (output of TOPDigitizer or raw data unpacker) relations to TOPSimHi...
Definition: TOPDigit.h:34
Belle2::TOPDigit::getPixelID
int getPixelID() const
Returns pixel ID (1-based)
Definition: TOPDigit.h:286
Belle2::TOPDigit::m_timeError
float m_timeError
time uncertainty (r.m.s) in [ns]
Definition: TOPDigit.h:436
Belle2::TOPDigit::setTime
void setTime(double time)
Sets calibrated detection time.
Definition: TOPDigit.h:133
Belle2::TOPDigit::setRawTime
void setRawTime(double rawTime)
Sets raw detection time.
Definition: TOPDigit.h:127
Belle2::TOPDigit::m_time
float m_time
calibrated time in [ns], t0-subtracted
Definition: TOPDigit.h:435
Belle2::TOPDigit::m_channel
unsigned m_channel
hardware channel number (0-based)
Definition: TOPDigit.h:433
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOPDigit::setPrimaryChargeShare
void setPrimaryChargeShare()
Sets primary charge share flag.
Definition: TOPDigit.h:189
Belle2::TOPDigit::getPulseHeight
int getPulseHeight() const
Returns pulse height.
Definition: TOPDigit.h:394
Belle2::TOPDigit::removeStatus
void removeStatus(unsigned short bitmask)
Remove calibration status.
Definition: TOPDigit.h:184
Belle2::TOPDigit::getASICChannel
unsigned int getASICChannel() const
Returns ASIC channel number.
Definition: TOPDigit.h:346
Belle2::TOPDigit::setPulseHeight
void setPulseHeight(int pulseHeight)
Sets pulse height.
Definition: TOPDigit.h:145
Belle2::TOPDigit::setFirstWindow
void setFirstWindow(unsigned window)
Sets first ASIC window number of the merged waveform this hit is taken from.
Definition: TOPDigit.h:163
Belle2::TOPDigit::getTime
double getTime() const
Returns t0-subtracted and calibrated time.
Definition: TOPDigit.h:382
Belle2::TOPDigit::getTimeError
double getTimeError() const
Returns calibrated time uncertainty.
Definition: TOPDigit.h:388
Belle2::TOPDigit::getPMTPixelCol
int getPMTPixelCol() const
Returns PMT pixel column number (1-based)
Definition: TOPDigit.h:328
Belle2::TOPDigit::getPMTRow
int getPMTRow() const
Returns PMT row number (1-based)
Definition: TOPDigit.h:304
Belle2::TOPDigit::getPixelCol
int getPixelCol() const
Returns pixel column number (1-based)
Definition: TOPDigit.h:298
Belle2::TOPDigit::getModulo256Sample
int getModulo256Sample() const
Returns sample number modulo 256.
Definition: TOPDigit.cc:28
Belle2::TOPDigit::subtractT0
void subtractT0(double t0)
Subtract start time from m_time.
Definition: TOPDigit.h:205
Belle2::TOPDigit::setTimeError
void setTimeError(double timeError)
Sets calibrated time uncertainty.
Definition: TOPDigit.h:139
Belle2::TOPDigit::setDoubleHitResolution
static void setDoubleHitResolution(double time)
Sets double hit resolution.
Definition: TOPDigit.h:97
Belle2::TOPDigit::isCalibrated
bool isCalibrated() const
Returns calibration status.
Definition: TOPDigit.h:232
Belle2::TOPDigit::isModuleT0Calibrated
bool isModuleT0Calibrated() const
Returns calibration status.
Definition: TOPDigit.h:250
Belle2::TOPDigit::setIntegral
void setIntegral(int integral)
Sets pulse integral.
Definition: TOPDigit.h:157
Belle2::TOPDigit::setPixelID
void setPixelID(int pixelID)
Sets pixel ID.
Definition: TOPDigit.h:115
Belle2::TOPDigit::getPMTPixelRow
int getPMTPixelRow() const
Returns PMT pixel row number (1-based)
Definition: TOPDigit.h:322
Belle2::TOPDigit::m_integral
int m_integral
pulse integral [ADC counts]
Definition: TOPDigit.h:439
Belle2::TOPDigit::getBoardstackNumber
unsigned int getBoardstackNumber() const
Returns boardstack number.
Definition: TOPDigit.h:364
Belle2::TOPDigit::getCarrierNumber
unsigned int getCarrierNumber() const
Returns carrier board number.
Definition: TOPDigit.h:358
Belle2::TOPDigit::m_rawTime
float m_rawTime
raw time expressed in samples (TDC bins)
Definition: TOPDigit.h:434
Belle2::TOPDigit::setPulseWidth
void setPulseWidth(double width)
Sets pulse width.
Definition: TOPDigit.h:151
Belle2::TOPDigit::EHitQuality
EHitQuality
hit quality enumerators
Definition: TOPDigit.h:43
Belle2::TOPDigit::TOPDigit
TOPDigit()
Default constructor.
Definition: TOPDigit.h:77
Belle2::TOPDigit::addBGDigit
DigitBase::EAppendStatus addBGDigit(const DigitBase *bg) override
Implementation of the base class function.
Definition: TOPDigit.cc:38
Belle2::TOPDigit::getPulseWidth
double getPulseWidth() const
Returns pulse width.
Definition: TOPDigit.h:400
Belle2::TOPDigit::isChargeShare
bool isChargeShare() const
Returns charge share status.
Definition: TOPDigit.h:262
Belle2::TOPDigit::isPrimaryChargeShare
bool isPrimaryChargeShare() const
Returns charge share status.
Definition: TOPDigit.h:268
Belle2::TOPDigit::setChannel
void setChannel(unsigned int channel)
Sets hardware channel number (0-based)
Definition: TOPDigit.h:121
Belle2::TOPDigit::getModuleID
int getModuleID() const
Returns module ID.
Definition: TOPDigit.h:280
Belle2::TOPDigit::getUniqueChannelID
unsigned int getUniqueChannelID() const override
Implementation of the base class function.
Definition: TOPDigit.h:419
Belle2::DigitBase
A common base for subdetector Digits.
Definition: DigitBase.h:36
Belle2::TOPDigit::getIntegral
int getIntegral() const
Returns pulse integral.
Definition: TOPDigit.h:406
Belle2::TOPDigit::getPMTCol
int getPMTCol() const
Returns PMT column number (1-based)
Definition: TOPDigit.h:310
Belle2::TOPDigit::addStatus
void addStatus(unsigned short bitmask)
Add calibration status.
Definition: TOPDigit.h:179
Belle2::TOPDigit::isSecondaryChargeShare
bool isSecondaryChargeShare() const
Returns charge share status.
Definition: TOPDigit.h:274