Skip to content

Commit 97a764a

Browse files
authored
Fix the O2linter errors
1 parent bddb6d0 commit 97a764a

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

PWGHF/HFL/Tasks/taskSingleMuonSource.cxx

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#include <Framework/InitContext.h>
2727
#include <Framework/OutputObjHeader.h>
2828
#include <Framework/runDataProcessing.h>
29+
#include <Framework/O2DatabasePDGPlugin.h>
2930

3031
#include <Math/Vector4D.h>
31-
#include <TDatabasePDG.h>
3232
#include <TPDGCode.h>
3333
#include <TString.h>
3434

@@ -78,6 +78,8 @@ struct HfTaskSingleMuonSource {
7878
Configurable<int> charge{"charge", 0, "Muon track charge, validated values are 0, 1 and -1, 0 represents both 1 and -1"};
7979
Configurable<bool> pairSource{"pairSource", true, "check also the source of like-sign muon pairs"};
8080

81+
Service<o2::framework::O2DatabasePDG> pdgDB;
82+
8183
double pDcaMax = 594.0; // p*DCA maximum value for small Rab
8284
double pDcaMax2 = 324.0; // p*DCA maximum value for large Rabs
8385
double rAbsMid = 26.5; // R at absorber end minimum value
@@ -87,6 +89,9 @@ struct HfTaskSingleMuonSource {
8789
double etaUp = -2.5; // up edge of eta acceptance
8890
double edgeZ = 10.0; // edge of event position Z
8991
double ptLow = 1.0; // low edge of pT for muon pairs
92+
int pdgLow = 10; // low edge of pdgCode for particle separation
93+
int pdgMid = 1000; // intermediate edge of pdgCode for particle separation
94+
int pdgHigh = 10000; // up edge of pdgCode for particle separation
9095

9196
HistogramRegistry registry{
9297
"registry",
@@ -116,7 +121,7 @@ struct HfTaskSingleMuonSource {
116121

117122
HistogramConfigSpec const h1ColNumber{HistType::kTH1F, {axisColNumber}};
118123
HistogramConfigSpec const h1Pt{HistType::kTH1F, {axisPt}};
119-
HistogramConfigSpec h1Mass{HistType::kTH1F, {axisMass}};
124+
HistogramConfigSpec const h1Mass{HistType::kTH1F, {axisMass}};
120125
HistogramConfigSpec const h2PtDCA{HistType::kTH2F, {axisPt, axisDCA}};
121126
HistogramConfigSpec const h2PtChi2{HistType::kTH2F, {axisPt, axisChi2}};
122127
HistogramConfigSpec const h2PtDeltaPt{HistType::kTH2F, {axisPt, axisDeltaPt}};
@@ -161,7 +166,7 @@ struct HfTaskSingleMuonSource {
161166
mcPart = *(mcPart.mothers_first_as<aod::McParticles>());
162167

163168
const auto pdgAbs(std::abs(mcPart.pdgCode()));
164-
if (pdgAbs < 10 || pdgAbs == 21) {
169+
if (pdgAbs < kElectron || pdgAbs == kGluon) {
165170
break; // Quark and gluon
166171
}
167172

@@ -170,8 +175,7 @@ struct HfTaskSingleMuonSource {
170175
continue;
171176
}
172177

173-
if (pdgAbs == kTauMinus) {
174-
// Tau
178+
if (pdgAbs == kTauMinus) { // Tau
175179
SETBIT(mask, HasTauParent);
176180
continue;
177181
}
@@ -182,28 +186,27 @@ struct HfTaskSingleMuonSource {
182186
continue;
183187
} // Beam particle
184188

185-
if ((pdgRem < 100) || (pdgRem >= 10000)) {
189+
if ((pdgRem < pdgLow) || (pdgRem >= pdgHigh)) {
186190
continue;
187191
}
188-
if ((pdgRem % 100 == 1 || pdgRem % 100 == 3) && pdgRem > 1000) { // diquarks
192+
if ((pdgRem % 100 == kDown || pdgRem % 100 == kStrange) && pdgRem > pdgMid) { // diquarks
189193
continue;
190194
}
191195
// compute the flavor of constituent quark
192196
const int flv(pdgRem / std::pow(10, static_cast<int>(std::log10(pdgRem))));
193-
if (flv > 6) {
197+
if (flv > kTop) {
194198
// no more than 6 flavors
195199
continue;
196200
}
197-
if (flv < 4) {
201+
if (flv < kCharm) {
198202
// light flavor
199203
SETBIT(mask, HasLightParent);
200204
continue;
201205
}
202-
203-
auto* pdgData(TDatabasePDG::Instance()->GetParticle(mcPart.pdgCode()));
206+
auto* pdgData = pdgDB->GetParticle(mcPart.pdgCode());
204207
if ((pdgData != nullptr) && (pdgData->AntiParticle() == nullptr)) {
205208
SETBIT(mask, HasQuarkoniumParent);
206-
} else if (flv == 4) {
209+
} else if (flv == kCharm) {
207210
SETBIT(mask, HasCharmParent);
208211
} else {
209212
SETBIT(mask, HasBeautyParent);
@@ -276,11 +279,13 @@ struct HfTaskSingleMuonSource {
276279
// fill the histograms of each particle types
277280
void fillHistograms(const McMuons::iterator& muon)
278281
{
282+
const int type0 = 0;
283+
const int type2 = 2;
279284
const auto mask(getMask(muon));
280285
const auto pt(muon.pt()), chi2(muon.chi2MatchMCHMFT());
281286
const auto dca(RecoDecay::sqrtSumOfSquares(muon.fwdDcaX(), muon.fwdDcaY()));
282287

283-
if (trackType == 0 || trackType == 2) {
288+
if (trackType == type0 || trackType == type2) {
284289
if (!muon.has_matchMCHTrack()) {
285290
return;
286291
}
@@ -346,6 +351,7 @@ struct HfTaskSingleMuonSource {
346351
int traceAncestor(const McMuons::iterator& muon, aod::McParticles const& mctracks)
347352
{
348353
int mcNum = 0;
354+
const int hadronStatus = 80;
349355
if (!muon.has_mcParticle()) {
350356
return 0;
351357
}
@@ -355,30 +361,32 @@ struct HfTaskSingleMuonSource {
355361
}
356362
while (mcPart.has_mothers()) { // the first hadron after hadronization
357363
auto mother = mcPart.mothers_first_as<aod::McParticles>();
358-
if (std::abs(mother.getGenStatusCode()) < 80) {
364+
if (std::abs(mother.getGenStatusCode()) < hadronStatus) {
359365
break;
360366
}
361367
mcPart = mother;
362368
}
363369
int flv = mcPart.pdgCode() / std::pow(10, static_cast<int>(std::log10(std::abs(mcPart.pdgCode()))));
364-
if (abs(flv) == 5 && mcPart.pdgCode() < 1000)
370+
if (std::abs(flv) == kBottom && mcPart.pdgCode() < pdgMid) {
365371
flv = -flv;
372+
}
366373
for (int i = (mcPart.mothers_first_as<aod::McParticles>()).globalIndex(); i <= (mcPart.mothers_last_as<aod::McParticles>()).globalIndex(); i++) { // loop over the lund string
367-
for (auto mctrack : mctracks) {
374+
for (const auto& mctrack : mctracks) {
368375
if (mctrack.globalIndex() != i) {
369376
continue;
370377
}
371-
if ((mctrack.pdgCode() != flv) && (abs(mctrack.pdgCode()) < abs(flv) * 1000)) {
378+
if ((mctrack.pdgCode() != flv) && (std::abs(mctrack.pdgCode()) < std::abs(flv) * 1000)) {
372379
continue;
373380
}
374-
while (mctrack.has_mothers()) {
375-
int motherflv = (mctrack.mothers_first_as<aod::McParticles>()).pdgCode() / std::pow(10, static_cast<int>(std::log10(abs((mctrack.mothers_first_as<aod::McParticles>()).pdgCode())))); // find the mother with same flavor
376-
auto mother = (abs(motherflv) == abs(flv)) ? (mctrack.mothers_first_as<aod::McParticles>()) : (mctrack.mothers_last_as<aod::McParticles>());
377-
if ((mother.pdgCode() != mctrack.pdgCode()) && (abs(mctrack.pdgCode()) < 10)) { // both mother is not the the quark with same flavor
378-
mcNum = mctrack.globalIndex();
381+
auto currentTrk = mctrack;
382+
while (currentTrk.has_mothers()) {
383+
int motherflv = (currentTrk.mothers_first_as<aod::McParticles>()).pdgCode() / std::pow(10, static_cast<int>(std::log10(std::abs((currentTrk.mothers_first_as<aod::McParticles>()).pdgCode())))); // find the mother with same flavor
384+
auto mother = (std::abs(motherflv) == std::abs(flv)) ? (currentTrk.mothers_first_as<aod::McParticles>()) : (currentTrk.mothers_last_as<aod::McParticles>());
385+
if ((mother.pdgCode() != currentTrk.pdgCode()) && (std::abs(currentTrk.pdgCode()) < kElectron)) { // both mother is not the the quark with same flavor
386+
mcNum = currentTrk.globalIndex();
379387
return mcNum;
380388
}
381-
mctrack = mother;
389+
currentTrk = mother;
382390
}
383391
}
384392
}
@@ -393,7 +401,7 @@ struct HfTaskSingleMuonSource {
393401
if (anc1 == 0 || anc2 == 0) {
394402
return false;
395403
}
396-
for (auto mcPart : mcParts) {
404+
for (const auto& mcPart : mcParts) {
397405
if (mcPart.globalIndex() == anc1) {
398406
moth11 = (mcPart.mothers_first_as<aod::McParticles>()).globalIndex();
399407
moth12 = (mcPart.mothers_last_as<aod::McParticles>()).globalIndex();
@@ -410,7 +418,8 @@ struct HfTaskSingleMuonSource {
410418
}
411419
void fillPairs(const McMuons::iterator& muon, const McMuons::iterator& muon2, aod::McParticles const& mcParts)
412420
{
413-
if (trackType != 3) {
421+
const int type3 = 3;
422+
if (trackType != type3) {
414423
return;
415424
}
416425
float mm = o2::constants::physics::MassMuon;
@@ -483,7 +492,10 @@ struct HfTaskSingleMuonSource {
483492
continue;
484493
}
485494
}
486-
if ((muon.chi2() >= 1e6) || (muon.chi2() < 0)) {
495+
if (muon.chi2() < 0) {
496+
continue;
497+
}
498+
if (muon.chi2MatchMCHMID() < 0) {
487499
continue;
488500
}
489501
if (charge != 0 && muon.sign() != charge) {
@@ -523,10 +535,10 @@ struct HfTaskSingleMuonSource {
523535
}
524536
}
525537

526-
if ((muon2.chi2() >= 1e6) || (muon2.chi2() < 0)) {
538+
if (muon2.chi2() < 0) {
527539
continue;
528540
}
529-
if ((muon2.chi2MatchMCHMID() >= 1e6) || (muon2.chi2MatchMCHMID() < 0)) {
541+
if (muon2.chi2MatchMCHMID() < 0) {
530542
continue;
531543
}
532544
fillPairs(muon, muon2, mcParts);

0 commit comments

Comments
 (0)