ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SG::AuxVectorBase::ResortAuxHelper Class Reference

Helper to factor out template-independent part of resortAux. More...

Collaboration diagram for SG::AuxVectorBase::ResortAuxHelper:

Public Member Functions

 ResortAuxHelper (size_t sz, size_t index, AuxVectorBase &vec)
 Set up for resorting. More...
 
void resortElement (size_t idx, SG::AuxElement *elt)
 

Private Member Functions

 ResortAuxHelper ()
 

Private Attributes

AuxVectorBasem_vec
 
size_t m_index
 
std::vector< size_t > m_imap
 
std::vector< size_t > m_rmap
 
std::vector< void * > m_auxdata
 
std::vector< SG::auxid_tm_auxids
 

Detailed Description

Helper to factor out template-independent part of resortAux.

See the cxx file for more details.

Definition at line 844 of file AuxVectorBase.h.

Constructor & Destructor Documentation

◆ ResortAuxHelper() [1/2]

SG::AuxVectorBase::ResortAuxHelper::ResortAuxHelper ( size_t  sz,
size_t  index,
AuxVectorBase vec 
)

Set up for resorting.

Parameters
szThe number of elements in the resort range.
indexThe index of the first element in the range in the container.
vecThe containing vector.

Definition at line 312 of file AuxVectorBase.cxx.

315  : m_vec (vec),
316  m_index (index),
317  m_imap (sz),
318  m_rmap (sz)
319 {
320  for (size_t i = 0; i < sz; i++)
321  m_imap[i] = m_rmap[i] = i;
322 
323  const SG::auxid_set_t& auxid_set = vec.getAuxIDs();
324  size_t naux = auxid_set.size();
325  m_auxdata.reserve (naux);
326  m_auxids.reserve (naux);
327  for (SG::auxid_t auxid : auxid_set) {
328  m_auxdata.push_back (vec.getDataArrayForResort (auxid));
329  m_auxids.push_back (auxid);
330  }
331 }

◆ ResortAuxHelper() [2/2]

SG::AuxVectorBase::ResortAuxHelper::ResortAuxHelper ( )
private

Member Function Documentation

◆ resortElement()

void SG::AuxVectorBase::ResortAuxHelper::resortElement ( size_t  idx,
SG::AuxElement elt 
)
Parameters
Resortone element.
idxThe index of the element within the range.
eltThe element.

Definition at line 340 of file AuxVectorBase.cxx.

341 {
342  // V
343  // x: 9 8 7 6 5 0 1 2 3 4
344  // m_index: 0 1 2 3 4 0 1 2 3 4
345  // imap 9 8 7 6 5 4 3 2 1 0
346  // rmap 9 8 7 6 5 4 3 2 1 0
347  // aux 19 18 17 16 15 14 13 12 11 10
348  //
349  // imap[i] tells in which slot the auxdata originally in slot
350  // i is currently located.
351  // rmap[i] gives the original location of the auxdata
352  // currently in slot i.
353  //
354  // each time through the loop, looking at index i:
355  // -- look at the index that was set.
356  // we want to move the aux data originally at
357  // auxindex=v[i]->index() here.
358  // -- that data is currently at slot ii1 = imap[auxindex]
359  // -- swap auxdata between slots i and ii1
360  // -- swap rmap between slots i and ii1
361  // -- swap imap entries rmap[i] and rmap[ii1]
362  // -- set v[i]->index() to index.
363  // but need to remember to take into account any offset between
364  // the beginning of the range we're given and the beginning
365  // of the container (i.e., index was nonzero on entry).
366  //
367  // ??? can this be made more efficient? do we need so much
368  // working storage??? xxx
369 
370  size_t index = m_index;
371  size_t auxindex = elt->index();
372  ATHCONTAINERS_ASSERT (auxindex-index < m_imap.size());
373  size_t ii1 = m_imap[auxindex-index];
374  if (ii1 != idx) {
375  ATHCONTAINERS_ASSERT (ii1 > idx);
376  // swap between auxdata slots dx+index, ii1+index
378  size_t naux = m_auxids.size();
379  SG::AuxVectorData& cont = *elt->container();
380  for (size_t iid = 0; iid < naux; iid++) {
381  r.swap (m_auxids[iid], cont, idx+index, cont, ii1+index, 1);
382  }
383  std::swap (m_rmap[idx], m_rmap[ii1]);
384  std::swap (m_imap[m_rmap[idx]], m_imap[m_rmap[ii1]]);
385  }
386 
388 }

Member Data Documentation

◆ m_auxdata

std::vector<void*> SG::AuxVectorBase::ResortAuxHelper::m_auxdata
private

Definition at line 855 of file AuxVectorBase.h.

◆ m_auxids

std::vector<SG::auxid_t> SG::AuxVectorBase::ResortAuxHelper::m_auxids
private

Definition at line 856 of file AuxVectorBase.h.

◆ m_imap

std::vector<size_t> SG::AuxVectorBase::ResortAuxHelper::m_imap
private

Definition at line 853 of file AuxVectorBase.h.

◆ m_index

size_t SG::AuxVectorBase::ResortAuxHelper::m_index
private

Definition at line 852 of file AuxVectorBase.h.

◆ m_rmap

std::vector<size_t> SG::AuxVectorBase::ResortAuxHelper::m_rmap
private

Definition at line 854 of file AuxVectorBase.h.

◆ m_vec

AuxVectorBase& SG::AuxVectorBase::ResortAuxHelper::m_vec
private

Definition at line 851 of file AuxVectorBase.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
fitman.sz
sz
Definition: fitman.py:527
SG::AuxVectorBase::ResortAuxHelper::m_imap
std::vector< size_t > m_imap
Definition: AuxVectorBase.h:853
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
SG::AuxVectorBase::ResortAuxHelper::m_auxids
std::vector< SG::auxid_t > m_auxids
Definition: AuxVectorBase.h:856
index
Definition: index.py:1
SG::AuxVectorBase::ResortAuxHelper::m_vec
AuxVectorBase & m_vec
Definition: AuxVectorBase.h:851
SG::AuxVectorBase::ResortAuxHelper::m_index
size_t m_index
Definition: AuxVectorBase.h:852
SG::AuxVectorBase::ResortAuxHelper::m_auxdata
std::vector< void * > m_auxdata
Definition: AuxVectorBase.h:855
SG::AuxVectorBase::setIndexForResort
void setIndexForResort(SG::AuxElement *elt, size_t idx)
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
SG::AuxVectorBase::ResortAuxHelper::m_rmap
std::vector< size_t > m_rmap
Definition: AuxVectorBase.h:854
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
ATHCONTAINERS_ASSERT
#define ATHCONTAINERS_ASSERT(X)
Definition: ATHCONTAINERS_ASSERT.h:31
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
CxxUtils::ConcurrentBitset::size
bit_t size() const
Count the number of 1 bits in the set.
lumiFormat.i
int i
Definition: lumiFormat.py:92
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
DeMoScan.index
string index
Definition: DeMoScan.py:362
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:167
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.