Skip to content

Commit 063d268

Browse files
committed
[PWGLF] O2 linter
1 parent dd005a4 commit 063d268

File tree

1 file changed

+82
-67
lines changed

1 file changed

+82
-67
lines changed

PWGLF/Tasks/Resonances/f0980analysis.cxx

Lines changed: 82 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11-
12-
/// \author Junlee Kim (jikim1290@gmail.com)
11+
///
12+
/// \file f0980analysis.cxx
13+
/// \brief f0(980) analysis in pp 13.6 TeV
14+
/// \author Yunseul Bae (ybae@cern.ch), Junlee Kim (jikim1290@gmail.com)
15+
/// \since 30/06/2025
1316

1417
#include "PWGLF/DataModel/LFResonanceTables.h"
1518

@@ -29,6 +32,8 @@
2932

3033
#include <vector>
3134

35+
using namespace o2::constants::physics;
36+
3237
struct f0980analysis {
3338
SliceCache cache;
3439
HistogramRegistry histos{
@@ -78,7 +83,7 @@ struct f0980analysis {
7883
Configurable<double> cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 5.0, "TPC nSigma cut for Pion"}; // TPC
7984
Configurable<double> cMaxTPCnSigmaPionWoTOF{"cMaxTPCnSigmaPionWoTOF", 2.0, "TPC nSigma cut without TOF for Pion"};
8085
Configurable<double> nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"};
81-
Configurable<int> SelectType{"SelectType", 0, "PID selection type"};
86+
Configurable<int> selectType{"SelectType", 0, "PID selection type"};
8287

8388
// Axis
8489
ConfigurableAxis massAxis{"massAxis", {400, 0.2, 2.2}, "Invariant mass axis"};
@@ -88,41 +93,41 @@ struct f0980analysis {
8893
{
8994
std::vector<double> lptBinning = {0, 5.0, 13.0, 20.0, 50.0, 1000.0};
9095

91-
AxisSpec RTAxis = {3, 0, 3};
92-
AxisSpec LptAxis = {lptBinning}; // Minimum leading hadron pT selection
96+
AxisSpec rtAxis = {3, 0, 3};
97+
AxisSpec lptAxis = {lptBinning}; // Minimum leading hadron pT selection
9398

94-
AxisSpec PIDqaAxis = {120, -6, 6};
99+
AxisSpec pidQaAxis = {120, -6, 6};
95100
AxisSpec pTqaAxis = {200, 0, 20};
96-
AxisSpec phiqaAxis = {72, 0., 2.0 * o2::constants::math::PI};
97-
AxisSpec EPAxis = {10, 0, o2::constants::math::PI};
98-
AxisSpec EPqaAxis = {200, -o2::constants::math::PI, o2::constants::math::PI};
99-
AxisSpec EPresAxis = {200, -2, 2};
101+
AxisSpec phiqaAxis = {72, 0, o2::constants::math::TWOPI};
102+
AxisSpec epAxis = {10, 0, o2::constants::math::PI};
103+
AxisSpec epQaAxis = {200, -o2::constants::math::PI, o2::constants::math::PI};
104+
AxisSpec epResAxis = {200, -2, 2};
100105

101106
if (cfgFindRT) {
102107
histos.add("hInvMass_f0980_US", "unlike invariant mass",
103-
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, RTAxis, LptAxis}});
108+
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, rtAxis, lptAxis}});
104109
histos.add("hInvMass_f0980_LSpp", "++ invariant mass",
105-
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, RTAxis, LptAxis}});
110+
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, rtAxis, lptAxis}});
106111
histos.add("hInvMass_f0980_LSmm", "-- invariant mass",
107-
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, RTAxis, LptAxis}});
112+
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, rtAxis, lptAxis}});
108113
}
109114
histos.add("hInvMass_f0980_US_EPA", "unlike invariant mass",
110-
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, EPAxis}});
115+
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, epAxis}});
111116
histos.add("hInvMass_f0980_LSpp_EPA", "++ invariant mass",
112-
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, EPAxis}});
117+
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, epAxis}});
113118
histos.add("hInvMass_f0980_LSmm_EPA", "-- invariant mass",
114-
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, EPAxis}});
119+
{HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, epAxis}});
115120

