ATLAS Offline Software
PackedLinkVectorHelper.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
3  */
13 
14 
15 namespace SG::detail {
16 
17 
41 std::pair<size_t, bool>
43  sgkey_t sgkey,
45  IProxyDict* sg,
46  InitLinkFunc_t* initLinkFunc)
47 {
48  if (sgkey == 0) {
49  if (!links.empty())
50  return std::make_pair (0u, true);
51  }
52  else {
53  for (size_t i = 1; i < links.size(); ++i) {
54  if (links[i].key() == sgkey) return std::make_pair (i, true);
55  }
56  }
57  size_t oldsz = links.size();
58  size_t newsz = oldsz+1;
59  if (oldsz == 0 && sgkey != 0) {
60  newsz = 2;
61  }
62  bool cacheValid = resizeLinks (linkedVec, newsz);
63  initLinkFunc (links.back(), sgkey, sg);
64  return std::make_pair (links.size() - 1, cacheValid);
65 }
66 
67 
86 bool
89  const const_DataLinkBase_span& srcDLinks,
90  IProxyDict* sg,
91  InitLinkFunc_t* initLinkFunc)
92 {
93  DataLinkBase_span DLinks = getLinkBaseSpan (linkedVec);
94  if (sg == nullptr) {
95  sg = storeFromSpan (DLinks);
96  }
97  bool cacheValid = true;
98  for (PackedLinkBase& l : links) {
99  size_t in_coll = l.collection();
100  if (in_coll > 0) {
101  LinkedVector lv (linkedVec);
102  auto [index, thisValid] = findCollectionBase
103  (lv, srcDLinks.at(in_coll).key(), DLinks, sg, initLinkFunc);
104  l.setCollection (index);
105  cacheValid &= thisValid;
106  }
107  }
108  return cacheValid;
109 }
110 
111 
112 #ifndef XAOD_STANDALONE
113 
129 bool
132  DataLinkBase_span& dlinks,
133  const SG::ThinningCache* tc,
134  IProxyDict* sg,
135  InitLinkFunc_t* initLinkFunc)
136 {
137  bool cacheValid = true;
138  for (PackedLinkBase& l : links) {
139  if (l.collection() != 0) {
140  sgkey_t sgkey = dlinks[l.collection()].key();
141  size_t index = l.index();
142  sgkey_t sgkey_out = sgkey;
143  size_t index_out = index;
144  if (sg) {
145  sg->tryELRemap (sgkey, index, sgkey_out, index_out);
146  }
147  DataProxyHolder::thin (sgkey_out, index_out, tc);
148  l.setIndex (index_out);
149  if (sgkey_out != sgkey) {
150  LinkedVector lv (linkedVec);
151  auto [index, flag] = findCollectionBase (lv, sgkey_out, dlinks,
152  sg, initLinkFunc);
153  l.setCollection (index);
154  cacheValid &= flag;
155  }
156  }
157  }
158  return cacheValid;
159 }
160 #endif
161 
162 
170 bool
172 {
173  return linkedVec->resize (sz);
174 }
175 
176 
177 } // namespace SG::detail
common.sgkey
def sgkey(tool)
Definition: common.py:1028
SG::detail
Definition: DataVectorWithAllocFwd.h:22
fitman.sz
sz
Definition: fitman.py:527
index
Definition: index.py:1
SG::DataProxyHolder::thin
static bool thin(sgkey_t &sgkey, size_t &index, const SG::ThinningCache *thinningCache)
Adjust for thinning, with explicitly provided thinning cache.
Definition: DataProxyHolder.cxx:506
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
SG::detail::PackedLinkVectorHelperBase::resizeLinks
static bool resizeLinks(LinkedVector &linkedVec, size_t sz)
Resize a linked vector of DataLinks.
Definition: PackedLinkVectorHelper.cxx:171
SG::detail::PackedLinkVectorHelperBase::LinkedVector
Helper to access the IAuxTypeVector for an aux variable.
Definition: PackedLinkVectorHelper.h:84
SG::detail::PackedLinkVectorHelperBase::findCollectionBase
static std::pair< size_t, bool > findCollectionBase(LinkedVector &linkedVec, sgkey_t sgkey, DataLinkBase_span &links, IProxyDict *sg, InitLinkFunc_t *initLinkFunc)
Find the collection index in the linked DataLinks for a sgkey.
Definition: PackedLinkVectorHelper.cxx:42
SG::detail::AuxDataSpan
Auxiliary variable span wrapper.
Definition: AuxDataSpan.h:72
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
CxxUtils::span
Simplified version of the C++20 std::span.
Definition: span.h:67
SG::detail::PackedLinkVectorHelperBase::applyThinningBase
static bool applyThinningBase(IAuxTypeVector &linkedVec, PackedLinkBase_span &links, DataLinkBase_span &dlinks, const SG::ThinningCache *tc, IProxyDict *sg, InitLinkFunc_t *initLinkFunc)
Apply thinning to packed links, to prepare them for output.
Definition: PackedLinkVectorHelper.cxx:130
SG::detail::AuxDataConstSpan
Auxiliary variable span wrapper (const).
Definition: AuxDataSpan.h:186
lumiFormat.i
int i
Definition: lumiFormat.py:85
IProxyDict::tryELRemap
virtual bool tryELRemap(sgkey_t sgkey_in, size_t index_in, sgkey_t &sgkey_out, size_t &index_out)
Test to see if the target of an ElementLink has moved.
Definition: IProxyDict.cxx:48
DMTest::links
links
Definition: CLinks_v1.cxx:22
master.flag
bool flag
Definition: master.py:29
SG::detail::PackedLinkVectorHelperBase::updateLinksBase
static bool updateLinksBase(IAuxTypeVector &linkedVec, PackedLinkBase_span &links, const const_DataLinkBase_span &srcDLinks, IProxyDict *sg, InitLinkFunc_t *initLinkFunc)
Update collection index of a collection of PackedLink.
Definition: PackedLinkVectorHelper.cxx:87
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
DeMoScan.index
string index
Definition: DeMoScan.py:364
SG::IAuxTypeVector::resize
virtual bool resize(size_t sz)=0
Change the size of the vector.
SG::PackedLinkBase
A packed version of ElementLink.
Definition: PackedLinkImpl.h:47
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
SG::detail::PackedLinkVectorHelperBase::getLinkBaseSpan
static DataLinkBase_span getLinkBaseSpan(IAuxTypeVector &linkedVec)
Return a span over all the linked DataLinkBase's, from the linked vector.
SG::detail::PackedLinkVectorHelperBase::storeFromSpan
static IProxyDict * storeFromSpan(DataLinkBase_span &links)
Return the current store from the first valid link in the span.
SG::ThinningCache
Cache thinning decisions for converters.
Definition: ThinningCache.h:48
SG::detail::AuxDataConstSpan::at
const T & at(size_t index) const
Bounds-checked element access.
Definition: AuxDataSpan.h:228
PackedLinkVector.h
Implementation of IAuxTypeVector for PackedLink types.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37