Skip to content

Commit fced477

Browse files
Digitization parameters as ConfigurableParam and unit test (#5680)
* DigitizationParameters derived from ConfigurableParams * unit test for raw 2 digits conversion * clang * remove test_raw_conversion_ft0
1 parent f8ddbb7 commit fced477

10 files changed

Lines changed: 70 additions & 60 deletions

File tree

Detectors/CTF/test/test_ctf_io_ft0.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <boost/test/unit_test.hpp>
1515
#include "DetectorsCommonDataFormats/NameConf.h"
1616
#include "FT0Reconstruction/CTFCoder.h"
17+
#include "FT0Simulation/DigitizationParameters.h"
1718
#include "Framework/Logger.h"
1819
#include <TFile.h>
1920
#include <TRandom.h>
@@ -46,7 +47,7 @@ BOOST_AUTO_TEST_CASE(CTFTest)
4647
uint16_t q = gRandom->Integer(4096);
4748
uint8_t chain = gRandom->Rndm() > 0.5 ? 0 : 1;
4849
channels.emplace_back(ich, t, q, chain);
49-
if (std::abs(t) < Geometry::mTime_trg_gate) {
50+
if (std::abs(t) < DigitizationParameters::mTime_trg_gate) {
5051
if (ich < 4 * uint8_t(Geometry::NCellsA)) {
5152
trig.nChanA++;
5253
ampTotA += q;

Detectors/FIT/FT0/base/include/FT0Base/Geometry.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ class Geometry
3737
///
3838
TVector3 centerMCP(int imcp) { return mMCP[imcp]; }
3939

40-
static constexpr int Nchannels = 208; // number od channels
41-
static constexpr int NCellsA = 24; // number of radiatiors on A side
42-
static constexpr int NCellsC = 28; // number of radiatiors on C side
43-
static constexpr float ZdetA = 335; // number of radiatiors on A side
44-
static constexpr float ZdetC = 82; // number of radiatiors on C side
45-
static constexpr float ChannelWidth = 13.02; // channel width in ps
46-
static constexpr float MV_2_Nchannels = 2.2857143; //amplitude channel 7 mV ->16channels
47-
static constexpr float MV_2_NchannelsInverse = 0.437499997; //inverse amplitude channel 7 mV ->16channels
48-
static constexpr int mTime_trg_gate = 192; // #channels
40+
static constexpr int Nchannels = 208; // number od channels
41+
static constexpr int NCellsA = 24; // number of radiatiors on A side
42+
static constexpr int NCellsC = 28; // number of radiatiors on C side
43+
static constexpr float ZdetA = 335; // number of radiatiors on A side
44+
static constexpr float ZdetC = 82; // number of radiatiors on C side
45+
static constexpr float ChannelWidth = 13.02; // channel width in ps
46+
static constexpr float ChannelWidthInverse = 0.076804916; // channel width in ps inverse
47+
// static constexpr float MV_2_Nchannels = 2.2857143; //amplitude channel 7 mV ->16channels
48+
// static constexpr float MV_2_NchannelsInverse = 0.437499997; //inverse amplitude channel 7 mV ->16channels
49+
// static constexpr int mTime_trg_gate = 192; // #channels
4950

5051
private:
5152
TVector3 mMCP[52];

Detectors/FIT/FT0/reconstruction/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ o2_add_library(FT0Reconstruction
1616

1717
PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat O2::Framework
1818
O2::FT0Base
19+
O2::FT0Simulation
1920
O2::DataFormatsFT0
2021
O2::DetectorsRaw
2122
O2::CommonDataFormat

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "DataFormatsFT0/Digit.h"
2424
#include "DataFormatsFT0/ChannelData.h"
2525
#include "DetectorsCommonDataFormats/DetID.h"
26+
#include "FT0Simulation/DigitizationParameters.h"
2627
#include "DetectorsBase/CTFCoderBase.h"
2728
#include "rANS/rans.h"
2829

@@ -60,6 +61,8 @@ class CTFCoder : public o2::ctf::CTFCoderBase
6061

6162
void appendToTree(TTree& tree, CTF& ec);
6263
void readFromTree(TTree& tree, int entry, std::vector<Digit>& digitVec, std::vector<ChannelData>& channelVec);
64+
// DigitizationParameters const &mParameters;
65+
// o2::ft0::Geometry mGeometry;
6366

6467
ClassDefNV(CTFCoder, 1);
6568
};
@@ -164,7 +167,9 @@ void CTFCoder::decompress(const CompressedDigits& cd, VDIG& digitVec, VCHAN& cha
164167
const auto& chan = channelVec.emplace_back((chID += cd.idChan[icc]), cd.cfdTime[icc], cd.qtcAmpl[icc], cd.qtcChain[icc]);
165168
//
166169
// rebuild digit
167-
if (std::abs(chan.CFDTime) < Geometry::mTime_trg_gate) {
170+
int isInTrig = DigitizationParameters::mTime_trg_gate;
171+
// if (std::abs(chan.CFDTime) < DigitizationParameters::mTime_trg_gate) {
172+
if (std::abs(chan.CFDTime) < isInTrig) {
168173
if (chan.ChId < 4 * uint8_t(Geometry::NCellsA)) { // A side
169174
amplA += chan.QTCAmpl;
170175
timeA += chan.CFDTime;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class CollisionTimeRecoTask
4040
gsl::span<const o2::ft0::ChannelData> inChData,
4141
gsl::span<o2::ft0::ChannelDataFloat> outChData);
4242
void FinishTask();
43+
// DigitizationParameters const &mParameters;
44+
// o2::ft0::Geometry mGeometry;
4345

4446
private:
4547
ClassDefNV(CollisionTimeRecoTask, 1);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "FairLogger.h" // for LOG
1616
#include "DataFormatsFT0/RecPoints.h"
1717
#include "FT0Base/Geometry.h"
18+
#include "FT0Simulation/DigitizationParameters.h"
1819
#include <DataFormatsFT0/ChannelData.h>
1920
#include <DataFormatsFT0/Digit.h>
2021
#include <cmath>
@@ -48,7 +49,7 @@ o2::ft0::RecPoints CollisionTimeRecoTask::process(o2::ft0::Digit const& bcd,
4849
for (int ich = 0; ich < nch; ich++) {
4950
outChData[ich] = o2::ft0::ChannelDataFloat{inChData[ich].ChId,
5051
inChData[ich].CFDTime * Geometry::ChannelWidth,
51-
(double)inChData[ich].QTCAmpl * Geometry::MV_2_NchannelsInverse,
52+
(double)inChData[ich].QTCAmpl * DigitizationParameters::mMV_2_NchannelsInverse,
5253
inChData[ich].ChainQTC};
5354

5455
// only signals with amplitude participate in collision time

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

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,39 @@
1111
#ifndef ALICEO2_FT0_DIGITIZATION_PARAMETERS
1212
#define ALICEO2_FT0_DIGITIZATION_PARAMETERS
1313
#include <FT0Base/Geometry.h>
14+
#include <CommonUtils/ConfigurableParamHelper.h>
1415

1516
namespace o2::ft0
1617
{
1718

18-
struct DigitizationParameters {
19-
int nCellsA = Geometry::NCellsA;
20-
int nCellsC = Geometry::NCellsC;
21-
float zDetA = Geometry::ZdetA;
22-
float zDetC = Geometry::ZdetC;
23-
float bunchWidth = 25; //ns
24-
float channelWidth = Geometry::ChannelWidth;
25-
float ChannelWidthInverse = 0.076804916; // channel width in ps inverse
19+
struct DigitizationParameters
20+
: o2::conf::ConfigurableParamHelper<DigitizationParameters> {
21+
float mBunchWidth = 25; //ns
22+
float mChannelWidthInverse = 0.076804916; // channel width in ps inverse
2623
float mMCPs = (Geometry::NCellsA + Geometry::NCellsC) * 4; //number of MCPs
2724
float mCFD_trsh = 3.; // [mV]
2825
float mAmp_trsh = 100; // [ph.e]
2926
float mAmpRecordLow = -4; // integrate charge from
30-
3127
float mAmpRecordUp = 15; // to [ns]
32-
int mTime_trg_gate = 192; // #channels
33-
// int mTime_trg_gate = 2000; //2000/13; (+-2ns) #channels no limits
34-
float mTimeDiffAC = (Geometry::ZdetA - Geometry::ZdetC) * TMath::C();
35-
float C_side_cable_cmps = 2.86; //ns
36-
float A_side_cable_cmps = 11.110; //ns
37-
int mtrg_central_trh = 600.; // channels
38-
int mtrg_semicentral_trh = 300.; // channels
28+
// float mTimeDiffAC = (Geometry::ZdetA - Geometry::ZdetC) * TMath::C();
29+
float mC_side_cable_cmps = 2.86; //ns
30+
float mA_side_cable_cmps = 11.110; //ns
31+
int mtrg_central_trh = 600.; // channels
32+
int mtrg_semicentral_trh = 300.; // channels
3933

40-
float mMip_in_V = 7; //MIP to mV
41-
float mPe_in_mip = 0.004; // invserse Np.e. in MIP 1./250.
42-
float mCfdShift = 1.66; //ns
43-
float mCFDShiftPos = 1.47; //// shift positive part of CFD signal; distance between 0.3 of max amplitude to max
44-
float mCFDdeadTime = 15.6; // ns
45-
float AmpIntegrationTime = 19; //ns
46-
float IntegWindowDelayA = 6; // ns, A side
47-
float IntegWindowDelayC = -1.6; // ns, C side
48-
float charge2amp = 0.22;
34+
float mMip_in_V = 7; //MIP to mV
35+
float mPe_in_mip = 0.004; // invserse Np.e. in MIP 1./250.
36+
float mCfdShift = 1.66; //ns
37+
float mCFDShiftPos = 1.47; //// shift positive part of CFD signal; distance between 0.3 of max amplitude to max
38+
float mCFDdeadTime = 15.6; // ns
39+
float mCharge2amp = 0.22;
4940
float mNoiseVar = 0.1; //noise level
5041
float mNoisePeriod = 1 / 0.9; // GHz low frequency noise period;
51-
float mV_2_Nchannels = 2.2857143; //7 mV ->16channels
42+
static constexpr float mMV_2_Nchannels = 2.2857143; //amplitude channel 7 mV ->16channels
43+
static constexpr float mMV_2_NchannelsInverse = 0.437499997; //inverse amplitude channel 7 mV ->16channels
44+
static constexpr int mTime_trg_gate = 192; // #channels
45+
46+
O2ParamDef(DigitizationParameters, "DigitizationParameters");
5247
};
5348
} // namespace o2::ft0
5449
#endif

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Digitizer
100100
if (x <= 0.0f) {
101101
return 0.0f;
102102
}
103-
float const y = x / mParameters.bunchWidth * DP::SIGNAL_TABLE_SIZE;
103+
float const y = x / mParameters.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.bunchWidth * DP::SIGNAL_TABLE_SIZE;
114+
auto const y = x / mParameters.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,8 @@ class Digitizer
141141
std::deque<BCCache> mCache;
142142
std::array<GoodInteractionTimeRecord, 208> mDeadTimes;
143143

144-
DigitizationParameters mParameters;
144+
DigitizationParameters const& mParameters;
145+
o2::ft0::Geometry mGeometry;
145146

146147
NoiseRandomRingType mRndGaus;
147148
int mNumNoiseSamples; // number of noise samples in one BC
@@ -156,7 +157,7 @@ class Digitizer
156157
std::vector<o2::ft0::DetTrigInput>& digitsTrig,
157158
o2::dataformats::MCTruthContainer<o2::ft0::MCLabel>& labels);
158159

159-
ClassDefNV(Digitizer, 1);
160+
ClassDefNV(Digitizer, 2);
160161
};
161162

162163
// signal shape function

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "FT0Simulation/Digitizer.h"
1212
#include "FT0Simulation/DigitizationConstants.h"
13+
#include "FT0Simulation/DigitizationParameters.h"
1314
#include "SimulationDataFormat/MCTruthContainer.h"
1415
#include <CommonDataFormat/InteractionRecord.h>
1516

@@ -22,7 +23,6 @@
2223
#include <optional>
2324

2425
using namespace o2::ft0;
25-
//using o2::ft0::Geometry;
2626

2727
ClassImp(Digitizer);
2828

@@ -90,22 +90,22 @@ 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.bunchWidth};
93+
CFDOutput result{std::nullopt, -0.5f * mParameters.mBunchWidth};
9494
bool is_positive = true;
9595

9696
// reset the chache
9797
std::fill_n(std::begin(mSignalCache), std::size(mSignalCache), -1.0f);
9898

9999
// we need double precision for time in order to match previous behaviour
100-
for (double time = min_time; time < 0.5 * mParameters.bunchWidth; time += DP::SIGNAL_CACHE_DT) {
100+
for (double time = min_time; time < 0.5 * mParameters.mBunchWidth; time += DP::SIGNAL_CACHE_DT) {
101101
float const val = value_at(time);
102-
int const index = std::lround((time + 0.5 * mParameters.bunchWidth) / DP::SIGNAL_CACHE_DT);
102+
int const index = std::lround((time + 0.5 * mParameters.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.bunchWidth) / DP::SIGNAL_CACHE_DT);
108+
int const index_prev = std::lround((time - mParameters.mCFDShiftPos + 0.5f * mParameters.mBunchWidth) / DP::SIGNAL_CACHE_DT);
109109
val_prev = ((index_prev < 0 || index_prev >= mSignalCache.size() || mSignalCache[index_prev] < 0.0f)
110110
? value_at(time - mParameters.mCFDShiftPos) // was not computed before
111111
: mSignalCache[index_prev]); // is available in the cache
@@ -167,8 +167,8 @@ void Digitizer::process(const std::vector<o2::ft0::HitType>* hits,
167167
}
168168

169169
Int_t hit_ch = hit.GetDetectorID();
170-
Bool_t is_A_side = (hit_ch < 4 * mParameters.nCellsA);
171-
Float_t time_compensate = is_A_side ? mParameters.A_side_cable_cmps : mParameters.C_side_cable_cmps;
170+
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;
172172
Double_t hit_time = hit.GetTime() - time_compensate;
173173
if (hit_time > 250) {
174174
continue; //not collect very slow particles
@@ -224,20 +224,20 @@ void Digitizer::storeBC(BCCache& bc,
224224
if (!cfd.particle) {
225225
continue;
226226
}
227-
int smeared_time = 1000. * (*cfd.particle - mParameters.mCfdShift) * mParameters.ChannelWidthInverse;
227+
int smeared_time = 1000. * (*cfd.particle - mParameters.mCfdShift) * mParameters.mChannelWidthInverse;
228228
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.charge2amp;
230-
float amp = is_time_in_signal_gate ? mParameters.mV_2_Nchannels * charge : 0;
229+
float charge = measure_amplitude(channel_times) * mParameters.mCharge2amp;
230+
float amp = is_time_in_signal_gate ? mParameters.mMV_2_Nchannels * charge : 0;
231231
if (amp > 4095) {
232232
amp = 4095;
233233
}
234-
LOG(DEBUG) << mEventID << " bc " << firstBCinDeque.bc << " orbit " << firstBCinDeque.orbit << ", ipmt " << ipmt << ", smeared_time " << smeared_time << " nStored " << nStored;
234+
LOG(INFO) << mEventID << " bc " << firstBCinDeque.bc << " orbit " << firstBCinDeque.orbit << ", ipmt " << ipmt << ", smeared_time " << smeared_time << " nStored " << nStored;
235235
digitsCh.emplace_back(ipmt, smeared_time, int(amp), chain);
236236
nStored++;
237237

238238
// fill triggers
239239

240-
Bool_t is_A_side = (ipmt <= 4 * mParameters.nCellsA);
240+
Bool_t is_A_side = (ipmt <= 4 * mGeometry.NCellsA);
241241
if (!is_time_in_signal_gate) {
242242
continue;
243243
}
@@ -322,7 +322,7 @@ 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.bunchWidth / mParameters.mNoisePeriod);
325+
mNumNoiseSamples = std::ceil(mParameters.mBunchWidth / mParameters.mNoisePeriod);
326326
mNoiseSamples.resize(mNumNoiseSamples);
327327

328328
// set up tables with sinc function values (times noiseVar)
@@ -332,23 +332,24 @@ void Digitizer::initParameters()
332332
// we make a table of sinc values between -num_noise_samples and 2*num_noise_samples
333333
mSincTable[i].resize(3 * mNumNoiseSamples);
334334
for (int j = -mNumNoiseSamples; j < 2 * mNumNoiseSamples; ++j) {
335-
mSincTable[i][mNumNoiseSamples + j] = mParameters.mNoiseVar * sinc((time + 0.5f * mParameters.bunchWidth) / mParameters.mNoisePeriod - j);
335+
mSincTable[i][mNumNoiseSamples + j] = mParameters.mNoiseVar * sinc((time + 0.5f * mParameters.mBunchWidth) / mParameters.mNoisePeriod - j);
336336
}
337337
}
338338
// set up the lookup table for the signal form
339339
for (size_t i = 0; i < DP::SIGNAL_TABLE_SIZE; ++i) {
340-
float const x = float(i) / float(DP::SIGNAL_TABLE_SIZE) * mParameters.bunchWidth;
340+
float const x = float(i) / float(DP::SIGNAL_TABLE_SIZE) * mParameters.mBunchWidth;
341341
mSignalTable[i] = signalForm_i(x);
342342
}
343343

344344
// cache for signal time series used by the CFD -BC/2 .. +3BC/2
345-
mSignalCache.resize(std::lround(mParameters.bunchWidth / DP::SIGNAL_CACHE_DT));
345+
mSignalCache.resize(std::lround(mParameters.mBunchWidth / DP::SIGNAL_CACHE_DT));
346346
}
347347
//_______________________________________________________________________
348348
void Digitizer::init()
349349
{
350350
LOG(INFO) << " @@@ Digitizer::init " << std::endl;
351351
mDeadTimes.fill({InteractionRecord(0), -100.});
352+
printParameters();
352353
}
353354
//_______________________________________________________________________
354355
void Digitizer::finish()
@@ -364,5 +365,7 @@ void Digitizer::printParameters() const
364365
<< mParameters.mCfdShift << "CFD distance between 0.3 of max amplitude to max \n"
365366
<< mParameters.mCFDShiftPos << "MIP -> mV " << mParameters.mMip_in_V << " Pe in MIP \n"
366367
<< mParameters.mPe_in_mip << "noise level " << mParameters.mNoiseVar << " noise frequency \n"
367-
<< mParameters.mNoisePeriod << std::endl;
368+
<< mParameters.mNoisePeriod << " mMCPs " << mParameters.mMCPs;
368369
}
370+
371+
O2ParamImpl(DigitizationParameters);

Steer/DigitizerWorkflow/src/FT0DigitizerSpec.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class FT0DPLDigitizerTask : public o2::base::BaseDPLDigitizer
4444
using GRP = o2::parameters::GRPObject;
4545

4646
public:
47-
FT0DPLDigitizerTask() : o2::base::BaseDPLDigitizer(), mDigitizer(DigitizationParameters{}) {}
47+
FT0DPLDigitizerTask() : o2::base::BaseDPLDigitizer(), mDigitizer(DigitizationParameters::Instance()) {}
4848
explicit FT0DPLDigitizerTask(o2::ft0::DigitizationParameters const& parameters)
4949
: o2::base::BaseDPLDigitizer(), mDigitizer(parameters){};
5050
~FT0DPLDigitizerTask() override = default;

0 commit comments

Comments
 (0)