Belle II Software  release-05-02-19
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< uint16_t, const BKLMSimHit * >::iterator &firstHit, const std::multimap< uint16_t, const BKLMSimHit * >::iterator &end)
 Simulate BKLM strip. More...
 
void simulate (const std::multimap< uint16_t, const EKLMSimHit * >::iterator &firstHit, const std::multimap< uint16_t, const EKLMSimHit * >::iterator &end)
 Simulate EKLM 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 setChannelData (const EKLMChannelData *channelData)
 Set channel 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 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
 Stands for nDigitizations*ADCSamplingTime.
 
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 39 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 71 of file ScintillatorSimulator.cc.

74  :
75  m_DigPar(digPar),
76  m_fitter(fitter),
77  m_DigitizationInitialTime(digitizationInitialTime),
78  m_Debug(debug),
79  m_FPGAStat(c_ScintillatorFirmwareNoSignal),
80  m_npe(0),
81  m_Energy(0),
82  m_MCTime(-1),
83  m_SiPMMCTime(-1)
84 {
85  int i;
86  /* cppcheck-suppress variableScope */
87  double time, attenuationTime;
92  /* Amplitude arrays. */
93  m_amplitudeDirect = (float*)malloc(m_DigPar->getNDigitizations() *
94  sizeof(float));
95  if (m_amplitudeDirect == nullptr)
96  B2FATAL(MemErr);
97  m_amplitudeReflected = (float*)malloc(m_DigPar->getNDigitizations() *
98  sizeof(float));
99  if (m_amplitudeReflected == nullptr)
100  B2FATAL(MemErr);
101  m_amplitude = (float*)malloc(m_DigPar->getNDigitizations() * sizeof(float));
102  if (m_amplitude == nullptr)
103  B2FATAL(MemErr);
104  m_ADCAmplitude = (int*)malloc(m_DigPar->getNDigitizations() * sizeof(int));
105  if (m_ADCAmplitude == nullptr)
106  B2FATAL(MemErr);
107  m_SignalTimeDependence = (double*)malloc((m_DigPar->getNDigitizations() + 1) *
108  sizeof(double));
109  if (m_SignalTimeDependence == nullptr)
110  B2FATAL(MemErr);
112  sizeof(double));
113  if (m_SignalTimeDependenceDiff == nullptr)
114  B2FATAL(MemErr);
115  attenuationTime = 1.0 / m_DigPar->getPEAttenuationFrequency();
116  for (i = 0; i <= m_DigPar->getNDigitizations(); i++) {
117  time = digPar->getADCSamplingTime() * i;
119  exp(-digPar->getPEAttenuationFrequency() * time) * attenuationTime /
120  digPar->getADCSamplingTime();
121  if (i > 0) {
124  }
125  }
126  m_Photoelectrons = nullptr;
127  m_PhotoelectronIndex = nullptr;
128  m_PhotoelectronIndex2 = nullptr;
130 }

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 446 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 337 of file ScintillatorSimulator.cc.

◆ getFitStatus()

enum KLM::ScintillatorFirmwareFitStatus getFitStatus ( ) const

Get fit status.

Returns
Status of the fit.

Definition at line 518 of file ScintillatorSimulator.cc.

◆ getMCTime()

float getMCTime ( ) const
inline

Get MC time.

Returns
MC time.

Definition at line 150 of file ScintillatorSimulator.h.

