ATLAS Offline Software
GlobalLArCellContainer.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 <ranges>
7 #include <algorithm>
8 
9 namespace GlobalSim {
10 
11  // Main constructor setting up FEB2 LUTs
12  GlobalLArCellContainer::GlobalLArCellContainer(const std::map<std::string,Feb2MuxInfo>& febMap) {
13 
14  std::map<std::string, std::vector<std::pair<int,std::string>>> tempMap;
15 
16  // Loop over map of FEB2s to establish LUTs and lists
17  for (const auto & [feb2, muxInfo] : febMap) {
18  m_feb2Flags.insert({feb2, {false, false}});
19  m_feb2Keys.insert(feb2);
20  m_muxKeys.insert(muxInfo.muxName);
21  m_muxFlags.insert({muxInfo.muxName, {false, false}});
22  m_feb2ToMux.insert({feb2, muxInfo.muxName});
23 
24  tempMap[muxInfo.muxName].emplace_back(muxInfo.indexOnMux, feb2);
25  }
26 
27  // Sort FEB2 vectors for each MUX
28  for (auto& [muxName, vec] : tempMap) {
29  std::sort(vec.begin(), vec.end(), [](const auto& a, const auto& b) {
30  return a.first < b.first; // sort by indexOnMux
31  });
32 
33  // Copy only the FEB2 names into m_muxToFeb2Ordered
34  std::vector<std::string> orderedFeb2s;
35  orderedFeb2s.reserve(vec.size());
36  for (const auto& [idx, feb2] : vec) {
37  orderedFeb2s.push_back(feb2);
38  }
39  m_muxToFeb2Ordered[muxName] = std::move(orderedFeb2s);
40  }
41  }
42 
43 
44  // Copy constructor
47  {
48  // Deep-copy DataVector elements
49  for (const auto& cellPtr : other) {
50  DataVector<GlobalLArCell>::push_back(std::make_unique<GlobalLArCell>(*cellPtr));
51  }
52 
53  // Copy the maps and sets
54  m_feb2Flags = other.m_feb2Flags;
55  m_feb2Keys = other.m_feb2Keys;
56  m_muxKeys = other.m_muxKeys;
57  m_muxFlags = other.m_muxFlags;
58  m_maxCellsPerFeb2 = other.m_maxCellsPerFeb2;
59  m_muxToFeb2Ordered = other.m_muxToFeb2Ordered;
60  m_feb2ToMux = other.m_feb2ToMux;
61  }
62 
63 
64  // Reimplementation of the push_back function to fill GlobalLArCells
66  auto cell = std::make_unique<GlobalLArCell>(theCell);
67  auto* cellPtr = cell.get();
69 
70  m_feb2ToCells[cellPtr->getFEB2()].push_back(cellPtr);
71  }
72 
73 
74  // Function to get all GlobalLArCells for a given FEB2 name
75  const std::vector<GlobalLArCell*>& GlobalLArCellContainer::getCellsForFeb2(const std::string& feb2) const {
76 
77  static const std::vector<GlobalLArCell*> emptyCellVector; // fallback if not found
78  auto it = m_feb2ToCells.find(feb2);
79 
80  if (it != m_feb2ToCells.end()) {
81  return it->second;
82  }
83 
84  return emptyCellVector;
85  }
86 
87 
88  // Function to get ordered list of FEB2s for a given MUX name
89  const std::vector<std::string>& GlobalLArCellContainer::getOrderedFeb2sForMux(const std::string& mux) const {
90 
91  static const std::vector<std::string> emptyMux;
92  auto it = m_muxToFeb2Ordered.find(mux);
93  if (it != m_muxToFeb2Ordered.end()) {
94  return it->second;
95  }
96 
97  return emptyMux;
98  }
99 
100 
101  // Function to get the associated MUX name for a given FEB2
102  const std::string& GlobalLArCellContainer::getMuxForFeb2(const std::string& feb2Key) const {
103  auto it = m_feb2ToMux.find(feb2Key);
104  if (it == m_feb2ToMux.end()) {
105  throw std::runtime_error("Unknown FEB2 key: " + feb2Key);
106  }
107  return it->second;
108  }
109 
110 
111  // Function to set overflow and error flag for a FEB2
112  void GlobalLArCellContainer::setFeb2Flags(const std::string& feb2Key, bool overflow, bool error) {
113  auto& flags = m_feb2Flags[feb2Key];
114  flags.overflow = overflow;
115  flags.error = error;
116 
117  // Propagate FEB2 flags to the MUX
118  if (overflow) {
119  auto& muxFlags = m_muxFlags[m_feb2ToMux[feb2Key]];
120  muxFlags.overflow = overflow;
121  }
122  if (error) {
123  auto& muxFlags = m_muxFlags[m_feb2ToMux[feb2Key]];
124  muxFlags.error = error;
125  }
126  }
127 
128 
129  // Function to check whether a given FEB2 is in overflow
130  bool GlobalLArCellContainer::feb2InOverflow(const std::string& feb2Key) const {
131  auto it = m_feb2Flags.find(feb2Key);
132  return (it != m_feb2Flags.end()) ? it->second.overflow : false;
133  }
134 
135 
136  // Function to check if a given FEB2 is in error
137  bool GlobalLArCellContainer::feb2InError(const std::string& feb2Key) const {
138  auto it = m_feb2Flags.find(feb2Key);
139  return (it != m_feb2Flags.end()) ? it->second.error : false;
140  }
141 
142 
143  // Function to check whether a given MUX is in overflow
144  bool GlobalLArCellContainer::muxInOverflow(const std::string& muxKey) const {
145  auto it = m_muxFlags.find(muxKey);
146  return (it != m_muxFlags.end()) ? it->second.overflow : false;
147  }
148 
149 
150  // Function to check if a given MUX is in error
151  bool GlobalLArCellContainer::muxInError(const std::string& muxKey) const {
152  auto it = m_muxFlags.find(muxKey);
153  return (it != m_muxFlags.end()) ? it->second.error : false;
154  }
155 
156 } // namespace GlobalSim
GlobalSim::GlobalLArCellContainer::feb2InOverflow
bool feb2InOverflow(const std::string &feb2Key) const
Check if a given FEB2 is in overflow.
Definition: GlobalLArCellContainer.cxx:130
GlobalSim::GlobalLArCellContainer::getOrderedFeb2sForMux
const std::vector< std::string > & getOrderedFeb2sForMux(const std::string &mux) const
Function to get ordered list of FEB2s for a given MUX name.
Definition: GlobalLArCellContainer.cxx:89
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
GlobalSim::GlobalLArCellContainer::feb2InError
bool feb2InError(const std::string &feb2Key) const
Check if a given FEB2 is in error.
Definition: GlobalLArCellContainer.cxx:137
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
GlobalSim::GlobalLArCellContainer::GlobalLArCellContainer
GlobalLArCellContainer()=default
Default constructor.
GlobalSim::GlobalLArCellContainer::push_back
void push_back(const GlobalLArCell &theCell)
Reimplementation of the push_back function to fill LArCells.
Definition: GlobalLArCellContainer.cxx:65
skel.it
it
Definition: skel.GENtoEVGEN.py:407
GlobalSim::GlobalLArCellContainer::m_muxFlags
std::map< std::string, StatusFlags > m_muxFlags
map which stores overflow and error bits for each MUX
Definition: GlobalLArCellContainer.h:87
GlobalLArCellContainer.h
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
GlobalSim::GlobalLArCellContainer::m_muxKeys
std::unordered_set< std::string > m_muxKeys
vector of all MUX names
Definition: GlobalLArCellContainer.h:91
GlobalSim::GlobalLArCellContainer::m_maxCellsPerFeb2
std::size_t m_maxCellsPerFeb2
Maximum number of cells per FEB2 in given energy encoding scheme.
Definition: GlobalLArCellContainer.h:99
GlobalSim
AlgTool to obtain a selection of eFex RoIs read in from the event store.
Definition: dump.h:8
GlobalSim::GlobalLArCellContainer::getCellsForFeb2
const std::vector< GlobalLArCell * > & getCellsForFeb2(const std::string &feb2) const
Function to get all GlobalLArCells for a given FEB2 name.
Definition: GlobalLArCellContainer.cxx:75
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
GlobalSim::GlobalLArCellContainer::m_feb2Keys
std::unordered_set< std::string > m_feb2Keys
vector of all FEB2 names
Definition: GlobalLArCellContainer.h:89
fitman.mux
mux
Definition: fitman.py:547
GlobalSim::GlobalLArCellContainer::m_feb2Flags
std::map< std::string, StatusFlags > m_feb2Flags
map which stores overflow and error bits for each FEB2
Definition: GlobalLArCellContainer.h:85
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
GlobalSim::GlobalLArCellContainer::getMuxForFeb2
const std::string & getMuxForFeb2(const std::string &feb2Key) const
Function to get the associated MUX name for a given FEB2.
Definition: GlobalLArCellContainer.cxx:102
GlobalSim::GlobalLArCellContainer
Definition: GlobalLArCellContainer.h:22
GlobalSim::GlobalLArCellContainer::muxInOverflow
bool muxInOverflow(const std::string &muxKey) const
Check if a given MUX is in overflow.
Definition: GlobalLArCellContainer.cxx:144
a
TList * a
Definition: liststreamerinfos.cxx:10
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
GlobalSim::GlobalLArCellContainer::setFeb2Flags
void setFeb2Flags(const std::string &feb2Key, bool overflow, bool error)
Set overflow and error flag for a FEB2.
Definition: GlobalLArCellContainer.cxx:112
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
GlobalSim::GlobalLArCellContainer::m_feb2ToCells
std::map< std::string, std::vector< GlobalLArCell * > > m_feb2ToCells
map which keeps track of which cells are associated with which FEB2
Definition: GlobalLArCellContainer.h:93
GlobalSim::GlobalLArCellContainer::m_muxToFeb2Ordered
std::map< std::string, std::vector< std::string > > m_muxToFeb2Ordered
map which holds the ordered list of FEB2s for each MUX
Definition: GlobalLArCellContainer.h:95
GlobalSim::GlobalLArCell
Definition: GlobalLArCell.h:14
get_generator_info.error
error
Definition: get_generator_info.py:40
GlobalSim::GlobalLArCellContainer::m_feb2ToMux
std::map< std::string, std::string > m_feb2ToMux
map which acts as lookuptable to get the associated MUX from a FEB2 name
Definition: GlobalLArCellContainer.h:97
error
Definition: IImpactPoint3dEstimator.h:70
GlobalSim::GlobalLArCellContainer::muxInError
bool muxInError(const std::string &muxKey) const
Check if a given MUX is in error.
Definition: GlobalLArCellContainer.cxx:151