ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterMomentStore.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef CALOEVENT_CALOCLUSTERMOMENTSTORE_H
6#define CALOEVENT_CALOCLUSTERMOMENTSTORE_H
7
9
10#include <vector>
11#include <map>
12#include <cstddef>
13
15{
16 public:
17
21 explicit CaloClusterMomentStore(const CaloClusterMomentStore& rMomStore);
22 explicit CaloClusterMomentStore(const CaloClusterMomentStore* pMomStore);
27
33 typedef int moment_key;
35 typedef std::map<moment_key,moment_value> moment_store;
37 typedef moment_store::const_iterator moment_store_const_iter;
39 typedef moment_store::iterator moment_store_iter;
41 typedef std::vector<moment_type> moment_type_list;
42
43 // Work around ROOT-9709. Hide m_actual from cling --- but that means
44 // that we also need to ensure that the inline functions defined here
45 // are actually emitted out-of-line.
46#ifdef __CLING__
47# define ATH_CLING_BODY(BODY) ;
48#else
49# define ATH_CLING_BODY(BODY) __attribute__((used)) BODY
50#endif
51
54 {
55 public:
60 ATH_CLING_BODY (: m_actual(iStore) { } )
62#ifdef __clang__
64#else
66#endif
67
70 ATH_CLING_BODY( { ++m_actual; return *this; } )
72 CaloClusterMomentIterator operator++() { return this->next(); }
73
74 CaloClusterMomentIterator operator++(int) { return this->next(); }
75
78 ATH_CLING_BODY( { --m_actual; return *this; } )
80 CaloClusterMomentIterator operator--() { return this->prev(); }
81
82 CaloClusterMomentIterator operator--(int) { return this->prev(); }
83
89 bool operator==(const CaloClusterMomentIterator& anOtherIter) const
90 ATH_CLING_BODY( { return m_actual == anOtherIter.m_actual; } )
98 bool operator==(CaloClusterMomentIterator& anOtherIter)
99 ATH_CLING_BODY( { return m_actual == anOtherIter.m_actual; } )
100
106 bool operator!=(const CaloClusterMomentIterator& anOtherIter) const
107 ATH_CLING_BODY( { return m_actual != anOtherIter.m_actual; } )
115 bool operator!=(CaloClusterMomentIterator& anOtherIter)
116 ATH_CLING_BODY( { return m_actual != anOtherIter.m_actual; } )
117
119 // CaloClusterMoment& operator*() { return this->getMoment(); }
120 const CaloClusterMoment& operator*() const { return this->getMoment(); }
121
122 // CaloClusterMoment& getMoment() { return (*m_actual).second; }
123 const CaloClusterMoment& getMoment() const
124 ATH_CLING_BODY( { return (*m_actual).second; } )
126 moment_type getMomentType() const
127 ATH_CLING_BODY( { return (moment_type)(*m_actual).first; } )
128
129 private:
130#ifndef __CLING__
133#endif
134 };
135
138
144 virtual void insert(const moment_type& rMomType,
145 const moment_value& rMomData);
154 virtual bool retrieve(const moment_type& rMomType,
155 moment_value& rMomData) const;
166 virtual bool retrieve(const moment_iterator& rMomIter,
167 moment_value& rMomData) const;
174 virtual bool retrieveMomentTypes(moment_type_list& rMomTypeList) const;
176 virtual moment_iterator begin() const;
177 virtual moment_iterator end() const;
185 virtual moment_iterator find(const moment_type& rMomType) const;
190 virtual bool contains(const moment_type& rMomType) const;
192 size_t size() const;
193
198 virtual const moment_store& momentStore() const;
205 virtual void setMomentStore(const moment_store& rMomStore );
206 virtual void setMomentStore(moment_store&& rMomStore );
207
208 private:
209
211};
212
213inline void CaloClusterMomentStore::insert(const moment_type& rMomType,
214 const moment_value& rMomData)
215{
216 (*(m_store.insert(moment_store::value_type((moment_key)rMomType,rMomData))).first).second = rMomData;
217}
218
221{
222 return moment_iterator(m_store.begin());
223}
224
227{
228 return moment_iterator(m_store.end());
229}
230
233{
234 return moment_iterator(m_store.find((moment_key)rMomType));
235}
236
237inline bool CaloClusterMomentStore::contains(const moment_type& rMomType) const
238{
239 return m_store.find((moment_key)rMomType) != m_store.end();
240}
241
242inline size_t CaloClusterMomentStore::size() const
243{
244 return m_store.size();
245}
246
249{
250 return m_store;
251}
252
254 rMomStore)
255{
256 m_store = rMomStore;
257}
259 rMomStore)
260{
261 m_store = std::move(rMomStore);
262}
263
267#endif
#define ATH_CLING_BODY(BODY)
bool operator==(const CaloClusterMomentIterator &anOtherIter) const bool operator
Equality comparator.
CaloClusterMomentIterator() ATH_CLING_BODY(
Default constructor.
CaloClusterMomentIterator prev() CaloClusterMomentIterator operator--()
Iterator reverse method.
CaloClusterMomentIterator next() CaloClusterMomentIterator operator++()
Iterator advance method.
CaloClusterMomentIterator operator--(int)
Iterator prior reverse operator.
CaloClusterMomentIterator(moment_store_const_iter iStore) ~CaloClusterMomentIterator() ATH_CLING_BODY(
Useful constructor.
CaloClusterMomentIterator operator++(int)
Iterator prior advance operator.
std::vector< moment_type > moment_type_list
List of moment types.
moment_store::iterator moment_store_iter
Internal moment store iterator type.
moment_store::const_iterator moment_store_const_iter
Internal moment store const iterator type.
virtual ~CaloClusterMomentStore()
Default destructor.
virtual moment_iterator end() const
iterator loop terminator
CaloClusterMomentIterator moment_iterator
External moment iterator type.
CaloClusterMomentStore & operator=(const CaloClusterMomentStore &rMomStore)
Assignment.
virtual void setMomentStore(const moment_store &rMomStore)
Set internal store.
virtual void insert(const moment_type &rMomType, const moment_value &rMomData)
Insert key/data pair.
CaloClusterMoment::MomentType moment_type
Moment type.
std::map< moment_key, moment_value > moment_store
Internal moment store type.
virtual const moment_store & momentStore() const
Access to internal store.
int moment_key
Moment key type.
virtual bool retrieveMomentTypes(moment_type_list &rMomTypeList) const
Retrieve list of moment types in store.
CaloClusterMomentStore()
Default constructor.
virtual bool retrieve(const moment_type &rMomType, moment_value &rMomData) const
Retrieve cluster moment for a given key.
CaloClusterMoment moment_value
Moment data.
virtual moment_iterator find(const moment_type &rMomType) const
}
size_t size() const
Number of stored moments.
virtual bool contains(const moment_type &rMomType) const
Containment check.
virtual moment_iterator begin() const
{
defines enums and data types for different moments of CaloCluster
MomentType
enums to identify different moments