Skip to content

Commit 2aaf427

Browse files
committed
FT0 CTF stores gate value + proper usage of DigitizationParams
1 parent b9f08d3 commit 2aaf427

File tree

9 files changed

+53
-54
lines changed

9 files changed

+53
-54
lines changed

DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/CTF.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ struct CTFHeader {
2929
uint32_t nTriggers = 0; /// number of triggers in TF
3030
uint32_t firstOrbit = 0; /// 1st orbit of TF
3131
uint16_t firstBC = 0; /// 1st BC of TF
32-
33-
ClassDefNV(CTFHeader, 1);
32+
uint16_t triggerGate = 192; // trigger gate used at encoding
33+
ClassDefNV(CTFHeader, 2);
3434
};
3535

3636
/// Intermediate, compressed but not yet entropy-encoded digits

Detectors/CTF/test/test_ctf_io_ft0.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(CTFTest)
3131
sw.Start();
3232
o2::InteractionRecord ir(0, 0);
3333

34-
int mTime_trg_gate = 192; // #channels
34+
int trg_gate = DigitizationParameters::Instance().mTime_trg_gate;
3535
constexpr int MAXChan = 4 * (Geometry::NCellsA + Geometry::NCellsC);
3636
for (int idig = 0; idig < 1000; idig++) {
3737
ir += 1 + gRandom->Integer(200);
@@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(CTFTest)
4747
uint16_t q = gRandom->Integer(4096);
4848
uint8_t chain = gRandom->Rndm() > 0.5 ? 0 : 1;
4949
channels.emplace_back(ich, t, q, chain);
50-
if (std::abs(t) < DigitizationParameters::mTime_trg_gate) {
50+
if (std::abs(t) < trg_gate) {
5151
if (ich < 4 * uint8_t(Geometry::NCellsA)) {
5252
trig.nChanA++;
5353
ampTotA += q;

Detectors/FIT/FT0/reconstruction/include/FT0Reconstruction/CTFCoder.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ void CTFCoder::decompress(const CompressedDigits& cd, VDIG& digitVec, VCHAN& cha
166166
auto icc = channelVec.size();
167167
const auto& chan = channelVec.emplace_back((chID += cd.idChan[icc]), cd.cfdTime[icc], cd.qtcAmpl[icc], cd.qtcChain[icc]);
168168
//
169-
// rebuild digit
170-
int isInTrig = DigitizationParameters::mTime_trg_gate;
171-
// if (std::abs(chan.CFDTime) < DigitizationParameters::mTime_trg_gate) {
172-
if (std::abs(chan.CFDTime) < isInTrig) {
169+
if (std::abs(chan.CFDTime) < cd.header.triggerGate) {
173170
if (chan.ChId < 4 * uint8_t(Geometry::NCellsA)) { // A side
174171
amplA += chan.QTCAmpl;
175172
timeA += chan.CFDTime;

Detectors/FIT/FT0/reconstruction/src/CTFCoder.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/// \brief class for entropy encoding/decoding of FT0 digits data
1414

1515
#include "FT0Reconstruction/CTFCoder.h"
16+
#include "FT0Simulation/DigitizationParameters.h"
1617
#include "CommonUtils/StringUtils.h"
1718
#include <TTree.h>
1819

@@ -48,6 +49,7 @@ void CTFCoder::compress(CompressedDigits& cd, const gsl::span<const Digit>& digi
4849
cd.header.nTriggers = digitVec.size();
4950
cd.header.firstOrbit = dig0.getOrbit();
5051
cd.header.firstBC = dig0.getBC();
52+
cd.header.triggerGate = DigitizationParameters::Instance().mTime_trg_gate;
5153

5254
cd.trigger.resize(cd.header.nTriggers);
5355
cd.bcInc.resize(cd.header.nTriggers);

Detectors/FIT/FT0/reconstruction/src/CollisionTimeRecoTask.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ o2::ft0::RecPoints CollisionTimeRecoTask::process(o2::ft0::Digit const& bcd,
4646
LOG(DEBUG) << " event time " << timeStamp << " orbit " << bcd.mIntRecord.orbit << " bc " << bcd.mIntRecord.bc;
4747

4848
int nch = inChData.size();
49+
const auto parInv = DigitizationParameters::Instance().mMV_2_NchannelsInverse;
4950
for (int ich = 0; ich < nch; ich++) {
5051
outChData[ich] = o2::ft0::ChannelDataFloat{inChData[ich].ChId,
5152
inChData[ich].CFDTime * Geometry::ChannelWidth,
52-
(double)inChData[ich].QTCAmpl * DigitizationParameters::mMV_2_NchannelsInverse,
53+
(double)inChData[ich].QTCAmpl * parInv,
5354
inChData[ich].ChainQTC};
5455

5556
// only signals with amplitude participate in collision time

Detectors/FIT/FT0/simulation/include/FT0Simulation/DigitizationParameters.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ struct DigitizationParameters
3939
float mCharge2amp = 0.22;
4040
float mNoiseVar = 0.1; //noise level
4141
float mNoisePeriod = 1 / 0.9; // GHz low frequency noise period;
42+
short mTime_trg_gate = 192; // #channels
43+
4244
static constexpr float mMV_2_Nchannels = 2.2857143; //amplitude channel 7 mV ->16channels
4345
static constexpr float mMV_2_NchannelsInverse = 0.437499997; //inverse amplitude channel 7 mV ->16channels
44-
static constexpr int mTime_trg_gate = 192; // #channels
4546

4647
O2ParamDef(DigitizationParameters, "DigitizationParameters");
4748
};

Detectors/FIT/FT0/simulation/include/FT0Simulation/Digitizer.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Digitizer
4040
typedef math_utils::RandomRing<float_v::size() * DP::NOISE_RANDOM_RING_SIZE> NoiseRandomRingType;
4141

4242
public:
43-
Digitizer(const DigitizationParameters& params, Int_t mode = 0) : mMode(mode), mParameters(params), mRndGaus(NoiseRandomRingType::RandomType::Gaus), mNumNoiseSamples(), mNoiseSamples(), mSincTable(), mSignalTable(), mSignalCache() { initParameters(); }
43+
Digitizer(Int_t mode = 0) : mMode(mode), mRndGaus(NoiseRandomRingType::RandomType::Gaus), mNumNoiseSamples(), mNoiseSamples(), mSincTable(), mSignalTable(), mSignalCache() { initParameters(); }
4444
~Digitizer() = default;
4545

4646
void process(const std::vector<o2::ft0::HitType>* hits, std::vector<o2::ft0::Digit>& digitsBC,
@@ -100,7 +100,7 @@ class Digitizer
100100
if (x <= 0.0f) {
101101
return 0.0f;
102102
}
103-
float const y = x / mParameters.mBunchWidth * DP::SIGNAL_TABLE_SIZE;
103+
float const y = x / DigitizationParameters::Instance().mBunchWidth * DP::SIGNAL_TABLE_SIZE;
104104
int const index = std::floor(y);
105105
if (index + 1 >= DP::SIGNAL_TABLE_SIZE) {
106106
return mSignalTable.back();
@@ -111,7 +111,7 @@ class Digitizer
111111

112112
inline Vc::float_v signalFormVc(Vc::float_v x) const
113113
{ // table lookup for the signal shape (SIMD version)
114-
auto const y = x / mParameters.mBunchWidth * DP::SIGNAL_TABLE_SIZE;
114+
auto const y = x / DigitizationParameters::Instance().mBunchWidth * DP::SIGNAL_TABLE_SIZE;
115115
Vc::float_v::IndexType const index = Vc::floor(y);
116116
auto const rem = y - index;
117117
Vc::float_v val(0);
@@ -141,7 +141,6 @@ class Digitizer
141141
std::deque<BCCache> mCache;
142142
std::array<GoodInteractionTimeRecord, 208> mDeadTimes;
143143

144-
DigitizationParameters const& mParameters;
145144
o2::ft0::Geometry mGeometry;
146145

147146
NoiseRandomRingType mRndGaus;

Detectors/FIT/FT0/simulation/src/Digitizer.cxx

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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

127127
double 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
//_______________________________________________________________________
348349
void Digitizer::init()
@@ -359,13 +360,14 @@ void Digitizer::finish()
359360

360361
void 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

371373
O2ParamImpl(DigitizationParameters);

Steer/DigitizerWorkflow/src/FT0DigitizerSpec.cxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "Headers/DataHeader.h"
1818
#include "Steer/HitProcessingManager.h" // for DigitizationContext
1919
#include "FT0Simulation/Digitizer.h"
20-
#include "FT0Simulation/DigitizationParameters.h"
2120
#include "DataFormatsFT0/ChannelData.h"
2221
#include "DataFormatsFT0/HitType.h"
2322
#include "DataFormatsFT0/Digit.h"
@@ -44,9 +43,7 @@ class FT0DPLDigitizerTask : public o2::base::BaseDPLDigitizer
4443
using GRP = o2::parameters::GRPObject;
4544

4645
public:
47-
FT0DPLDigitizerTask() : o2::base::BaseDPLDigitizer(), mDigitizer(DigitizationParameters::Instance()) {}
48-
explicit FT0DPLDigitizerTask(o2::ft0::DigitizationParameters const& parameters)
49-
: o2::base::BaseDPLDigitizer(), mDigitizer(parameters){};
46+
FT0DPLDigitizerTask() : o2::base::BaseDPLDigitizer(), mDigitizer() {}
5047
~FT0DPLDigitizerTask() override = default;
5148

5249
void initDigitizerTask(framework::InitContext& ic) override

0 commit comments

Comments
 (0)