Belle II Software development
ScintillatorFirmware Class Reference

FPGA fitter class. More...

#include <ScintillatorFirmware.h>

Public Member Functions

 ScintillatorFirmware (int nPoints)
 Constructor.
 
 ~ScintillatorFirmware ()
 Destructor.
 
enum ScintillatorFirmwareFitStatus fit (const int *amp, int threshold, KLMScintillatorFirmwareFitResult *fitData)
 FPGA fitter.
 

Private Attributes

int m_nPoints
 Number of points.
 

Detailed Description

FPGA fitter class.

Definition at line 31 of file ScintillatorFirmware.h.

Constructor & Destructor Documentation

◆ ScintillatorFirmware()

ScintillatorFirmware ( int  nPoints)
explicit

Constructor.

Parameters
[in]nPointsNumber of points in amplitude arrays.

Definition at line 14 of file ScintillatorFirmware.cc.

14 :
15 m_nPoints(nPoints)
16{
17}

◆ ~ScintillatorFirmware()

Destructor.

Definition at line 19 of file ScintillatorFirmware.cc.

20{
21}

Member Function Documentation

◆ fit()

enum KLM::ScintillatorFirmwareFitStatus fit ( const int *  amp,
int  threshold,
KLMScintillatorFirmwareFitResult fitData 
)

FPGA fitter.

Parameters
[in]ampDigital amplitude.
[in]thresholdThreshold.
[out]fitDataFit data.
Returns
Fit status.

Definition at line 23 of file ScintillatorFirmware.cc.

25{
26 /*
27 * Upper bound of the background region: number of points before threshold
28 * crossing.
29 */
30 const int nPointsSigBg = 10;
31 double bg;
32 float sigAmp;
33 int i, ithr, ibg, sum, bgSum, min;
34 sum = 0;
35 bgSum = 0;
36 /* Get threshold crossing time, sum of ADC outputs and minimal output. */
37 ithr = -1;
38 min = 0; /* To avoid warning, re-initialized at the first cycle. */
39 for (i = 0; i < m_nPoints; i++) {
40 if (amp[i] < threshold) {
41 if (ithr < 0)
42 ithr = i;
43 }
44 sum = sum + amp[i];
45 if (i == 0)
46 min = amp[i];
47 else if (amp[i] < min)
48 min = amp[i];
49 }
50 /* No signal. */
51 if (ithr < 0)
52 return c_ScintillatorFirmwareNoSignal;
53 /* Region for background (pedestal) level. */
54 ibg = std::max(ithr - nPointsSigBg, 0);
55 /* Cannot determine background level, no data before signal. */
56 if (ibg == 0)
57 return c_ScintillatorFirmwareNoSignal;
58 /* Determine background (pedestal) level. */
59 for (i = 0; i < ibg; i++)
60 bgSum = bgSum + amp[i];
61 bg = float(bgSum) / i;
62 sigAmp = bg * m_nPoints - sum;
63 if (sigAmp < 0)
64 sigAmp = 0;
65 fitData->setStartTime(ithr);
66 fitData->setBackgroundAmplitude(bg);
67 fitData->setAmplitude(sigAmp);
68 fitData->setMinimalAmplitude(min);
69 return c_ScintillatorFirmwareSuccessfulFit;
70}

Member Data Documentation

◆ m_nPoints

int m_nPoints
private

Number of points.

Definition at line 58 of file ScintillatorFirmware.h.


The documentation for this class was generated from the following files: