ATLAS Offline Software
Public Types | Static Public Member Functions | Static Private Member Functions | List of all members
SG::detail::PackedLinkVectorHelper< CONT > Class Template Reference

Helper functions for managing PackedLink variables. More...

#include <PackedLinkVectorHelper.h>

Inheritance diagram for SG::detail::PackedLinkVectorHelper< CONT >:
Collaboration diagram for SG::detail::PackedLinkVectorHelper< CONT >:

Public Types

using Link_t = ElementLink< CONT >
 The (linked) data links. More...
 
using DLink_t = DataLink< CONT >
 
using DataLink_span = detail::AuxDataSpan< DataLink< CONT > >
 
using const_DataLink_span = detail::AuxDataConstSpan< DataLink< CONT > >
 
using PLink_t = PackedLink< CONT >
 The PackedLinks. More...
 
using PackedLink_span = CxxUtils::span< PLink_t >
 
using DataLinkBase = ::DataLinkBase
 
typedef void InitLinkFunc_t(DataLinkBase &dl, sgkey_t sgkey, IProxyDict *sg)
 Function to initialize a DataLink to a given hashed key. More...
 
using DataLinkBase_span = detail::AuxDataSpan< DataLinkBase >
 Spans over the linked DataLinks. More...
 
using const_DataLinkBase_span = detail::AuxDataConstSpan< DataLinkBase >
 
using PackedLinkBase_span = CxxUtils::span< PackedLinkBase >
 Span over links. More...
 

Static Public Member Functions

static std::pair< size_t, bool > findCollection (LinkedVector &linkedVec, sgkey_t sgkey, DataLinkBase_span &links, IProxyDict *sg)
 Find the collection index in the linked DataLinks for a sgkey. More...
 
static bool updateLinks (IAuxTypeVector &linkedVec, SG::PackedLink< CONT > *ptr, size_t n, const const_DataLinkBase_span &srcDLinks, IProxyDict *sg)
 Update collection index of a collection of PackedLink. More...
 
static bool updateLinks (IAuxTypeVector &linkedVec, SG::PackedLink< CONT > *ptr, size_t n, const IAuxTypeVector &srclv, IProxyDict *sg)
 Update collection index of a collection of PackedLink. More...
 
template<class VALLOC >
static bool updateLinks (IAuxTypeVector &linkedVec, std::vector< SG::PackedLink< CONT >, VALLOC > *ptr, size_t n, const IAuxTypeVector &srclv, IProxyDict *sg)
 Update collection index of a collection of PackedLink vectors. More...
 
template<class VALLOC , ElementLinkRange< CONT > RANGE>
static bool assignVElt (std::vector< PLink_t, VALLOC > &velt, IAuxTypeVector &linkedVec, DataLinkBase_span &dlinks, const RANGE &x)
 Assign a range of ElementLink to a vector of Packedlink. More...
 
template<class VALLOC , ElementLinkRange< CONT > RANGE>
static bool insertVElt (std::vector< PLink_t, VALLOC > &velt, size_t pos, IAuxTypeVector &linkedVec, DataLinkBase_span &dlinks, const RANGE &x)
 Insert a range of ElementLink into a vector of Packedlink. More...
 
static bool applyThinning (IAuxTypeVector &linkedVec, PackedLink< CONT > *ptr, size_t n, DataLinkBase_span &dlinks, const SG::ThinningCache *tc, IProxyDict *sg)
 Apply thinning to packed links, to prepare them for output. More...
 
static IProxyDictstoreFromSpan (DataLinkBase_span &links)
 Return the current store from the first valid link in the span. More...
 
static DataLinkBase_span getLinkBaseSpan (IAuxTypeVector &linkedVec)
 Return a span over all the linked DataLinkBase's, from the linked vector. More...
 
static const_DataLinkBase_span getLinkBaseSpan (const IAuxTypeVector &linkedVec)
 Return a span over all the linked DataLinks. More...
 
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. More...
 
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. More...
 
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. More...
 

Static Private Member Functions

static void initLink (DataLinkBase &dl, sgkey_t sgkey, IProxyDict *sg)
 Initialize a DataLink. More...
 
static bool resizeLinks (LinkedVector &linkedVec, size_t sz)
 Resize a linked vector of DataLinks. More...
 

Detailed Description

template<class CONT>
class SG::detail::PackedLinkVectorHelper< CONT >

Helper functions for managing PackedLink variables.

The template argument is the target type of the links.

Definition at line 254 of file PackedLinkVectorHelper.h.

Member Typedef Documentation

◆ const_DataLink_span

Definition at line 262 of file PackedLinkVectorHelper.h.

◆ const_DataLinkBase_span

Definition at line 70 of file PackedLinkVectorHelper.h.

◆ DataLink_span

template<class CONT >
using SG::detail::PackedLinkVectorHelper< CONT >::DataLink_span = detail::AuxDataSpan<DataLink<CONT> >

Definition at line 261 of file PackedLinkVectorHelper.h.

◆ DataLinkBase

Definition at line 57 of file PackedLinkVectorHelper.h.

◆ DataLinkBase_span

Spans over the linked DataLinks.

These hold the span data by reference, so they update if the underlying vector changes.

Definition at line 69 of file PackedLinkVectorHelper.h.

◆ DLink_t

template<class CONT >
using SG::detail::PackedLinkVectorHelper< CONT >::DLink_t = DataLink<CONT>

Definition at line 260 of file PackedLinkVectorHelper.h.

◆ InitLinkFunc_t

typedef void SG::detail::PackedLinkVectorHelperBase::InitLinkFunc_t(DataLinkBase &dl, sgkey_t sgkey, IProxyDict *sg)
inherited

Function to initialize a DataLink to a given hashed key.

Definition at line 61 of file PackedLinkVectorHelper.h.

◆ Link_t

template<class CONT >
using SG::detail::PackedLinkVectorHelper< CONT >::Link_t = ElementLink<CONT>

The (linked) data links.

Definition at line 259 of file PackedLinkVectorHelper.h.

◆ PackedLink_span

Definition at line 266 of file PackedLinkVectorHelper.h.

◆ PackedLinkBase_span

Span over links.

Definition at line 127 of file PackedLinkVectorHelper.h.

◆ PLink_t

template<class CONT >
using SG::detail::PackedLinkVectorHelper< CONT >::PLink_t = PackedLink<CONT>

The PackedLinks.

Definition at line 265 of file PackedLinkVectorHelper.h.

Member Function Documentation

◆ applyThinning()

template<class CONT >
static bool SG::detail::PackedLinkVectorHelper< CONT >::applyThinning ( IAuxTypeVector linkedVec,
PackedLink< CONT > *  ptr,
size_t  n,
DataLinkBase_span dlinks,
const SG::ThinningCache tc,
IProxyDict sg 
)
static

Apply thinning to packed links, to prepare them for output.

Parameters
linkedVecInterface for the linked vector of DataLinks.
ptrPointer to the start of the PackedLink collection.
nLength of the PackedLink collection.
dlinksSpan over the source link vector, as DataLinkBase.
tcThe ThinningCache for this object, if it exists.
sgThe IProxyDict of the current store. If null, take it from the links in srcDlinks, or use the global, thread-local default.

Returns true if it is known that the payload of the linked vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

◆ applyThinningBase()

bool SG::detail::PackedLinkVectorHelperBase::applyThinningBase ( IAuxTypeVector linkedVec,
PackedLinkBase_span links,
DataLinkBase_span dlinks,
const SG::ThinningCache tc,
IProxyDict sg,
InitLinkFunc_t initLinkFunc 
)
staticinherited

Apply thinning to packed links, to prepare them for output.

Parameters
linkedVecInterface for the linked vector of DataLinks.
linksSpan over the links to update, as PackedLinkBase.
dlinksSpan over the source link vector, as DataLinkBase.
tcThe ThinningCache for this object, if it exists.
sgThe IProxyDict of the current store. If null, take it from the links in srcDlinks, or use the global, thread-local default.
initFuncFunction to initialize a DataLink to a given hashed key.

Returns true if it is known that the payload of the linked vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

Definition at line 130 of file PackedLinkVectorHelper.cxx.

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 }

◆ assignVElt()

template<class CONT >
template<class VALLOC , ElementLinkRange< CONT > RANGE>
static bool SG::detail::PackedLinkVectorHelper< CONT >::assignVElt ( std::vector< PLink_t, VALLOC > &  velt,
IAuxTypeVector linkedVec,
DataLinkBase_span dlinks,
const RANGE &  x 
)
static

Assign a range of ElementLink to a vector of Packedlink.

Parameters
vectThe vector of PackedLink to which to assign.
linkedVecInterface for the linked vector of DataLinks.
dlinksSpan over the link vector, as DataLinkBase.
xThe range to assign.

Returns true if it is known that the payload of the linked vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

◆ findCollection()

template<class CONT >
static std::pair<size_t, bool> SG::detail::PackedLinkVectorHelper< CONT >::findCollection ( LinkedVector linkedVec,
sgkey_t  sgkey,
DataLinkBase_span links,
IProxyDict sg 
)
static

Find the collection index in the linked DataLinks for a sgkey.

Parameters
linkedVecHow to find the linked vector.
sgkeyHashed key for which to search.
linksSpan over the vector of DataLinks. May be modified if the vector grows.
sgThe IProxyDict of the current store. May be null to use the global, thread-local default.

Searches for a DataLink matching sgkey in the linked vector. If not found, then a new entry is added. Returns a pair (INDEX, CACHEVALID). INDEX is the index in the vector of the sgkey (and thus the collection index to store in the PackedLink). CACHEVALID is true if it is known that the payload of the vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

◆ findCollectionBase()

std::pair< size_t, bool > SG::detail::PackedLinkVectorHelperBase::findCollectionBase ( LinkedVector linkedVec,
sgkey_t  sgkey,
DataLinkBase_span links,
IProxyDict sg,
InitLinkFunc_t initLinkFunc 
)
staticinherited

Find the collection index in the linked DataLinks for a sgkey.

Parameters
linkedVecHow to find the linked vector.
sgkeyHashed key for which to search.
linksSpan over the vector of DataLinks, as DataLinkBase. May be modified if the vector grows.
sgThe IProxyDict of the current store. May be null to use the global, thread-local default.
initFuncFunction to initialize a DataLink to a given hashed key.

Searches for a DataLinkBase matching sgkey in the linked vector. If not found, then a new entry is added. Returns a pair (INDEX, CACHEVALID). INDEX is the index in the vector of the sgkey (and thus the collection index to store in the PackedLink). CACHEVALID is true if it is known that the payload of the vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

This does not actually initialize the DataLink if the vector grows. The caller should test if the size of the span changed and if so, initialize the last element using sgkey.

Definition at line 42 of file PackedLinkVectorHelper.cxx.

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 }

◆ getLinkBaseSpan() [1/2]

static const_DataLinkBase_span SG::detail::PackedLinkVectorHelperBase::getLinkBaseSpan ( const IAuxTypeVector linkedVec)
staticinherited

Return a span over all the linked DataLinks.

from the linked vector.

Parameters
linkedVecInterface for the linked vector of DataLinks.

◆ getLinkBaseSpan() [2/2]

static DataLinkBase_span SG::detail::PackedLinkVectorHelperBase::getLinkBaseSpan ( IAuxTypeVector linkedVec)
staticinherited

Return a span over all the linked DataLinkBase's, from the linked vector.

Parameters
linkedVecInterface for the linked vector of DataLinkBase's.

◆ initLink()

template<class CONT >
static void SG::detail::PackedLinkVectorHelper< CONT >::initLink ( DataLinkBase dl,
sgkey_t  sgkey,
IProxyDict sg 
)
staticprivate

Initialize a DataLink.

Parameters
dlThe link to initialize. Really of type DLink_t.
sgkeyHashed key to which to initialize the link.
sgThe IProxyDict of the current store. May be null to use the global, thread-local default.

◆ insertVElt()

template<class CONT >
template<class VALLOC , ElementLinkRange< CONT > RANGE>
static bool SG::detail::PackedLinkVectorHelper< CONT >::insertVElt ( std::vector< PLink_t, VALLOC > &  velt,
size_t  pos,
IAuxTypeVector linkedVec,
DataLinkBase_span dlinks,
const RANGE &  x 
)
static

Insert a range of ElementLink into a vector of Packedlink.

Parameters
vectThe vector of PackedLink to which to assign.
posThe position at which to do the insertion.
linkedVecInterface for the linked vector of DataLinks.
dlinksSpan over the link vector, as DataLinkBase.
xThe range to assign.

Returns true if it is known that the payload of the linked vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

◆ resizeLinks()

bool SG::detail::PackedLinkVectorHelperBase::resizeLinks ( LinkedVector linkedVec,
size_t  sz 
)
staticprivateinherited

Resize a linked vector of DataLinks.

Parameters
linkedVecHow to find the linked vector.
szThe new size of the container.

Returns true if it is known the the underlying vector did not move.

