ATLAS Offline Software
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);
26  virtual ~CaloClusterMomentStore();
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;
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(); }
74  CaloClusterMomentIterator operator++(int) { return this->next(); }
75 
78  ATH_CLING_BODY( { --m_actual; return *this; } )
80  CaloClusterMomentIterator operator--() { return this->prev(); }
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(); }
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__
132  moment_store_const_iter m_actual;
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 
213 inline 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 
237 inline bool CaloClusterMomentStore::contains(const moment_type& rMomType) const
238 {
239  return m_store.find((moment_key)rMomType) != m_store.end();
240 }
241 
242 inline 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 }
267 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
CaloClusterMomentStore::moment_store_iter
moment_store::iterator moment_store_iter
Internal moment store iterator type.
Definition: CaloClusterMomentStore.h:39
CaloClusterMoment::MomentType
MomentType
enums to identify different moments
Definition: CaloClusterMoment.h:38
CaloClusterMomentStore::moment_type
CaloClusterMoment::MomentType moment_type
Moment type.
Definition: CaloClusterMomentStore.h:31
CaloClusterMomentStore::momentStore
virtual const moment_store & momentStore() const
Access to internal store.
Definition: CaloClusterMomentStore.h:248
CaloClusterMomentStore::setMomentStore
virtual void setMomentStore(const moment_store &rMomStore)
Set internal store.
Definition: CaloClusterMomentStore.h:253
CaloClusterMomentStore::operator=
CaloClusterMomentStore & operator=(const CaloClusterMomentStore &rMomStore)
Assignment.
Definition: CaloClusterMomentStore.cxx:25
CaloClusterMomentStore::moment_store_const_iter
moment_store::const_iterator moment_store_const_iter
Internal moment store const iterator type.
Definition: CaloClusterMomentStore.h:37
CaloClusterMomentStore::CaloClusterMomentIterator
Internally used iterator.
Definition: CaloClusterMomentStore.h:54
ATH_CLING_BODY
#define ATH_CLING_BODY(BODY)
Definition: CaloClusterMomentStore.h:49
CaloClusterMomentStore::moment_iterator
CaloClusterMomentIterator moment_iterator
External moment iterator type.
Definition: CaloClusterMomentStore.h:137
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
CaloClusterMomentStore::moment_value
CaloClusterMoment moment_value
Moment data.
Definition: CaloClusterMomentStore.h:29
CaloClusterMomentStore::retrieveMomentTypes
virtual bool retrieveMomentTypes(moment_type_list &rMomTypeList) const
Retrieve list of moment types in store.
Definition: CaloClusterMomentStore.cxx:58
CaloClusterMomentStore::contains
virtual bool contains(const moment_type &rMomType) const
Containment check.
Definition: CaloClusterMomentStore.h:237
CaloClusterMomentStore
Stores CaloClusterMoment in a keyed map.
Definition: CaloClusterMomentStore.h:15
CaloClusterMomentStore::begin
virtual moment_iterator begin() const
{
Definition: CaloClusterMomentStore.h:220
CaloClusterMomentStore::CaloClusterMomentIterator::operator==
bool operator==(const CaloClusterMomentIterator &anOtherIter) const bool operator
Equality comparator.
CaloClusterMomentStore::~CaloClusterMomentStore
virtual ~CaloClusterMomentStore()
Default destructor.
Definition: CaloClusterMomentStore.cxx:33
CaloClusterMomentStore::CaloClusterMomentIterator::prev
CaloClusterMomentIterator prev() CaloClusterMomentIterator operator--()
Iterator reverse method.
Definition: CaloClusterMomentStore.h:77
CaloClusterMomentStore::CaloClusterMomentIterator::CaloClusterMomentIterator
CaloClusterMomentIterator() ATH_CLING_BODY(
Default constructor.
Definition: CaloClusterMomentStore.h:57
CaloClusterMomentStore::find
virtual moment_iterator find(const moment_type &rMomType) const
}
Definition: CaloClusterMomentStore.h:232
CaloClusterMomentStore::moment_key
int moment_key
Moment key type.
Definition: CaloClusterMomentStore.h:33
CaloClusterMomentStore::moment_type_list
std::vector< moment_type > moment_type_list
List of moment types.
Definition: CaloClusterMomentStore.h:41
CaloClusterMomentStore::CaloClusterMomentIterator::operator++
CaloClusterMomentIterator operator++(int)
Iterator prior advance operator.
Definition: CaloClusterMomentStore.h:74
CaloClusterMoment.h
CaloClusterMomentStore::insert
virtual void insert(const moment_type &rMomType, const moment_value &rMomData)
Insert key/data pair.
Definition: CaloClusterMomentStore.h:213
CaloClusterMomentStore::m_store
moment_store m_store
Definition: CaloClusterMomentStore.h:210
CaloClusterMomentStore::retrieve
virtual bool retrieve(const moment_type &rMomType, moment_value &rMomData) const
Retrieve cluster moment for a given key.
Definition: CaloClusterMomentStore.cxx:37
CaloClusterMomentStore::CaloClusterMomentIterator::operator--
CaloClusterMomentIterator operator--(int)
Iterator prior reverse operator.
Definition: CaloClusterMomentStore.h:82
CaloClusterMomentStore::moment_store
std::map< moment_key, moment_value > moment_store
Internal moment store type.
Definition: CaloClusterMomentStore.h:35
CaloClusterMomentStore::end
virtual moment_iterator end() const
iterator loop terminator
Definition: CaloClusterMomentStore.h:226
CaloClusterMomentStore::CaloClusterMomentIterator::next
CaloClusterMomentIterator next() CaloClusterMomentIterator operator++()
Iterator advance method.
Definition: CaloClusterMomentStore.h:69
CaloClusterMoment
defines enums and data types for different moments of CaloCluster
Definition: CaloClusterMoment.h:29
DeMoScan.first
bool first
Definition: DeMoScan.py:536
CaloClusterMomentStore::CaloClusterMomentStore
CaloClusterMomentStore()
Default constructor.
Definition: CaloClusterMomentStore.cxx:9
CaloClusterMomentStore::size
size_t size() const
Number of stored moments.
Definition: CaloClusterMomentStore.h:242
CaloClusterMomentStore::CaloClusterMomentIterator::CaloClusterMomentIterator
CaloClusterMomentIterator(moment_store_const_iter iStore) ~CaloClusterMomentIterator() ATH_CLING_BODY(
Useful constructor.
Definition: CaloClusterMomentStore.h:59