Skip to content

Commit 993d58c

Browse files
author
ariffero
committed
Avoid magic numbers
1 parent cf72014 commit 993d58c

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

PWGUD/Tasks/FwdMuonsUPC.cxx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ float kEtaMin = -4.0;
172172
float kEtaMax = -2.5;
173173
const float kPtMin = 0.;
174174

175+
const float kMaxAmpV0A = 100.;
176+
const int kReqMatchMIDTracks = 2;
177+
const int kReqMatchMFTTracks = 2;
178+
const int kMaxChi2MFTMatch = 30;
179+
const float kMaxZDCTime = 2.;
180+
const float kMaxZDCTimeHisto = 10.;
181+
const int kMuonPDG = 13;
182+
175183
struct FwdMuonsUPC {
176184

177185
// a pdg object
@@ -462,7 +470,7 @@ struct FwdMuonsUPC {
462470
float rAbs = fwdTrack.rAtAbsorberEnd();
463471
float pDca = fwdTrack.pDca();
464472
TLorentzVector p;
465-
auto mMu = particleMass(13);
473+
auto mMu = particleMass(kMuonPDG);
466474
p.SetXYZM(fwdTrack.px(), fwdTrack.py(), fwdTrack.pz(), mMu);
467475
float eta = p.Eta();
468476
float pt = p.Pt();
@@ -482,18 +490,18 @@ struct FwdMuonsUPC {
482490
// function to compute phi for azimuth anisotropy
483491
void computePhiAnis(TLorentzVector p1, TLorentzVector p2, int sign1, float& phiAverage, float& phiCharge)
484492
{
485-
486493
TLorentzVector tSum, tDiffAv, tDiffCh;
487494
tSum = p1 + p2;
495+
float halfUnity = 0.5;
488496
if (sign1 > 0) {
489497
tDiffCh = p1 - p2;
490-
if (gRandom->Rndm() > 0.5)
498+
if (gRandom->Rndm() > halfUnity)
491499
tDiffAv = p1 - p2;
492500
else
493501
tDiffAv = p2 - p1;
494502
} else {
495503
tDiffCh = p2 - p1;
496-
if (gRandom->Rndm() > 0.5)
504+
if (gRandom->Rndm() > halfUnity)
497505
tDiffAv = p2 - p1;
498506
else
499507
tDiffAv = p1 - p2;
@@ -518,7 +526,7 @@ struct FwdMuonsUPC {
518526
const auto& ampsRelBCsV0A = cand.ampRelBCsV0A();
519527
for (unsigned int i = 0; i < ampsV0A.size(); ++i) {
520528
if (std::abs(ampsRelBCsV0A[i]) <= 1) {
521-
if (ampsV0A[i] > 100.)
529+
if (ampsV0A[i] > kMaxAmpV0A)
522530
return;
523531
}
524532
}
@@ -535,7 +543,7 @@ struct FwdMuonsUPC {
535543
nMIDs++;
536544
if (tr2.chi2MatchMCHMID() > 0)
537545
nMIDs++;
538-
if (nMIDs != 2)
546+
if (nMIDs != kReqMatchMIDTracks)
539547
return;
540548

541549
// MFT-MID match selection (if MFT is requested by the trackType)
@@ -545,11 +553,11 @@ struct FwdMuonsUPC {
545553
kEtaMax = -2.5;
546554

547555
int nMFT = 0;
548-
if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30)
556+
if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < kMaxChi2MFTMatch)
549557
nMFT++;
550-
if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30)
558+
if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < kMaxChi2MFTMatch)
551559
nMFT++;
552-
if (nMFT != 2)
560+
if (nMFT != kReqMatchMFTTracks)
553561
return;
554562
}
555563

@@ -561,7 +569,7 @@ struct FwdMuonsUPC {
561569

562570
// form Lorentz vectors
563571
TLorentzVector p1, p2;
564-
auto mMu = particleMass(13);
572+
auto mMu = particleMass(kMuonPDG);
565573
p1.SetXYZM(tr1.px(), tr1.py(), tr1.pz(), mMu);
566574
p2.SetXYZM(tr2.px(), tr2.py(), tr2.pz(), mMu);
567575
TLorentzVector p = p1 + p2;
@@ -589,9 +597,9 @@ struct FwdMuonsUPC {
589597
computePhiAnis(p1, p2, tr1.sign(), phiAverage, phiCharge);
590598

591599
// zdc info
592-
if (std::abs(zdc.timeA) < 10)
600+
if (std::abs(zdc.timeA) < kMaxZDCTimeHisto)
593601
registry.fill(HIST("hTimeZNA"), zdc.timeA);
594-
if (std::abs(zdc.timeC) < 10)
602+
if (std::abs(zdc.timeC) < kMaxZDCTimeHisto)
595603
registry.fill(HIST("hTimeZNC"), zdc.timeC);
596604
registry.fill(HIST("hEnergyZN"), zdc.enA, zdc.enC);
597605

@@ -600,9 +608,9 @@ struct FwdMuonsUPC {
600608
bool neutronC = false;
601609
int znClass = -1;
602610

603-
if (std::abs(zdc.timeA) < 2)
611+
if (std::abs(zdc.timeA) < kMaxZDCTime)
604612
neutronA = true;
605-
if (std::abs(zdc.timeC) < 2)
613+
if (std::abs(zdc.timeC) < kMaxZDCTime)
606614
neutronC = true;
607615

608616
if (std::isinf(zdc.timeC))
@@ -684,12 +692,12 @@ struct FwdMuonsUPC {
684692
{
685693

686694
// check that all pairs are mu+mu-
687-
if (std::abs(McPart1.pdgCode()) != 13 && std::abs(McPart2.pdgCode()) != 13)
695+
if (std::abs(McPart1.pdgCode()) != kMuonPDG && std::abs(McPart2.pdgCode()) != kMuonPDG)
688696
LOGF(debug, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode());
689697

690698
// create Lorentz vectors
691699
TLorentzVector p1, p2;
692-
auto mMu = particleMass(13);
700+
auto mMu = particleMass(kMuonPDG);
693701
p1.SetXYZM(McPart1.px(), McPart1.py(), McPart1.pz(), mMu);
694702
p2.SetXYZM(McPart2.px(), McPart2.py(), McPart2.pz(), mMu);
695703
TLorentzVector p = p1 + p2;
@@ -753,15 +761,15 @@ struct FwdMuonsUPC {
753761
{
754762

755763
// check that all pairs are mu+mu-
756-
if (std::abs(McPart1.pdgCode()) != 13 && std::abs(McPart2.pdgCode()) != 13)
764+
if (std::abs(McPart1.pdgCode()) != kMuonPDG && std::abs(McPart2.pdgCode()) != kMuonPDG)
757765
LOGF(debug, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode());
758766

759767
// V0 selection
760768
const auto& ampsV0A = cand.amplitudesV0A();
761769
const auto& ampsRelBCsV0A = cand.ampRelBCsV0A();
762770
for (unsigned int i = 0; i < ampsV0A.size(); ++i) {
763771
if (std::abs(ampsRelBCsV0A[i]) <= 1) {
764-
if (ampsV0A[i] > 100.)
772+
if (ampsV0A[i] > kMaxAmpV0A)
765773
return;
766774
}
767775
}
@@ -778,7 +786,7 @@ struct FwdMuonsUPC {
778786
nMIDs++;
779787
if (tr2.chi2MatchMCHMID() > 0)
780788
nMIDs++;
781-
if (nMIDs != 2)
789+
if (nMIDs != kReqMatchMIDTracks)
782790
return;
783791

784792
// MFT-MID match selection (if MFT is requested by the trackType)
@@ -788,11 +796,11 @@ struct FwdMuonsUPC {
788796
kEtaMax = -2.5;
789797

790798
int nMFT = 0;
791-
if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30)
799+
if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < kMaxChi2MFTMatch)
792800
nMFT++;
793-
if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30)
801+
if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < kMaxChi2MFTMatch)
794802
nMFT++;
795-
if (nMFT != 2)
803+
if (nMFT != kReqMatchMFTTracks)
796804
return;
797805
}
798806

@@ -804,7 +812,7 @@ struct FwdMuonsUPC {
804812

805813
// form Lorentz vectors
806814
TLorentzVector p1, p2;
807-
auto mMu = particleMass(13);
815+
auto mMu = particleMass(kMuonPDG);
808816
p1.SetXYZM(tr1.px(), tr1.py(), tr1.pz(), mMu);
809817
p2.SetXYZM(tr2.px(), tr2.py(), tr2.pz(), mMu);
810818
TLorentzVector p = p1 + p2;

0 commit comments

Comments
 (0)