ATLAS Offline Software
JetMapBase.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef JETEVENT_JETMAPBASE_H
8 #define JETEVENT_JETMAPBASE_H
9 
11 #include <vector>
12 #include <map>
13 #include <memory>
14 
15 template<class P>
16 class JetMapBase
17 {
18 public:
19 
21  typedef P data_t;
23  typedef std::vector<data_t> record_t;
24 
34  class record_ptr_t {
35  public:
36  record_ptr_t(record_t* r=NULL) : m_ptr(r) {};
37  bool isValid()const{return m_ptr !=NULL;}
38  const record_t& operator*() const {return *m_ptr;}
39  const record_t* operator->() const {return m_ptr;}
40  const record_t* get() const {return m_ptr;}
41  record_t& operator*() {return *m_ptr;}
42  record_t* operator->() {return m_ptr;}
43  record_t* get() {return m_ptr;}
44  void destroy() {if (isValid()) delete m_ptr; m_ptr=NULL;}
45  void set(record_t *r){m_ptr = r;}
46  protected:
48  };
50  typedef size_t key_t;
52  typedef std::map<key_t, record_ptr_t> map_t;
53 
54 
58  JetMapBase(const JetMapBase& base) = delete;
59  JetMapBase& operator=(const JetMapBase& base) = delete;
61  virtual ~JetMapBase();
62 
72  virtual bool addRecord(size_t jetIndex) const;
73 
78  virtual const record_t* getRecord(size_t jetIndex) const;
79 
88  virtual void assignRecord(size_t jetIndex, record_t* rec) const;
89 
101  virtual void addData(size_t jetIndex,size_t keyIndex,const data_t& data)
102  const;
117  virtual bool retrieveData(size_t jetIndex,size_t keyIndex,data_t& data)
118  const;
119 
120  virtual const data_t& accessData(size_t jetIndex,size_t keyIndex) const;
121 
122  virtual size_t numberOfMoments(size_t jetIndex) const;
123 
124  virtual void clear();
125  virtual void clear(SG::OwnershipPolicy ){clear();}
126 
128 
129 protected:
130 
137  virtual void removeRecord(size_t jetIndex) const;
138 
146  virtual void transferRecord(const JetMapBase<P> *fromMap, size_t oldIndex, size_t newIndex ) const;
147 
148  friend class Jet;
149  template <class T>
151 
152  map_t& map();
153  const map_t& map() const;
154 
155 
156 #if !defined(__REFLEX__) && !defined(__CLING__)
157  // /*! @brief Store last valid record index */
158  // mutable size_t m_lastIndex; not used so remove it for simplicity
160  mutable map_t m_store;
162  static const data_t m_nullData;
163 
165 #endif
166 
167 
169 };
170 
172 public:
173  size_t getNewId() {m_counter++;return m_counter;};
174 
175 protected:
176  void reset(){m_counter=0;}
177 
178  size_t m_counter;
179 
180 
181 };
182 
190 #if !defined(__REFLEX__) && !defined(__CLING__)
191 #include "JetEvent/JetMapBase.icc"
192 #endif
193 
194 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
JetMapBase::record_ptr_t::get
record_t * get()
Definition: JetMapBase.h:43
JetMapBase::record_ptr_t::m_ptr
record_t * m_ptr
Definition: JetMapBase.h:47
base
std::string base
Definition: hcg.cxx:78
JetMapBase::record_ptr_t::get
const record_t * get() const
Definition: JetMapBase.h:40
beamspotman.r
def r
Definition: beamspotman.py:676
JetMapBase::record_ptr_t::operator->
record_t * operator->()
Definition: JetMapBase.h:42
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
JetMapBase::JetMapBase
JetMapBase(const JetMapBase &base)=delete
No copy ctor, assignment.
Jet
Basic data class defines behavior for all Jet objects The Jet class is the principal data class for...
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
JetMapBase::operator=
JetMapBase & operator=(const JetMapBase &base)=delete
JetMoment::MomentData
Definition: JetMoment.h:21
DMTest::P
P_v1 P
Definition: P.h:23
OrphanJetCounter::m_counter
size_t m_counter
Definition: JetMapBase.h:178
JetMapBase::m_store
map_t m_store
Store last valid record index ‍/ mutable size_t m_lastIndex; not used so remove it for simplicity /!
Definition: JetMapBase.h:160
OrphanJetCounter::reset
void reset()
Definition: JetMapBase.h:176
JetMapBase::ownPolicy
SG::OwnershipPolicy ownPolicy()
Definition: JetMapBase.h:127
JetMapBase::data_t
P data_t
Publish payload data type.
Definition: JetMapBase.h:21
JetMapBase::record_ptr_t
pointer wrapper, just to make certain the default pointers in maps are NULL
Definition: JetMapBase.h:34
JetMapBase::key_t
size_t key_t
Publish key type.
Definition: JetMapBase.h:50
JetMapBase::record_ptr_t::destroy
void destroy()
Definition: JetMapBase.h:44
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
JetMapBase
Definition: JetMapBase.h:17
JetMapBase::numberOfMoments
virtual size_t numberOfMoments(size_t jetIndex) const
JetMapBase::map
const map_t & map() const
JetMapBase::removeRecord
virtual void removeRecord(size_t jetIndex) const
remove a record
JetMapBase::transferRecord
virtual void transferRecord(const JetMapBase< P > *fromMap, size_t oldIndex, size_t newIndex) const
transfer a record from an other map
JetMapBase::record_ptr_t::record_ptr_t
record_ptr_t(record_t *r=NULL)
Definition: JetMapBase.h:36
JetMapBase::map
map_t & map()
JetMomentMapConverterBase
Definition: JetMomentMapConverterBase.h:10
JetMapBase::record_ptr_t::set
void set(record_t *r)
Definition: JetMapBase.h:45
OrphanJetCounter::getNewId
size_t getNewId()
Definition: JetMapBase.h:173
JetMapBase::JetMapBase
JetMapBase()
Constructor
JetMapBase::m_end
map_t::iterator m_end
Definition: JetMapBase.h:164
JetMapBase::~JetMapBase
virtual ~JetMapBase()
destructor
JetMapBase::record_ptr_t::operator->
const record_t * operator->() const
Definition: JetMapBase.h:39
OwnershipPolicy.h
JetMapBase::retrieveData
virtual bool retrieveData(size_t jetIndex, size_t keyIndex, data_t &data) const
Retrieve data.
JetMapBase::clear
virtual void clear(SG::OwnershipPolicy)
Definition: JetMapBase.h:125
JetMapBase::addRecord
virtual bool addRecord(size_t jetIndex) const
Add a record.
JetMapBase::record_ptr_t::isValid
bool isValid() const
Definition: JetMapBase.h:37
JetMapBase::accessData
virtual const data_t & accessData(size_t jetIndex, size_t keyIndex) const
JetMapBase::assignRecord
virtual void assignRecord(size_t jetIndex, record_t *rec) const
assign a given record to a given jet
JetMapBase::map_t
std::map< key_t, record_ptr_t > map_t
publish store type
Definition: JetMapBase.h:52
JetMapBase::record_ptr_t::operator*
const record_t & operator*() const
Definition: JetMapBase.h:38
JetMapBase::addData
virtual void addData(size_t jetIndex, size_t keyIndex, const data_t &data) const
Add data.
JetMapBase::getRecord
virtual const record_t * getRecord(size_t jetIndex) const
get the full record for a given jet
JetMapBase.icc
JetMapBase::record_t
std::vector< data_t > record_t
Publish record type.
Definition: JetMapBase.h:23
JetMapBase::record_ptr_t::operator*
record_t & operator*()
Definition: JetMapBase.h:41
JetMapBase::m_ownPolicy
SG::OwnershipPolicy m_ownPolicy
Definition: JetMapBase.h:168
JetMapBase::clear
virtual void clear()
JetMapBase::m_nullData
static const data_t m_nullData
Null data reference.
Definition: JetMapBase.h:162
OrphanJetCounter
Definition: JetMapBase.h:171