Belle II Software  release-08-01-10
ScintillatorSimulator Class Reference

Digitize EKLMSim2Hits to get EKLM StripHits. More...

#include <ScintillatorSimulator.h>

Collaboration diagram for ScintillatorSimulator:

Classes

struct  Photoelectron
 Photoelectron data. More...
 

Public Member Functions

 ScintillatorSimulator (const KLMScintillatorDigitizationParameters *digPar, ScintillatorFirmware *fitter, double digitizationInitialTime, bool debug)
 Constructor. More...
 
 ScintillatorSimulator (const ScintillatorSimulator &)=delete
 Copy constructor (disabled).
 
ScintillatorSimulatoroperator= (const ScintillatorSimulator &)=delete
 Operator = (disabled).
 
 ~ScintillatorSimulator ()
 Destructor.
 
void simulate (const std::multimap< KLMChannelNumber, const KLMSimHit * >::iterator &firstHit, const std::multimap< KLMChannelNumber, const KLMSimHit * >::iterator &end)
 Simulate a strip. More...
 
KLMScintillatorFirmwareFitResultgetFPGAFit ()
 Get fit data.
 
enum ScintillatorFirmwareFitStatus getFitStatus () const
 Get fit status. More...
 
double getNPhotoelectrons ()
 Get number of photoelectrons (fit result).
 
int getNGeneratedPhotoelectrons ()
 Get generated number of photoelectrons.
 
double getEnergy ()
 Get total energy deposited in the strip (sum over ssimulation hits).
 
void setFEEData (const KLMScintillatorFEEData *FEEData)
 Set FEE data.
 
void generatePhotoelectrons (double stripLen, double distSiPM, int nPhotons, double timeShift, bool isReflected)
 Generate photoelectrons. More...
 
void fillSiPMOutput (float *hist, bool useDirect, bool useReflected)
 Fill SiPM output. More...
 
float getMCTime () const
 Get MC time. More...
 
float getSiPMMCTime () const
 Get SiPM MC time. More...
 

Private Member Functions

void reallocPhotoElectronBuffers (int size)
 Reallocate photoelectron buffers. More...
 
void prepareSimulation ()
 Prepare simulation.
 
void performSimulation ()
 Perform common simulation stage.
 
int * sortPhotoelectrons (int nPhotoelectrons)
 Sort photoelectrons. More...
 
void addRandomSiPMNoise ()
 Add random noise to the signal (amplitude-dependend).
 
void simulateADC ()
 Simulate ADC (create digital signal from analog),.
 
void debugOutput ()
 Debug output (signal and fit result histograms).
 

Private Attributes

const KLMTimem_Time
 Time.
 
const KLMScintillatorDigitizationParametersm_DigPar
 Parameters.
 
ScintillatorFirmwarem_fitter
 Fitter.
 
double m_DigitizationInitialTime
 Initial digitization time.
 
bool m_Debug
 Debug mode (generates additional output files with histograms).
 
double m_histRange
 Time range, (number of digitizations) * (ADC sampling time).
 
float * m_amplitudeDirect
 Analog amplitude (direct).
 
float * m_amplitudeReflected
 Analog amplitude (reflected).
 
float * m_amplitude
 Analog amplitude.
 
int * m_ADCAmplitude
 Digital amplitude.
 
double * m_SignalTimeDependence
 Buffer for signal time dependence calculation.
 
double * m_SignalTimeDependenceDiff
 Buffer for signal time dependence calculation.
 
struct Photoelectronm_Photoelectrons
 Buffer for photoelectron data.
 
int * m_PhotoelectronIndex
 Buffer for photoelectron indices.
 
int * m_PhotoelectronIndex2
 Buffer for photoelectron indices.
 
int m_PhotoelectronBufferSize
 Size of photoelectron data buffer.
 
enum ScintillatorFirmwareFitStatus m_FPGAStat
 FPGA fit status.
 
