Skip to content

Commit 5c54664

Browse files
authored
Introduction of fired channels in ZDC digitization (#4326)
* Adding more lineshapes * Autotrigger bits are now for all channels. Rename to Hits * Discriminator are enabled on all channels * New data member for discriminated channels that are actually used for triggering * Move AllChannelsMask to highest bit * Enable hits on non triggering channels * Introduce hits besides triggers * Allow triggering on all channels
1 parent 6383682 commit 5c54664

7 files changed

Lines changed: 65 additions & 43 deletions

File tree

DataFormats/Detectors/ZDC/src/BCData.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void BCData::print() const
2424
printf("%s ", channelName(ic));
2525
}
2626
}
27-
printf("] Triggered: [");
27+
printf("] Hits: [");
2828
for (int ic = 0; ic < NChannels; ic++) {
2929
if (triggers & (0x1 << ic)) {
3030
printf("%s ", channelName(ic));

Detectors/ZDC/base/include/ZDCBase/Constants.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ constexpr int NChannels = 2 * (NChannelsZN + NChannelsZP) + NChannelsZEM;
5454
constexpr uint32_t AllChannelsMask = (0x1 << NChannels) - 1;
5555

5656
constexpr int NModules = 8;
57-
constexpr int MaxTriggerChannels = 10;
57+
constexpr int NChPerModule = 4;
58+
constexpr int NWPerBc = 3;
59+
constexpr int MaxTriggerChannels = NChannels;
5860

5961
constexpr int MaxTDCValues = 5; // max number of TDC values to store in reconstructed event
6062
constexpr int NTDCChannels = 10; // max number of TDC values to store in reconstructed event

Detectors/ZDC/base/src/ModuleConfig.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ void Module::print() const
2323
printf("\n");
2424
printf("Trigger conf: ");
2525
for (int ic = 0; ic < MaxChannels; ic++) {
26+
const auto& cnf = trigChannelConf[ic];
2627
if (trigChannel[ic]) {
27-
const auto& cnf = trigChannelConf[ic];
28-
printf("[%s: F:%2d L:%2d S:%2d T:%2d] ", channelName(channelID[ic]), cnf.first, cnf.last, cnf.shift, cnf.threshold);
28+
printf("[TRIG %s: F:%2d L:%2d S:%2d T:%2d] ", channelName(channelID[ic]), cnf.first, cnf.last, cnf.shift, cnf.threshold);
29+
} else if (cnf.shift > 0 && cnf.threshold > 0) {
30+
printf("[DISC %s: F:%2d L:%2d S:%2d T:%2d] ", channelName(channelID[ic]), cnf.first, cnf.last, cnf.shift, cnf.threshold);
2931
}
3032
}
3133
printf("\n");
@@ -70,8 +72,11 @@ void Module::setChannel(int slot, int8_t chID, int16_t lID, bool read, bool trig
7072
linkID[slot] = lID;
7173
channelID[slot] = chID;
7274
readChannel[slot] = read;
75+
// In the 2020 firmware implementation, autotrigger bits are computed for each channel
76+
// Therefore we put the trig flag just for the triggering channels
77+
// Discriminator parameters are stored for all modules
7378
trigChannel[slot] = trig;
74-
if (trig) {
79+
if (tS > 0 && tT > 0) {
7580
if (tL + tS + 1 >= NTimeBinsPerBC) {
7681
LOG(FATAL) << "Sum of Last and Shift trigger parameters exceed allowed range";
7782
}

Detectors/ZDC/macro/CreateModuleConfig.C

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
3232
int modID;
3333

3434
//-------------------------------------------
35+
// Up to 8 modules with four channels
36+
// setChannel(int slot, int8_t chID, int16_t lID, bool read, bool trig = false, int tF = 0, int tL = 0, int tS = 0, int tT = 0)
3537
{
3638
modID = 0;
3739
auto& module = conf.modules[modID];
3840
module.id = modID;
3941
module.setChannel(0, IdZNAC, 0, true, true, -5, 6, 4, 12);
40-
module.setChannel(1, IdZNASum, 1, false, false);
41-
module.setChannel(2, IdZNA1, 2, true, false);
42-
module.setChannel(3, IdZNA2, 3, true, false);
42+
module.setChannel(1, IdZNASum, 1, false, false, -5, 6, 4, 12);
43+
module.setChannel(2, IdZNA1, 2, true, false, -5, 6, 4, 12);
44+
module.setChannel(3, IdZNA2, 3, true, false, -5, 6, 4, 12);
4345
//
4446
}
4547
//-------------------------------------------
@@ -48,9 +50,9 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
4850
auto& module = conf.modules[modID];
4951
module.id = modID;
5052
module.setChannel(0, IdZNAC, 4, false, true, -5, 6, 4, 12);
51-
module.setChannel(1, IdZNASum, 5, true, false);
52-
module.setChannel(2, IdZNA1, 6, true, false);
53-
module.setChannel(3, IdZNA2, 7, true, false);
53+
module.setChannel(1, IdZNASum, 5, true, false, -5, 6, 4, 12);
54+
module.setChannel(2, IdZNA3, 6, true, false, -5, 6, 4, 12);
55+
module.setChannel(3, IdZNA4, 7, true, false, -5, 6, 4, 12);
5456
//
5557
}
5658
//-------------------------------------------
@@ -59,9 +61,9 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
5961
auto& module = conf.modules[modID];
6062
module.id = modID;
6163
module.setChannel(0, IdZNCC, 8, true, true, -5, 6, 4, 12);
62-
module.setChannel(1, IdZNCSum, 9, false, false);
63-
module.setChannel(2, IdZNC1, 10, true, false);
64-
module.setChannel(3, IdZNC2, 11, true, false);
64+
module.setChannel(1, IdZNCSum, 9, false, false, -5, 6, 4, 12);
65+
module.setChannel(2, IdZNC1, 10, true, false, -5, 6, 4, 12);
66+
module.setChannel(3, IdZNC2, 11, true, false, -5, 6, 4, 12);
6567
//
6668
}
6769
//-------------------------------------------
@@ -70,9 +72,9 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
7072
auto& module = conf.modules[modID];
7173
module.id = modID;
7274
module.setChannel(0, IdZNCC, 12, false, true, -5, 6, 4, 12);
73-
module.setChannel(1, IdZNCSum, 13, true, false);
74-
module.setChannel(2, IdZNC3, 14, true, false);
75-
module.setChannel(3, IdZNC4, 15, true, false);
75+
module.setChannel(1, IdZNCSum, 13, true, false, -5, 6, 4, 12);
76+
module.setChannel(2, IdZNC3, 14, true, false, -5, 6, 4, 12);
77+
module.setChannel(3, IdZNC4, 15, true, false, -5, 6, 4, 12);
7678
//
7779
}
7880
//-------------------------------------------
@@ -82,8 +84,8 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
8284
module.id = modID;
8385
module.setChannel(0, IdZPAC, 16, true, true, -5, 6, 4, 12);
8486
module.setChannel(1, IdZEM1, 16, true, true, -5, 6, 4, 12);
85-
module.setChannel(2, IdZPA1, 17, true, false);
86-
module.setChannel(3, IdZPA2, 17, true, false);
87+
module.setChannel(2, IdZPA1, 17, true, false, -5, 6, 4, 12);
88+
module.setChannel(3, IdZPA2, 17, true, false, -5, 6, 4, 12);
8789
//
8890
}
8991
//-------------------------------------------
@@ -92,9 +94,9 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
9294
auto& module = conf.modules[modID];
9395
module.id = modID;
9496
module.setChannel(0, IdZPAC, 18, false, true, -5, 6, 4, 12);
95-
module.setChannel(1, IdZPASum, 18, true, false);
96-
module.setChannel(2, IdZPA1, 19, true, false);
97-
module.setChannel(3, IdZPA2, 19, true, false);
97+
module.setChannel(1, IdZPASum, 18, true, false, -5, 6, 4, 12);
98+
module.setChannel(2, IdZPA3, 19, true, false, -5, 6, 4, 12);
99+
module.setChannel(3, IdZPA4, 19, true, false, -5, 6, 4, 12);
98100
//
99101
}
100102
//-------------------------------------------
@@ -104,8 +106,8 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
104106
module.id = modID;
105107
module.setChannel(0, IdZPCC, 16, true, true, -5, 6, 4, 12);
106108
module.setChannel(1, IdZEM2, 16, true, true, -5, 6, 4, 12);
107-
module.setChannel(2, IdZPC1, 17, true, false);
108-
module.setChannel(3, IdZPC2, 17, true, false);
109+
module.setChannel(2, IdZPC1, 17, true, false, -5, 6, 4, 12);
110+
module.setChannel(3, IdZPC2, 17, true, false, -5, 6, 4, 12);
109111
//
110112
}
111113
//-------------------------------------------
@@ -114,9 +116,9 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
114116
auto& module = conf.modules[modID];
115117
module.id = modID;
116118
module.setChannel(0, IdZPCC, 18, false, true, -5, 6, 4, 12);
117-
module.setChannel(1, IdZPCSum, 18, true, false);
118-
module.setChannel(2, IdZPC3, 19, true, false);
119-
module.setChannel(3, IdZPC4, 19, true, false);
119+
module.setChannel(1, IdZPCSum, 18, true, false, -5, 6, 4, 12);
120+
module.setChannel(2, IdZPC3, 19, true, false, -5, 6, 4, 12);
121+
module.setChannel(3, IdZPC4, 19, true, false, -5, 6, 4, 12);
120122
//
121123
}
122124
conf.check();