116-
histos.add("QA/hEPResAB", "", {HistType::kTH2F, {centAxis, EPresAxis}});
117-
histos.add("QA/hEPResAC", "", {HistType::kTH2F, {centAxis, EPresAxis}});
118-
histos.add("QA/hEPResBC", "", {HistType::kTH2F, {centAxis, EPresAxis}});
121+
histos.add("QA/hEPResAB", "", {HistType::kTH2F, {centAxis, epResAxis}});
122+
histos.add("QA/hEPResAC", "", {HistType::kTH2F, {centAxis, epResAxis}});
123+
histos.add("QA/hEPResBC", "", {HistType::kTH2F, {centAxis, epResAxis}});
119124

120-
histos.add("QA/Nsigma_TPC", "", {HistType::kTH2F, {pTqaAxis, PIDqaAxis}});
121-
histos.add("QA/Nsigma_TOF", "", {HistType::kTH2F, {pTqaAxis, PIDqaAxis}});
122-
histos.add("QA/TPC_TOF", "", {HistType::kTH2F, {PIDqaAxis, PIDqaAxis}});
125+
histos.add("QA/Nsigma_TPC", "", {HistType::kTH2F, {pTqaAxis, pidQaAxis}});
126+
histos.add("QA/Nsigma_TOF", "", {HistType::kTH2F, {pTqaAxis, pidQaAxis}});
127+
histos.add("QA/TPC_TOF", "", {HistType::kTH2F, {pidQaAxis, pidQaAxis}});
123128

124129
histos.add("QA/LTpt", "", {HistType::kTH3F, {pTqaAxis, centAxis, phiqaAxis}});
125-
histos.add("QA/EPhist", "", {HistType::kTH2F, {centAxis, EPqaAxis}});
130+
histos.add("QA/EPhist", "", {HistType::kTH2F, {centAxis, epQaAxis}});
126131

