Skip to content

Commit 70a163d

Browse files
committed
[EMCAL-1154] Adjust CellLabels for cross talk emulation
- The CellLabel class used gsl::span as its members to store the mcLabels and amplitude fractions. However, when we want to use the cross talk emulation, we want to add new cells which happens inside the cross talk emulation function. Outside of this function the newley added CellLabels would point to dangling memory. That's why we need to change this to std::vectors and using hard copies here. For sure this will lead to more memory usage and CPU time, but not noticable I think.
1 parent fdab6db commit 70a163d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <cstddef>
1616
#include <cstdint>
1717
#include <gsl/span>
18+
#include <vector>
1819

1920
namespace o2
2021
{
@@ -37,7 +38,7 @@ class CellLabel
3738
/// \brief Constructor
3839
/// \param labels list of mc labels
3940
/// \param amplitudeFractions list of amplitude fractions
40-
CellLabel(const gsl::span<const int> labels, const gsl::span<const float> amplitudeFractions);
41+
CellLabel(std::vector<int> labels, std::vector<float> amplitudeFractions);
4142

4243
// ~CellLabel() = default;
4344
// CellLabel(const CellLabel& clus) = default;
@@ -52,21 +53,21 @@ class CellLabel
5253
int32_t GetLabel(size_t index) const { return mLabels[index]; }
5354

5455
/// \brief Getter for labels
55-
gsl::span<const int32_t> GetLabels() const { return mLabels; }
56+
std::vector<int32_t> GetLabels() const { return mLabels; }
5657

5758
/// \brief Getter for amplitude fraction
5859
/// \param index index which amplitude fraction to get
5960
float GetAmplitudeFraction(size_t index) const { return mAmplitudeFraction[index]; }
6061

6162
/// \brief Getter for amplitude fractions
62-
gsl::span<const float> GetAmplitudeFractions() const { return mAmplitudeFraction; }
63+
std::vector<float> GetAmplitudeFractions() const { return mAmplitudeFraction; }
6364

6465
/// \brief Getter for label with leading amplitude fraction
6566
int32_t GetLeadingMCLabel() const;
6667

6768
protected:
68-
gsl::span<const int32_t> mLabels; ///< List of MC particles that generated the cluster, ordered in deposited energy.
69-
gsl::span<const float> mAmplitudeFraction; ///< List of the fraction of the cell energy coming from a MC particle. Index aligns with mLabels!
69+
std::vector<int32_t> mLabels; ///< List of MC particles that generated the cluster, ordered in deposited energy.
70+
std::vector<float> mAmplitudeFraction; ///< List of the fraction of the cell energy coming from a MC particle. Index aligns with mLabels!
7071
};
7172

7273
} // namespace emcal

DataFormats/Detectors/EMCAL/src/CellLabel.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
#include <cstddef>
1717
#include <cstdint>
1818
#include <gsl/span>
19+
#include <vector>
1920

2021
using namespace o2::emcal;
2122

22-
CellLabel::CellLabel(const gsl::span<const int> labels, const gsl::span<const float> amplitudeFractions) : mLabels(labels), mAmplitudeFraction(amplitudeFractions)
23+
CellLabel::CellLabel(std::vector<int> labels, std::vector<float> amplitudeFractions) : mLabels(labels), mAmplitudeFraction(amplitudeFractions)
2324
{
2425
if (labels.size() != amplitudeFractions.size()) {
2526
LOG(error) << "Size of labels " << labels.size() << " does not match size of amplitude fraction " << amplitudeFractions.size() << " !";

0 commit comments

Comments
 (0)