Detectors/ZDC/macro/CreateSimCondition.C

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ void CreateSimCondition(std::string sourceDataPath = "signal_shapes.root",
3535
const float Gains[5] = {15.e-3, 30.e-3, 100.e-3, 15.e-3, 30.e-3}; // gain (response per photoelectron)
3636
const float fudgeFactor = 2.7; // ad hoc factor to tune the gain in the MC
3737

38+
// Source of line shapes, pedestal and noise for each channel
39+
// Missing histos for: towers 1-4 of all calorimeters, zem1, all towers of zpc
40+
std::string ShapeName[o2::zdc::NChannels] = {
41+
"znatc", "znatc", "znatc", "znatc", "znatc", "znatc", // ZNAC, ZNA1, ZNA2, ZNA3, ZNA4, ZNAS (shape not used)
42+
"zpatc", "zpatc", "zpatc", "zpatc", "zpatc", "zpatc", // ZPAC, ZPA1, ZPA2, ZPA3, ZPA4, ZPAS (shape not used)
43+
"zem2", "zem2", // ZEM1, ZEM2
44+
"znctc", "znctc", "znctc", "znctc", "znctc", "znctc", // ZNCC, ZNC1, ZNC2, ZNC3, ZNC4, ZNCS (shape not used)
45+
"zpatc", "zpatc", "zpatc", "zpatc", "zpatc", "zpatc" // ZPCC, ZPC1, ZPC2, ZPC3, ZPC4, ZPCS (shape not used)
46+
};
47+
3848
for (int ic = 0; ic < o2::zdc::NChannels; ic++) {
3949

4050
auto& channel = conf.channels[ic];
@@ -43,9 +53,7 @@ void CreateSimCondition(std::string sourceDataPath = "signal_shapes.root",
4353
//
4454
channel.gain = (tower != o2::zdc::Sum) ? fudgeFactor * Gains[det - 1] : 1.0;
4555
//
46-
// at the moment we use wf_znatc histo for all channels, to be fixed when
47-
// more histos are created. So, we read in the loop the same histo
48-
std::string histoShapeName = "hw_znatc";
56+
std::string histoShapeName = "hw_" + ShapeName[ic];
4957
TH1* histoShape = (TH1*)sourceData.GetObjectUnchecked(histoShapeName.c_str());
5058
if (!histoShape) {
5159
LOG(FATAL) << "Failed to extract the shape histogram " << histoShapeName;
@@ -72,14 +80,14 @@ void CreateSimCondition(std::string sourceDataPath = "signal_shapes.root",
7280
//
7381
channel.pedestal = gRandom->Gaus(1800., 30.);
7482
//
75-
std::string histoPedNoiseName = "hb_znatc"; // same comment here (at the moment the same histo used)
83+
std::string histoPedNoiseName = "hb_" + ShapeName[ic];
7684
TH1* histoPedNoise = (TH1*)sourceData.GetObjectUnchecked(histoPedNoiseName.c_str());
7785
if (!histoPedNoise) {
7886
LOG(FATAL) << "Failed to extract the pedestal noise histogram " << histoPedNoise;
7987
}
8088
channel.pedestalNoise = histoPedNoise->GetRMS();
8189
//
82-
std::string histoPedFluctName = "hp_znatc"; // same comment here (at the moment the same histo used)
90+
std::string histoPedFluctName = "hp_" + ShapeName[ic];
8391
TH1* histoPedFluct = (TH1*)sourceData.GetObjectUnchecked(histoPedFluctName.c_str());
8492
if (!histoPedFluct) {
8593
LOG(FATAL) << "Failed to extract the pedestal fluctuation histogram " << histoPedFluct;

Detectors/ZDC/simulation/include/ZDCSimulation/Digitizer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Digitizer
4141
bool digitized = false;
4242
bool triggerChecked = false;
4343
uint32_t trigChanMask = 0; // mask of triggered channels IDs
44-
static constexpr uint32_t AllChannelsMask = 0x1 << NChannels;
44+
static constexpr uint32_t AllChannelsMask = 0x80000000;
4545

4646
BCCache();
4747

@@ -133,7 +133,7 @@ class Digitizer
133133
o2::InteractionTimeRecord mIR;
134134
std::deque<o2::InteractionRecord> mIRExternalTrigger; // IRs of externally provided triggered (at the moment MC sampled interactions)
135135

136-
std::deque<BCCache> mCache; // cached BCs data
136+
std::deque<BCCache> mCache; // cached BCs data
137137
std::array<std::vector<int16_t>, NChannels> mTrigChannelsData; // buffer for fast access to triggered channels data
138138
int mTrigBinMin = 0xffff; // prefetched min and max
139139
int mTrigBinMax = -0xffff; // bins to be checked for trigger
@@ -143,6 +143,7 @@ class Digitizer
143143
const SimCondition* mSimCondition = nullptr; ///< externally set SimCondition
144144
const ModuleConfig* mModuleConfig = nullptr; ///< externally set ModuleConfig
145145
std::vector<TriggerChannelConfig> mTriggerConfig; ///< triggering channels
146+
uint32_t mTriggerableChanMask = 0; ///< mask of digital discriminators that can actually trigger a module
146147
std::vector<ModuleConfAux> mModConfAux; ///< module check helper
147148
std::vector<BCCache*> mFastCache; ///< for the fast iteration over cached BCs + dummy
148149
std::vector<uint32_t> mStoreChanMask; ///< pattern of channels to store

Detectors/ZDC/simulation/src/Digitizer.cxx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void Digitizer::digitizeBC(BCCache& bc)
181181
auto& bcdata = bc.data;
182182
// apply gain
183183
for (int idet : {ZNA, ZPA, ZNC, ZPC}) {
184-
for (int ic : {Ch1, Ch2, Ch3, Ch4}) {
184+
for (int ic : {Common, Ch1, Ch2, Ch3, Ch4}) {
185185
int chan = toChannel(idet, ic);
186186
auto gain = mSimCondition->channels[chan].gain;
187187
for (int ib = NTimeBinsPerBC; ib--;) {
@@ -226,7 +226,7 @@ bool Digitizer::triggerBC(int ibc)
226226
for (int ic = mTriggerConfig.size(); ic--;) {
227227
const auto& trigCh = mTriggerConfig[ic];
228228
bool okPrev = false;
229-
int last1 = trigCh.last + 2;
229+
int last1 = trigCh.last + 2; // To be modified. The new requirement is 3 consecutive samples
230230
// look for 2 consecutive bins (the 1st one spanning trigCh.first : trigCh.last range) so that
231231
// signal[bin]-signal[bin+trigCh.shift] > trigCh.threshold
232232
for (int ib = trigCh.first; ib < last1; ib++) { // ib may be negative, so we shift by offs and look in the ADC cache
@@ -237,7 +237,7 @@ bool Digitizer::triggerBC(int ibc)
237237
bool ok = bcF.data[trigCh.id][binF] - bcL.data[trigCh.id][binL] > trigCh.threshold;
238238
if (ok && okPrev) { // trigger ok!
239239
bcCached.trigChanMask |= 0x1 << trigCh.id; // register trigger mask
240-
LOG(DEBUG) << " triggering channel " << int(trigCh.id) << " => " << bcCached.trigChanMask;
240+
LOG(DEBUG) << " triggering channel " << int(trigCh.id) << "(" << ChannelNames[trigCh.id] << ") => " << bcCached.trigChanMask;
241241
break;
242242
}
243243
okPrev = ok;
@@ -251,7 +251,7 @@ bool Digitizer::triggerBC(int ibc)
251251
}
252252
}
253253

254-
if (bcCached.trigChanMask) { // there are triggered channels, flag modules/channels to read
254+
if (bcCached.trigChanMask & mTriggerableChanMask) { // there are triggered channels, flag modules/channels to read
255255
for (int ibcr = ibc - mNBCAHead; ibcr <= ibc; ibcr++) {
256256
auto& bcr = mStoreChanMask[ibcr + mNBCAHead];
257257
for (const auto& mdh : mModConfAux) {
@@ -314,7 +314,7 @@ void Digitizer::phe2Sample(int nphe, int parID, double timeHit, std::array<o2::I
314314
break;
315315
}
316316
if (sample >= 0) {
317-
auto signal = chanConfig.shape[sample] * nphe; // signal accounting for the gain
317+
auto signal = chanConfig.shape[sample] * nphe; // signal not accounting for the gain
318318
(*bcCache).data[channel][ib] += signal;
319319
added = true;
320320
}
@@ -398,11 +398,10 @@ void Digitizer::refreshCCDB()
398398
for (const auto& md : mModuleConfig->modules) {
399399
if (md.id >= 0) {
400400
mModConfAux.emplace_back(md);
401-
//
402401
for (int ic = Module::MaxChannels; ic--;) {
403-
if (md.trigChannel[ic]) { // check if this triggering channel was already registered
402+
if (md.trigChannel[ic] || (md.trigChannelConf[ic].shift > 0 && md.trigChannelConf[ic].threshold > 0)) {
404403
bool skip = false;
405-
for (int is = mTriggerConfig.size(); is--;) {
404+
for (int is = mTriggerConfig.size(); is--;) { // check if this triggering channel was already registered
406405
if (mTriggerConfig[is].id == md.channelID[ic]) {
407406
skip = true;
408407
break;
@@ -414,7 +413,12 @@ void Digitizer::refreshCCDB()
414413
LOG(FATAL) << "Wrong trigger settings";
415414
}
416415
mTriggerConfig.emplace_back(trgChanConf);
417-
LOG(INFO) << "Adding channel " << int(trgChanConf.id) << '(' << channelName(trgChanConf.id) << ") as triggering one";
416+
if (md.trigChannel[ic]) {
417+
LOG(INFO) << "Adding channel " << int(trgChanConf.id) << '(' << channelName(trgChanConf.id) << ") as triggering one";
418+
mTriggerableChanMask |= 0x1 << trgChanConf.id;
419+
} else {
420+
LOG(INFO) << "Adding channel " << int(trgChanConf.id) << '(' << channelName(trgChanConf.id) << ") as discriminator";
421+
}
418422
if (trgChanConf.first < mTrigBinMin) {
419423
mTrigBinMin = trgChanConf.first;
420424
}

0 commit comments

Comments
 (0)