Definition at line 171 of file PackedLinkVectorHelper.cxx.

172 {
173  return linkedVec->resize (sz);
174 }

◆ storeFromSpan()

static IProxyDict* SG::detail::PackedLinkVectorHelperBase::storeFromSpan ( DataLinkBase_span links)
staticinherited

Return the current store from the first valid link in the span.

If there are no valid links, then return the global default.

Parameters
linksThe span of links.

◆ updateLinks() [1/3]

template<class CONT >
static bool SG::detail::PackedLinkVectorHelper< CONT >::updateLinks ( IAuxTypeVector linkedVec,
SG::PackedLink< CONT > *  ptr,
size_t  n,
const const_DataLinkBase_span srcDLinks,
IProxyDict sg 
)
static

Update collection index of a collection of PackedLink.

Parameters
linkedVecInterface for the linked vector of DataLinks.
ptrPointer to the start of the PackedLink collection.
nLength of the PackedLink collection.
srcDLinksSpan over the vector of DataLinks for the source container of the links.
sgThe IProxyDict of the current store. If null, take it from the links in srcDlinks, or use the global, thread-local default.

To be used after links have been copied/moved from one container to another. The collection indices are updated to be appropriate for the destination container. Returns true if it is known that the payload of the linked vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

◆ updateLinks() [2/3]

template<class CONT >
static bool SG::detail::PackedLinkVectorHelper< CONT >::updateLinks ( IAuxTypeVector linkedVec,
SG::PackedLink< CONT > *  ptr,
size_t  n,
const IAuxTypeVector srclv,
IProxyDict sg 
)
static

Update collection index of a collection of PackedLink.

Parameters
linkedVecInterface for the linked vector of DataLinks.
ptrPointer to the start of the PackedLink collection.
nLength of the PackedLink collection.
srclvInterface for the linked vector for the source container of the links.
sgThe IProxyDict of the current store. If null, take it from the links in srcDlinks, or use the global, thread-local default.

To be used after links have been copied/moved from one container to another. The collection indices are updated to be appropriate for the destination container. Returns true if it is known that the payload of the linked vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

◆ updateLinks() [3/3]

template<class CONT >
template<class VALLOC >
static bool SG::detail::PackedLinkVectorHelper< CONT >::updateLinks ( IAuxTypeVector linkedVec,
std::vector< SG::PackedLink< CONT >, VALLOC > *  ptr,
size_t  n,
const IAuxTypeVector srclv,
IProxyDict sg 
)
static

Update collection index of a collection of PackedLink vectors.

Parameters
linkedVecInterface for the linked vector of DataLinks.
ptrPointer to the start of the PackedLink vector collection.
nLength of the PackedLink vector collection.
srclvInterface for the linked vector for the source container of the links.
sgThe IProxyDict of the current store. If null, take it from the links in srcDlinks, or use the global, thread-local default.

To be used after links have been copied/moved from one container to another. The collection indices are updated to be appropriate for the destination container. Returns true if it is known that the payload of the linked vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

◆ updateLinksBase()

bool SG::detail::PackedLinkVectorHelperBase::updateLinksBase ( IAuxTypeVector linkedVec,
PackedLinkBase_span links,
const const_DataLinkBase_span srcDLinks,
IProxyDict sg,
InitLinkFunc_t initLinkFunc 
)
staticinherited

Update collection index of a collection of PackedLink.

Parameters
linkedVecInterface for the linked vector of DataLinks.
linksSpan over the links to update, as PackedLinkBase.
srcDLinksSpan over the source link vector, as DataLinkBase.
sgThe IProxyDict of the current store. If null, take it from the links in srcDlinks, or use the global, thread-local default.
initFuncFunction to initialize a DataLink to a given hashed key.

To be used after links have been copied/moved from one container to another. The collection indices are updated to be appropriate for the destination container. Returns true if it is known that the payload of the linked vector has not moved. (If this is false, any caches/iterators must be assumed to be invalid.)

Definition at line 87 of file PackedLinkVectorHelper.cxx.

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 }

The documentation for this class was generated from the following file:
common.sgkey
def sgkey(tool)
Definition: common.py:1028
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:504
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::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
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
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::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::detail::PackedLinkVectorHelperBase::DataLinkBase_span
detail::AuxDataSpan< DataLinkBase > DataLinkBase_span
Spans over the linked DataLinks.
Definition: PackedLinkVectorHelper.h:69
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.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37