Belle II Software  release-05-02-19
top data objects
Collaboration diagram for top data objects:

Classes

class  TOPAsicMask
 Class to store bit fields of masked ASICs, as reported in raw data. More...
 
class  TOPAssociatedPDF
 Class to store analytic PDF associated with a photon. More...
 
class  TOPBarHit
 Class to store track parameters of incoming MC particles relation to MCParticle filled in top/simulation/src/SensitiveBar.cc. More...
 
class  TOPDigit
 Class to store TOP digitized hits (output of TOPDigitizer or raw data unpacker) relations to TOPSimHits, MCParticles. More...
 
class  TOPInterimFEInfo
 Class to store debug info of raw data in Interim FE format. More...
 
class  TOPLikelihood
 Class to store TOP log likelihoods (output of TOPReconstructor). More...
 
class  TOPPDFCollection
 Class to store analytical PDF relation from Tracks filled top/modules/TOPPDFDebugger/src/TOPPDFDebuggerModule.cc. More...
 
class  TOPProductionEventDebug
 Class to store debugging information about the event headers in the by the TOP production debugging raw data format one of these should be available per boardstack per event. More...
 
class  TOPProductionHitDebug
 Class to store debugging information about the hit headers in the TOP production debugging raw data format. More...
 
class  TOPPull
 Class to store photon pull in respect to PDF used in reconstruction. More...
 
class  TOPRawDigit
 Class to store unpacked raw data (hits in feature-extraction format) It provides also calculation of 50% CFD leading and falling edge times and errors. More...
 
class  TOPRawWaveform
 Class to store raw data waveforms. More...
 
class  TOPRecBunch
 Class to store results of TOPBunchFinder. More...
 
class  TOPSimCalPulse
 Calibration pulse time and amplitude generated by TOPCalPulseGenerator. More...
 
class  TOPSimHit
 Class to store simulated hits of Cherenkov photons on PMT's input for digitization module (TOPDigitizer). More...
 
class  TOPSimPhoton
 Class to store Cherenkov photons at emission and at detection relation to TOPSimHit filled in top/simulation/src/SensitivePMT.cc. More...
 
class  TOPSlowData
 Class to store slow data unpacked from raw data. More...
 
class  TOPTemplateFitResult
 Class to store template fit result from feature extraction data. More...
 
class  TOPTimeZero
 Class to store T0 information. More...
 
class  TOPTriggerDigit
 Class to store trigger time stamps. More...
 
class  TOPTriggerMCInfo
 Class to store Monte Carlo information useful for trigger studies. More...
 

Functions

bool isActive (int moduleID, unsigned channel) const
 Returns true if channel is not explicitely labeled as masked. More...
 
const PDFPeakgetSinglePeak () const
 Returns a PDF peak selected randomly according to weights. More...
 
int getModulo256Sample () const
 Returns sample number modulo 256. More...
 
DigitBase::EAppendStatus addBGDigit (const DigitBase *bg) override
 Implementation of the base class function. More...
 
bool isPedestalJump () const
 Checks if feature extraction finds a pedestal jump. More...
 
