Skip to content

Commit bfb07c5

Browse files
udmitriealibuild
andauthored
[Common] Add flag to save QA histograms and add event selection (#15416)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 79fa3b6 commit bfb07c5

File tree

1 file changed

+75
-37
lines changed

1 file changed

+75
-37
lines changed

Common/TableProducer/zdcExtraTableProducer.cxx

Lines changed: 75 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@ struct ZdcExtraTableProducer {
5858
// Event selections
5959
Configurable<bool> cfgEvSelSel8{"cfgEvSelSel8", true, "Event selection: sel8"};
6060
Configurable<float> cfgEvSelVtxZ{"cfgEvSelVtxZ", 10, "Event selection: zVtx"};
61-
Configurable<bool> cfgEvSelsDoOccupancySel{"cfgEvSelsDoOccupancySel", true, "Event selection: do occupancy selection"};
61+
Configurable<bool> cfgEvSelsDoOccupancySel{"cfgEvSelsDoOccupancySel", false, "Event selection: do occupancy selection"};
6262
Configurable<float> cfgEvSelsMaxOccupancy{"cfgEvSelsMaxOccupancy", 10000, "Event selection: set max occupancy"};
63-
Configurable<bool> cfgEvSelsNoSameBunchPileupCut{"cfgEvSelsNoSameBunchPileupCut", true, "Event selection: no same bunch pileup cut"};
64-
Configurable<bool> cfgEvSelsIsGoodZvtxFT0vsPV{"cfgEvSelsIsGoodZvtxFT0vsPV", true, "Event selection: is good ZVTX FT0 vs PV"};
65-
Configurable<bool> cfgEvSelsNoCollInTimeRangeStandard{"cfgEvSelsNoCollInTimeRangeStandard", true, "Event selection: no collision in time range standard"};
66-
Configurable<bool> cfgEvSelsIsVertexITSTPC{"cfgEvSelsIsVertexITSTPC", true, "Event selection: is vertex ITSTPC"};
67-
Configurable<bool> cfgEvSelsIsGoodITSLayersAll{"cfgEvSelsIsGoodITSLayersAll", true, "Event selection: is good ITS layers all"};
63+
Configurable<bool> cfgEvSelsNoSameBunchPileupCut{"cfgEvSelsNoSameBunchPileupCut", false, "Event selection: no same bunch pileup cut"};
64+
Configurable<bool> cfgEvSelsIsGoodZvtxFT0vsPV{"cfgEvSelsIsGoodZvtxFT0vsPV", false, "Event selection: is good ZVTX FT0 vs PV"};
65+
Configurable<bool> cfgEvSelsNoCollInTimeRangeStandard{"cfgEvSelsNoCollInTimeRangeStandard", false, "Event selection: no collision in time range standard"};
66+
Configurable<bool> cfgEvSelsIsVertexITSTPC{"cfgEvSelsIsVertexITSTPC", false, "Event selection: is vertex ITSTPC"};
67+
Configurable<bool> cfgEvSelsIsGoodITSLayersAll{"cfgEvSelsIsGoodITSLayersAll", false, "Event selection: is good ITS layers all"};
6868
// Calibration settings
6969
Configurable<float> cfgCalibrationDownscaling{"cfgCalibrationDownscaling", 1.f, "Percentage of events to be saved to derived table"};
7070

71-
HistogramRegistry registry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
71+
// Output settings
72+
Configurable<bool> cfgSaveQaHistos{"cfgSaveQaHistos", false, "Flag to save QA histograms"};
7273

7374
enum SelectionCriteria {
7475
evSel_zvtx,
@@ -83,8 +84,27 @@ struct ZdcExtraTableProducer {
8384
nEventSelections
8485
};
8586

87+
HistogramRegistry registry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
88+
8689
void init(InitContext const&)
8790
{
91+
92+
registry.add("hEventCount", "Number of Event; Cut; #Events Passed Cut", {HistType::kTH1D, {{nEventSelections, 0, nEventSelections}}});
93+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_allEvents + 1, "All events");
94+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_zvtx + 1, "vtxZ");
95+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_sel8 + 1, "Sel8");
96+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_occupancy + 1, "kOccupancy");
97+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoSameBunchPileup + 1, "kNoSameBunchPileup");
98+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV");
99+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoCollInTimeRangeStandard + 1, "kNoCollInTimeRangeStandard");
100+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsVertexITSTPC + 1, "kIsVertexITSTPC");
101+
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodITSLayersAll + 1, "kIsGoodITSLayersAll");
102+
103+
// Skip histogram registration if QA flag is false
104+
if (!cfgSaveQaHistos) {
105+
return;
106+
}
107+
88108
registry.add("ZNApmc", "ZNApmc; ZNA PMC; Entries", {HistType::kTH1F, {{nBins, -0.5, maxZN}}});
89109
registry.add("ZNCpmc", "ZNCpmc; ZNC PMC; Entries", {HistType::kTH1F, {{nBins, -0.5, maxZN}}});
90110
registry.add("ZNApm1", "ZNApm1; ZNA PM1; Entries", {HistType::kTH1F, {{nBins, -0.5, maxZN}}});
@@ -100,17 +120,6 @@ struct ZdcExtraTableProducer {
100120

101121
registry.add("ZNACentroid", "ZNA Centroid; X; Y", {HistType::kTH2F, {{50, -1.5, 1.5}, {50, -1.5, 1.5}}});
102122
registry.add("ZNCCentroid", "ZNC Centroid; X; Y", {HistType::kTH2F, {{50, -1.5, 1.5}, {50, -1.5, 1.5}}});
103-
104-
registry.add("hEventCount", "Number of Event; Cut; #Events Passed Cut", {HistType::kTH1D, {{nEventSelections, 0, nEventSelections}}});
105-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_allEvents + 1, "All events");
106-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_zvtx + 1, "vtxZ");
107-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_sel8 + 1, "Sel8");
108-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_occupancy + 1, "kOccupancy");
109-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoSameBunchPileup + 1, "kNoSameBunchPileup");
110-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV");
111-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoCollInTimeRangeStandard + 1, "kNoCollInTimeRangeStandard");
112-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsVertexITSTPC + 1, "kIsVertexITSTPC");
113-
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodITSLayersAll + 1, "kIsGoodITSLayersAll");
114123
}
115124

