Belle II Software  release-06-01-15
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 BKLMSimHit * >::iterator &firstHit, const std::multimap< KLMChannelNumber, const BKLMSimHit * >::iterator &end)
 Simulate BKLM strip. More...
 
void simulate (const std::multimap< KLMChannelNumber, const EKLMSimHit * >::iterator &firstHit, const std::multimap< KLMChannelNumber, 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 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 69 of file ScintillatorSimulator.cc.

72  :
74  m_DigPar(digPar),
75  m_fitter(fitter),
76  m_DigitizationInitialTime(digitizationInitialTime),
77  m_Debug(debug),
78  m_FPGAStat(c_ScintillatorFirmwareNoSignal),
79  m_npe(0),
80  m_Energy(0),
81  m_MCTime(-1),
82  m_SiPMMCTime(-1)
83 {
84  int i;
85  const double samplingTime = m_DigPar->getADCSamplingTDCPeriods() *
87  /* cppcheck-suppress variableScope */
88  double time, attenuationTime;
89  m_histRange = m_DigPar->getNDigitizations() * samplingTime;
93  /* Amplitude arrays. */
94  m_amplitudeDirect = (float*)malloc(m_DigPar->getNDigitizations() *
95  sizeof(float));
96  if (m_amplitudeDirect == nullptr)
97  B2FATAL(MemErr);
98  m_amplitudeReflected = (float*)malloc(m_DigPar->getNDigitizations() *
99  sizeof(float));
100  if (m_amplitudeReflected == nullptr)
101  B2FATAL(MemErr);
102  m_amplitude = (float*)malloc(m_DigPar->getNDigitizations() * sizeof(float));
103  if (m_amplitude == nullptr)
104  B2FATAL(MemErr);
105  m_ADCAmplitude = (int*)malloc(m_DigPar->getNDigitizations() * sizeof(int));
106  if (m_ADCAmplitude == nullptr)
107  B2FATAL(MemErr);
108  m_SignalTimeDependence = (double*)malloc((m_DigPar->getNDigitizations() + 1) *
109  sizeof(double));
110  if (m_SignalTimeDependence == nullptr)
111  B2FATAL(MemErr);
113  sizeof(double));
114  if (m_SignalTimeDependenceDiff == nullptr)
115  B2FATAL(MemErr);
116  attenuationTime = 1.0 / m_DigPar->getPEAttenuationFrequency();
117  for (i = 0; i <= m_DigPar->getNDigitizations(); i++) {
118  time = samplingTime * i;
120  exp(-digPar->getPEAttenuationFrequency() * time) * attenuationTime /
121  samplingTime;
122  if (i > 0) {
125  }
126  }
127  m_Photoelectrons = nullptr;
128  m_PhotoelectronIndex = nullptr;
129  m_PhotoelectronIndex2 = nullptr;
131 }
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 448 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 338 of file ScintillatorSimulator.cc.

◆ getFitStatus()

enum KLM::ScintillatorFirmwareFitStatus getFitStatus ( ) const

Get fit status.

Returns
Status of the fit.

Definition at line 515 of file ScintillatorSimulator.cc.

◆ getMCTime()

float getMCTime ( ) const
inline

Get MC time.

Returns
MC time.

Definition at line 141 of file ScintillatorSimulator.h.

142  {
143  return m_MCTime;
144  }

◆ getSiPMMCTime()

float getSiPMMCTime ( ) const
inline

Get SiPM MC time.

Returns
SiPM MC yime.

Definition at line 150 of file ScintillatorSimulator.h.

◆ reallocPhotoElectronBuffers()

void reallocPhotoElectronBuffers ( int  size)
private

Reallocate photoelectron buffers.

Parameters
[in]sizeNew size of buffers.

Definition at line 45 of file ScintillatorSimulator.cc.

◆ simulate() [1/2]

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

Simulate BKLM strip.

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

Definition at line 170 of file ScintillatorSimulator.cc.

◆ simulate() [2/2]

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

Simulate EKLM strip.

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

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


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