Skip to content

Commit 2b7fd0a

Browse files
committed
Fix code-check errors
1 parent 400f834 commit 2b7fd0a

1 file changed

Lines changed: 68 additions & 39 deletions

File tree

PWGMM/UE/Tasks/flattenicityTask.cxx

Lines changed: 68 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
#include <Framework/AnalysisTask.h>
2424
#include <Framework/Configurable.h>
2525
#include <Framework/HistogramRegistry.h>
26+
#include <Framework/HistogramSpec.h>
2627
#include <Framework/O2DatabasePDGPlugin.h>
2728
#include <Framework/runDataProcessing.h>
2829

29-
#include <TPDGCode.h>
30-
3130
#include <algorithm>
3231
#include <array>
3332
#include <cmath>
@@ -49,7 +48,8 @@ using CollisionsWithSelection =
4948

5049
struct FlattenicityTask {
5150

52-
Service<o2::framework::O2DatabasePDG> pdg;
51+
// NOLINTNEXTLINE(misc-include-cleaner) - Service<> is provided by Framework/AnalysisTask.h; there is no separate standalone header for it in this O2 version.
52+
Service<o2::framework::O2DatabasePDG> pdg{};
5353

5454
// ========================================================================
5555
// FT0 geometry
@@ -123,10 +123,12 @@ struct FlattenicityTask {
123123
bool isChargedParticle(int pdgCode)
124124
{
125125
const auto* pdgParticle = pdg->GetParticle(pdgCode);
126-
if (!pdgParticle)
126+
if (!pdgParticle) {
127127
return false;
128-
if (std::abs(pdgParticle->Charge()) < ChargeEpsilon)
128+
}
129+
if (std::abs(pdgParticle->Charge()) < ChargeEpsilon) {
129130
return false;
131+
}
130132
return true;
131133
}
132134

@@ -137,13 +139,16 @@ struct FlattenicityTask {
137139
float computeRho(const std::array<float, N>& counts)
138140
{
139141
float total = 0.0f;
140-
for (std::size_t i = 0; i < N; ++i)
142+
for (std::size_t i = 0; i < N; ++i) {
141143
total += counts[i];
142-
if (total <= 0.0f)
144+
}
145+
if (total <= 0.0f) {
143146
return -1.0f;
147+
}
144148
const float mean = total / static_cast<float>(N);
145-
if (mean <= 0.0f)
149+
if (mean <= 0.0f) {
146150
return -1.0f;
151+
}
147152
float sumSq = 0.0f;
148153
for (std::size_t i = 0; i < N; ++i) {
149154
const float diff = counts[i] - mean;
@@ -156,8 +161,9 @@ struct FlattenicityTask {
156161
float computeFlattenicity(const std::array<float, N>& counts)
157162
{
158163
const float rho = computeRho(counts);
159-
if (rho < 0.0f)
164+
if (rho < 0.0f) {
160165
return -1.0f;
166+
}
161167
return 1.0f - rho;
162168
}
163169

@@ -166,14 +172,16 @@ struct FlattenicityTask {
166172
// ========================================================================
167173
int getFT0ASector(int channel)
168174
{
169-
if (channel < 0 || channel >= NchA)
175+
if (channel < 0 || channel >= NchA) {
170176
return -1;
177+
}
171178
return channel / ChannelsPerSector;
172179
}
173180
int getFT0CSector(int channel)
174181
{
175-
if (channel < 0 || channel >= NchC)
182+
if (channel < 0 || channel >= NchC) {
176183
return -1;
184+
}
177185
return channel / ChannelsPerSector;
178186
}
179187

@@ -184,8 +192,9 @@ struct FlattenicityTask {
184192
{
185193
const bool inFT0A = (eta > FT0AEtaMin && eta < FT0AEtaMax);
186194
const bool inFT0C = (eta > FT0CEtaMin && eta < FT0CEtaMax);
187-
if (!inFT0A && !inFT0C)
195+
if (!inFT0A && !inFT0C) {
188196
return -1;
197+
}
189198
isFT0A = inFT0A;
190199

191200
// Wrap phi into [0, 2pi) using the O2-standard helper - avoids the
@@ -201,12 +210,11 @@ struct FlattenicityTask {
201210
int etaBin = static_cast<int>(std::floor((eta - FT0AEtaMin) / etaWidth));
202211
etaBin = std::max(0, std::min(etaBin, NEtaA - 1));
203212
return etaBin * NPhiSectors + phiBin;
204-
} else {
205-
const float etaWidth = (FT0CEtaMax - FT0CEtaMin) / static_cast<float>(NEtaC);
206-
int etaBin = static_cast<int>(std::floor((eta - FT0CEtaMin) / etaWidth));
207-
etaBin = std::max(0, std::min(etaBin, NEtaC - 1));
208-
return NchA + etaBin * NPhiSectors + phiBin;
209213
}
214+
const float etaWidth = (FT0CEtaMax - FT0CEtaMin) / static_cast<float>(NEtaC);
215+
int etaBin = static_cast<int>(std::floor((eta - FT0CEtaMin) / etaWidth));
216+
etaBin = std::max(0, std::min(etaBin, NEtaC - 1));
217+
return NchA + etaBin * NPhiSectors + phiBin;
210218
}
211219

212220
// ========================================================================
@@ -241,12 +249,14 @@ struct FlattenicityTask {
241249
}
242250
const float rhoA = computeRho(countsA);
243251
const float rhoC = computeRho(countsC);
244-
if (rhoA < 0.0f || rhoC < 0.0f)
252+
if (rhoA < 0.0f || rhoC < 0.0f) {
245253
return false;
254+
}
246255
flattenicityAverage = 1.0f - 0.5f * (rhoA + rhoC);
247256
const float rhoCombined = computeRho(countsCombined);
248-
if (rhoCombined < 0.0f)
257+
if (rhoCombined < 0.0f) {
249258
return false;
259+
}
250260
flattenicityCombined = 1.0f - rhoCombined;
251261
return true;
252262
}
@@ -256,8 +266,9 @@ struct FlattenicityTask {
256266
// ========================================================================
257267
void processMC(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles)
258268
{
259-
if (std::abs(mcCollision.posZ()) > cfgVzMax)
269+
if (std::abs(mcCollision.posZ()) > cfgVzMax) {
260270
return;
271+
}
261272
// Combined 208-cell truth grid (cells 0..NchA-1 = FT0A-like, NchA..NCell-1
262273
// = FT0C-like) AND the two separate sub-arrays, filled in parallel, so we
263274
// can compute BOTH truth definitions - average and combined - the same
@@ -269,26 +280,33 @@ struct FlattenicityTask {
269280
bool hasFT0A = false, hasFT0C = false;
270281

271282
for (const auto& particle : mcParticles) {
272-
if ((particle.flags() & NPhysicalPrimaryBit) == 0)
283+
if ((particle.flags() & NPhysicalPrimaryBit) == 0) {
273284
continue;
274-
if (!isChargedParticle(particle.pdgCode()))
285+
}
286+
if (!isChargedParticle(particle.pdgCode())) {
275287
continue;
276-
if (particle.pt() <= cfgPtMin)
288+
}
289+
if (particle.pt() <= cfgPtMin) {
277290
continue; // Antonio: require pT > 0
278-
if (std::abs(particle.eta()) < cfgEtaMax)
291+
}
292+
if (std::abs(particle.eta()) < cfgEtaMax) {
279293
++nChINEL;
294+
}
280295

281296
const bool inFT0A = (particle.eta() > FT0AEtaMin && particle.eta() < FT0AEtaMax);
282297
const bool inFT0C = (particle.eta() > FT0CEtaMin && particle.eta() < FT0CEtaMax);
283-
if (inFT0A)
298+
if (inFT0A) {
284299
hasFT0A = true;
285-
if (inFT0C)
300+
}
301+
if (inFT0C) {
286302
hasFT0C = true;
303+
}
287304

288305
bool isFT0A = false;
289306
const int cellId = assignToFT0Cell(particle.eta(), particle.phi(), isFT0A);
290-
if (cellId < 0 || cellId >= NCell)
307+
if (cellId < 0 || cellId >= NCell) {
291308
continue;
309+
}
292310
truthCounts[cellId] += 1.0f;
293311
if (isFT0A) {
294312
truthCountsA[cellId] += 1.0f;
@@ -297,21 +315,24 @@ struct FlattenicityTask {
297315
}
298316

299317
histos.fill(HIST("Truth/hCellOccupancy"), cellId);
300-
if (isFT0A)
318+
if (isFT0A) {
301319
histos.fill(HIST("Truth/hCellOccupancyFT0A"), cellId);
302-
else
320+
} else {
303321
histos.fill(HIST("Truth/hCellOccupancyFT0C"), cellId - NchA);
322+
}
304323
}
305324

306-
if (nChINEL == 0)
325+
if (nChINEL == 0) {
307326
return;
327+
}
308328
histos.fill(HIST("QA/hEvents"), 1);
309329
histos.fill(HIST("QA/hNchINEL"), nChINEL);
310330

311331
// Require activity on BOTH sides of the detector (Antonio's instruction),
312332
// for MC truth exactly as already required on the reco side.
313-
if (!hasFT0A || !hasFT0C)
333+
if (!hasFT0A || !hasFT0C) {
314334
return;
335+
}
315336
histos.fill(HIST("QA/hEvents"), 2);
316337

317338
// Definition 1: average of two separately-normalized rho's (mirrors the
@@ -343,22 +364,28 @@ struct FlattenicityTask {
343364
aod::FT0s const& ft0s,
344365
FullTracks const& tracks)
345366
{
346-
if (cfgApplySel8 && !collision.sel8())
367+
if (cfgApplySel8 && !collision.sel8()) {
347368
return;
348-
if (std::abs(collision.posZ()) > cfgVzMax)
369+
}
370+
if (std::abs(collision.posZ()) > cfgVzMax) {
349371
return;
372+
}
350373

351374
int nChINEL = 0;
352375
for (const auto& track : tracks) {
353-
if (track.collisionId() != collision.globalIndex())
376+
if (track.collisionId() != collision.globalIndex()) {
354377
continue;
355-
if (track.pt() <= cfgPtMin)
378+
}
379+
if (track.pt() <= cfgPtMin) {
356380
continue;
357-
if (std::abs(track.eta()) < cfgEtaMax)
381+
}
382+
if (std::abs(track.eta()) < cfgEtaMax) {
358383
++nChINEL;
384+
}
359385
}
360-
if (nChINEL == 0)
386+
if (nChINEL == 0) {
361387
return;
388+
}
362389

363390
histos.fill(HIST("QA/hEvents"), 3);
364391
histos.fill(HIST("QA/hNchINEL"), nChINEL);
@@ -372,12 +399,14 @@ struct FlattenicityTask {
372399
break;
373400
}
374401
}
375-
if (!foundFT0)
402+
if (!foundFT0) {
376403
return;
404+
}
377405

378406
float flattenicityAverage = -1.0f, flattenicityCombined = -1.0f, sumFT0M = 0.0f;
379-
if (!computeFT0Flattenicities(ft0, flattenicityAverage, flattenicityCombined, sumFT0M))
407+
if (!computeFT0Flattenicities(ft0, flattenicityAverage, flattenicityCombined, sumFT0M)) {
380408
return;
409+
}
381410

382411
histos.fill(HIST("Reco/hFT0Mraw"), sumFT0M);
383412
histos.fill(HIST("Reco/hFT0Mraw_fine"), sumFT0M);

0 commit comments

Comments
 (0)