116125
template <typename TCollision>
@@ -176,7 +185,7 @@ struct ZdcExtraTableProducer {
176185
void process(ColEvSels const& cols, BCsRun3 const& /*bcs*/, aod::Zdcs const& /*zdcs*/)
177186
{
178187
// collision-based event selection
179-
int nTowers = 4; // number of ZDC towers
188+
constexpr int NTowers = 4; // number of ZDC towers
180189

181190
for (auto const& collision : cols) {
182191
const auto& foundBC = collision.foundBC_as<BCsRun3>();
@@ -185,6 +194,24 @@ struct ZdcExtraTableProducer {
185194

186195
uint8_t evSelection = eventSelected(collision);
187196

197+
// add event selection
198+
if (cfgEvSelSel8 && !(evSelection & (1 << evSel_sel8)))
199+
continue;
200+
if (!(evSelection & (1 << evSel_zvtx)))
201+
continue;
202+
if (cfgEvSelsDoOccupancySel && !(evSelection & (1 << evSel_occupancy)))
203+
continue;
204+
if (cfgEvSelsNoSameBunchPileupCut && !(evSelection & (1 << evSel_kNoSameBunchPileup)))
205+
continue;
206+
if (cfgEvSelsIsGoodZvtxFT0vsPV && !(evSelection & (1 << evSel_kIsGoodZvtxFT0vsPV)))
207+
continue;
208+
if (cfgEvSelsNoCollInTimeRangeStandard && !(evSelection & (1 << evSel_kNoCollInTimeRangeStandard)))
209+
continue;
210+
if (cfgEvSelsIsVertexITSTPC && !(evSelection & (1 << evSel_kIsVertexITSTPC)))
211+
continue;
212+
if (cfgEvSelsIsGoodITSLayersAll && !(evSelection & (1 << evSel_kIsGoodITSLayersAll)))
213+
continue;
214+
188215
float centrality = collision.centFT0C();
189216

190217
// To assure that ZN have a genuine signal (tagged by the relative TDC)
@@ -196,6 +223,7 @@ struct ZdcExtraTableProducer {
196223
//
197224
double tdcZNC = zdc.timeZNC();
198225
double tdcZNA = zdc.timeZNA();
226+
199227
// OR we can select a narrow window in both ZN TDCs using the configurable parameters
200228
if (tdcCut) { // a narrow TDC window is set
201229
if ((tdcZNC >= tdcZNmincut) && (tdcZNC <= tdcZNmaxcut)) {
@@ -219,29 +247,34 @@ struct ZdcExtraTableProducer {
219247
double pmqZNA[4] = {};
220248
//
221249
if (isZNChit) {
222-
for (int it = 0; it < nTowers; it++) {
250+
for (int it = 0; it < NTowers; it++) {
223251
pmqZNC[it] = (zdc.energySectorZNC())[it];
224252
sumZNC += pmqZNC[it];
225253
}
226-
registry.get<TH1>(HIST("ZNCpmc"))->Fill(pmcZNC);
227-
registry.get<TH1>(HIST("ZNCpm1"))->Fill(pmqZNC[0]);
228-
registry.get<TH1>(HIST("ZNCpm2"))->Fill(pmqZNC[1]);
229-
registry.get<TH1>(HIST("ZNCpm3"))->Fill(pmqZNC[2]);
230-
registry.get<TH1>(HIST("ZNCpm4"))->Fill(pmqZNC[3]);
231-
registry.get<TH1>(HIST("ZNCsumq"))->Fill(sumZNC);
254+
255+
if (cfgSaveQaHistos) {
256+
registry.get<TH1>(HIST("ZNCpmc"))->Fill(pmcZNC);
257+
registry.get<TH1>(HIST("ZNCpm1"))->Fill(pmqZNC[0]);
258+
registry.get<TH1>(HIST("ZNCpm2"))->Fill(pmqZNC[1]);
259+
registry.get<TH1>(HIST("ZNCpm3"))->Fill(pmqZNC[2]);
260+
registry.get<TH1>(HIST("ZNCpm4"))->Fill(pmqZNC[3]);
261+
registry.get<TH1>(HIST("ZNCsumq"))->Fill(sumZNC);
262+
}
232263
}
233264
if (isZNAhit) {
234-
for (int it = 0; it < nTowers; it++) {
265+
for (int it = 0; it < NTowers; it++) {
235266
pmqZNA[it] = (zdc.energySectorZNA())[it];
236267
sumZNA += pmqZNA[it];
237268
}
238269
//
239-
registry.get<TH1>(HIST("ZNApmc"))->Fill(pmcZNA);
240-
registry.get<TH1>(HIST("ZNApm1"))->Fill(pmqZNA[0]);
241-
registry.get<TH1>(HIST("ZNApm2"))->Fill(pmqZNA[1]);
242-
registry.get<TH1>(HIST("ZNApm3"))->Fill(pmqZNA[2]);
243-
registry.get<TH1>(HIST("ZNApm4"))->Fill(pmqZNA[3]);
244-
registry.get<TH1>(HIST("ZNAsumq"))->Fill(sumZNA);
270+
if (cfgSaveQaHistos) {
271+
registry.get<TH1>(HIST("ZNApmc"))->Fill(pmcZNA);
272+
registry.get<TH1>(HIST("ZNApm1"))->Fill(pmqZNA[0]);
273+
registry.get<TH1>(HIST("ZNApm2"))->Fill(pmqZNA[1]);
274+
registry.get<TH1>(HIST("ZNApm3"))->Fill(pmqZNA[2]);
275+
registry.get<TH1>(HIST("ZNApm4"))->Fill(pmqZNA[3]);
276+
registry.get<TH1>(HIST("ZNAsumq"))->Fill(sumZNA);
277+
}
245278
}
246279

247280
// Q-vectors (centroid) calculation
@@ -257,8 +290,7 @@ struct ZdcExtraTableProducer {
257290
float numXZNA = 0., numYZNA = 0., denZNA = 0.;
258291

259292
// Calculate weighted sums of the x and y coordinates
260-
constexpr int kNTowers = 4; // number of ZDC towers
261-
for (int i = 0; i < kNTowers; i++) {
293+
for (int i = 0; i < NTowers; i++) {
262294
if (pmqZNC[i] > 0.) {
263295
float wZNC = std::pow(pmqZNC[i], kAlpha);
264296
numXZNC -= X[i] * wZNC; // numerator x (minus sign due to opposite orientation of ZNC)
@@ -307,8 +339,14 @@ struct ZdcExtraTableProducer {
307339
centroidZNA[0] = 999.;
308340
centroidZNA[1] = 999.;
309341
}
310-
registry.get<TH2>(HIST("ZNCCentroid"))->Fill(centroidZNC[0], centroidZNC[1]);
311-
registry.get<TH2>(HIST("ZNACentroid"))->Fill(centroidZNA[0], centroidZNA[1]);
342+
if (cfgSaveQaHistos) {
343+
if (isZNChit) {
344+
registry.get<TH2>(HIST("ZNCCentroid"))->Fill(centroidZNC[0], centroidZNC[1]);
345+
}
346+
if (isZNAhit) {
347+
registry.get<TH2>(HIST("ZNACentroid"))->Fill(centroidZNA[0], centroidZNA[1]);
348+
}
349+
}
312350

313351
auto vz = collision.posZ();
314352
auto vx = collision.posX();

0 commit comments

Comments
 (0)