ATLAS Offline Software
SCT_CablingData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // STL includes
8 #include <algorithm>
9 
10 //Utility functions at file scope
11 namespace {
12  //make a number even
13  IdentifierHash even(const IdentifierHash& hash) {
14  return (hash>>1) << 1;
15  }
16 }
17 
21 
23  invalidate();
24 }
25 
32 }
33 
36 }
37 
39  //compute the index for insertion to the onlineId/Hash array
40  const unsigned int indx{onlineId.index()};
41  if (m_onlineId2HashArray[indx].is_valid()) return false; //don't insert if theres already a valid hash there
42  m_onlineId2HashArray[indx] = hash;
43  return true;
44 }
45 
47  const unsigned int indx{onlineId.index()};
48  if (indx==SCT_OnlineId::INVALID_INDEX) {
49  return s_invalidHash;
50  }
51  return m_onlineId2HashArray[indx];
52 }
53 
56 }
57 
59  if (m_hash2OnlineIdArray[hash].is_valid()) return false; //don't insert if there's already a valid online id there
60  //insert to hash/onlineId array
61  m_hash2OnlineIdArray[hash] = onlineId;
62  return true;
63 }
64 
66  return hash.is_valid()? m_hash2OnlineIdArray[hash] : s_invalidId;
67 }
68 
70  m_sn2HashMap.clear();
71 }
72 
74  return m_sn2HashMap.insert(std::make_pair(sn, hash)).second;
75 }
76 
78  std::map<SCT_SerialNumber, IdentifierHash>::const_iterator it{m_sn2HashMap.find(sn)};
79  if (it==m_sn2HashMap.end()) return s_invalidHash;
80  return it->second;
81 }
82 
85 }
86 
88  const IdentifierHash evenHash{even(hash)};
89  if (m_hash2SnArray[evenHash]!=s_invalidSn) return false; //don't insert if there's already a valid online id there
90  m_hash2SnArray[evenHash] = sn;
91  return true;
92 }
93 
95  return hash.is_valid() ? m_hash2SnArray[even(hash)] : s_invalidSn;
96 }
97 
99  m_rodIdSet.clear();
100 }
101 
103  m_rodIdSet.insert(rod);
104 }
105 
106 void SCT_CablingData::getRods(std::vector<std::uint32_t>& usersVector) const {
107  std::copy(m_rodIdSet.begin(), m_rodIdSet.end(), std::back_inserter(usersVector));
108 }
109 
110 unsigned int SCT_CablingData::getHashEntries() const {
111  return m_sn2HashMap.size();
112 }
SCT_CablingData::m_hash2SnArray
std::array< SCT_SerialNumber, NUMBER_OF_HASHES > m_hash2SnArray
Array for hash to serial number.
Definition: SCT_CablingData.h:98
SCT_CablingData::s_invalidSn
static const SCT_SerialNumber s_invalidSn
Invalid SCT_SerialNumber.
Definition: SCT_CablingData.h:103
SCT_CablingData::getHashFromSerialNumber
IdentifierHash getHashFromSerialNumber(const SCT_SerialNumber &sn) const
Get IdentifierHash from SCT_SerialNumber.
Definition: SCT_CablingData.cxx:77
SCT_CablingData::setRod
void setRod(const std::uint32_t &rod)
Set m_rodIdSet.
Definition: SCT_CablingData.cxx:102
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SCT_CablingData::getHashFromOnlineId
IdentifierHash getHashFromOnlineId(const SCT_OnlineId &onlineId) const
Get IdentifierHash from SCT_OnlineId.
Definition: SCT_CablingData.cxx:46
SCT_OnlineId
Definition: SCT_OnlineId.h:22
SCT_CablingData::setSerialNumberForHash
bool setSerialNumberForHash(const SCT_SerialNumber &sn, const IdentifierHash &hash)
Set m_hash2SnArray.
Definition: SCT_CablingData.cxx:87
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SCT_CablingData::invalidateHashesForOnlineIds
void invalidateHashesForOnlineIds()
Invalidate m_onlineId2HashArray.
Definition: SCT_CablingData.cxx:34
SCT_CablingData::m_onlineId2HashArray
std::array< IdentifierHash, SCT_OnlineId::NUMBER_OF_INDICES > m_onlineId2HashArray
Array for onlineId to hash.
Definition: SCT_CablingData.h:95
SCT_CablingData::setHashForSerialNumber
bool setHashForSerialNumber(const IdentifierHash &hash, const SCT_SerialNumber &sn)
Set m_sn2HashMap.
Definition: SCT_CablingData.cxx:73
SCT_CablingData::setOnlineIdForHash
bool setOnlineIdForHash(const SCT_OnlineId &onlineId, const IdentifierHash &hash)
Set m_hash2OnlineIdArray.
Definition: SCT_CablingData.cxx:58
SCT_CablingData::invalidateSerialNumbersForHashes
void invalidateSerialNumbersForHashes()
Invalidate m_hash2SnArray.
Definition: SCT_CablingData.cxx:83
SCT_CablingData::m_rodIdSet
std::set< std::uint32_t > m_rodIdSet
Set of robIds.
Definition: SCT_CablingData.h:99
SCT_CablingData::invalidateOnlineIdsForHashes
void invalidateOnlineIdsForHashes()
Invalidate m_hash2OnlineIdArray.
Definition: SCT_CablingData.cxx:54
SCT_CablingData::m_sn2HashMap
std::map< SCT_SerialNumber, IdentifierHash > m_sn2HashMap
Data map for serial number to hash.
Definition: SCT_CablingData.h:97
SCT_CablingData::invalidateRods
void invalidateRods()
Invalidate m_rodIdSet.
Definition: SCT_CablingData.cxx:98
RunTileMonitoring.rod
rod
Definition: RunTileMonitoring.py:134
SCT_OnlineId::index
unsigned int index() const
Return an index in the range 0-9215, calculated from parts of the onlineId.
Definition: SCT_OnlineId.cxx:112
SCT_CablingData::s_invalidId
static const SCT_OnlineId s_invalidId
Invalid SCT_OnlineId.
Definition: SCT_CablingData.h:102
SCT_CablingData::SCT_CablingData
SCT_CablingData()
constructor
Definition: SCT_CablingData.cxx:22
SCT_CablingData::invalidate
void invalidate()
Invalidate all data members.
Definition: SCT_CablingData.cxx:26
SCT_CablingData::invalidateHashesForSerialNumbers
void invalidateHashesForSerialNumbers()
Invalidate m_sn2HashMap.
Definition: SCT_CablingData.cxx:69
SCT_SerialNumber
Definition: SCT_SerialNumber.h:22
SCT_CablingData::getRods
void getRods(std::vector< std::uint32_t > &usersVector) const
Get a vector of all RODs.
Definition: SCT_CablingData.cxx:106
SCT_CablingData::m_hash2OnlineIdArray
std::array< SCT_OnlineId, NUMBER_OF_HASHES > m_hash2OnlineIdArray
Array for hash to onlineId; hash goes from 0-8175.
Definition: SCT_CablingData.h:96
SCT_OnlineId::INVALID_INDEX
@ INVALID_INDEX
Definition: SCT_OnlineId.h:57
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
SCT_CablingData.h
SCT_CablingData::getOnlineIdFromHash
SCT_OnlineId getOnlineIdFromHash(const IdentifierHash &hash) const
Get SCT_OnlineId from IdentifierHash.
Definition: SCT_CablingData.cxx:65
SCT_CablingData::s_invalidHash
static const IdentifierHash s_invalidHash
Invalid IdentifierHash.
Definition: SCT_CablingData.h:101
calibdata.copy
bool copy
Definition: calibdata.py:27
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
SCT_CablingData::getSerialNumberFromHash
SCT_SerialNumber getSerialNumberFromHash(const IdentifierHash &hash) const
Get SCT_SerialNumber from IdentifierHash.
Definition: SCT_CablingData.cxx:94
SCT_CablingData::getHashEntries
unsigned int getHashEntries() const
Return the size of m_sn2HashMap.
Definition: SCT_CablingData.cxx:110
SCT_CablingData::setHashForOnlineId
bool setHashForOnlineId(const IdentifierHash &hash, const SCT_OnlineId &onlineId)
Set m_onlineId2HashArray.
Definition: SCT_CablingData.cxx:38