152  {
153  return m_SiPMMCTime;

◆ getSiPMMCTime()

float getSiPMMCTime ( ) const
inline

Get SiPM MC time.

Returns
SiPM MC yime.

Definition at line 159 of file ScintillatorSimulator.h.

◆ reallocPhotoElectronBuffers()

void reallocPhotoElectronBuffers ( int  size)
private

Reallocate photoelectron buffers.

Parameters
[in]sizeNew size of buffers.

Definition at line 47 of file ScintillatorSimulator.cc.

◆ simulate() [1/2]

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

Simulate BKLM strip.

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

Definition at line 169 of file ScintillatorSimulator.cc.

◆ simulate() [2/2]

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

Simulate EKLM strip.

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

Definition at line 219 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 289 of file ScintillatorSimulator.cc.


The documentation for this class was generated from the following files:
Belle2::KLMScintillatorDigitizationParameters::getADCPedestal
float getADCPedestal() const
Get ADC pedestal.
Definition: KLMScintillatorDigitizationParameters.h:114
Belle2::KLM::ScintillatorSimulator::m_DigitizationInitialTime
double m_DigitizationInitialTime
Initial digitization time.
Definition: ScintillatorSimulator.h:211
Belle2::KLM::ScintillatorSimulator::m_MCTime
float m_MCTime
MC time.
Definition: ScintillatorSimulator.h:274
Belle2::KLMScintillatorDigitizationParameters::getPEAttenuationFrequency
float getPEAttenuationFrequency() const
Get attenuation frequency of a single photoelectron pulse.
Definition: KLMScintillatorDigitizationParameters.h:290
Belle2::KLMScintillatorDigitizationParameters::getNDigitizations
int getNDigitizations() const
Get number of digitizations (points) in one sample.
Definition: KLMScintillatorDigitizationParameters.h:98
Belle2::KLM::ScintillatorSimulator::m_fitter
ScintillatorFirmware * m_fitter
Fitter.
Definition: ScintillatorSimulator.h:208
Belle2::KLM::ScintillatorSimulator::m_SignalTimeDependence
double * m_SignalTimeDependence
Buffer for signal time dependence calculation.
Definition: ScintillatorSimulator.h:232
Belle2::KLM::ScintillatorSimulator::m_ADCAmplitude
int * m_ADCAmplitude
Digital amplitude.
Definition: ScintillatorSimulator.h:229
Belle2::KLM::ScintillatorSimulator::m_npe
int m_npe
Number of photoelectrons (generated).
Definition: ScintillatorSimulator.h:256
Belle2::KLM::ScintillatorSimulator::m_amplitudeDirect
float * m_amplitudeDirect
Analog amplitude (direct).
Definition: ScintillatorSimulator.h:220
Belle2::KLMScintillatorDigitizationParameters::getADCSamplingTime
float getADCSamplingTime() const
Get ADC sampling time in ns.
Definition: KLMScintillatorDigitizationParameters.h:82
Belle2::KLM::ScintillatorSimulator::m_Pedestal
double m_Pedestal
Pedestal.
Definition: ScintillatorSimulator.h:265
Belle2::KLM::ScintillatorSimulator::m_Photoelectrons
struct Photoelectron * m_Photoelectrons
Buffer for photoelectron data.
Definition: ScintillatorSimulator.h:238
Belle2::KLM::ScintillatorSimulator::m_PhotoelectronIndex
int * m_PhotoelectronIndex
Buffer for photoelectron indices.
Definition: ScintillatorSimulator.h:241
Belle2::KLM::ScintillatorSimulator::m_Threshold
int m_Threshold
Threshold.
Definition: ScintillatorSimulator.h:271
Belle2::KLMScintillatorDigitizationParameters::getADCPEAmplitude
float getADCPEAmplitude() const
Get ADC photoelectron amplitude.
Definition: KLMScintillatorDigitizationParameters.h:130
Belle2::KLM::ScintillatorSimulator::m_SignalTimeDependenceDiff
double * m_SignalTimeDependenceDiff
Buffer for signal time dependence calculation.
Definition: ScintillatorSimulator.h:235
Belle2::KLM::ScintillatorSimulator::m_Debug
bool m_Debug
Debug mode (generates additional output files with histograms).
Definition: ScintillatorSimulator.h:214
Belle2::KLM::ScintillatorSimulator::m_amplitudeReflected
float * m_amplitudeReflected
Analog amplitude (reflected).
Definition: ScintillatorSimulator.h:223
Belle2::KLM::ScintillatorSimulator::m_Energy
double m_Energy
Total energy deposited in the strip.
Definition: ScintillatorSimulator.h:259
Belle2::KLM::ScintillatorSimulator::m_amplitude
float * m_amplitude
Analog amplitude.
Definition: ScintillatorSimulator.h:226
Belle2::KLM::ScintillatorSimulator::reallocPhotoElectronBuffers
void reallocPhotoElectronBuffers(int size)
Reallocate photoelectron buffers.
Definition: ScintillatorSimulator.cc:47
Belle2::KLM::ScintillatorSimulator::m_SiPMMCTime
float m_SiPMMCTime
MC time at SiPM.
Definition: ScintillatorSimulator.h:277
Belle2::KLM::ScintillatorSimulator::m_PhotoelectronAmplitude
double m_PhotoelectronAmplitude
Photoelectron amplitude.
Definition: ScintillatorSimulator.h:268
Belle2::KLM::ScintillatorSimulator::m_PhotoelectronIndex2
int * m_PhotoelectronIndex2
Buffer for photoelectron indices.
Definition: ScintillatorSimulator.h:244
Belle2::KLM::ScintillatorSimulator::m_DigPar
const KLMScintillatorDigitizationParameters * m_DigPar
Parameters.
Definition: ScintillatorSimulator.h:205
Belle2::KLM::ScintillatorSimulator::m_FPGAStat
enum ScintillatorFirmwareFitStatus m_FPGAStat
FPGA fit status.
Definition: ScintillatorSimulator.h:250
Belle2::KLMScintillatorDigitizationParameters::getADCThreshold
int getADCThreshold() const
Get ADC readout corresponding to saturation.
Definition: KLMScintillatorDigitizationParameters.h:146
Belle2::KLM::ScintillatorSimulator::m_histRange
double m_histRange
Stands for nDigitizations*ADCSamplingTime.
Definition: ScintillatorSimulator.h:217