Skip to content

Commit 8e75e48

Browse files
committed
[PWGEM,PWGEM-36] PhotonMeson: Fix issues found in emcalQC and Pi0 Flow task by clang-tidy
- This commit fixes issues found in the two mentioned tasks that were found with the newly added O2Physics-code-check (clang-tidy) - Also adds extra histograms for the track matching QA
1 parent b9d05e0 commit 8e75e48

2 files changed

Lines changed: 67 additions & 45 deletions

File tree

PWGEM/PhotonMeson/Tasks/emcalQC.cxx

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ struct EmcalQC {
9797
Configurable<bool> emcUseSecondaryTM{"emcUseSecondaryTM", false, "flag to use EMCal secondary track matching cut or not"};
9898
} emccuts;
9999

100+
struct : ConfigurableGroup {
101+
std::string prefix = "axis_group";
102+
ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {100, 0., 20.}, "pT axis for photon candidates"};
103+
} axisGroup;
104+
100105
void defineEMEventCut()
101106
{
102107
fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut");
@@ -146,6 +151,10 @@ struct EmcalQC {
146151
defineEMCCut();
147152
defineEMEventCut();
148153

154+
const AxisSpec thnAxisPt{axisGroup.thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"};
155+
const AxisSpec thAxisdEta{200, -0.06, 0.06, "#Delta#eta"};
156+
const AxisSpec thAxisdPhi{200, -0.06, 0.06, "#Delta#varphi (rad)"};
157+
149158
o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry);
150159
auto hEMCCollisionCounter = fRegistry.add<TH1>("Event/hEMCCollisionCounter", "Number of collisions after event cuts", HistType::kTH1D, {{7, 0.5, 7.5}}, false);
151160
hEMCCollisionCounter->GetXaxis()->SetBinLabel(1, "all");
@@ -156,6 +165,13 @@ struct EmcalQC {
156165
hEMCCollisionCounter->GetXaxis()->SetBinLabel(6, "+unique"); // TVX with z < 10cm and Sel8 and good z xertex and unique (only collision in the BC)
157166
hEMCCollisionCounter->GetXaxis()->SetBinLabel(7, "+EMC readout"); // TVX with z < 10cm and Sel8 and good z xertex and unique (only collision in the BC) and kTVXinEMC
158167
o2::aod::pwgem::photonmeson::utils::clusterhistogram::addClusterHistograms(&fRegistry, cfgDo2DQA);
168+
169+
if (doprocessQCTM) {
170+
fRegistry.add("Cluster/hDeltaEtaPhiAllPrimTracks", "#Delta#eta #Delta#varphi distribution of all matched prim. tracks", HistType::kTH3D, {thAxisdEta, thAxisdPhi, thnAxisPt}, false);
171+
fRegistry.add("Cluster/hDeltaEtaPhiClosestPrimTracks", "#Delta#eta #Delta#varphi distribution of the Closest matched prim. track", HistType::kTH3D, {thAxisdEta, thAxisdPhi, thnAxisPt}, false);
172+
fRegistry.add("Cluster/hDeltaEtaPhiAllSecTracks", "#Delta#eta #Delta#varphi distribution of all matched sec. tracks", HistType::kTH3D, {thAxisdEta, thAxisdPhi, thnAxisPt}, false);
173+
fRegistry.add("Cluster/hDeltaEtaPhiClosestSecTracks", "#Delta#eta #Delta#varphi distribution of the Closest matched sec. track", HistType::kTH3D, {thAxisdEta, thAxisdPhi, thnAxisPt}, false);
174+
}
159175
}
160176

161177
bool isEventGood(MyCollision const& collision)
@@ -189,7 +205,7 @@ struct EmcalQC {
189205
if (!fEMEventCut.IsSelected(collision)) {
190206
return false;
191207
}
192-
if (!(eventcuts.cfgOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgOccupancyMax)) {
208+
if (!(eventcuts.cfgOccupancyMin <= collision.trackOccupancyInTimeRange()) || !(collision.trackOccupancyInTimeRange() < eventcuts.cfgOccupancyMax)) {
193209
return false;
194210
}
195211

@@ -216,11 +232,11 @@ struct EmcalQC {
216232

217233
// Define two boleans to see, whether the cluster "survives" the EMC cluster cuts to later check, whether the cuts in this task align with the ones in EMCPhotonCut.h:
218234
bool survivesIsSelectedEMCalCuts = true; // Survives "manual" cuts listed in this task
219-
bool survivesIsSelectedCuts = false;
235+
bool survivesIsSelectedCuts = true;
220236

221237
survivesIsSelectedCuts = fEMCCut.IsSelected(cluster);
222238
for (int icut = 0; icut < static_cast<int>(EMCPhotonCut::EMCPhotonCuts::kNCuts); icut++) { // Loop through different cut observables
223-
EMCPhotonCut::EMCPhotonCuts specificcut = static_cast<EMCPhotonCut::EMCPhotonCuts>(icut);
239+
auto specificcut = static_cast<EMCPhotonCut::EMCPhotonCuts>(icut);
224240
if (!fEMCCut.IsSelectedEMCal(specificcut, cluster)) { // Check whether cluster passes this cluster requirement, if not, fill why in the next row
225241
fRegistry.fill(HIST("Cluster/hClusterQualityCuts"), icut + 1, cluster.e(), collision.weight());
226242
survivesIsSelectedEMCalCuts = false;
@@ -240,12 +256,10 @@ struct EmcalQC {
240256
}
241257
}
242258
fRegistry.fill(HIST("Cluster/after/hNgamma"), ngAfter, collision.weight());
243-
244-
return;
245259
}
246260

247261
template <o2::soa::is_table TClusters, o2::soa::is_table TMatchedTracks, o2::soa::is_table TMatchedSecondaries>
248-
void doClusterQA(MyCollision const& collision, TClusters const& clusters, TMatchedTracks const& primTracks, TMatchedSecondaries const& secTracks)
262+
void doClusterQAWithTM(MyCollision const& collision, TClusters const& clusters, TMatchedTracks const& primTracks, TMatchedSecondaries const& secTracks)
249263
{
250264
fRegistry.fill(HIST("Cluster/before/hNgamma"), clusters.size(), collision.weight());
251265
int ngAfter = 0;
@@ -263,11 +277,11 @@ struct EmcalQC {
263277

264278
// Define two boleans to see, whether the cluster "survives" the EMC cluster cuts to later check, whether the cuts in this task align with the ones in EMCPhotonCut.h:
265279
bool survivesIsSelectedEMCalCuts = true; // Survives "manual" cuts listed in this task
266-
bool survivesIsSelectedCuts = false;
280+
bool survivesIsSelectedCuts = true;
267281

268282
survivesIsSelectedCuts = fEMCCut.IsSelected(cluster, primTracksPerCluster, secTracksPerCluster);
269283
for (int icut = 0; icut < static_cast<int>(EMCPhotonCut::EMCPhotonCuts::kNCuts); icut++) { // Loop through different cut observables
270-
EMCPhotonCut::EMCPhotonCuts specificcut = static_cast<EMCPhotonCut::EMCPhotonCuts>(icut);
284+
auto specificcut = static_cast<EMCPhotonCut::EMCPhotonCuts>(icut);
271285
if (specificcut == EMCPhotonCut::EMCPhotonCuts::kTM || specificcut == EMCPhotonCut::EMCPhotonCuts::kSecondaryTM) {
272286
// will do track matching cuts extra later or never depending on chosen process function
273287
continue;
@@ -277,6 +291,20 @@ struct EmcalQC {
277291
survivesIsSelectedEMCalCuts = false;
278292
}
279293
}
294+
if (primTracksPerCluster.size() > 0) {
295+
const auto closestPrimTrack = primTracksPerCluster.begin();
296+
fRegistry.fill(HIST("Cluster/hDeltaEtaPhiClosestPrimTracks"), closestPrimTrack.deltaEta(), closestPrimTrack.deltaPhi(), cluster.pt());
297+
}
298+
for (const auto& matchedPrimTrack : primTracksPerCluster) {
299+
fRegistry.fill(HIST("Cluster/hDeltaEtaPhiAllPrimTracks"), matchedPrimTrack.deltaEta(), matchedPrimTrack.deltaPhi(), cluster.pt());
300+
}
301+
if (secTracksPerCluster.size() > 0) {
302+
const auto closestSecTrack = secTracksPerCluster.begin();
303+
fRegistry.fill(HIST("Cluster/hDeltaEtaPhiClosestSecTracks"), closestSecTrack.deltaEta(), closestSecTrack.deltaPhi(), cluster.pt());
304+
}
305+
for (const auto& matchedSecTrack : secTracksPerCluster) {
306+
fRegistry.fill(HIST("Cluster/hDeltaEtaPhiAllSecTracks"), matchedSecTrack.deltaEta(), matchedSecTrack.deltaPhi(), cluster.pt());
307+
}
280308

281309
if (!fEMCCut.IsSelectedEMCal(EMCPhotonCut::EMCPhotonCuts::kTM, cluster, primTracksPerCluster)) { // Check whether cluster passes this cluster requirement, if not, fill why in the next row
282310
fRegistry.fill(HIST("Cluster/hClusterQualityCuts"), static_cast<double>(EMCPhotonCut::EMCPhotonCuts::kTM) + 1, cluster.e(), collision.weight());
@@ -300,8 +328,6 @@ struct EmcalQC {
300328
}
301329
}
302330
fRegistry.fill(HIST("Cluster/after/hNgamma"), ngAfter, collision.weight());
303-
304-
return;
305331
}
306332

307333
void processQC(MyCollisions const& collisions, EMCalPhotons const& clusters)
@@ -327,7 +353,7 @@ struct EmcalQC {
327353
}
328354

329355
auto clustersPerColl = clusters.sliceBy(perCollisionEMC, collision.collisionId());
330-
doClusterQA(collision, clustersPerColl, matchedPrims, matchedSeconds);
356+
doClusterQAWithTM(collision, clustersPerColl, matchedPrims, matchedSeconds);
331357

332358
} // end of collision loop
333359
} // end of process
@@ -339,7 +365,7 @@ struct EmcalQC {
339365
PROCESS_SWITCH(EmcalQC, processDummy, "Dummy function", true);
340366
};
341367

342-
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
368+
WorkflowSpec defineDataProcessing(ConfigContext const& context)
343369
{
344-
return WorkflowSpec{adaptAnalysisTask<EmcalQC>(cfgc)};
370+
return WorkflowSpec{adaptAnalysisTask<EmcalQC>(context)};
345371
}

PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@ using namespace o2::aod::pwgem::photon;
7676
enum QvecEstimator {
7777
FT0M = 0,
7878
FT0A = 1,
79-
FT0C,
80-
TPCPos,
81-
TPCNeg,
82-
TPCTot,
83-
FV0A
79+
FT0C = 2,
80+
TPCPos = 3,
81+
TPCNeg = 4,
82+
TPCTot = 5,
83+
FV0A = 6
8484
};
8585

8686
enum CentralityEstimator {
8787
None = 0,
8888
CFT0A = 1,
89-
CFT0C,
90-
CFT0M,
91-
NCentralityEstimators
89+
CFT0C = 2,
90+
CFT0M = 3,
91+
NCentralityEstimators = 4
9292
};
9393

9494
enum Harmonics {
@@ -233,21 +233,21 @@ struct TaskPi0FlowEMC {
233233
std::string prefix = "rotationConfig";
234234
Configurable<bool> cfgDoRotation{"cfgDoRotation", false, "Flag to enable rotation background method."};
235235
Configurable<int> cfgDownsampling{"cfgDownsampling", 1, "Calculate rotation background only for every <value> collision."};
236-
Configurable<float> cfgRotAngle{"cfgRotAngle", std::move(const_cast<float&>(o2::constants::math::PIHalf)), "Angle used for the rotation method."};
236+
Configurable<float> cfgRotAngle{"cfgRotAngle", static_cast<float>(o2::constants::math::PIHalf), "Angle used for the rotation method."};
237237
Configurable<bool> cfgUseWeights{"cfgUseWeights", false, "Flag to enable weights for rotation background method."};
238238
} rotationConfig;
239239

240240
struct : ConfigurableGroup {
241241
std::string prefix = "correctionConfig";
242242
Configurable<std::string> cfgSpresoPath{"cfgSpresoPath", "Users/m/mhemmer/EM/Flow/Resolution", "Path to SP resolution file"};
243-
Configurable<int> cfgApplySPresolution{"cfgApplySPresolution", 0, "Apply resolution correction"};
243+
Configurable<bool> cfgApplySPresolution{"cfgApplySPresolution", 0, "Apply resolution correction"};
244244
Configurable<bool> doEMCalCalib{"doEMCalCalib", 0, "Produce output for EMCal calibration"};
245245
Configurable<bool> cfgEnableNonLin{"cfgEnableNonLin", false, "flag to turn extra non linear energy calibration on/off"};
246246
} correctionConfig;
247247

248248
SliceCache cache;
249249
EventPlaneHelper epHelper;
250-
o2::framework::Service<o2::ccdb::BasicCCDBManager> ccdb;
250+
o2::framework::Service<o2::ccdb::BasicCCDBManager> ccdb{};
251251
int runNow = 0;
252252
int runBefore = -1;
253253

@@ -269,8 +269,8 @@ struct TaskPi0FlowEMC {
269269

270270
HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false};
271271

272-
o2::emcal::Geometry* emcalGeom;
273-
o2::emcal::BadChannelMap* mBadChannels;
272+
o2::emcal::Geometry* emcalGeom = nullptr;
273+
o2::emcal::BadChannelMap* mBadChannels = nullptr;
274274
TH1D* h1SPResolution = nullptr;
275275
// Constants for eta and phi ranges for the look up table
276276
static constexpr double EtaMin = -0.75, etaMax = 0.75;
@@ -279,7 +279,7 @@ struct TaskPi0FlowEMC {
279279
static constexpr double PhiMin = 1.35, phiMax = 5.75;
280280
static constexpr int NBinsPhi = 440; // (440 bins = 0.01 step size covering most regions)
281281

282-
std::array<int8_t, NBinsEta * NBinsPhi> lookupTable1D;
282+
std::array<int8_t, NBinsEta * NBinsPhi> lookupTable1D{};
283283
float epsilon = 1.e-8;
284284

285285
// static constexpr
@@ -506,8 +506,8 @@ struct TaskPi0FlowEMC {
506506
template <const int histType>
507507
void fillThn(const float mass, const float pt, const float cent, const float sp)
508508
{
509-
static constexpr std::string_view FlowHistTypes[3] = {"hSparsePi0Flow", "hSparseBkgRotFlow", "hSparseBkgMixFlow"};
510-
static constexpr std::string_view HistTypes[3] = {"hSparsePi0", "hSparseBkgRot", "hSparseBkgMix"};
509+
static constexpr std::array<std::string_view, 3> FlowHistTypes = {"hSparsePi0Flow", "hSparseBkgRotFlow", "hSparseBkgMixFlow"};
510+
static constexpr std::array<std::string_view, 3> HistTypes = {"hSparsePi0", "hSparseBkgRot", "hSparseBkgMix"};
511511
registry.fill(HIST(FlowHistTypes[histType]), mass, pt, cent, sp);
512512
registry.fill(HIST(HistTypes[histType]), mass, pt, cent);
513513
}
@@ -668,9 +668,8 @@ struct TaskPi0FlowEMC {
668668
int iRowLast = 24;
669669
if (emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::EMCAL_HALF) {
670670
iRowLast /= 2; // 2/3 sm case
671-
} else if (emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::EMCAL_THIRD) {
672-
iRowLast /= 3; // 1/3 sm case
673-
} else if (emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::DCAL_EXT) {
671+
} else if ((emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::EMCAL_THIRD) ||
672+
(emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::DCAL_EXT)) {
674673
iRowLast /= 3; // 1/3 sm case
675674
}
676675

@@ -836,7 +835,6 @@ struct TaskPi0FlowEMC {
836835
} // end of loop over third photon
837836
}
838837
}
839-
return;
840838
}
841839

842840
/// \brief Calculate background using rotation background method
@@ -952,7 +950,6 @@ struct TaskPi0FlowEMC {
952950
}
953951
} // end of loop over PCM photons
954952
} // if(iCellIDphotonEMC > -1)
955-
return;
956953
}
957954

958955
/// Compute the scalar product
@@ -983,7 +980,6 @@ struct TaskPi0FlowEMC {
983980
}
984981

985982
fillThn<histType>(massCand, ptCand, cent, scalprodCand);
986-
return;
987983
}
988984

989985
/// \brief check if standard event cuts + FT0 occupancy + centrality + QVec good is
@@ -1105,7 +1101,7 @@ struct TaskPi0FlowEMC {
11051101
if (!(fEMCCut.IsSelected(photon))) {
11061102
continue;
11071103
}
1108-
if (cfgDistanceToEdge.value && (checkEtaPhi1D(photon.eta(), RecoDecay::constrainAngle(photon.phi())) >= cfgEMCalMapLevelSameEvent.value)) {
1104+
if (cfgDistanceToEdge.value > 0 && (checkEtaPhi1D(photon.eta(), RecoDecay::constrainAngle(photon.phi())) >= cfgEMCalMapLevelSameEvent.value)) {
11091105
continue;
11101106
}
11111107
registry.fill(HIST("clusterQA/hEClusterAfter"), photon.corrE()); // accepted after cuts
@@ -1145,7 +1141,7 @@ struct TaskPi0FlowEMC {
11451141
// general event selection
11461142
continue;
11471143
}
1148-
if (!(eventcuts.cfgFT0COccupancyMin <= c1.ft0cOccupancyInTimeRange() && c1.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax) || !(eventcuts.cfgFT0COccupancyMin <= c2.ft0cOccupancyInTimeRange() && c2.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) {
1144+
if (!(eventcuts.cfgFT0COccupancyMin <= c1.ft0cOccupancyInTimeRange()) || !(c1.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax) || !(eventcuts.cfgFT0COccupancyMin <= c2.ft0cOccupancyInTimeRange()) || !(c2.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) {
11491145
// occupancy selection
11501146
continue;
11511147
}
@@ -1168,7 +1164,7 @@ struct TaskPi0FlowEMC {
11681164
continue;
11691165
}
11701166
// Cut edge clusters away, similar to rotation method to ensure same acceptance is used
1171-
if (cfgDistanceToEdge.value) {
1167+
if (cfgDistanceToEdge.value > 0) {
11721168
if (checkEtaPhi1D(g1.eta(), RecoDecay::constrainAngle(g1.phi())) >= cfgEMCalMapLevelBackground.value) {
11731169
continue;
11741170
}
@@ -1259,7 +1255,7 @@ struct TaskPi0FlowEMC {
12591255
}
12601256

12611257
// Cut edge clusters away, similar to rotation method to ensure same acceptance is used
1262-
if (cfgDistanceToEdge.value) {
1258+
if (cfgDistanceToEdge.value > 0) {
12631259
if (checkEtaPhi1D(g1.eta(), RecoDecay::constrainAngle(g1.phi())) >= cfgEMCalMapLevelSameEvent.value) {
12641260
continue;
12651261
}
@@ -1335,7 +1331,7 @@ struct TaskPi0FlowEMC {
13351331
// general event selection
13361332
continue;
13371333
}
1338-
if (!(eventcuts.cfgFT0COccupancyMin <= c1.ft0cOccupancyInTimeRange() && c1.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax) || !(eventcuts.cfgFT0COccupancyMin <= c2.ft0cOccupancyInTimeRange() && c2.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) {
1334+
if (!(eventcuts.cfgFT0COccupancyMin <= c1.ft0cOccupancyInTimeRange()) || !(c1.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax) || !(eventcuts.cfgFT0COccupancyMin <= c2.ft0cOccupancyInTimeRange()) || !(c2.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) {
13391335
// occupancy selection
13401336
continue;
13411337
}
@@ -1358,7 +1354,7 @@ struct TaskPi0FlowEMC {
13581354
continue;
13591355
}
13601356
// Cut edge clusters away, similar to rotation method to ensure same acceptance is used
1361-
if (cfgDistanceToEdge.value) {
1357+
if (cfgDistanceToEdge.value > 0) {
13621358
if (checkEtaPhi1D(g1.eta(), RecoDecay::constrainAngle(g1.phi())) >= cfgEMCalMapLevelBackground.value) {
13631359
continue;
13641360
}
@@ -1431,7 +1427,7 @@ struct TaskPi0FlowEMC {
14311427
if (!(emcFlags.test(photon.globalIndex()))) {
14321428
continue;
14331429
}
1434-
if (cfgDistanceToEdge.value && (checkEtaPhi1D(photon.eta(), RecoDecay::constrainAngle(photon.phi())) >= cfgEMCalMapLevelSameEvent.value)) {
1430+
if (cfgDistanceToEdge.value > 0 && (checkEtaPhi1D(photon.eta(), RecoDecay::constrainAngle(photon.phi())) >= cfgEMCalMapLevelSameEvent.value)) {
14351431
continue;
14361432
}
14371433
if (emccuts.cfgEnableQA.value) {
@@ -1536,7 +1532,7 @@ struct TaskPi0FlowEMC {
15361532
// general event selection
15371533
continue;
15381534
}
1539-
if (!(eventcuts.cfgFT0COccupancyMin <= c1.ft0cOccupancyInTimeRange() && c1.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax) || !(eventcuts.cfgFT0COccupancyMin <= c2.ft0cOccupancyInTimeRange() && c2.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) {
1535+
if (!(eventcuts.cfgFT0COccupancyMin <= c1.ft0cOccupancyInTimeRange()) || !(c1.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax) || !(eventcuts.cfgFT0COccupancyMin <= c2.ft0cOccupancyInTimeRange()) || !(c2.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) {
15401536
// occupancy selection
15411537
continue;
15421538
}
@@ -1586,7 +1582,7 @@ struct TaskPi0FlowEMC {
15861582

15871583
}; // End struct TaskPi0FlowEMC
15881584

1589-
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
1585+
WorkflowSpec defineDataProcessing(ConfigContext const& context)
15901586
{
1591-
return WorkflowSpec{adaptAnalysisTask<TaskPi0FlowEMC>(cfgc)};
1587+
return WorkflowSpec{adaptAnalysisTask<TaskPi0FlowEMC>(context)};
15921588
}

0 commit comments

Comments
 (0)