Skip to content

Commit ecb7ceb

Browse files
udmitriealibuild
andauthored
[Common] zdcExtraTableProducer: Add and refactor configurables (#16820)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 520c3f2 commit ecb7ceb

1 file changed

Lines changed: 42 additions & 28 deletions

File tree

Common/TableProducer/zdcExtraTableProducer.cxx

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include <TH2.h>
3434
#include <TRandom3.h>
3535

36+
#include <Rtypes.h>
37+
38+
#include <array>
3639
#include <cmath>
3740
#include <cstdint>
3841

@@ -52,10 +55,12 @@ struct ZdcExtraTableProducer {
5255
//
5356
Configurable<int> nBins{"nBins", 400, "n bins"};
5457
Configurable<float> maxZN{"maxZN", 399.5, "Max ZN signal"};
55-
Configurable<bool> tdcCut{"tdcCut", false, "Flag for TDC cut"};
56-
Configurable<float> tdcZNmincut{"tdcZNmincut", -2.5, "Min ZN TDC cut"};
57-
Configurable<float> tdcZNmaxcut{"tdcZNmaxcut", 2.5, "Max ZN TDC cut"};
58-
Configurable<bool> cfgUsePMC{"cfgUsePMC", true, "Use common PM (true) or sum of PMs (false) "};
58+
Configurable<bool> applyTdcCut{"applyTdcCut", false, "Flag for TDC cut"};
59+
Configurable<float> tdcZnMin{"tdcZnMin", -2.5, "Min ZN TDC cut"};
60+
Configurable<float> tdcZnMax{"tdcZnMax", 2.5, "Max ZN TDC cut"};
61+
Configurable<bool> useCfactor{"useCfactor", true, "Use C normalization factor (depends on multiplicity) for centroid calculation"};
62+
Configurable<bool> usePMC{"usePMC", true, "Use common PM (true) or sum of PMs (false) "};
63+
5964
// Event selections
6065
Configurable<bool> cfgEvSelSel8{"cfgEvSelSel8", true, "Event selection: sel8"};
6166
Configurable<float> cfgEvSelVtxZ{"cfgEvSelVtxZ", 10, "Event selection: zVtx"};
@@ -66,11 +71,10 @@ struct ZdcExtraTableProducer {
6671
Configurable<bool> cfgEvSelsNoCollInTimeRangeStandard{"cfgEvSelsNoCollInTimeRangeStandard", false, "Event selection: no collision in time range standard"};
6772
Configurable<bool> cfgEvSelsIsVertexITSTPC{"cfgEvSelsIsVertexITSTPC", false, "Event selection: is vertex ITSTPC"};
6873
Configurable<bool> cfgEvSelsIsGoodITSLayersAll{"cfgEvSelsIsGoodITSLayersAll", false, "Event selection: is good ITS layers all"};
69-
// Calibration settings
70-
Configurable<float> cfgCalibrationDownscaling{"cfgCalibrationDownscaling", 1.f, "Percentage of events to be saved to derived table"};
7174

7275
// Output settings
73-
Configurable<bool> cfgSaveQaHistos{"cfgSaveQaHistos", false, "Flag to save QA histograms"};
76+
Configurable<float> calibrationDownscaling{"calibrationDownscaling", 1.f, "Percentage of events to be saved to derived table"};
77+
Configurable<bool> saveQaHistos{"saveQaHistos", false, "Flag to save QA histograms"};
7478

7579
enum SelectionCriteria {
7680
ZVtxCut,
@@ -102,7 +106,7 @@ struct ZdcExtraTableProducer {
102106
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(IsGoodITSLayersAll + 1, "IsGoodITSLayersAll");
103107

104108
// Skip histogram registration if QA flag is false
105-
if (!cfgSaveQaHistos) {
109+
if (!saveQaHistos) {
106110
return;
107111
}
108112

@@ -124,10 +128,10 @@ struct ZdcExtraTableProducer {
124128
}
125129

126130
template <typename TCollision>
127-
uint8_t eventSelected(TCollision collision)
131+
uint8_t eventSelected(TCollision const& collision)
128132
{
129133
uint8_t selectionBits = 0;
130-
bool selected;
134+
bool selected = false;
131135

132136
registry.fill(HIST("hEventCount"), AllEvents);
133137

@@ -234,11 +238,11 @@ struct ZdcExtraTableProducer {
234238
double tdcZNA = zdc.timeZNA();
235239

236240
// OR we can select a narrow window in both ZN TDCs using the configurable parameters
237-
if (tdcCut) { // a narrow TDC window is set
238-
if ((tdcZNC >= tdcZNmincut) && (tdcZNC <= tdcZNmaxcut)) {
241+
if (applyTdcCut) { // a narrow TDC window is set
242+
if ((tdcZNC >= tdcZnMin) && (tdcZNC <= tdcZnMax)) {
239243
isZNChit = true;
240244
}
241-
if ((tdcZNA >= tdcZNmincut) && (tdcZNA <= tdcZNmaxcut)) {
245+
if ((tdcZNA >= tdcZnMin) && (tdcZNA <= tdcZnMax)) {
242246
isZNAhit = true;
243247
}
244248
} else { // if no window on TDC is set
@@ -252,16 +256,16 @@ struct ZdcExtraTableProducer {
252256
//
253257
double sumZNC = 0;
254258
double sumZNA = 0;
255-
double pmqZNC[4] = {};
256-
double pmqZNA[4] = {};
259+
std::array<double, 4> pmqZNC = {};
260+
std::array<double, 4> pmqZNA = {};
257261
//
258262
if (isZNChit) {
259263
for (int it = 0; it < NTowers; it++) {
260264
pmqZNC[it] = (zdc.energySectorZNC())[it];
261265
sumZNC += pmqZNC[it];
262266
}
263267

264-
if (cfgSaveQaHistos) {
268+
if (saveQaHistos) {
265269
registry.get<TH1>(HIST("ZNCpmc"))->Fill(pmcZNC);
266270
registry.get<TH1>(HIST("ZNCpm1"))->Fill(pmqZNC[0]);
267271
registry.get<TH1>(HIST("ZNCpm2"))->Fill(pmqZNC[1]);
@@ -276,7 +280,7 @@ struct ZdcExtraTableProducer {
276280
sumZNA += pmqZNA[it];
277281
}
278282
//
279-
if (cfgSaveQaHistos) {
283+
if (saveQaHistos) {
280284
registry.get<TH1>(HIST("ZNApmc"))->Fill(pmcZNA);
281285
registry.get<TH1>(HIST("ZNApm1"))->Fill(pmqZNA[0]);
282286
registry.get<TH1>(HIST("ZNApm2"))->Fill(pmqZNA[1]);
@@ -291,8 +295,8 @@ struct ZdcExtraTableProducer {
291295
constexpr float kBeamEne = 5.36 * 0.5;
292296

293297
// Provide coordinates of centroid over ZN (side C) front face
294-
constexpr float X[4] = {-1.75, 1.75, -1.75, 1.75};
295-
constexpr float Y[4] = {-1.75, -1.75, 1.75, 1.75};
298+
constexpr std::array<float, 4> X = {-1.75, 1.75, -1.75, 1.75};
299+
constexpr std::array<float, 4> Y = {-1.75, -1.75, 1.75, 1.75};
296300
constexpr float kAlpha = 0.395; // saturation correction
297301

298302
float numXZNC = 0., numYZNC = 0., denZNC = 0.;
@@ -318,20 +322,26 @@ struct ZdcExtraTableProducer {
318322
float zncCommon = 0;
319323
float znaCommon = 0;
320324

321-
// Use sum of PMTs (cfgUsePMC == false) when common PMT is saturated
322-
if (cfgUsePMC) {
325+
// Use sum of PMTs (usePMC == false) when common PMT is saturated
326+
if (usePMC) {
323327
zncCommon = pmcZNC;
324328
znaCommon = pmcZNA;
325329
} else {
326330
zncCommon = sumZNC;
327331
znaCommon = sumZNA;
328332
}
329333

330-
float centroidZNC[2], centroidZNA[2];
334+
std::array<float, 2> centroidZNC = {};
335+
std::array<float, 2> centroidZNA = {};
331336

332337
if (denZNC != 0.) {
333-
float nSpecnC = zncCommon / kBeamEne;
334-
float cZNC = 1.89358 - 0.71262 / (nSpecnC + 0.71789);
338+
float cZNC = 1.0;
339+
340+
if (useCfactor) {
341+
float nSpecnC = zncCommon / kBeamEne;
342+
cZNC = 1.89358 - 0.71262 / (nSpecnC + 0.71789);
343+
}
344+
335345
centroidZNC[0] = cZNC * numXZNC / denZNC;
336346
centroidZNC[1] = cZNC * numYZNC / denZNC;
337347
} else {
@@ -340,15 +350,19 @@ struct ZdcExtraTableProducer {
340350
}
341351
//
342352
if (denZNA != 0.) {
343-
float nSpecnA = znaCommon / kBeamEne;
344-
float cZNA = 1.89358 - 0.71262 / (nSpecnA + 0.71789);
353+
float cZNA = 1.0;
354+
if (useCfactor) {
355+
float nSpecnA = znaCommon / kBeamEne;
356+
cZNA = 1.89358 - 0.71262 / (nSpecnA + 0.71789);
357+
}
358+
345359
centroidZNA[0] = cZNA * numXZNA / denZNA;
346360
centroidZNA[1] = cZNA * numYZNA / denZNA;
347361
} else {
348362
centroidZNA[0] = 999.;
349363
centroidZNA[1] = 999.;
350364
}
351-
if (cfgSaveQaHistos) {
365+
if (saveQaHistos) {
352366
if (isZNChit) {
353367
registry.get<TH2>(HIST("ZNCCentroid"))->Fill(centroidZNC[0], centroidZNC[1]);
354368
}
@@ -361,7 +375,7 @@ struct ZdcExtraTableProducer {
361375
auto vx = collision.posX();
362376
auto vy = collision.posY();
363377

364-
if ((isZNAhit || isZNChit) && (gRandom->Uniform() < cfgCalibrationDownscaling)) {
378+
if ((isZNAhit || isZNChit) && (gRandom->Uniform() < calibrationDownscaling)) {
365379
zdcextras(pmcZNA, pmqZNA[0], pmqZNA[1], pmqZNA[2], pmqZNA[3], tdcZNA, centroidZNA[0], centroidZNA[1], pmcZNC, pmqZNC[0], pmqZNC[1], pmqZNC[2], pmqZNC[3], tdcZNC, centroidZNC[0], centroidZNC[1], centrality, vx, vy, vz, foundBC.timestamp(), foundBC.runNumber(), evSelection);
366380
}
367381
}

0 commit comments

Comments
 (0)