KLMScintillatorFirmwareFitResult m_FPGAFit
 FPGA fit data.
 
int m_npe
 Number of photoelectrons (generated).
 
double m_Energy
 Total energy deposited in the strip.
 
std::string m_stripName
 Name of the strip.
 
double m_Pedestal
 Pedestal.
 
double m_PhotoelectronAmplitude
 Photoelectron amplitude.
 
int m_Threshold
 Threshold.
 
float m_MCTime
 MC time.
 
float m_SiPMMCTime
 MC time at SiPM.
 

Detailed Description

Digitize EKLMSim2Hits to get EKLM StripHits.

Definition at line 30 of file ScintillatorSimulator.h.

Constructor & Destructor Documentation

◆ ScintillatorSimulator()

ScintillatorSimulator ( const KLMScintillatorDigitizationParameters digPar,
ScintillatorFirmware fitter,
double  digitizationInitialTime,
bool  debug 
)

Constructor.

Parameters
[in]digParDigitization parameters.
[in]digitizationInitialTimeInitial digitization time.
[in]fitterFitter.
[in]debugUse debug mode.

Definition at line 62 of file ScintillatorSimulator.cc.

65  :
67  m_DigPar(digPar),
68  m_fitter(fitter),
69  m_DigitizationInitialTime(digitizationInitialTime),
70  m_Debug(debug),
71  m_FPGAStat(c_ScintillatorFirmwareNoSignal),
72  m_npe(0),
73  m_Energy(0),
74  m_MCTime(-1),
75  m_SiPMMCTime(-1)
76 {
77  int i;
78  const double samplingTime = m_DigPar->getADCSamplingTDCPeriods() *
80  /* cppcheck-suppress variableScope */
81  double time, attenuationTime;
82  m_histRange = m_DigPar->getNDigitizations() * samplingTime;
86  /* Amplitude arrays. */
87  m_amplitudeDirect = (float*)malloc(m_DigPar->getNDigitizations() *
88  sizeof(float));
89  if (m_amplitudeDirect == nullptr)
90  B2FATAL(MemErr);
91  m_amplitudeReflected = (float*)malloc(m_DigPar->getNDigitizations() *
92  sizeof(float));
93  if (m_amplitudeReflected == nullptr)
94  B2FATAL(MemErr);
95  m_amplitude = (float*)malloc(m_DigPar->getNDigitizations() * sizeof(float));
96  if (m_amplitude == nullptr)
97  B2FATAL(MemErr);
98  m_ADCAmplitude = (int*)malloc(m_DigPar->getNDigitizations() * sizeof(int));
99  if (m_ADCAmplitude == nullptr)
100  B2FATAL(MemErr);
101  m_SignalTimeDependence = (double*)malloc((m_DigPar->getNDigitizations() + 1) *
102  sizeof(double));
103  if (m_SignalTimeDependence == nullptr)
104  B2FATAL(MemErr);
106  sizeof(double));
107  if (m_SignalTimeDependenceDiff == nullptr)
108  B2FATAL(MemErr);
109  attenuationTime = 1.0 / m_DigPar->getPEAttenuationFrequency();
110  for (i = 0; i <= m_DigPar->getNDigitizations(); i++) {
111  time = samplingTime * i;
113  exp(-digPar->getPEAttenuationFrequency() * time) * attenuationTime /
114  samplingTime;
115  if (i > 0) {
118  }
119  }
120  m_Photoelectrons = nullptr;
121  m_PhotoelectronIndex = nullptr;
122  m_PhotoelectronIndex2 = nullptr;
124 }
float getPEAttenuationFrequency() const
Get attenuation frequency of a single photoelectron pulse.
int getADCThreshold() const
Get ADC readout corresponding to saturation.
float getADCPEAmplitude() const
Get ADC photoelectron amplitude.
int getADCSamplingTDCPeriods() const
Get ADC sampling time in TDC periods.
int getNDigitizations() const
Get number of digitizations (points) in one sample.
double getTDCPeriod() const
Get TDC period.
Definition: KLMTime.h:45
static KLMTime & Instance()
Instantiation.
Definition: KLMTime.cc:14
int * m_PhotoelectronIndex2
Buffer for photoelectron indices.
float * m_amplitudeReflected
Analog amplitude (reflected).
double * m_SignalTimeDependence
Buffer for signal time dependence calculation.
double * m_SignalTimeDependenceDiff
Buffer for signal time dependence calculation.
double m_Energy
Total energy deposited in the strip.
float * m_amplitudeDirect
Analog amplitude (direct).
double m_histRange
Time range, (number of digitizations) * (ADC sampling time).
void reallocPhotoElectronBuffers(int size)
Reallocate photoelectron buffers.
bool m_Debug
Debug mode (generates additional output files with histograms).
double m_DigitizationInitialTime
Initial digitization time.
struct Photoelectron * m_Photoelectrons
Buffer for photoelectron data.
ScintillatorFirmware * m_fitter
Fitter.
enum ScintillatorFirmwareFitStatus m_FPGAStat
FPGA fit status.
double m_PhotoelectronAmplitude
Photoelectron amplitude.
int * m_PhotoelectronIndex
Buffer for photoelectron indices.
int m_npe
Number of photoelectrons (generated).
const KLMScintillatorDigitizationParameters * m_DigPar
Parameters.

