Belle II Software development
ScintillatorSimulator.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11/* KLM headers. */
12#include <klm/dataobjects/KLMElementNumberDefinitions.h>
13#include <klm/dataobjects/KLMSimHit.h>
14#include <klm/dbobjects/KLMScintillatorDigitizationParameters.h>
15#include <klm/dbobjects/KLMScintillatorFEEData.h>
16#include <klm/simulation/ScintillatorFirmware.h>
17#include <klm/time/KLMTime.h>
18
19namespace Belle2 {
25 namespace KLM {
26
31
32 public:
33
36 int bin;
37 double expTime;
39 };
40
50 double digitizationInitialTime,
51 bool debug);
52
57
62
67
73 void simulate(
74 const std::multimap<KLMChannelNumber, const KLMSimHit*>::iterator& firstHit,
75 const std::multimap<KLMChannelNumber, const KLMSimHit*>::iterator& end);
76
81
86 enum ScintillatorFirmwareFitStatus getFitStatus() const;
87
91 double getNPhotoelectrons();
92
97
101 double getEnergy();
102
106 void setFEEData(const KLMScintillatorFEEData* FEEData);
107
116 void generatePhotoelectrons(double stripLen, double distSiPM,
117 int nPhotons, double timeShift,
118 bool isReflected);
119
126 void fillSiPMOutput(float* hist, bool useDirect, bool useReflected);
127
132 float getMCTime() const
133 {
134 return m_MCTime;
135 }
136
141 float getSiPMMCTime() const
142 {
143 return m_SiPMMCTime;
144 }
145
146 private:
147
152 void reallocPhotoElectronBuffers(int size);
153
157 void prepareSimulation();
158
162 void performSimulation();
163
169 int* sortPhotoelectrons(int nPhotoelectrons);
170
174 void addRandomSiPMNoise();
175
179 void simulateADC();
180
184 void debugOutput();
185
188
191
194
197
200
203
206
209
212
215
218
221
224
227
230
233
235 enum ScintillatorFirmwareFitStatus m_FPGAStat;
236
239
241 int m_npe;
242
244 double m_Energy;
245
247 std::string m_stripName;
248
251
254
257
259 float m_MCTime;
260
263
264 };
265
266 }
267
269}
Class to store KLM scintillator simulation parameters in the database.
KLM time conversion.
Definition: KLMTime.h:27
Digitize EKLMSim2Hits to get EKLM StripHits.
float getSiPMMCTime() const
Get SiPM MC time.
void setFEEData(const KLMScintillatorFEEData *FEEData)
Set FEE data.
int * m_PhotoelectronIndex2
Buffer for photoelectron indices.
float * m_amplitudeReflected
Analog amplitude (reflected).
void debugOutput()
Debug output (signal and fit result histograms).
enum ScintillatorFirmwareFitStatus getFitStatus() const
Get fit status.
double * m_SignalTimeDependence
Buffer for signal time dependence calculation.
void generatePhotoelectrons(double stripLen, double distSiPM, int nPhotons, double timeShift, bool isReflected)
Generate photoelectrons.
double * m_SignalTimeDependenceDiff
Buffer for signal time dependence calculation.
double m_Energy
Total energy deposited in the strip.
float * m_amplitudeDirect
Analog amplitude (direct).
ScintillatorSimulator(const ScintillatorSimulator &)=delete
Copy constructor (disabled).
void addRandomSiPMNoise()
Add random noise to the signal (amplitude-dependend).
void simulateADC()
Simulate ADC (create digital signal from analog),.
ScintillatorSimulator & operator=(const ScintillatorSimulator &)=delete
Operator = (disabled).
void prepareSimulation()
Prepare simulation.
double getEnergy()
Get total energy deposited in the strip (sum over ssimulation hits).
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.
double getNPhotoelectrons()
Get number of photoelectrons (fit result).
struct Photoelectron * m_Photoelectrons
Buffer for photoelectron data.
ScintillatorFirmware * m_fitter
Fitter.
std::string m_stripName
Name of the strip.
enum ScintillatorFirmwareFitStatus m_FPGAStat
FPGA fit status.
KLMScintillatorFirmwareFitResult * getFPGAFit()
Get fit data.
KLMScintillatorFirmwareFitResult m_FPGAFit
FPGA fit data.
void performSimulation()
Perform common simulation stage.
double m_PhotoelectronAmplitude
Photoelectron amplitude.
int getNGeneratedPhotoelectrons()
Get generated number of photoelectrons.
int * m_PhotoelectronIndex
Buffer for photoelectron indices.
void simulate(const std::multimap< KLMChannelNumber, const KLMSimHit * >::iterator &firstHit, const std::multimap< KLMChannelNumber, const KLMSimHit * >::iterator &end)
Simulate a strip.
void fillSiPMOutput(float *hist, bool useDirect, bool useReflected)
Fill SiPM output.
int * sortPhotoelectrons(int nPhotoelectrons)
Sort photoelectrons.
int m_npe
Number of photoelectrons (generated).
int m_PhotoelectronBufferSize
Size of photoelectron data buffer.
const KLMScintillatorDigitizationParameters * m_DigPar
Parameters.
Abstract base class for different kinds of events.
int bin
Hit time bin in ADC output histogram.
bool isReflected
Direct (false) or reflected (true).
double expTime
exp(-m_DigPar->PEAttenuationFreq * (-time))