ATLAS Offline Software
LArMCSym.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <algorithm>
7 #include <cstdlib>
8 
9 
19  const CaloCell_ID* caloId,
20  std::vector<HWIdentifier>&& oflHashtoSymOnl,
21  std::vector<HWIdentifier>&& onlHashtoSymOnl,
22  std::vector<HWIdentifier>&& symIds) :
23  m_onlineID(onlId),
24  m_caloCellID(caloId),
25  m_oflHashtoSymOnl (initIndices (oflHashtoSymOnl, symIds)),
26  m_onlHashtoSymOnl (initIndices (onlHashtoSymOnl, symIds)),
27  m_symIds(symIds)
28 {
29 }
30 
31 
32 std::vector<LArMCSym::IdPair_t>
33 LArMCSym::initIndices (const std::vector<HWIdentifier>& ids,
34  const std::vector<HWIdentifier>& symIds) const
35 {
36  std::vector<IdPair_t> out;
37  out.reserve (ids.size());
38  HWIdentifier last_id;
39  size_t idx = NO_INDEX;
40  for (const HWIdentifier& id : ids) {
41  if (!id.is_valid()) {
42  idx = NO_INDEX;
43  }
44  else if (id != last_id) {
45  if (idx < symIds.size()-1 && symIds[idx+1] == id) {
46  ++idx;
47  }
48  else {
49  auto it = std::lower_bound (symIds.begin(), symIds.end(), id);
50  if (it == symIds.end() || *it != id) std::abort();
51  idx = it - symIds.begin();
52  }
53  }
54  out.emplace_back (id.get_identifier32().get_compact(), idx);
55  last_id = id;
56  }
57 
58  return out;
59 }
60 
skel.it
it
Definition: skel.GENtoEVGEN.py:396
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
HWIdentifier
Definition: HWIdentifier.h:13
LArMCSym::LArMCSym
LArMCSym()=delete
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
LArOnlineID
Definition: LArOnlineID.h:20
LArMCSym::NO_INDEX
static constexpr size_t NO_INDEX
Return for an index if there's no valid symmetric identifier.
Definition: LArMCSym.h:41
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
LArMCSym::symIds
const std::vector< HWIdentifier > & symIds() const
Return the list of symmetric hashes.
Definition: LArMCSym.h:132
LArMCSym::initIndices
std::vector< IdPair_t > initIndices(const std::vector< HWIdentifier > &ids, const std::vector< HWIdentifier > &symIds) const
Definition: LArMCSym.cxx:33
LArMCSym.h