bool isAtWindowDiscontinuity (unsigned short storageDepth=508) const
 Checks if feature extraction points are at window discontinuity (e.g. More...
 
bool areWindowsInOrder (unsigned short storageDepth=508) const
 Checks if storage windows come in the consecutive order before the last sample (no gaps before the last sample) Note: returns true if m_windows is empty. More...
 
double correctTime (double time, unsigned short storageDepth=508) const
 Corrects time after window discontinuity by adding missing samples. More...
 
double timeErrorCoefficient (double y1, double y2) const
 Calculate the coefficient of time error. More...
 
int getIntegral (int sampleRise, int samplePeak, int sampleFall) const
 Returns integral of a peak. More...
 
int Integral (int sampleRise, int samplePeak, int sampleFall) const
 Returns integral of a peak. More...
 
int featureExtraction (int threshold, int hysteresis, int thresholdCount) const
 Do feature extraction. More...
 
 TOPTemplateFitResult ()
 Default constructor.
 
 TOPTemplateFitResult (short risingEdge, short backgroundOffset, short amplitude, short chisquare)
 Usefull contructor for data from Zynqs. More...
 
 TOPTemplateFitResult (double risingEdge, double risingEdgeTime, double backgroundOffset, double amplitude, double chisquare)
 Usefull contructor for software implementation of template fit in basf2. More...
 
void setRisingEdgeAndConvert (unsigned short risingEdge)
 Sets rising edge from Zynq and converts to double This does not convert from sample to time space. More...
 
double risingEdgeShortToRisingEdgeDouble (unsigned short risingEdgeS) const
 Convert rising edge saved in short to double. More...
 

Variables

static float s_doubleHitResolution = 0
 double hit resolving time in [ns]
 
static float s_pileupTime = 0
 pile-up time in [ns]
 

Detailed Description

Function Documentation

◆ addBGDigit()

DigitBase::EAppendStatus addBGDigit ( const DigitBase bg)
overridevirtual

Implementation of the base class function.

Pile-up method.

Parameters
bgBG digit
Returns
append status

Implements DigitBase.

Definition at line 38 of file TOPDigit.cc.

39  {
40  const auto* bgDigit = static_cast<const TOPDigit*>(bg);
41  double diff = m_time - bgDigit->getTime();
42 
43  if (fabs(diff) > s_doubleHitResolution) return DigitBase::c_Append; // no pile-up
44 
45  if (fabs(diff) < s_pileupTime) { // pile-up results in time averaging
46  double time[2] = {m_time, bgDigit->getTime()};
47  double rawTime[2] = {m_rawTime, bgDigit->getRawTime()};
48  int pulseHeight[2] = {m_pulseHeight, bgDigit->getPulseHeight()};
49  double sum = pulseHeight[0] + pulseHeight[1];
50  if (sum > 0) {
51  m_time = (time[0] * pulseHeight[0] + time[1] * pulseHeight[1]) / sum;
52  m_rawTime = (rawTime[0] * pulseHeight[0] + rawTime[1] * pulseHeight[1]) / sum;
53  // m_timeError =
54  // m_pulseWidth =
55  // m_integral =
56  } else {
57  m_time = (time[0] + time[1]) / 2;
58  m_rawTime = (rawTime[0] + rawTime[1]) / 2;
59  // m_timeError =
60  // m_pulseWidth =
61  // m_integral =
62  }
63  m_pulseHeight = int(sum);
64  double reweight = sum > 0 ? pulseHeight[0] / sum : 0.5;
65  auto relSimHits = this->getRelationsTo<TOPSimHit>();
66  for (size_t i = 0; i < relSimHits.size(); ++i) {
67  float weight = relSimHits.weight(i) * reweight;
68  relSimHits.setWeight(i, weight);
69  }
70  auto relRawDigits = this->getRelationsTo<TOPRawDigit>();
71  for (size_t i = 0; i < relRawDigits.size(); ++i) {
72  float weight = relRawDigits.weight(i) * reweight;
73  relRawDigits.setWeight(i, weight);
74  }
75  auto relMCParticles = this->getRelationsTo<MCParticle>();
76  for (size_t i = 0; i < relMCParticles.size(); ++i) {
77  float weight = relMCParticles.weight(i) * reweight;
78  relMCParticles.setWeight(i, weight);
79  }
80  } else { // pile-up results in discarding the second-in-time hit
81  if (diff > 0) {
82  // bg digit is the first-in-time hit, therefore replace and remove relations
83  *this = *bgDigit;
84 
85  // remove relations (going from back side!)
86  auto relSimHits = this->getRelationsTo<TOPSimHit>();
87  for (int i = relSimHits.size() - 1; i >= 0; --i) {
88  relSimHits.remove(i);
89  }
90  auto relRawDigits = this->getRelationsTo<TOPRawDigit>();
91  for (int i = relRawDigits.size() - 1; i >= 0; --i) {
92  relRawDigits.remove(i);
93  }
94  auto relMCParticles = this->getRelationsTo<MCParticle>();
95  for (int i = relMCParticles.size() - 1; i >= 0; --i) {
96  relMCParticles.remove(i);
97  }
98  }
99  }
101 
102  }

◆ areWindowsInOrder()

bool areWindowsInOrder ( unsigned short  storageDepth = 508) const

Checks if storage windows come in the consecutive order before the last sample (no gaps before the last sample) Note: returns true if m_windows is empty.

Parameters
storageDepthstorage depth
Returns
true, if no gaps before the last sample or m_windows is empty

Definition at line 54 of file TOPRawDigit.cc.

55  {
56  unsigned lastSample = getSampleFall() + 1;
57  unsigned last = lastSample / c_WindowSize + 1;
58  unsigned size = m_windows.size();
59  for (unsigned i = 1; i < std::min(last, size); i++) {
60  int diff = m_windows[i] - m_windows[i - 1];
61  if (diff < 0) diff += storageDepth;
62  if (diff != 1) return false;
63  }
64  return true;
65  }

◆ correctTime()

double correctTime ( double  time,
unsigned short  storageDepth = 508 
) const

Corrects time after window discontinuity by adding missing samples.

Parameters
timeleading or falling edge time [samples]
storageDepthstorage depth
Returns
time corrected for missing samples if any, otherwise returns input value [samples]

Definition at line 68 of file TOPRawDigit.cc.

◆ featureExtraction()

int featureExtraction ( int  threshold,
int  hysteresis,
int  thresholdCount 
) const

Do feature extraction.

Parameters
thresholdpulse height threshold [ADC counts]
hysteresisthreshold hysteresis [ADC counts]
thresholdCountminimal number of samples above threshold
Returns
number of feature extraction data (hits found)

Definition at line 46 of file TOPRawWaveform.cc.

48  {
49 
50  m_features.clear();
51 
52  int currentThr = threshold;
53  bool lastState = false;
54  int samplePeak = 0;
55  int size = m_data.size();
56  int aboveThr = 0;
57  for (int i = 0; i < size; i++) {
58  const auto& adc = m_data[i];
59  if (adc > currentThr and i < size - 1) {
60  currentThr = threshold - hysteresis;
61  if (!lastState or adc > m_data[samplePeak]) samplePeak = i;
62  lastState = true;
63  aboveThr++;
64  } else {
65  currentThr = threshold;
66  if (lastState and aboveThr >= thresholdCount) {
67  auto halfValue = m_data[samplePeak] / 2;
68  auto sampleRise = samplePeak;
69  while (sampleRise > 0 and m_data[sampleRise] > halfValue) sampleRise--;
70  if (sampleRise == 0 and m_data[sampleRise] > halfValue) continue;
71  auto sampleFall = samplePeak;
72  while (sampleFall < size - 1 and m_data[sampleFall] > halfValue) sampleFall++;
73  if (sampleFall == size - 1 and m_data[sampleFall] > halfValue) continue;
74  sampleFall--;
75  FeatureExtraction feature;
76  feature.sampleRise = sampleRise + m_startSample;
77  feature.samplePeak = samplePeak + m_startSample;
78  feature.sampleFall = sampleFall + m_startSample;
79  feature.vRise0 = m_data[sampleRise];
80  feature.vRise1 = m_data[sampleRise + 1];
81  feature.vPeak = m_data[samplePeak];
82  feature.vFall0 = m_data[sampleFall];
83  feature.vFall1 = m_data[sampleFall + 1];
84  feature.integral = Integral(sampleRise, samplePeak, sampleFall);
85  m_features.push_back(feature);
86  }
87  lastState = false;
88  aboveThr = 0;
89  }
90  }
91 
92  return m_features.size();
93  }

◆ getIntegral()

int getIntegral ( int  sampleRise,
int  samplePeak,
int  sampleFall 
) const

Returns integral of a peak.

Parameters
sampleRisesample number just before 50% CFD crossing at leading edge
samplePeaksample number at maximum
sampleFallsample number just before 50% CFD crossing at falling edge
Returns
integral

Definition at line 21 of file TOPRawWaveform.cc.

◆ getModulo256Sample()

int getModulo256Sample ( ) const

Returns sample number modulo 256.

Returns
sample number modulo 256

Definition at line 28 of file TOPDigit.cc.

◆ getSinglePeak()

const TOPAssociatedPDF::PDFPeak * getSinglePeak ( ) const

Returns a PDF peak selected randomly according to weights.

Null ptr is returned if background is selected instead.

Definition at line 30 of file TOPAssociatedPDF.cc.

30  {
31  cum += m_weights[i];
32  if (prob < cum) return &m_peaks[i];
33  }
34  return 0;
35  }
36 
38 }

