diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArCompactSubset.h b/LArCalorimeter/LArRawConditions/LArRawConditions/LArCompactSubset.h index 91d3272e565f1059c3542c9d3aa9c21cabe99a4d..1ef0cdda505034d502ebd4ed24a57bd5d052f6a7 100644 --- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArCompactSubset.h +++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArCompactSubset.h @@ -1,6 +1,6 @@ // This file's extension implies that it's C, but it's really -*- C++ -*-. /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /** * @file LArRawConditions/LArCompactSubset.h @@ -272,14 +272,14 @@ public: /** * @brief Constructor from channel index and subset reference. */ - const_iterator (unsigned int chan, LArCompactSubsetVector& subset); + const_iterator (unsigned int chan, const LArCompactSubsetVector& subset); /** * @brief Iterator dereference. * Yields a channel proxy. */ - LArCompactSubsetChannelProxy operator*() const; + LArCompactSubsetConstChannelProxy operator*() const; /** @@ -319,7 +319,7 @@ public: unsigned int m_chan; /// Subset within which we live. - LArCompactSubsetVector* m_subset; + const LArCompactSubsetVector* m_subset; }; @@ -346,7 +346,14 @@ public: * @brief Vector indexing. Returns a channel proxy. * @param i Channel index within the vector. */ - LArCompactSubsetChannelProxy operator[] (size_t i) const; + LArCompactSubsetChannelProxy operator[] (size_t i); + + + /** + * @brief Vector indexing. Returns a channel proxy. + * @param i Channel index within the vector. + */ + LArCompactSubsetConstChannelProxy operator[] (size_t i) const; /// Begin iterator. @@ -446,7 +453,13 @@ public: /** * @brief `Dereference' the pointer. */ - LArCompactSubsetChannelVector operator*() const; + LArCompactSubsetChannelVector operator*(); + + + /** + * @brief `Dereference' the pointer. + */ + LArCompactSubsetConstChannelVector operator*() const; /** @@ -571,14 +584,14 @@ public: * @brief Adjust iterator. * @param delta Amount by which to advance the iterator. */ - iterator operator+ (size_t delta) const; + iterator operator+ (size_t delta); /** * @brief Iterator difference. * @param other Other iterator for difference. */ - difference_type operator- (const iterator& other) const; + difference_type operator- (const iterator& other); private: diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArCompactSubset.icc b/LArCalorimeter/LArRawConditions/LArRawConditions/LArCompactSubset.icc index f0327caab52319a346671b9d8ef5629d7fc8e384..0dd768307cc1cfdf4e69fdff776172ca65aeed9f 100644 --- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArCompactSubset.icc +++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArCompactSubset.icc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /** * @file LArRawConditions/LArCompactSubset.icc @@ -276,7 +276,7 @@ LArCompactSubsetChannelVector::const_iterator::const_iterator() */ inline LArCompactSubsetChannelVector::const_iterator::const_iterator - (unsigned int chan, LArCompactSubsetVector& subset) + (unsigned int chan, const LArCompactSubsetVector& subset) : m_chan (chan), m_subset (&subset) { @@ -300,10 +300,10 @@ LArCompactSubsetChannelVector::const_iterator::operator++() * Yields a channel proxy. */ inline -LArCompactSubsetChannelProxy +LArCompactSubsetConstChannelProxy LArCompactSubsetChannelVector::const_iterator::operator*() const { - return LArCompactSubsetChannelProxy (m_chan, *m_subset); + return LArCompactSubsetConstChannelProxy (m_chan, *m_subset); } @@ -385,7 +385,7 @@ size_t LArCompactSubsetChannelVector::size() const */ inline LArCompactSubsetChannelProxy -LArCompactSubsetChannelVector::operator[] (size_t i) const +LArCompactSubsetChannelVector::operator[] (size_t i) { unsigned int chan = m_subset->chanIndex (m_febIndex) + i; assert (chan <= m_subset->chanIndex (m_febIndex+1)); @@ -393,6 +393,20 @@ LArCompactSubsetChannelVector::operator[] (size_t i) const } +/** + * @brief Vector indexing. Returns a channel proxy. + * @param i Channel index within the vector. + */ +inline +LArCompactSubsetConstChannelProxy +LArCompactSubsetChannelVector::operator[] (size_t i) const +{ + unsigned int chan = m_subset->chanIndex (m_febIndex) + i; + assert (chan <= m_subset->chanIndex (m_febIndex+1)); + return LArCompactSubsetConstChannelProxy (chan, *m_subset); +} + + /** * @brief Begin iterator. */ @@ -499,12 +513,23 @@ LArCompactSubsetChannelVectorPointer::LArCompactSubsetChannelVectorPointer */ inline LArCompactSubsetChannelVector -LArCompactSubsetChannelVectorPointer::operator*() const +LArCompactSubsetChannelVectorPointer::operator*() { return LArCompactSubsetChannelVector (m_febIndex, m_subset); } +/** + * @brief `Dereference' the pointer. + */ +inline +LArCompactSubsetConstChannelVector +LArCompactSubsetChannelVectorPointer::operator*() const +{ + return LArCompactSubsetConstChannelVector (m_febIndex, m_subset); +} + + /** * @brief `Dereference' the pointer. */ @@ -616,7 +641,7 @@ LArCompactSubsetVector::iterator::operator++() */ inline LArCompactSubsetVector::iterator -LArCompactSubsetVector::iterator::operator+ (size_t delta) const +LArCompactSubsetVector::iterator::operator+ (size_t delta) { return iterator (m_febIndex + delta, m_subset); } @@ -628,7 +653,7 @@ LArCompactSubsetVector::iterator::operator+ (size_t delta) const */ inline LArCompactSubsetVector::iterator::difference_type -LArCompactSubsetVector::iterator::operator- (const iterator& other) const +LArCompactSubsetVector::iterator::operator- (const iterator& other) { return m_febIndex - other.m_febIndex; } diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerDB.h b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerDB.h index c9c7fb181e160d1849bd6112151f094535f4a43d..0085936fb64a4bd4655023d80845b1e80258dadc 100755 --- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerDB.h +++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerDB.h @@ -1,7 +1,7 @@ //Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ @@ -51,6 +51,7 @@ public: typedef LArConditionsSubsetTraits<T> Traits; typedef typename Traits::FebId FebId; typedef typename Traits::ChannelVector ChannelVector; + typedef typename Traits::ConstChannelVector ConstChannelVector; typedef typename Traits::ChannelVectorPointer ChannelVectorPointer; typedef typename std::map<FebId, ChannelVectorPointer > ConditionsMap; typedef typename std::unordered_map<FebId, ChannelVectorPointer > ConditionsHashMap; @@ -594,7 +595,7 @@ LArConditionsContainerDB<T>::get(const FebId febId, const int channel) const return Traits::empty(); } - const ChannelVector& vec = *it->second; + const ConstChannelVector& vec = *it->second; // First check the size - channel vec may be empty if (channel < static_cast<int>(vec.size())) { return vec[channel];