Skip to content

Commit 04aafb9

Browse files
authored
Add QA histogram saving option and update registry
Added a flag cfgSaveQaHistos to control saving QA histograms and updated histogram registration accordingly.
1 parent 4bd1e70 commit 04aafb9

File tree

1 file changed

+44
-23
lines changed

1 file changed

+44
-23
lines changed

Common/TableProducer/zdcExtraTableProducer.cxx

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ struct ZdcExtraTableProducer {
6767
Configurable<bool> cfgEvSelsIsGoodITSLayersAll{"cfgEvSelsIsGoodITSLayersAll", true, "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"};
70-
71-
HistogramRegistry registry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
70+
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}}});
@@ -101,16 +121,6 @@ struct ZdcExtraTableProducer {
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}}});
103123

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");
114124
}
115125

116126
template <typename TCollision>
@@ -119,7 +129,7 @@ struct ZdcExtraTableProducer {
119129
uint8_t selectionBits = 0;
120130
bool selected;
121131

122-
registry.fill(HIST("hEventCount"), evSel_allEvents);
132+
registry.fill(HIST("hEventCount"), evSel_allEvents);
123133

124134
selected = std::fabs(collision.posZ()) < cfgEvSelVtxZ;
125135
if (selected) {
@@ -130,44 +140,44 @@ struct ZdcExtraTableProducer {
130140
selected = collision.sel8();
131141
if (selected) {
132142
selectionBits |= (uint8_t)(0x1u << evSel_sel8);
133-
registry.fill(HIST("hEventCount"), evSel_sel8);
143+
registry.fill(HIST("hEventCount"), evSel_sel8);
134144
}
135145

136146
auto occupancy = collision.trackOccupancyInTimeRange();
137147
selected = occupancy <= cfgEvSelsMaxOccupancy;
138148
if (selected) {
139149
selectionBits |= (uint8_t)(0x1u << evSel_occupancy);
140-
registry.fill(HIST("hEventCount"), evSel_occupancy);
150+
registry.fill(HIST("hEventCount"), evSel_occupancy);
141151
}
142152

143153
selected = collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup);
144154
if (selected) {
145155
selectionBits |= (uint8_t)(0x1u << evSel_kNoSameBunchPileup);
146-
registry.fill(HIST("hEventCount"), evSel_kNoSameBunchPileup);
156+
registry.fill(HIST("hEventCount"), evSel_kNoSameBunchPileup);
147157
}
148158

149159
selected = collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV);
150160
if (selected) {
151161
selectionBits |= (uint8_t)(0x1u << evSel_kIsGoodZvtxFT0vsPV);
152-
registry.fill(HIST("hEventCount"), evSel_kIsGoodZvtxFT0vsPV);
162+
registry.fill(HIST("hEventCount"), evSel_kIsGoodZvtxFT0vsPV);
153163
}
154164

155165
selected = collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard);
156166
if (selected) {
157167
selectionBits |= (uint8_t)(0x1u << evSel_kNoCollInTimeRangeStandard);
158-
registry.fill(HIST("hEventCount"), evSel_kNoCollInTimeRangeStandard);
168+
registry.fill(HIST("hEventCount"), evSel_kNoCollInTimeRangeStandard);
159169
}
160170

161171
selected = collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC);
162172
if (selected) {
163173
selectionBits |= (uint8_t)(0x1u << evSel_kIsVertexITSTPC);
164-
registry.fill(HIST("hEventCount"), evSel_kIsVertexITSTPC);
174+
registry.fill(HIST("hEventCount"), evSel_kIsVertexITSTPC);
165175
}
166176

167177
selected = collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll);
168178
if (selected) {
169179
selectionBits |= (uint8_t)(0x1u << evSel_kIsGoodITSLayersAll);
170-
registry.fill(HIST("hEventCount"), evSel_kIsGoodITSLayersAll);
180+
registry.fill(HIST("hEventCount"), evSel_kIsGoodITSLayersAll);
171181
}
172182

173183
return selectionBits;
@@ -196,12 +206,13 @@ struct ZdcExtraTableProducer {
196206
//
197207
double tdcZNC = zdc.timeZNC();
198208
double tdcZNA = zdc.timeZNA();
209+
199210
// OR we can select a narrow window in both ZN TDCs using the configurable parameters
200211
if (tdcCut) { // a narrow TDC window is set
201-
if ((tdcZNC >= tdcZNmincut) && (tdcZNC <= tdcZNmaxcut)) {
212+
if ((tdcZNC >= tdcZNmincut) && (tdcZNC <= tdcZNmaxcut) ) {
202213
isZNChit = true;
203214
}
204-
if ((tdcZNA >= tdcZNmincut) && (tdcZNA <= tdcZNmaxcut)) {
215+
if ((tdcZNA >= tdcZNmincut) && (tdcZNA <= tdcZNmaxcut) ) {
205216
isZNAhit = true;
206217
}
207218
} else { // if no window on TDC is set
@@ -223,26 +234,33 @@ struct ZdcExtraTableProducer {
223234
pmqZNC[it] = (zdc.energySectorZNC())[it];
224235
sumZNC += pmqZNC[it];
225236
}
226-
registry.get<TH1>(HIST("ZNCpmc"))->Fill(pmcZNC);
237+
238+
if (cfgSaveQaHistos)
239+
{
240+
registry.get<TH1>(HIST("ZNCpmc"))->Fill(pmcZNC);
227241
registry.get<TH1>(HIST("ZNCpm1"))->Fill(pmqZNC[0]);
228242
registry.get<TH1>(HIST("ZNCpm2"))->Fill(pmqZNC[1]);
229243
registry.get<TH1>(HIST("ZNCpm3"))->Fill(pmqZNC[2]);
230244
registry.get<TH1>(HIST("ZNCpm4"))->Fill(pmqZNC[3]);
231245
registry.get<TH1>(HIST("ZNCsumq"))->Fill(sumZNC);
232246
}
247+
}
233248
if (isZNAhit) {
234249
for (int it = 0; it < kNTowers; it++) {
235250
pmqZNA[it] = (zdc.energySectorZNA())[it];
236251
sumZNA += pmqZNA[it];
237252
}
238253
//
254+
if (cfgSaveQaHistos)
255+
{
239256
registry.get<TH1>(HIST("ZNApmc"))->Fill(pmcZNA);
240257
registry.get<TH1>(HIST("ZNApm1"))->Fill(pmqZNA[0]);
241258
registry.get<TH1>(HIST("ZNApm2"))->Fill(pmqZNA[1]);
242259
registry.get<TH1>(HIST("ZNApm3"))->Fill(pmqZNA[2]);
243260
registry.get<TH1>(HIST("ZNApm4"))->Fill(pmqZNA[3]);
244261
registry.get<TH1>(HIST("ZNAsumq"))->Fill(sumZNA);
245262
}
263+
}
246264

247265
// Q-vectors (centroid) calculation
248266
// kBeamEne -- LHC Run 3 Pb-Pb collision energy (5.36 TeV per nucleon pair)
@@ -306,8 +324,11 @@ struct ZdcExtraTableProducer {
306324
centroidZNA[0] = 999.;
307325
centroidZNA[1] = 999.;
308326
}
327+
if (cfgSaveQaHistos)
328+
{
309329
registry.get<TH2>(HIST("ZNCCentroid"))->Fill(centroidZNC[0], centroidZNC[1]);
310330
registry.get<TH2>(HIST("ZNACentroid"))->Fill(centroidZNA[0], centroidZNA[1]);
331+
}
311332

312333
auto vz = collision.posZ();
313334
auto vx = collision.posX();

0 commit comments

Comments
 (0)