Belle II Software development
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  TOPLikelihoodScanResult
 Class to store the result of the TOP LL scan (output of TOPLLScanner). More...
 
class  TOPPDFCollection
 Class to store analytical PDF relation from Tracks filled top/modules/TOPPDFDebugger/src/TOPPDFDebuggerModule.cc. More...
 
class  TOPPixelLikelihood
 Class to store pixel-by-pixel likelihoods for a track relation from Tracks filled in 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.
 
const PDFPeakgetSinglePeak () const
 Returns a PDF peak selected randomly according to weights.
 
int getModulo256Sample () const
 Returns sample number modulo 256.
 
DigitBase::EAppendStatus addBGDigit (const DigitBase *bg) override
 Implementation of the base class function.
 
bool isPedestalJump () const
 Checks if feature extraction finds a pedestal jump.
 
bool isAtWindowDiscontinuity (unsigned short storageDepth=508) const
 Checks if feature extraction points are at window discontinuity (e.g.
 
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.
 
double correctTime (double time, unsigned short storageDepth=508) const
 Corrects time after window discontinuity by adding missing samples.
 
double timeErrorCoefficient (double y1, double y2) const
 Calculate the coefficient of time error.
 
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.
 
 TOPTemplateFitResult ()
 Default constructor.
 
 TOPTemplateFitResult (short risingEdge, short backgroundOffset, short amplitude, short chisquare)
 Usefull contructor for data from Zynqs.
 
 TOPTemplateFitResult (double risingEdge, double risingEdgeTime, double backgroundOffset, double amplitude, double chisquare)
 Usefull contructor for software implementation of template fit in basf2.
 
void setRisingEdgeAndConvert (unsigned short risingEdge)
 Sets rising edge from Zynq and converts to double This does not convert from sample to time space.
 
double risingEdgeShortToRisingEdgeDouble (unsigned short risingEdgeS) const
 Convert rising edge saved in short to double.
 

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 36 of file TOPDigit.cc.

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

◆ 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 52 of file TOPRawDigit.cc.

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

◆ 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 66 of file TOPRawDigit.cc.

67 {
68 if (m_windows.empty()) return time;
69
70 unsigned last = int(time) / c_WindowSize + 1;
71 unsigned size = m_windows.size();
72 int missing = 0;
73 for (unsigned i = 1; i < std::min(last, size); i++) {
74 int diff = m_windows[i] - m_windows[i - 1];
75 if (diff < 0) diff += storageDepth;
76 if (diff != 1) missing += diff - 1;
77 if (diff == 0) B2ERROR("TOPRawDigit: two consecutive windows with the same number");
78 }
79
80 return time + missing * c_WindowSize;
81 }

◆ 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 44 of file TOPRawWaveform.cc.

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

◆ 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 19 of file TOPRawWaveform.cc.

20 {
21 sampleRise -= m_startSample;
22 samplePeak -= m_startSample;
23 sampleFall -= m_startSample;
24
25 return Integral(sampleRise, samplePeak, sampleFall);
26 }

◆ getModulo256Sample()

int getModulo256Sample ( ) const

Returns sample number modulo 256.

Returns
sample number modulo 256

Definition at line 26 of file TOPDigit.cc.

27 {
28 int sample = int(m_rawTime);
29 if (m_rawTime < 0) sample--;
30 sample += (int) m_firstWindow * 64;
31 if (sample < 0) return 256 + sample % 256;
32 return sample % 256;
33 }

◆ getSinglePeak()

const TOPAssociatedPDF::PDFPeak * getSinglePeak ( ) const

Returns a PDF peak selected randomly according to weights.

Null ptr is returned if background or delta-ray contribution is selected instead.

Definition at line 20 of file TOPAssociatedPDF.cc.

21 {
22 if (m_weights.empty()) return 0;
23
24 float sum = m_BGWeight + m_deltaRayWeight;
25 for (const auto& w : m_weights) sum += w;
26 float prob = sum * gRandom->Rndm();
27 float cumul = 0;
28 for (size_t i = 0; i < m_weights.size(); i++) {
29 cumul += m_weights[i];
30 if (prob < cumul) return &m_peaks[i];
31 }
32 return 0;
33 }

◆ 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 28 of file TOPRawWaveform.cc.

29 {
30 int min = samplePeak - 3 * (samplePeak - sampleRise);
31 if (min < 0) min = 0;
32 int max = samplePeak + 4 * (sampleFall + 1 - samplePeak);
33 int size = m_data.size();
34 if (max > size) max = size;
35 int integral = 0;
36 while (min < max) {
37 integral += m_data[min];
38 min++;
39 }
40 return integral;
41 }

◆ 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 17 of file TOPAsicMask.cc.

18 {
19 if (m_masks.empty()) return true;
20
21 unsigned asic = channel / 8;
22 unsigned bs = (moduleID - 1) * 4 + asic / 16;
23 if (bs >= m_masks.size()) return true;
24
25 unsigned word = m_masks[bs];
26 unsigned bit = asic % 16;
27 return ((word >> bit) & 0x1) == 0;
28 }

◆ 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 34 of file TOPRawDigit.cc.

35 {
36 if (m_windows.empty()) return false;
37
38 unsigned size = m_windows.size();
39 unsigned i0 = getSampleRise() / c_WindowSize;
40 if (i0 >= size) i0 = size - 1;
41 unsigned i1 = (getSampleFall() + 1) / c_WindowSize;
42 if (i1 >= size) i1 = size - 1;
43 if (i0 == i1) return false;
44
45 int diff = m_windows[i1] - m_windows[i0];
46 if (diff < 0) diff += storageDepth;
47 if (diff != 1) return true;
48 return false;
49 }

◆ isPedestalJump()

bool isPedestalJump ( ) const

Checks if feature extraction finds a pedestal jump.

Returns
true if pedestal jump

Definition at line 23 of file TOPRawDigit.cc.

24 {
25 if (m_sampleRise == 0) {
26 if ((m_dSampleFall + 1) % 64 == 0) return true;
27 } else if ((m_sampleRise + 1) % 64 == 0) {
28 if (m_dSampleFall % 64 == 0) return true;
29 }
30 return false;
31 }

◆ 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 47 of file TOPTemplateFitResult.cc.

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

◆ 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 41 of file TOPTemplateFitResult.cc.

42 {
43 m_risingEdgeRaw = risingEdge;
44 m_risingEdge = risingEdgeShortToRisingEdgeDouble(risingEdge);
45 }

◆ 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 84 of file TOPRawDigit.cc.

85 {
86 double dy = y2 - y1;
87 double ym = m_VPeak / 2.0;
88 double a = 1.0 / (2.0 * dy);
89 double b = (ym - y2) / (dy * dy);
90 double c = (ym - y1) / (dy * dy);
91
92 return sqrt(a * a + b * b + c * c);
93 }
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28

◆ TOPTemplateFitResult() [1/3]

Default constructor.

Definition at line 20 of file TOPTemplateFitResult.cc.

20{}

◆ TOPTemplateFitResult() [2/3]

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 33 of file TOPTemplateFitResult.cc.

35 : m_risingEdge(risingEdge), m_risingEdgeTime(risingEdgeTime), m_backgroundOffset(backgroundOffset), m_amplitude(amplitude),
36 m_chisquare(chisquare)
37 {
38 m_risingEdgeRaw = -1;
39 }

◆ TOPTemplateFitResult() [3/3]

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 22 of file TOPTemplateFitResult.cc.

24 {
25 m_risingEdgeRaw = risingEdge;
26 m_risingEdge = risingEdgeShortToRisingEdgeDouble(risingEdge);
27 m_backgroundOffset = backgroundOffset;
28 m_amplitude = amplitude;
29 m_chisquare = chisquare;
30 m_risingEdgeTime = -1.;
31 }

Variable Documentation

◆ s_doubleHitResolution

float s_doubleHitResolution = 0
staticprivate

double hit resolving time in [ns]

Definition at line 435 of file TOPDigit.h.

◆ s_pileupTime

float s_pileupTime = 0
staticprivate

pile-up time in [ns]

Definition at line 436 of file TOPDigit.h.