◆ Integral()

int Integral ( int  sampleRise,
int  samplePeak,
int  sampleFall 
) const
private

Returns integral of a peak.

Parameters
sampleRisew.r.t array boundaries
samplePeakw.r.t array boundaries
sampleFallw.r.t array boundaries
Returns
integral

Definition at line 30 of file TOPRawWaveform.cc.

◆ isActive()

bool isActive ( int  moduleID,
unsigned  channel 
) const

Returns true if channel is not explicitely labeled as masked.

Parameters
moduleIDmodule ID (1-based)
channelhardware channel number (0-based)

Definition at line 27 of file TOPAsicMask.cc.

◆ isAtWindowDiscontinuity()

bool isAtWindowDiscontinuity ( unsigned short  storageDepth = 508) const

Checks if feature extraction points are at window discontinuity (e.g.

discontinuity happens between sampleRise and sampleFall+1) NOTE: always false if m_windows is empty

Parameters
storageDepthstorage depth
Returns
true if window discontinuity is found between sampleRise and sampleFall+1

Definition at line 36 of file TOPRawDigit.cc.

◆ isPedestalJump()

bool isPedestalJump ( ) const

Checks if feature extraction finds a pedestal jump.

Returns
true if pedestal jump

Definition at line 25 of file TOPRawDigit.cc.

