diff --git a/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h b/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h index 81766a3a59cdc..543e49fb06dd8 100644 --- a/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h +++ b/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace o2 { @@ -34,10 +35,15 @@ class CellLabel public: // CellLabel() = default; - /// \brief Constructor + /// \brief Constructor using std::vector by moving NOT copying /// \param labels list of mc labels /// \param amplitudeFractions list of amplitude fractions - CellLabel(const gsl::span labels, const gsl::span amplitudeFractions); + CellLabel(std::vector labels, std::vector amplitudeFractions); + + /// \brief Constructor using gsl::span + /// \param labels list of mc labels + /// \param amplitudeFractions list of amplitude fractions + CellLabel(gsl::span labels, gsl::span amplitudeFractions); // ~CellLabel() = default; // CellLabel(const CellLabel& clus) = default; @@ -52,21 +58,21 @@ class CellLabel int32_t GetLabel(size_t index) const { return mLabels[index]; } /// \brief Getter for labels - gsl::span GetLabels() const { return mLabels; } + std::vector GetLabels() const { return mLabels; } /// \brief Getter for amplitude fraction /// \param index index which amplitude fraction to get float GetAmplitudeFraction(size_t index) const { return mAmplitudeFraction[index]; } /// \brief Getter for amplitude fractions - gsl::span GetAmplitudeFractions() const { return mAmplitudeFraction; } + std::vector GetAmplitudeFractions() const { return mAmplitudeFraction; } /// \brief Getter for label with leading amplitude fraction int32_t GetLeadingMCLabel() const; protected: - gsl::span mLabels; ///< List of MC particles that generated the cluster, ordered in deposited energy. - gsl::span mAmplitudeFraction; ///< List of the fraction of the cell energy coming from a MC particle. Index aligns with mLabels! + std::vector mLabels; ///< List of MC particles that generated the cluster, ordered in deposited energy. + std::vector mAmplitudeFraction; ///< List of the fraction of the cell energy coming from a MC particle. Index aligns with mLabels! }; } // namespace emcal diff --git a/DataFormats/Detectors/EMCAL/src/CellLabel.cxx b/DataFormats/Detectors/EMCAL/src/CellLabel.cxx index e37368ea181d7..70a1a642c5449 100644 --- a/DataFormats/Detectors/EMCAL/src/CellLabel.cxx +++ b/DataFormats/Detectors/EMCAL/src/CellLabel.cxx @@ -16,10 +16,19 @@ #include #include #include +#include +#include using namespace o2::emcal; -CellLabel::CellLabel(const gsl::span labels, const gsl::span amplitudeFractions) : mLabels(labels), mAmplitudeFraction(amplitudeFractions) +CellLabel::CellLabel(std::vector labels, std::vector amplitudeFractions) : mLabels(std::move(labels)), mAmplitudeFraction(std::move(amplitudeFractions)) +{ + if (labels.size() != amplitudeFractions.size()) { + LOG(error) << "Size of labels " << labels.size() << " does not match size of amplitude fraction " << amplitudeFractions.size() << " !"; + } +} + +CellLabel::CellLabel(gsl::span labels, gsl::span amplitudeFractions) : mLabels(labels.begin(), labels.end()), mAmplitudeFraction(amplitudeFractions.begin(), amplitudeFractions.end()) { if (labels.size() != amplitudeFractions.size()) { LOG(error) << "Size of labels " << labels.size() << " does not match size of amplitude fraction " << amplitudeFractions.size() << " !";