Skip to content

Commit 6c6c8ba

Browse files
authored
[PWGLF] added protection against possible infinite loops (#9839)
1 parent 0004878 commit 6c6c8ba

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

PWGLF/Tasks/Nuspex/nucleiInJets.cxx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ struct NucleiInJets {
172172
registryQC.add("jet_ue_overlaps", "jet_ue_overlaps", HistType::kTH2F, {{20, 0.0, 20.0, "#it{n}_{jet}"}, {200, 0.0, 200.0, "#it{n}_{overlaps}"}});
173173
registryQC.add("ue_ue_overlaps", "ue_ue_overlaps", HistType::kTH2F, {{20, 0.0, 20.0, "#it{n}_{jet}"}, {200, 0.0, 200.0, "#it{n}_{overlaps}"}});
174174
registryQC.add("tot_overlaps", "tot_overlaps", HistType::kTH2F, {{20, 0.0, 20.0, "#it{n}_{jet}"}, {200, 0.0, 200.0, "#it{n}_{overlaps}"}});
175-
registryQC.add("hJetArea", "hJetArea", HistType::kTH1F, {{450, 0, 15, "Area"}});
175+
registryQC.add("hJetArea", "hJetArea", HistType::kTH1F, {{2000, 0, 2, "Area"}});
176+
registryQC.add("hError", "hError", HistType::kTH1F, {{5, 0, 5, "error"}});
176177

177178
// Event Counters
178179
registryData.add("number_of_events_data", "number of events in data", HistType::kTH1F, {{10, 0, 10, "counter"}});
@@ -530,7 +531,7 @@ struct NucleiInJets {
530531
std::vector<int> nParticlesInjet;
531532

532533
do {
533-
double dijMin(1e+06), diBmin(1e+06);
534+
double dijMin(1e+300), diBmin(1e+300);
534535
int iMin(0), jMin(0), iBmin(0);
535536
for (int i = 0; i < static_cast<int>(trk.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop]
536537
if (trk[i].Mag() == 0)
@@ -1018,7 +1019,7 @@ struct NucleiInJets {
10181019
std::vector<int> nParticlesInjet;
10191020

10201021
do {
1021-
double dijMin(1e+06), diBmin(1e+06);
1022+
double dijMin(1e+300), diBmin(1e+300);
10221023
int iMin(0), jMin(0), iBmin(0);
10231024
for (int i = 0; i < static_cast<int>(trk.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop]
10241025
if (trk[i].Mag() == 0)
@@ -1247,7 +1248,7 @@ struct NucleiInJets {
12471248
std::vector<int> nParticlesInjet;
12481249

12491250
do {
1250-
double dijMin(1e+06), diBmin(1e+06);
1251+
double dijMin(1e+300), diBmin(1e+300);
12511252
int iMin(0), jMin(0), iBmin(0);
12521253
for (int i = 0; i < static_cast<int>(trk.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop]
12531254
if (trk[i].Mag() == 0)
@@ -1413,7 +1414,7 @@ struct NucleiInJets {
14131414
std::vector<double> jetArea;
14141415

14151416
do {
1416-
double dijMin(1e+06), diBmin(1e+06);
1417+
double dijMin(1e+300), diBmin(1e+300);
14171418
int iMin(0), jMin(0), iBmin(0);
14181419
int nGhostsInJet(0);
14191420
for (int i = 0; i < static_cast<int>(trk.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop]
@@ -1446,11 +1447,16 @@ struct NucleiInJets {
14461447
}
14471448
if (dijMin > diBmin) {
14481449
double area = (static_cast<double>(nGhostsInJet) / static_cast<double>(nGhosts)) * TwoPI * 1.6;
1449-
jetArea.push_back(area);
1450+
double alphaJet = area / (PI * rJet * rJet);
1451+
jetArea.push_back(alphaJet);
14501452
jet.push_back(trk[iBmin]);
14511453
trk[iBmin].SetXYZ(0, 0, 0);
14521454
nParticlesRemoved++;
14531455
}
1456+
if (dijMin == diBmin) {
1457+
registryQC.fill(HIST("hError"), 0.5);
1458+
nParticlesRemoved = static_cast<int>(trk.size());
1459+
}
14541460
} while (nParticlesRemoved < static_cast<int>(trk.size()));
14551461

14561462
for (int i = 0; i < static_cast<int>(jet.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop]
@@ -1507,7 +1513,7 @@ struct NucleiInJets {
15071513
std::vector<int> nParticlesInjet;
15081514

15091515
do {
1510-
double dijMin(1e+06), diBmin(1e+06);
1516+
double dijMin(1e+300), diBmin(1e+300);
15111517
int iMin(0), jMin(0), iBmin(0);
15121518
for (int i = 0; i < static_cast<int>(trk.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop]
15131519
if (trk[i].Mag() == 0)

0 commit comments

Comments
 (0)