127132
if (doprocessMCLight) {
128133
histos.add("MCL/hpT_f0980_GEN", "generated f0 signals", HistType::kTH1F,
@@ -136,21 +141,26 @@ struct f0980analysis {
136141

137142
double massPi = MassPionCharged;
138143

139-
int RTIndex(double pairphi, double lhphi)
144+
constexpr float OneThird = 1.0f / 3.0f;
145+
constexpr float PIthird = o2::constants::math::PI * OneThird;
146+
constexpr float TWOPIthird = o2::constants::math::TWOPI * OneThird;
147+
148+
int rtIndex(double pairphi, double lhPhi)
140149
{
141-
double dphi = std::fabs(TVector2::Phi_mpi_pi(lhphi - pairphi));
142-
if (dphi < o2::constants::math::PI / 3.0)
150+
double dphi = std::fabs(TVector2::Phi_mpi_pi(lhPhi - pairphi));
151+
152+
if (dphi < PIthird)
143153
return 0;
144-
if (dphi < 2.0 * o2::constants::math::PI / 3.0 && dphi > o2::constants::math::PI / 3.0)
154+
if (dphi < TWOPIthird && dphi > PIthird)
145155
return 1;
146-
if (dphi > 2.0 * o2::constants::math::PI / 3.0)
156+
if (dphi > TWOPIthird)
147157
return 2;
148158

149159
return -1;
150160
}
151161

152162
template <typename TrackType>
153-
bool SelTrack(const TrackType track)
163+
bool selTrack(const TrackType track)
154164
{
155165
if (std::abs(track.pt()) < cfgMinPt)
156166
return false;
@@ -181,21 +191,26 @@ struct f0980analysis {
181191
}
182192

183193
template <typename TrackType>
184-
bool SelPion(const TrackType track)
194+
bool selPion(const TrackType track)
185195
{
186-
if (SelectType == 0) {
196+
constexpr int TPCorTOF = 0;
197+
constexpr int TPCOnly = 1;
198+
constexpr int Combined = 2;
199+
constexpr int Run2Like = 3;
200+
201+
if (selectType == TPCorTOF) {
187202
if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion || std::fabs(track.tofNSigmaPi()) >= cMaxTOFnSigmaPion)
188203
return false;
189204
}
190-
if (SelectType == 1) {
205+
if (selectType == TPConly) {
191206
if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion)
192207
return false;
193208
}
194-
if (SelectType == 2) {
209+
if (selectType == Combined) {
195210
if (track.tpcNSigmaPi() * track.tpcNSigmaPi() + track.tofNSigmaPi() * track.tofNSigmaPi() >= nsigmaCutCombinedPion * nsigmaCutCombinedPion)
196211
return false;
197212
}
198-
if (SelectType == 3) {
213+
if (selectType == Run2Like) {
199214
if (track.hasTOF()) {
200215
if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion || std::fabs(track.tofNSigmaPi()) >= cMaxTOFnSigmaPion)
201216
return false;
@@ -211,14 +226,14 @@ struct f0980analysis {
211226
void fillHistograms(const CollisionType& collision,
212227
const TracksType& dTracks)
213228
{
214-
double LHpt = 0.;
215-
double LHphi = 0.;
229+
double lhPt = 0.;
230+
double lhPhi = 0.;
216231
double relPhi = 0.;
217232
if (cfgFindRT) {
218-
for (auto& trk : dTracks) {
219-
if (trk.pt() > LHpt) {
220-
LHpt = trk.pt();
221-
LHphi = trk.phi();
233+
for (const auto& trk : dTracks) {
234+
if (trk.pt() > lhPt) {
235+
lhPt = trk.pt();
236+
lhPhi = trk.phi();
222237
}
223238
}
224239
}
@@ -227,64 +242,64 @@ struct f0980analysis {
227242
histos.fill(HIST("QA/hEPResAB"), collision.cent(), collision.evtPlResAB());
228243
histos.fill(HIST("QA/hEPResAC"), collision.cent(), collision.evtPlResBC());
229244
histos.fill(HIST("QA/hEPResBC"), collision.cent(), collision.evtPlResAC());
230-
histos.fill(HIST("QA/LTpt"), LHpt, collision.cent(), LHphi);
245+
histos.fill(HIST("QA/LTpt"), lhPt, collision.cent(), lhPhi);
231246

232-
ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<float>> Pion1, Pion2, Reco;
233-
for (auto& [trk1, trk2] :
247+
ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<float>> pion1, pion2, reco;
248+
for (const auto& [trk1, trk2] :
234249
combinations(CombinationsStrictlyUpperIndexPolicy(dTracks, dTracks))) {
235250

236-
if (!SelTrack(trk1) || !SelTrack(trk2))
251+
if (!selTrack(trk1) || !selTrack(trk2))
237252
continue;
238253
// TPC, TOF Nsigma distributions
239254
histos.fill(HIST("QA/Nsigma_TPC"), trk1.pt(), trk1.tpcNSigmaPi());
240255
histos.fill(HIST("QA/Nsigma_TOF"), trk1.pt(), trk1.tofNSigmaPi());
241256
histos.fill(HIST("QA/TPC_TOF"), trk1.tpcNSigmaPi(), trk1.tofNSigmaPi());
242257

243-
if (!SelPion(trk1) || !SelPion(trk2))
258+
if (!selPion(trk1) || !selPion(trk2))
244259
continue;
245260

246-
Pion1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi);
247-
Pion2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi);
248-
Reco = Pion1 + Pion2;
261+
pion1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi);
262+
pion2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi);
263+
reco = pion1 + pion2;
249264

250-
if (Reco.Rapidity() > cfgMaxRap || Reco.Rapidity() < cfgMinRap)
265+
if (reco.Rapidity() > cfgMaxRap || reco.Rapidity() < cfgMinRap)
251266
continue;
252267

253-
relPhi = TVector2::Phi_0_2pi(Reco.Phi() - collision.evtPl());
268+
relPhi = TVector2::Phi_0_2pi(reco.Phi() - collision.evtPl());
254269
if (relPhi > o2::constants::math::PI) {
255270
relPhi -= o2::constants::math::PI;
256271
}
257272

258273
if (trk1.sign() * trk2.sign() < 0) {
259274
if (cfgFindRT) {
260-
histos.fill(HIST("hInvMass_f0980_US"), Reco.M(), Reco.Pt(),
261-
collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt);
275+
histos.fill(HIST("hInvMass_f0980_US"), reco.M(), reco.Pt(),
276+
collision.cent(), rtIndex(reco.Phi(), lhPhi), lhPt);
262277
}
263-
histos.fill(HIST("hInvMass_f0980_US_EPA"), Reco.M(), Reco.Pt(),
278+
histos.fill(HIST("hInvMass_f0980_US_EPA"), reco.M(), reco.Pt(),
264279
collision.cent(), relPhi);
265280
if constexpr (IsMC) {
266-
if (std::abs(trk1.pdgCode()) != 211 || std::abs(trk2.pdgCode()) != 211)
281+
if (std::abs(trk1.pdgCode()) != Pdg::PiPlus || std::abs(trk2.pdgCode()) != Pdg::PiPlus)
267282
continue;
268283
if (trk1.motherId() != trk2.motherId())
269284
continue;
270-
if (std::abs(trk1.motherPDG()) != 9010221)
285+
if (std::abs(trk1.motherPDG()) != Pdg::f0_980) // 9010221
271286
continue;
272-
histos.fill(HIST("MCL/hpT_f0980_REC"), Reco.M(), Reco.Pt(),
287+
histos.fill(HIST("MCL/hpT_f0980_REC"), reco.M(), reco.Pt(),
273288
collision.cent());
274289
}
275290
} else if (trk1.sign() > 0 && trk2.sign() > 0) {
276291
if (cfgFindRT) {
277-
histos.fill(HIST("hInvMass_f0980_LSpp"), Reco.M(), Reco.Pt(),
278-
collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt);
292+
histos.fill(HIST("hInvMass_f0980_LSpp"), reco.M(), reco.Pt(),
293+
collision.cent(), rtIndex(reco.Phi(), lhPhi), lhPt);
279294
}
280-
histos.fill(HIST("hInvMass_f0980_LSpp_EPA"), Reco.M(), Reco.Pt(),
295+
histos.fill(HIST("hInvMass_f0980_LSpp_EPA"), reco.M(), reco.Pt(),
281296
collision.cent(), relPhi);
282297
} else if (trk1.sign() < 0 && trk2.sign() < 0) {
283298
if (cfgFindRT) {
284-
histos.fill(HIST("hInvMass_f0980_LSmm"), Reco.M(), Reco.Pt(),
285-
collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt);
299+
histos.fill(HIST("hInvMass_f0980_LSmm"), reco.M(), reco.Pt(),
300+
collision.cent(), rtIndex(reco.Phi(), lhPhi), lhPt);
286301
}
287-
histos.fill(HIST("hInvMass_f0980_LSmm_EPA"), Reco.M(), Reco.Pt(),
302+
histos.fill(HIST("hInvMass_f0980_LSmm_EPA"), reco.M(), reco.Pt(),
288303
collision.cent(), relPhi);
289304
}
290305
}
@@ -305,19 +320,19 @@ struct f0980analysis {
305320
}
306321
PROCESS_SWITCH(f0980analysis, processMCLight, "Process Event for MC", false);
307322

308-
void processMCTrue(aod::ResoMCParents& resoParents)
323+
void processMCTrue(const aod::ResoMCParents& resoParents)
309324
{
310-
for (auto& part : resoParents) { // loop over all pre-filtered MC particles
311-
if (std::abs(part.pdgCode()) != 9010221)
325+
for (const auto& part : resoParents) { // loop over all pre-filtered MC particles
326+
if (std::abs(part.pdgCode()) != Pdg::f0_980)
312327
continue;
313328
if (!part.producedByGenerator())
314329
continue;
315330
if (part.y() < cfgMinRap || part.y() > cfgMaxRap) {
316331
continue;
317332
}
318333
bool pass = false;
319-
if ((std::abs(part.daughterPDG1()) == 211 &&
320-
std::abs(part.daughterPDG2()) == 211)) {
334+
if ((std::abs(part.daughterPDG1()) == Pdg::PiPlus &&
335+
std::abs(part.daughterPDG2()) == Pdg::PiPlus)) {
321336
pass = true;
322337
}
323338
if (!pass) // If we have both decay products

0 commit comments

Comments
 (0)