diff --git a/core/data/CbmEvent.cxx b/core/data/CbmEvent.cxx index 5339587459d0af4342c274715e812578d88ed0f3..96bfae7e783f561402399aa4b84dbe32df39c3aa 100644 --- a/core/data/CbmEvent.cxx +++ b/core/data/CbmEvent.cxx @@ -39,12 +39,17 @@ void CbmEvent::ClearData(ECbmDataType type) { fIndexMap[type].clear(); } // ----- Get a data index ---------------------------------------------- -uint32_t CbmEvent::GetIndex(ECbmDataType type, uint32_t iData) +uint32_t CbmEvent::GetIndex(ECbmDataType type, uint32_t iData) const { - - if (fIndexMap.find(type) == fIndexMap.end()) return -1; - if (fIndexMap[type].size() <= iData) return -2; - return fIndexMap.at(type)[iData]; + auto it = fIndexMap.find(type); + if (it == fIndexMap.end()) { + return -1; + } + const auto& indices = it->second; + if (indices.size() <= iData) { + return -2; + } + return indices[iData]; } // ------------------------------------------------------------------------- diff --git a/core/data/CbmEvent.h b/core/data/CbmEvent.h index 8e790138fdb98ce8b36a7f0c921a504bb1d1ef16..043732d738f486cf25537478d12018549b7392d1 100644 --- a/core/data/CbmEvent.h +++ b/core/data/CbmEvent.h @@ -89,7 +89,7 @@ public: ** @param iData Running number of data object in event ** @value Index of data object in its TClonesArray **/ - uint32_t GetIndex(ECbmDataType type, uint32_t iData); + uint32_t GetIndex(ECbmDataType type, uint32_t iData) const; /** Get match object @@ -125,7 +125,7 @@ public: ** @param iTrack Running number of STS track in the event ** @value index Index of STS track in TClonesArray **/ - int32_t GetStsTrackIndex(int32_t iTrack) { return GetIndex(ECbmDataType::kStsTrack, iTrack); } + int32_t GetStsTrackIndex(int32_t iTrack) const { return GetIndex(ECbmDataType::kStsTrack, iTrack); } /** Get event end time @@ -209,6 +209,13 @@ public: **/ CbmVertex* GetVertex() { return &fVertex; } + + /** Get event vertex (constant access) + ** @value Pointer to vertex object + **/ + const CbmVertex* GetVertex() const { return &fVertex; } + + /** Swap two events **/ void Swap(CbmEvent& e);