Member Function Documentation

◆ fillSiPMOutput()

void fillSiPMOutput ( float *  hist,
bool  useDirect,
bool  useReflected 
)

Fill SiPM output.

Parameters
[in,out]histOutput histogram (signal is added to it).
[in]useDirectUse direct photons.
[in]useReflectedUse reflected photons.

Definition at line 418 of file ScintillatorSimulator.cc.

◆ generatePhotoelectrons()

void generatePhotoelectrons ( double  stripLen,
double  distSiPM,
int  nPhotons,
double  timeShift,
bool  isReflected 
)

Generate photoelectrons.

Parameters
[in]stripLenStrip length.
[in]distSiPMDistance from hit to SiPM.
[in]nPhotonsNumber of photons to be simulated.
[in]timeShiftTime of hit.
[in]isReflectedWhether the hits are reflected or not.

Definition at line 308 of file ScintillatorSimulator.cc.

◆ getFitStatus()

enum KLM::ScintillatorFirmwareFitStatus getFitStatus ( ) const

Get fit status.

Returns
Status of the fit.

Definition at line 485 of file ScintillatorSimulator.cc.

◆ getMCTime()

float getMCTime ( ) const
inline

Get MC time.

Returns
MC time.

Definition at line 132 of file ScintillatorSimulator.h.

133  {
134  return m_MCTime;
135  }

◆ getSiPMMCTime()

float getSiPMMCTime ( ) const
inline

Get SiPM MC time.

Returns
SiPM MC yime.

Definition at line 141 of file ScintillatorSimulator.h.

◆ reallocPhotoElectronBuffers()

void reallocPhotoElectronBuffers ( int  size)
private

Reallocate photoelectron buffers.

Parameters
[in]sizeNew size of buffers.

Definition at line 41 of file ScintillatorSimulator.cc.

◆ simulate()

void simulate ( const std::multimap< KLMChannelNumber, const KLMSimHit * >::iterator &  firstHit,
const std::multimap< KLMChannelNumber, const KLMSimHit * >::iterator &  end 
)

Simulate a strip.

Parameters
[in]firstHitFirst hit in this strip.
[in]endEnd of hit range.

Definition at line 163 of file ScintillatorSimulator.cc.

◆ sortPhotoelectrons()

int * sortPhotoelectrons ( int  nPhotoelectrons)
private

Sort photoelectrons.

Parameters
[in]nPhotoelectronsNumber of photoelectrons.
Returns
Pointer to index array.

Definition at line 260 of file ScintillatorSimulator.cc.


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