Belle II Software  release-06-02-00
CsIDigitizerModule.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 #ifndef CSIDIGITIZERMODULE_H
10 #define CSIDIGITIZERMODULE_H
11 
12 #include <framework/core/Module.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <beast/csi/dataobjects/CsiDigiHit.h>
15 #include <beast/csi/dataobjects/CsiSimHit.h>
16 #include <beast/csi/dataobjects/CsiHit.h>
17 
18 #include <vector>
19 
20 
21 
22 namespace Belle2 {
27  namespace csi {
28 
30  typedef std::vector<double> Signal;
32  typedef std::vector<int> DigitalSignal;
33 
43  class CsIDigitizerModule : public Module {
44 
45  public:
46 
51 
53  virtual ~CsIDigitizerModule();
54 
56  virtual void initialize() override;
57 
59  virtual void beginRun() override;
60 
65  virtual void event() override;
66 
68  virtual void endRun() override;
69 
71  virtual void terminate() override;
72 
73 
74  private:
75 
86  Signal genTimeSignal(double _energy, double _timeAvg, double _timeRMS, int iChannel, bool _save = 0);
87 
101  double genTimeSignal(Signal* _output, Signal _energies, Signal _times, int _iChannel, int _dt, int _nsam, bool _save = 0);
102 
111  Signal genSignalTemplate(int _n, int _i0, double _t1, double _t2 = 0.0, double _rFastTot = 1.0);
112 
113 
125  Signal firstOrderResponse(double _gain, Signal _u, double _y0, double _dt, double _tSlow, double _delay);
126 
127 
132  // Signal firstOrderResponse(double _gain, Signal _u, double _y0, double _dt, double _tSlow, double _delay, double _tRatio, double _tFast);
133 
134 
135 
153  uint16_t doChargeIntegration(Signal _u, int _NsamBL, uint16_t* BSL, uint32_t* Q, uint32_t* t,
154  std::vector<uint16_t>* _Waveform, std::vector<uint8_t>* _DPPCIBits,
155  int _Treshold, double _TriggerHoldoff = 0.0, double _GateWidth = 320.0,
156  double _GateOffset = 40.0, bool _recordTraces = false);
157 
158 
167  int addNoise(Signal* y, double _rms, double _offset);
168 
176  DigitalSignal doDigitization(Signal _v, double _LSB);
177 
178 
188  double f(double fi, double u_i, double u_j, double y, double invtau);
189 
190 
191 
192 
195  int getnSamples() const { return m_nSamples; }
196 
199  void setnSamples(int nsamples) { m_nSamples = nsamples; }
200 
201 
202  private:
203 
205  int m_hitNum;
206 
207  // Member data objects
208  double m_TrueEdep;
209  double m_Resolution;
210  double m_SampleRate;
211  double m_dt;
216  uint8_t m_CellId;
217  uint16_t m_Baseline;
218  uint32_t m_Charge;
219  uint16_t m_MaxADC;
220  uint32_t m_Time;
222  std::vector<uint16_t> m_Waveform;
223  std::vector<uint8_t> m_DPPCIBits;
225  const double m_tRisePMT = 2;
226  const double m_tTransitPMT = 48;
227  const double m_Zl = 50;
235  std::vector<double> m_calibConstants;
236  std::vector<double> m_noiseLevels;
237  std::vector<double> m_LY;
238  std::vector<double> m_tRatio;
239  std::vector<double> m_tFast;
240  std::vector<double> m_tSlow;
241  std::vector<double> m_LCE;
242  std::vector<double> m_PmtQE;
243  std::vector<double> m_PmtGain;
248  };
249 
250  }
252 }
253 
254 #endif /* CSIDIGITIZERMODULE_H */
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Digitizer for the BEAST CsI system.
uint16_t m_Baseline
Baseline (pedestal) frozen during charge integration.
int addNoise(Signal *y, double _rms, double _offset)
Adds noise to the signal.
Signal m_SimHitEdeps[16]
Array of signals (each corresponding to one channel)
double m_Resolution
Parameter: Resolution (in mV) of the ACD.
DigitalSignal doDigitization(Signal _v, double _LSB)
Digitizes the signal the signal.
Signal m_CsITlSignalTemplate
Template Signal of a CsITl trace.
double m_TrueEdep
Sum of the MC (true) deposited energies in the event-channel.
std::vector< double > m_noiseLevels
Noise level for each channel (in V)
std::vector< uint16_t > m_Waveform
Saved waveform.
virtual void initialize() override
Register input and output data.
double f(double fi, double u_i, double u_j, double y, double invtau)
This returns the RHS of first order differential equation.
const double m_Zl
Line impedance of the analog chain (to get voltage from anode current)
virtual void event() override
Each event This is where the actual digitization is done, and the hits are written to the DataStore.
Signal firstOrderResponse(double _gain, Signal _u, double _y0, double _dt, double _tSlow, double _delay)
Calculates the time response of a first order system (such as crystal, PMT, etc)
virtual void endRun() override
Clean up.
Signal genTimeSignal(double _energy, double _timeAvg, double _timeRMS, int iChannel, bool _save=0)
Generates a time signal for a mean energy deposit The energy deposit is modelled at a Gaussian whose ...
StoreArray< CsiSimHit > m_aSimHit
Each simulated particle in the crystal.
int m_nWFcounter
Counter for the number of waveforms to save.
int getnSamples() const
Gets the number of points in the waveforms arrays.
virtual void terminate() override
Final clean up.
double m_dt
Time interval (in ns) (calculated from m_SampleRate.
std::vector< double > m_LCE
Light collection efficiency for each channel.
void setnSamples(int nsamples)
Sets the number of points in the waveforms arrays.
const double m_tTransitPMT
48Mean transit time of the PMT signal (in ns)
std::vector< double > m_LY
Light yield for each channel (gamma per GeV)
int m_nSamples
Number of points requested in the waveform arrays.
virtual ~CsIDigitizerModule()
Default destructor.
virtual void beginRun() override
To do before each runs.
std::vector< double > m_PmtGain
PMT gain for each channel.
std::vector< double > m_PmtQE
PMT quantum efficiency for each channel.
std::vector< uint8_t > m_DPPCIBits
status of the DPP-CI
const double m_tRisePMT
2.6 Rise time of the PMT signal (in ns)
std::vector< double > m_tSlow
Slow time constant for each channel (ns)
std::vector< double > m_calibConstants
Calibration constants for each channel (in V/keV)
std::vector< double > m_tRatio
Ratio fast light / slow light for each channel.
StoreArray< CsiDigiHit > m_aDigiHit
Output: a digitized hit.
uint16_t doChargeIntegration(Signal _u, int _NsamBL, uint16_t *BSL, uint32_t *Q, uint32_t *t, std::vector< uint16_t > *_Waveform, std::vector< uint8_t > *_DPPCIBits, int _Treshold, double _TriggerHoldoff=0.0, double _GateWidth=320.0, double _GateOffset=40.0, bool _recordTraces=false)
Method to use when crystal has two light components.
double m_SampleRate
Parameter: Sample rate (in samples/sec) of the ADC.
int m_nWaveforms
Number of waveforms to save.
Signal m_SimHitTimes[16]
Array of signals (each corresponding to one channel)
uint16_t m_MaxADC
Max ACD of the hit (to check saturations)
StoreArray< CsiHit > m_aHit
Time-accumulated hits...
CsIDigitizerModule()
Constructor: Sets the description, the properties and the parameters of the module.
Signal genSignalTemplate(int _n, int _i0, double _t1, double _t2=0.0, double _rFastTot=1.0)
Generates the template for a signal (obsolete)
uint32_t m_Charge
Integrated Charge.
std::vector< double > m_tFast
Fast time constant for each channel (ns)
std::vector< int > DigitalSignal
Designed to hold a "digital" (limited by the DAQ board rate and resolution) signal
std::vector< double > Signal
Designed to hold a "continuous" (in time and amplitude) signal
Abstract base class for different kinds of events.