@@ -56,7 +56,7 @@ Digitizer::CFDOutput Digitizer::get_time(const std::vector<float>& times, float
5656 }
5757 // (2) add noise
5858 // find the right indices into the sinc table
59- int timeIndex = std::lround (time / mParameters .mNoisePeriod * mSincTable .size ());
59+ int timeIndex = std::lround (time / DigitizationParameters::Instance () .mNoisePeriod * mSincTable .size ());
6060 int timeOffset = timeIndex / mSincTable .size ();
6161 timeIndex %= mSincTable .size ();
6262 if (timeOffset >= mNumNoiseSamples ) { // this happens when time >= 25 ns
@@ -90,32 +90,32 @@ Digitizer::CFDOutput Digitizer::get_time(const std::vector<float>& times, float
9090 };
9191 auto const min_time = std::max (deadTime, *std::min_element (std::begin (times),
9292 std::end (times)));
93- CFDOutput result{std::nullopt , -0 .5f * mParameters .mBunchWidth };
93+ CFDOutput result{std::nullopt , -0 .5f * DigitizationParameters::Instance () .mBunchWidth };
9494 bool is_positive = true ;
9595
9696 // reset the chache
9797 std::fill_n (std::begin (mSignalCache ), std::size (mSignalCache ), -1 .0f );
98-
98+ const auto & params = DigitizationParameters::Instance ();
9999 // we need double precision for time in order to match previous behaviour
100- for (double time = min_time; time < 0.5 * mParameters .mBunchWidth ; time += DP::SIGNAL_CACHE_DT) {
100+ for (double time = min_time; time < 0.5 * params .mBunchWidth ; time += DP::SIGNAL_CACHE_DT) {
101101 float const val = value_at (time);
102- int const index = std::lround ((time + 0.5 * mParameters .mBunchWidth ) / DP::SIGNAL_CACHE_DT);
102+ int const index = std::lround ((time + 0.5 * params .mBunchWidth ) / DP::SIGNAL_CACHE_DT);
103103 if (index >= 0 && index < mSignalCache .size ()) { // save the value for later use
104104 mSignalCache [index] = val;
105105 }
106106 // look up the time-shifted signal value from the past
107107 float val_prev = 0 .0f ;
108- int const index_prev = std::lround ((time - mParameters .mCFDShiftPos + 0 .5f * mParameters .mBunchWidth ) / DP::SIGNAL_CACHE_DT);
108+ int const index_prev = std::lround ((time - params .mCFDShiftPos + 0 .5f * params .mBunchWidth ) / DP::SIGNAL_CACHE_DT);
109109 val_prev = ((index_prev < 0 || index_prev >= mSignalCache .size () || mSignalCache [index_prev] < 0 .0f )
110- ? value_at (time - mParameters .mCFDShiftPos ) // was not computed before
111- : mSignalCache [index_prev]); // is available in the cache
110+ ? value_at (time - params .mCFDShiftPos ) // was not computed before
111+ : mSignalCache [index_prev]); // is available in the cache
112112 float const cfd_val = 5 .0f * val_prev - val;
113- if (std::abs (val) > mParameters .mCFD_trsh && !is_positive && cfd_val > 0 .0f ) {
113+ if (std::abs (val) > params .mCFD_trsh && !is_positive && cfd_val > 0 .0f ) {
114114 if (!result.particle ) {
115115 result.particle = time;
116116 }
117- result.deadTime = time + mParameters .mCFDdeadTime ;
118- time += mParameters .mCFDdeadTime - DP::SIGNAL_CACHE_DT;
117+ result.deadTime = time + params .mCFDdeadTime ;
118+ time += params .mCFDdeadTime - DP::SIGNAL_CACHE_DT;
119119 is_positive = true ;
120120 } else {
121121 is_positive = cfd_val > 0 .0f ;
@@ -126,8 +126,8 @@ Digitizer::CFDOutput Digitizer::get_time(const std::vector<float>& times, float
126126
127127double Digitizer::measure_amplitude (const std::vector<float >& times) const
128128{
129- float const from = mParameters .mAmpRecordLow ;
130- float const to = from + mParameters .mAmpRecordUp ;
129+ float const from = DigitizationParameters::Instance () .mAmpRecordLow ;
130+ float const to = from + DigitizationParameters::Instance () .mAmpRecordUp ;
131131 // SIMD version has a negligible effect on the total wall time
132132 Vc::float_v acc (0 );
133133 Vc::float_v tv (0 );
@@ -165,10 +165,10 @@ void Digitizer::process(const std::vector<o2::ft0::HitType>* hits,
165165 if (hit.GetEnergyLoss () > 0 ) {
166166 continue ;
167167 }
168-
168+ const auto & params = DigitizationParameters::Instance ();
169169 Int_t hit_ch = hit.GetDetectorID ();
170170 Bool_t is_A_side = (hit_ch < 4 * mGeometry .NCellsA );
171- Float_t time_compensate = is_A_side ? mParameters .mA_side_cable_cmps : mParameters .mC_side_cable_cmps ;
171+ Float_t time_compensate = is_A_side ? params .mA_side_cable_cmps : params .mC_side_cable_cmps ;
172172 Double_t hit_time = hit.GetTime () - time_compensate;
173173 if (hit_time > 250 ) {
174174 continue ; // not collect very slow particles
@@ -199,17 +199,17 @@ void Digitizer::storeBC(BCCache& bc,
199199 int n_hit_A = 0 , n_hit_C = 0 , mean_time_A = 0 , mean_time_C = 0 ;
200200 int summ_ampl_A = 0 , summ_ampl_C = 0 ;
201201 int vertex_time;
202-
202+ const auto & params = DigitizationParameters::Instance ();
203203 int first = digitsCh.size (), nStored = 0 ;
204204 auto & particles = bc.hits ;
205205 std::sort (std::begin (particles), std::end (particles));
206206 auto channel_end = particles.begin ();
207207 std::vector<float > channel_times;
208- for (Int_t ipmt = 0 ; ipmt < mParameters .mMCPs ; ++ipmt) {
208+ for (Int_t ipmt = 0 ; ipmt < params .mMCPs ; ++ipmt) {
209209 auto channel_begin = channel_end;
210210 channel_end = std::find_if (channel_begin, particles.end (),
211211 [ipmt](BCCache::particle const & p) { return p.hit_ch != ipmt; });
212- if (channel_end - channel_begin < mParameters .mAmp_trsh ) {
212+ if (channel_end - channel_begin < params .mAmp_trsh ) {
213213 continue ;
214214 }
215215 channel_times.resize (channel_end - channel_begin);
@@ -224,10 +224,10 @@ void Digitizer::storeBC(BCCache& bc,
224224 if (!cfd.particle ) {
225225 continue ;
226226 }
227- int smeared_time = 1000 . * (*cfd.particle - mParameters .mCfdShift ) * mParameters .mChannelWidthInverse ;
228- bool is_time_in_signal_gate = (smeared_time > -mParameters .mTime_trg_gate && smeared_time < mParameters .mTime_trg_gate );
229- float charge = measure_amplitude (channel_times) * mParameters .mCharge2amp ;
230- float amp = is_time_in_signal_gate ? mParameters .mMV_2_Nchannels * charge : 0 ;
227+ int smeared_time = 1000 . * (*cfd.particle - params .mCfdShift ) * params .mChannelWidthInverse ;
228+ bool is_time_in_signal_gate = (smeared_time > -params .mTime_trg_gate && smeared_time < params .mTime_trg_gate );
229+ float charge = measure_amplitude (channel_times) * params .mCharge2amp ;
230+ float amp = is_time_in_signal_gate ? params .mMV_2_Nchannels * charge : 0 ;
231231 if (amp > 4095 ) {
232232 amp = 4095 ;
233233 }
@@ -255,10 +255,10 @@ void Digitizer::storeBC(BCCache& bc,
255255 Bool_t is_A, is_C, isVertex, is_Central, is_SemiCentral = 0 ;
256256 is_A = n_hit_A > 0 ;
257257 is_C = n_hit_C > 0 ;
258- is_Central = summ_ampl_A + summ_ampl_C >= mParameters .mtrg_central_trh ;
259- is_SemiCentral = summ_ampl_A + summ_ampl_C >= mParameters .mtrg_semicentral_trh ;
258+ is_Central = summ_ampl_A + summ_ampl_C >= params .mtrg_central_trh ;
259+ is_SemiCentral = summ_ampl_A + summ_ampl_C >= params .mtrg_semicentral_trh ;
260260 vertex_time = (mean_time_A - mean_time_C) * 0.5 ;
261- isVertex = is_A && is_C && (vertex_time > -mParameters .mTime_trg_gate && vertex_time < mParameters .mTime_trg_gate );
261+ isVertex = is_A && is_C && (vertex_time > -params .mTime_trg_gate && vertex_time < params .mTime_trg_gate );
262262 uint32_t amplA = is_A ? summ_ampl_A * 0.125 : 0 ; // sum amplitude A side / 8 (hardware)
263263 uint32_t amplC = is_C ? summ_ampl_C * 0.125 : 0 ; // sum amplitude C side / 8 (hardware)
264264 uint16_t timeA = is_A ? mean_time_A / n_hit_A : 0 ; // average time A side
@@ -322,27 +322,28 @@ void Digitizer::initParameters()
322322 auto const sinc = [](double x) { x *= TMath::Pi (); return (std::abs (x) < 1e-12 ) ? 1.0 : std::sin (x) / x; };
323323
324324 // number of noise samples in one BC
325- mNumNoiseSamples = std::ceil (mParameters .mBunchWidth / mParameters .mNoisePeriod );
325+ const auto & params = DigitizationParameters::Instance ();
326+ mNumNoiseSamples = std::ceil (params.mBunchWidth / params.mNoisePeriod );
326327 mNoiseSamples .resize (mNumNoiseSamples );
327328
328329 // set up tables with sinc function values (times noiseVar)
329330 for (size_t i = 0 , n = mSincTable .size (); i < n; ++i) {
330- float const time = i / float (n) * mParameters .mNoisePeriod ; // [0 .. 1/mParameters .mNoisePeriod)
331+ float const time = i / float (n) * params .mNoisePeriod ; // [0 .. 1/params .mNoisePeriod)
331332 LOG (DEBUG) << " initParameters " << i << " /" << n << " " << time;
332333 // we make a table of sinc values between -num_noise_samples and 2*num_noise_samples
333334 mSincTable [i].resize (3 * mNumNoiseSamples );
334335 for (int j = -mNumNoiseSamples ; j < 2 * mNumNoiseSamples ; ++j) {
335- mSincTable [i][mNumNoiseSamples + j] = mParameters .mNoiseVar * sinc ((time + 0 .5f * mParameters .mBunchWidth ) / mParameters .mNoisePeriod - j);
336+ mSincTable [i][mNumNoiseSamples + j] = params .mNoiseVar * sinc ((time + 0 .5f * params .mBunchWidth ) / params .mNoisePeriod - j);
336337 }
337338 }
338339 // set up the lookup table for the signal form
339340 for (size_t i = 0 ; i < DP::SIGNAL_TABLE_SIZE; ++i) {
340- float const x = float (i) / float (DP::SIGNAL_TABLE_SIZE) * mParameters .mBunchWidth ;
341+ float const x = float (i) / float (DP::SIGNAL_TABLE_SIZE) * params .mBunchWidth ;
341342 mSignalTable [i] = signalForm_i (x);
342343 }
343344
344345 // cache for signal time series used by the CFD -BC/2 .. +3BC/2
345- mSignalCache .resize (std::lround (mParameters .mBunchWidth / DP::SIGNAL_CACHE_DT));
346+ mSignalCache .resize (std::lround (params .mBunchWidth / DP::SIGNAL_CACHE_DT));
346347}
347348// _______________________________________________________________________
348349void Digitizer::init ()
@@ -359,13 +360,14 @@ void Digitizer::finish()
359360
360361void Digitizer::printParameters () const
361362{
363+ const auto & params = DigitizationParameters::Instance ();
362364 LOG (INFO) << " Run Digitzation with parametrs: \n "
363- << " CFD amplitude threshold \n " << mParameters .mCFD_trsh << " CFD signal gate in ps \n "
364- << mParameters .mTime_trg_gate << " shift to have signal around zero after CFD trancformation \n "
365- << mParameters .mCfdShift << " CFD distance between 0.3 of max amplitude to max \n "
366- << mParameters .mCFDShiftPos << " MIP -> mV " << mParameters .mMip_in_V << " Pe in MIP \n "
367- << mParameters .mPe_in_mip << " noise level " << mParameters .mNoiseVar << " noise frequency \n "
368- << mParameters .mNoisePeriod << " mMCPs " << mParameters .mMCPs ;
365+ << " CFD amplitude threshold \n " << params .mCFD_trsh << " CFD signal gate in ps \n "
366+ << params .mTime_trg_gate << " shift to have signal around zero after CFD trancformation \n "
367+ << params .mCfdShift << " CFD distance between 0.3 of max amplitude to max \n "
368+ << params .mCFDShiftPos << " MIP -> mV " << params .mMip_in_V << " Pe in MIP \n "
369+ << params .mPe_in_mip << " noise level " << params .mNoiseVar << " noise frequency \n "
370+ << params .mNoisePeriod << " mMCPs " << params .mMCPs ;
369371}
370372
371373O2ParamImpl (DigitizationParameters);
0 commit comments