Skip to content

Commit 553e3e7

Browse files
committed
Prevent dangling reference error when switching from gsl to std::span
1 parent 85d0325 commit 553e3e7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Common/TableProducer/multiplicityTable.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,14 @@ struct MultiplicityTable {
267267
int multNContribsEtaHalf = 0;
268268

269269
if (collision.has_fv0a()) {
270-
for (const auto& amplitude : collision.fv0a().amplitude()) {
270+
auto fv0a = collision.fv0a();
271+
for (const auto& amplitude : fv0a.amplitude()) {
271272
multFV0A += amplitude;
272273
}
273274
}
274275
if (collision.has_fv0c()) {
275-
for (const auto& amplitude : collision.fv0c().amplitude()) {
276+
auto fv0c = collision.fv0c();
277+
for (const auto& amplitude : fv0c.amplitude()) {
276278
multFV0C += amplitude;
277279
}
278280
}

Common/Tools/MultModule.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,14 @@ class MultModule
500500
//_______________________________________________________________________
501501
// forward detector signals, raw
502502
if (collision.has_fv0a()) {
503-
for (const auto& amplitude : collision.fv0a().amplitude()) {
503+
auto fv0a = collision.fv0a();
504+
for (const auto& amplitude : fv0a.amplitude()) {
504505
mults.multFV0A += amplitude;
505506
}
506507
}
507508
if (collision.has_fv0c()) {
508-
for (const auto& amplitude : collision.fv0c().amplitude()) {
509+
auto fv0c = collision.fv0c();
510+
for (const auto& amplitude : fv0c.amplitude()) {
509511
mults.multFV0C += amplitude;
510512
}
511513
}

0 commit comments

Comments
 (0)