ATLAS Offline Software
Loading...
Searching...
No Matches
LArMCSym.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <algorithm>
7#include <cstdlib>
8
9
19 const CaloCell_Base_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(std::move(symIds))
28{
29}
30
31
32std::vector<LArMCSym::IdPair_t>
33LArMCSym::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
Helper base class for offline cell identifiers.
const std::vector< HWIdentifier > & symIds() const
Return the list of symmetric hashes.
Definition LArMCSym.h:132
const LArOnlineID_Base * m_onlineID
Definition LArMCSym.h:152
const std::vector< IdPair_t > m_oflHashtoSymOnl
Definition LArMCSym.h:154
const std::vector< HWIdentifier > m_symIds
Definition LArMCSym.h:156
LArMCSym()=delete
std::vector< IdPair_t > initIndices(const std::vector< HWIdentifier > &ids, const std::vector< HWIdentifier > &symIds) const
Definition LArMCSym.cxx:33
static constexpr size_t NO_INDEX
Return for an index if there's no valid symmetric identifier.
Definition LArMCSym.h:41
const std::vector< IdPair_t > m_onlHashtoSymOnl
Definition LArMCSym.h:155
const CaloCell_Base_ID * m_caloCellID
Definition LArMCSym.h:153
Helper for the Liquid Argon Calorimeter cell identifiers.
STL namespace.