Skip to content

Commit 1014fbf

Browse files
author
ariffero
committed
Avoid magic numbers
1 parent cf72014 commit 1014fbf

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

PWGUD/Tasks/FwdMuonsUPC.cxx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ 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+
175180
struct FwdMuonsUPC {
176181

177182
// a pdg object
@@ -482,18 +487,18 @@ struct FwdMuonsUPC {
482487
// function to compute phi for azimuth anisotropy
483488
void computePhiAnis(TLorentzVector p1, TLorentzVector p2, int sign1, float& phiAverage, float& phiCharge)
484489
{
485-
486490
TLorentzVector tSum, tDiffAv, tDiffCh;
487491
tSum = p1 + p2;
492+
float halfUnity = 0.5;
488493
if (sign1 > 0) {
489494
tDiffCh = p1 - p2;
490-
if (gRandom->Rndm() > 0.5)
495+
if (gRandom->Rndm() > halfUnity)
491496
tDiffAv = p1 - p2;
492497
else
493498
tDiffAv = p2 - p1;
494499
} else {
495500
tDiffCh = p2 - p1;
496-
if (gRandom->Rndm() > 0.5)
501+
if (gRandom->Rndm() > halfUnity)
497502
tDiffAv = p2 - p1;
498503
else
499504
tDiffAv = p1 - p2;
@@ -518,7 +523,7 @@ struct FwdMuonsUPC {
518523
const auto& ampsRelBCsV0A = cand.ampRelBCsV0A();
519524
for (unsigned int i = 0; i < ampsV0A.size(); ++i) {
520525
if (std::abs(ampsRelBCsV0A[i]) <= 1) {
521-
if (ampsV0A[i] > 100.)
526+
if (ampsV0A[i] > kMaxAmpV0A)
522527
return;
523528
}
524529
}
@@ -535,7 +540,7 @@ struct FwdMuonsUPC {
535540
nMIDs++;
536541
if (tr2.chi2MatchMCHMID() > 0)
537542
nMIDs++;
538-
if (nMIDs != 2)
543+
if (nMIDs != kReqMatchMIDTracks)
539544
return;
540545

541546
// MFT-MID match selection (if MFT is requested by the trackType)
@@ -545,11 +550,11 @@ struct FwdMuonsUPC {
545550
kEtaMax = -2.5;
546551

547552
int nMFT = 0;
548-
if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30)
553+
if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < kMaxChi2MFTMatch)
549554
nMFT++;
550-
if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30)
555+
if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < kMaxChi2MFTMatch)
551556
nMFT++;
552-
if (nMFT != 2)
557+
if (nMFT != kReqMatchMFTTracks)
553558
return;
554559
}
555560

@@ -778,7 +783,7 @@ struct FwdMuonsUPC {
778783
nMIDs++;
779784
if (tr2.chi2MatchMCHMID() > 0)
780785
nMIDs++;
781-
if (nMIDs != 2)
786+
if (nMIDs != kReqMatchMIDTracks)
782787
return;
783788

784789
// MFT-MID match selection (if MFT is requested by the trackType)
@@ -788,11 +793,11 @@ struct FwdMuonsUPC {
788793
kEtaMax = -2.5;
789794

790795
int nMFT = 0;
791-
if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30)
796+
if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < kMaxChi2MFTMatch)
792797
nMFT++;
793-
if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30)
798+
if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < kMaxChi2MFTMatch)
794799
nMFT++;
795-
if (nMFT != 2)
800+
if (nMFT != kReqMatchMFTTracks)
796801
return;
797802
}
798803

0 commit comments

Comments
 (0)