ATLAS Offline Software
STGTPPackets.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
5 
6 #include <algorithm>
7 #include <exception>
8 #include <sstream>
9 #include <stdexcept>
10 #include <string>
11 #include <tuple>
12 #include <vector>
13 
17 
18 Muon::nsw::STGTPPadPacket::STGTPPadPacket(const std::vector<uint32_t>& payload) {
19  static constexpr auto PACKETS_SIZE = std::size_t{3};
20  if (std::size(payload) != PACKETS_SIZE) {
21  throw std::runtime_error(
22  Muon::nsw::format("Packet vector has size {} instead of expected size {}", std::size(payload), PACKETS_SIZE));
23  }
24 
25  const auto packets = std::span{payload.data(), std::size(payload)};
26  auto readPointer = std::size_t{0};
27  auto decode = [&packets](std::size_t& readPointer, const std::size_t size) {
28  return decode_and_advance<std::uint64_t, std::uint32_t>(packets, readPointer, size);
29  };
30 
32  for (std::size_t i = Muon::nsw::STGTPPad::num_pads; i > 0; --i) {
33  const auto index = i - 1;
35  }
36 
37  for (std::size_t i = Muon::nsw::STGTPPad::num_pads; i > 0; --i) {
38  const auto index = i - 1;
40  }
41 
43 
44  readPointer += Muon::nsw::STGTPPad::size_spare;
46 }
47 
49  static constexpr auto PACKETS_SIZE = std::size_t{8};
50  if (std::size(payload) != PACKETS_SIZE) {
51  throw std::runtime_error(
52  Muon::nsw::format("Packet vector has size {} instead of expected size {}", std::size(payload), PACKETS_SIZE));
53  }
54  auto readPointer = std::size_t{0};
55  const auto packets = std::span{payload.data(), std::size(payload)};
56  auto decode = [&packets](std::size_t& readPointer, const std::size_t size) {
57  return decode_and_advance<std::uint64_t, std::uint32_t>(packets, readPointer, size);
58  };
59 
61  m_nsw_segment_selector = decode(readPointer, Muon::nsw::STGTPSegments::size_nsw_segment_selector);
62  m_valid_segment_selector = decode(readPointer, Muon::nsw::STGTPSegments::size_valid_segment_selector);
63 
64  for (std::size_t i = Muon::nsw::STGTPSegments::num_segments; i > 0; --i) {
65  const auto index = i - 1;
66  m_segmentData.at(index).monitor = decode(readPointer, Muon::nsw::STGTPSegments::size_output_segment_monitor);
67  m_segmentData.at(index).spare = decode(readPointer, Muon::nsw::STGTPSegments::size_output_segment_spare);
68  m_segmentData.at(index).lowRes = decode(readPointer, Muon::nsw::STGTPSegments::size_output_segment_lowRes);
69  m_segmentData.at(index).phiRes = decode(readPointer, Muon::nsw::STGTPSegments::size_output_segment_phiRes);
70  m_segmentData.at(index).dTheta = decode(readPointer, Muon::nsw::STGTPSegments::size_output_segment_dTheta);
71  m_segmentData.at(index).phiID = decode(readPointer, Muon::nsw::STGTPSegments::size_output_segment_phiID);
72  m_segmentData.at(index).rIndex = decode(readPointer, Muon::nsw::STGTPSegments::size_output_segment_rIndex);
73  }
74 
75  m_BCID = decode(readPointer, Muon::nsw::STGTPSegments::size_bcid);
76  m_sectorID = decode(readPointer, Muon::nsw::STGTPSegments::size_sectorID);
77 }
78 
80  const std::size_t segment) const {
82  throw std::out_of_range(
83  Muon::nsw::format("Requested segment {} which does not exist (max {})", segment, STGTPSegments::num_segments - 1));
84  }
85  return m_segmentData.at(segment);
86 }
Muon::nsw::STGTPSegments::size_valid_segment_selector
constexpr int size_valid_segment_selector
Definition: NSWSTGTPDecodeBitmaps.h:81
Muon::nsw::STGTPPadPacket::STGTPPadPacket
STGTPPadPacket(const std::vector< std::uint32_t > &payload)
Definition: STGTPPackets.cxx:18
Muon::nsw::STGTPPadPacket::m_coincWedge
std::uint32_t m_coincWedge
Definition: STGTPPackets.h:31
CxxUtils::span
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
Muon::nsw::STGTPSegments::size_output_segment_spare
constexpr int size_output_segment_spare
Definition: NSWSTGTPDecodeBitmaps.h:84
Muon::nsw::STGTPSegments::size_output_segment_phiRes
constexpr int size_output_segment_phiRes
Definition: NSWSTGTPDecodeBitmaps.h:86
Muon::nsw::STGTPPad::size_idleFlag
constexpr std::size_t size_idleFlag
Definition: NSWSTGTPDecodeBitmaps.h:68
index
Definition: index.py:1
Muon::nsw::STGTPPadPacket::m_idleFlag
std::uint32_t m_idleFlag
Definition: STGTPPackets.h:30
Muon::nsw::STGTPSegments::size_output_segment_dTheta
constexpr int size_output_segment_dTheta
Definition: NSWSTGTPDecodeBitmaps.h:87
NSWSTGTPDecodeBitmaps.h
Muon::nsw::STGTPPad::size_coincidence_wedge
constexpr std::size_t size_coincidence_wedge
Definition: NSWSTGTPDecodeBitmaps.h:63
Muon::nsw::STGTPSegmentPacket::STGTPSegmentPacket
STGTPSegmentPacket(const std::vector< std::uint32_t > &payload)
Definition: STGTPPackets.cxx:48
STGTPPackets.h
Muon::nsw::STGTPPad::size_BCID
constexpr std::size_t size_BCID
Definition: NSWSTGTPDecodeBitmaps.h:66
Muon::nsw::STGTPPad::num_pads
constexpr std::size_t num_pads
Definition: NSWSTGTPDecodeBitmaps.h:60
Muon::nsw::STGTPSegments::size_output_segment_phiID
constexpr int size_output_segment_phiID
Definition: NSWSTGTPDecodeBitmaps.h:88
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Muon::nsw::STGTPPad::size_bandID
constexpr std::size_t size_bandID
Definition: NSWSTGTPDecodeBitmaps.h:65
Muon::nsw::STGTPSegments::num_segments
constexpr std::size_t num_segments
Definition: NSWSTGTPDecodeBitmaps.h:75
Muon::nsw::STGTPSegments::size_output_segment_lowRes
constexpr int size_output_segment_lowRes
Definition: NSWSTGTPDecodeBitmaps.h:85
lumiFormat.i
int i
Definition: lumiFormat.py:92
Muon::nsw::STGTPPadPacket::m_phiIDs
std::array< std::uint32_t, STGTPPad::num_pads > m_phiIDs
Definition: STGTPPackets.h:29
Muon::nsw::STGTPPad::size_phiID
constexpr std::size_t size_phiID
Definition: NSWSTGTPDecodeBitmaps.h:64
Muon::nsw::STGTPPadPacket::m_bandIDs
std::array< std::uint32_t, STGTPPad::num_pads > m_bandIDs
Definition: STGTPPackets.h:28
Muon::nsw::STGTPSegmentPacket::Segment
const SegmentData & Segment(std::size_t segment) const
Definition: STGTPPackets.cxx:79
Muon::nsw::STGTPSegments::size_lut_choice_selection
constexpr int size_lut_choice_selection
Definition: NSWSTGTPDecodeBitmaps.h:79
Muon::nsw::format
std::string format(const std::string &str, const T &arg)
Definition: NSWDecodeHelper.h:40
NSWDecodeHelper.h
python.PerfMonSerializer.decode
def decode(s)
Definition: PerfMonSerializer.py:388
Muon::nsw::STGTPSegments::size_output_segment_monitor
constexpr int size_output_segment_monitor
Definition: NSWSTGTPDecodeBitmaps.h:83
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
Muon::nsw::STGTPPadPacket::m_BCID
std::uint32_t m_BCID
Definition: STGTPPackets.h:27
NSWMMTPDecodeBitmaps.h
Muon::nsw::STGTPPad::size_spare
constexpr std::size_t size_spare
Definition: NSWSTGTPDecodeBitmaps.h:67
Muon::nsw::STGTPSegments::size_bcid
constexpr int size_bcid
Definition: NSWSTGTPDecodeBitmaps.h:91
Muon::nsw::STGTPSegments::size_nsw_segment_selector
constexpr int size_nsw_segment_selector
Definition: NSWSTGTPDecodeBitmaps.h:80
Muon::nsw::STGTPSegmentPacket::SegmentData
Definition: STGTPPackets.h:36
Muon::nsw::STGTPSegments::size_sectorID
constexpr int size_sectorID
Definition: NSWSTGTPDecodeBitmaps.h:92
Muon::nsw::STGTPSegments::size_output_segment_rIndex
constexpr int size_output_segment_rIndex
Definition: NSWSTGTPDecodeBitmaps.h:89
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5