Belle II Software  release-05-01-25
ScintillatorSimulator.h
1 /**************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Timofey Uglov, Kirill Chilikin *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 /* KLM headers. */
14 #include <klm/dataobjects/bklm/BKLMSimHit.h>
15 #include <klm/dataobjects/eklm/EKLMSimHit.h>
16 #include <klm/dbobjects/eklm/EKLMChannelData.h>
17 #include <klm/dbobjects/KLMScintillatorDigitizationParameters.h>
18 #include <klm/simulation/ScintillatorFirmware.h>
19 
20 namespace Belle2 {
26  namespace KLM {
27 
31  class ScintillatorSimulator {
32 
33  public:
34 
36  struct Photoelectron {
37  int bin;
38  double expTime;
39  bool isReflected;
40  };
41 
50  ScintillatorFirmware* fitter,
51  double digitizationInitialTime,
52  bool debug);
53 
58 
63 
68 
74  void simulate(
75  const std::multimap<uint16_t, const BKLMSimHit*>::iterator& firstHit,
76  const std::multimap<uint16_t, const BKLMSimHit*>::iterator& end);
77 
83  void simulate(
84  const std::multimap<uint16_t, const EKLMSimHit*>::iterator& firstHit,
85  const std::multimap<uint16_t, const EKLMSimHit*>::iterator& end);
86 
91 
96  enum ScintillatorFirmwareFitStatus getFitStatus() const;
97 
101  double getNPhotoelectrons();
102 
107 
111  double getEnergy();
112 
116  void setChannelData(const EKLMChannelData* channelData);
117 
126  void generatePhotoelectrons(double stripLen, double distSiPM,
127  int nPhotons, double timeShift,
128  bool isReflected);
129 
136  void fillSiPMOutput(float* hist, bool useDirect, bool useReflected);
137 
142  float getMCTime() const
143  {
144  return m_MCTime;
145  }
146 
151  float getSiPMMCTime() const
152  {
153  return m_SiPMMCTime;
154  }
155 
156  private:
157 
162  void reallocPhotoElectronBuffers(int size);
163 
167  void prepareSimulation();
168 
172  void performSimulation();
173 
179  int* sortPhotoelectrons(int nPhotoelectrons);
180 
184  void addRandomSiPMNoise();
185 
189  void simulateADC();
190 
194  void debugOutput();
195 
197  const KLMScintillatorDigitizationParameters* m_DigPar;
198 
200  ScintillatorFirmware* m_fitter;
201 
204 
206  bool m_Debug;
207 
209  double m_histRange;
210 
212  float* m_amplitudeDirect;
213 
215  float* m_amplitudeReflected;
216 
218  float* m_amplitude;
219 
221  int* m_ADCAmplitude;
222 
224  double* m_SignalTimeDependence;
225 
228 
230  struct Photoelectron* m_Photoelectrons;
231 
234 
237 
240 
242  enum ScintillatorFirmwareFitStatus m_FPGAStat;
243 
245  KLMScintillatorFirmwareFitResult m_FPGAFit;
246 
248  int m_npe;
249 
251  double m_Energy;
252 
254  std::string m_stripName;
255 
257  double m_Pedestal;
258 
261 
263  int m_Threshold;
264 
266  float m_MCTime;
267 
269  float m_SiPMMCTime;
270 
271  };
272 
273  }
274 
276 }
Belle2::EKLMChannelData
EKLM channel data.
Definition: EKLMChannelData.h:33
Belle2::KLM::ScintillatorSimulator::m_PhotoelectronBufferSize
int m_PhotoelectronBufferSize
Size of photoelectron data buffer.
Definition: ScintillatorSimulator.h:247
Belle2::KLM::ScintillatorSimulator::ScintillatorSimulator
ScintillatorSimulator(const KLMScintillatorDigitizationParameters *digPar, ScintillatorFirmware *fitter, double digitizationInitialTime, bool debug)
Constructor.
Definition: ScintillatorSimulator.cc:71
Belle2::KLM::ScintillatorSimulator
Digitize EKLMSim2Hits to get EKLM StripHits.
Definition: ScintillatorSimulator.h:39
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::KLM::ScintillatorSimulator::getNGeneratedPhotoelectrons
int getNGeneratedPhotoelectrons()
Get generated number of photoelectrons.
Definition: ScintillatorSimulator.cc:531
Belle2::KLM::ScintillatorSimulator::debugOutput
void debugOutput()
Debug output (signal and fit result histograms).
Definition: ScintillatorSimulator.cc:541
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::~ScintillatorSimulator
~ScintillatorSimulator()
Destructor.
Definition: ScintillatorSimulator.cc:133
Belle2::KLM::ScintillatorSimulator::m_ADCAmplitude
int * m_ADCAmplitude
Digital amplitude.
Definition: ScintillatorSimulator.h:229
Belle2::KLM::ScintillatorSimulator::getEnergy
double getEnergy()
Get total energy deposited in the strip (sum over ssimulation hits).
Definition: ScintillatorSimulator.cc:536
Belle2::KLM::ScintillatorSimulator::m_npe
int m_npe
Number of photoelectrons (generated).
Definition: ScintillatorSimulator.h:256
Belle2::KLM::ScintillatorSimulator::getFPGAFit
KLMScintillatorFirmwareFitResult * getFPGAFit()
Get fit data.
Definition: ScintillatorSimulator.cc:513
Belle2::KLM::ScintillatorSimulator::setChannelData
void setChannelData(const EKLMChannelData *channelData)
Set channel data.
Definition: ScintillatorSimulator.cc:146
Belle2::KLM::ScintillatorSimulator::getSiPMMCTime
float getSiPMMCTime() const
Get SiPM MC time.
Definition: ScintillatorSimulator.h:159
Belle2::KLM::ScintillatorSimulator::m_amplitudeDirect
float * m_amplitudeDirect
Analog amplitude (direct).
Definition: ScintillatorSimulator.h:220
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::Photoelectron::isReflected
bool isReflected
Direct (false) or reflected (true).
Definition: ScintillatorSimulator.h:47
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::KLM::ScintillatorSimulator::m_SignalTimeDependenceDiff
double * m_SignalTimeDependenceDiff
Buffer for signal time dependence calculation.
Definition: ScintillatorSimulator.h:235
Belle2::KLM::ScintillatorSimulator::getNPhotoelectrons
double getNPhotoelectrons()
Get number of photoelectrons (fit result).
Definition: ScintillatorSimulator.cc:523
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::KLM::ScintillatorSimulator::generatePhotoelectrons
void generatePhotoelectrons(double stripLen, double distSiPM, int nPhotons, double timeShift, bool isReflected)
Generate photoelectrons.
Definition: ScintillatorSimulator.cc:337
Belle2::KLM::ScintillatorSimulator::m_Debug
bool m_Debug
Debug mode (generates additional output files with histograms).
Definition: ScintillatorSimulator.h:214
Belle2::KLM::ScintillatorSimulator::operator=
ScintillatorSimulator & operator=(const ScintillatorSimulator &)=delete
Operator = (disabled).
Belle2::KLMScintillatorDigitizationParameters
Class to store KLM scintillator simulation parameters in the database.
Definition: KLMScintillatorDigitizationParameters.h:33
Belle2::KLM::ScintillatorSimulator::m_amplitudeReflected
float * m_amplitudeReflected
Analog amplitude (reflected).
Definition: ScintillatorSimulator.h:223
Belle2::KLM::ScintillatorSimulator::simulate
void simulate(const std::multimap< uint16_t, const BKLMSimHit * >::iterator &firstHit, const std::multimap< uint16_t, const BKLMSimHit * >::iterator &end)
Simulate BKLM strip.
Definition: ScintillatorSimulator.cc:169
Belle2::KLM::ScintillatorSimulator::m_Energy
double m_Energy
Total energy deposited in the strip.
Definition: ScintillatorSimulator.h:259
Belle2::KLM::ScintillatorSimulator::sortPhotoelectrons
int * sortPhotoelectrons(int nPhotoelectrons)
Sort photoelectrons.
Definition: ScintillatorSimulator.cc:289
Belle2::KLM::ScintillatorSimulator::addRandomSiPMNoise
void addRandomSiPMNoise()
Add random noise to the signal (amplitude-dependend).
Definition: ScintillatorSimulator.cc:281
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::fillSiPMOutput
void fillSiPMOutput(float *hist, bool useDirect, bool useReflected)
Fill SiPM output.
Definition: ScintillatorSimulator.cc:446
Belle2::KLM::ScintillatorSimulator::m_FPGAFit
KLMScintillatorFirmwareFitResult m_FPGAFit
FPGA fit data.
Definition: ScintillatorSimulator.h:253
Belle2::KLM::ScintillatorSimulator::getFitStatus
enum ScintillatorFirmwareFitStatus getFitStatus() const
Get fit status.
Definition: ScintillatorSimulator.cc:518
Belle2::KLM::ScintillatorFirmware
FPGA fitter class.
Definition: ScintillatorFirmware.h:33
Belle2::KLM::ScintillatorSimulator::m_stripName
std::string m_stripName
Name of the strip.
Definition: ScintillatorSimulator.h:262
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::Photoelectron::bin
int bin
Hit time bin in ADC output histogram.
Definition: ScintillatorSimulator.h:45
Belle2::KLM::ScintillatorSimulator::simulateADC
void simulateADC()
Simulate ADC (create digital signal from analog),.
Definition: ScintillatorSimulator.cc:498
Belle2::KLM::ScintillatorSimulator::prepareSimulation
void prepareSimulation()
Prepare simulation.
Definition: ScintillatorSimulator.cc:154
Belle2::KLMScintillatorFirmwareFitResult
FPGA fit simulation data.
Definition: KLMScintillatorFirmwareFitResult.h:50
Belle2::KLM::ScintillatorSimulator::getMCTime
float getMCTime() const
Get MC time.
Definition: ScintillatorSimulator.h:150
Belle2::KLM::ScintillatorSimulator::performSimulation
void performSimulation()
Perform common simulation stage.
Definition: ScintillatorSimulator.cc:259
Belle2::KLM::ScintillatorSimulator::m_FPGAStat
enum ScintillatorFirmwareFitStatus m_FPGAStat
FPGA fit status.
Definition: ScintillatorSimulator.h:250
Belle2::KLM::ScintillatorSimulator::Photoelectron::expTime
double expTime
exp(-m_DigPar->PEAttenuationFreq * (-time))
Definition: ScintillatorSimulator.h:46
Belle2::KLM::ScintillatorSimulator::m_histRange
double m_histRange
Stands for nDigitizations*ADCSamplingTime.
Definition: ScintillatorSimulator.h:217