◆ risingEdgeShortToRisingEdgeDouble()

double risingEdgeShortToRisingEdgeDouble ( unsigned short  risingEdgeS) const
private

Convert rising edge saved in short to double.

Parameters
risingEdgeSinput short
Returns
output double

Definition at line 49 of file TOPTemplateFitResult.cc.

50  {
51  double risingEdgeD = (risingEdgeS & 0xff00) >> 8;
52  int mask = 0x80;
53  for (int i = 0; i < 8; i++) {
54  int b = (risingEdgeS & mask);
55  if (b != 0) risingEdgeD += 1. / (pow(2, i + 1));
56  mask = mask >> 1;
57  }
58  return risingEdgeD;
59  }

◆ setRisingEdgeAndConvert()

void setRisingEdgeAndConvert ( unsigned short  risingEdge)

Sets rising edge from Zynq and converts to double This does not convert from sample to time space.

Parameters
risingEdgerising edge

Definition at line 43 of file TOPTemplateFitResult.cc.

◆ timeErrorCoefficient()

double timeErrorCoefficient ( double  y1,
double  y2 
) const
private

Calculate the coefficient of time error.

Parameters
y1first value (e.g. VRise0 or VFall0)
y2second value (e.g. VRise1 or VFall1)
Returns
coefficient of time error

Definition at line 86 of file TOPRawDigit.cc.

◆ TOPTemplateFitResult() [1/2]

TOPTemplateFitResult ( double  risingEdge,
double  risingEdgeTime,
double  backgroundOffset,
double  amplitude,
double  chisquare 
)

Usefull contructor for software implementation of template fit in basf2.

Parameters
risingEdgetemplate fit rising edge in samples
risingEdgeTimetemplate fit rising edge in ns
backgroundOffsetbackground offset
amplitudeamplitude
chisquarechi square

Definition at line 35 of file TOPTemplateFitResult.cc.

◆ TOPTemplateFitResult() [2/2]

TOPTemplateFitResult ( short  risingEdge,
short  backgroundOffset,
short  amplitude,
short  chisquare 
)
explicit

Usefull contructor for data from Zynqs.

Parameters
risingEdgetemplate fit rising edge, lower 8 bit are fraction
backgroundOffsetbackground offset
amplitudeamplitude
chisquarechi square

Definition at line 24 of file TOPTemplateFitResult.cc.

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::TOPRawWaveform::Integral
int Integral(int sampleRise, int samplePeak, int sampleFall) const
Returns integral of a peak.
Definition: TOPRawWaveform.cc:30
Belle2::TOPDigit::s_pileupTime
static float s_pileupTime
pile-up time in [ns]
Definition: TOPDigit.h:446
Belle2::TOPAssociatedPDF::m_peaks
std::vector< PDFPeak > m_peaks
collection of associated PDF peaks
Definition: TOPAssociatedPDF.h:121
Belle2::TOPAssociatedPDF::m_weights
std::vector< float > m_weights
corresponding weights
Definition: TOPAssociatedPDF.h:122
Belle2::TOPRawWaveform::m_startSample
int m_startSample
sample number of the first waveform sample
Definition: TOPRawWaveform.h:300
Belle2::DigitBase::c_DontAppend
@ c_DontAppend
do not append BG digit to digits
Definition: DigitBase.h:43
Belle2::TOPRawWaveform::m_features
std::vector< FeatureExtraction > m_features
cache for feature extraction data
Definition: TOPRawWaveform.h:312
Belle2::TOPRawDigit::getSampleFall
unsigned getSampleFall() const
Returns sample number at falling edge just before 50% CFD crossing.
Definition: TOPRawDigit.h:301
Belle2::TOPDigit::m_time
float m_time
calibrated time in [ns], t0-subtracted
Definition: TOPDigit.h:435
Belle2::TOPRawWaveform::m_data
std::vector< short > m_data
waveform ADC values
Definition: TOPRawWaveform.h:301
Belle2::TOPRawDigit::c_WindowSize
@ c_WindowSize
number of samples per window
Definition: TOPRawDigit.h:64
Belle2::TOPDigit::m_rawTime
float m_rawTime
raw time expressed in samples (TDC bins)
Definition: TOPDigit.h:434
Belle2::TOPRawDigit::m_windows
std::vector< unsigned short > m_windows
storage windows of waveform segments
Definition: TOPRawDigit.h:541
Belle2::DigitBase::c_Append
@ c_Append
append BG digit to digits
Definition: DigitBase.h:44
Belle2::TOPDigit::TOPDigit
TOPDigit()
Default constructor.
Definition: TOPDigit.h:77