ATLAS Offline Software
NSWSTGTPDecodeBitmaps.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef _MUON_NSW_STGTP_DECODE_BITMAPS_H_
6 #define _MUON_NSW_STGTP_DECODE_BITMAPS_H_
7 
9 #include <stdexcept>
10 #include <cstddef>
11 
12 namespace Muon
13 {
14  namespace nsw
15  {
16  namespace STGTPL1A {
17 
18  constexpr int size_head_fragID = 4;
19  constexpr int size_head_sectID = 4;
20  constexpr int size_head_EC = 1;
21  constexpr int size_head_flags = 7;
22  constexpr int size_head_BCID = 12;
23  constexpr int size_head_orbit = 2;
24  constexpr int size_head_spare = 2;
25  constexpr int size_L1ID = 32;
26 
27  constexpr int size_l1a_versionID = 8; // version 2+
28  constexpr int size_l1a_local_req_BCID = 12;
29  constexpr int size_l1a_local_rel_BCID = 12;
30  constexpr int size_l1a_open_BCID = 12;
31  constexpr int size_l1a_req_BCID = 12;
32  constexpr int size_l1a_close_BCID = 12;
33  constexpr int size_l1a_timeout = 12;
34  constexpr int size_l1a_open_BCID_offset = 12;
35  constexpr int size_l1a_req_BCID_offset = 12;
36  constexpr int size_l1a_close_BCID_offset = 12;
37  constexpr int size_l1a_timeout_config = 12;
38  constexpr int size_l1a_busy_thr = 8; // version 2+
39  constexpr int size_l1a_engine_snapshot = 16; // version 2+
40  constexpr int size_l1a_link_const = 32;
41  constexpr int size_l1a_padding = 8; // version 2+
42 
43 
44  constexpr int size_l1a_wdw_matching_engines_usage = 32; // this is only present in version 1
45  constexpr int loc_version1_anchor = 192;
46  constexpr uint32_t version1_anchor_value = 0xABC0ABC1;
47 
48 
49 
50  constexpr int size_stream_head_nbits = 16;
51  constexpr int size_stream_head_nwords = 16;
52  constexpr int size_stream_head_fifo_size = 16;
53  constexpr int size_stream_head_streamID = 16;
54  constexpr int size_trailer_CRC = 16;
55 
56 
57  };
58 
59  namespace STGTPPad {
60  constexpr std::size_t num_pads = 4;
61  constexpr std::size_t pad_stream_header = 0xAAD0;
62  constexpr std::size_t n_words = 3; // size in 32 bit words
63  constexpr std::size_t size_coincidence_wedge = 16;
64  constexpr std::size_t size_phiID = 6;
65  constexpr std::size_t size_bandID = 8;
66  constexpr std::size_t size_BCID = 12;
67  constexpr std::size_t size_spare = 3;
68  constexpr std::size_t size_idleFlag = 1;
69  constexpr std::size_t size_padding = 8;
70 
71  };
72 
73 
74  namespace STGTPSegments {
75  constexpr std::size_t num_segments = 8;
76 
77  constexpr int merge_stream_header = 0xAEE0;
78  constexpr int n_words = 32;
79  constexpr int size_lut_choice_selection = 24;
80  constexpr int size_nsw_segment_selector = 12;
81  constexpr int size_valid_segment_selector = 12;
82 
83  constexpr int size_output_segment_monitor = 1;
84  constexpr int size_output_segment_spare = 2;
85  constexpr int size_output_segment_lowRes = 1;
86  constexpr int size_output_segment_phiRes = 1;
87  constexpr int size_output_segment_dTheta = 5;
88  constexpr int size_output_segment_phiID = 6;
89  constexpr int size_output_segment_rIndex = 8;
90 
91  constexpr int size_bcid = 12;
92  constexpr int size_sectorID = 4;
93 
94  enum class MergedSegmentProperty {
95  Monitor = fill_bitmask<uint32_t>(0, size_output_segment_monitor),
96  Spare = fill_bitmask<uint32_t>(max_bit(Monitor) + 1, size_output_segment_spare),
97  lowRes = fill_bitmask<uint32_t>(max_bit(Spare) + 1, size_output_segment_lowRes),
98  phiRes = fill_bitmask<uint32_t>(max_bit(lowRes) + 1 , size_output_segment_phiRes),
99  dTheta = fill_bitmask<uint32_t>(max_bit(phiRes)+ 1, size_output_segment_dTheta),
100  phiID = fill_bitmask<uint32_t>(max_bit(dTheta)+1 , size_output_segment_phiID),
101  rIndex = fill_bitmask<uint32_t>(max_bit(phiID)+1, size_output_segment_rIndex)
102  };
103 
105  const auto shift = min_bit(static_cast<uint32_t>(prop));
106  if (shift < 0) {
107  throw std::runtime_error("bitshift is negative in NSWSTGTPDecodeBitmaps getSegmentProperty");
108  }
109  return (mask & static_cast<uint32_t>(prop) ) >> shift;
110  }
111 
112  constexpr void encodeSegmentProperty(const MergedSegmentProperty prop, const uint32_t word, uint32_t& buffer) {
113  const auto shift = min_bit(static_cast<uint32_t>(prop));
114  if (shift < 0) {
115  throw std::runtime_error("bitshift is negative in NSWSTGTPDecodeBitmaps encodeSegmentProperty");
116  }
117  uint32_t shifted_word = (word << shift);
118  buffer = (buffer) | (shifted_word & static_cast<uint32_t>(prop));
119  }
120 
121  namespace moduleIDBits{
123  constexpr uint8_t stationID = 1;
125  constexpr uint8_t detectorSite = 1;
127  constexpr uint8_t stationEta = 4;
129  constexpr uint8_t stationPhi = 8;
130  }
131  enum class ModuleIDProperty{
132  stationID = fill_bitmask<uint32_t>(0, moduleIDBits::stationID),
133  detectorSite = fill_bitmask<uint32_t>(max_bit(stationID) +1, moduleIDBits::detectorSite),
134  stationEta = fill_bitmask<uint32_t>(max_bit(detectorSite) + 1, moduleIDBits::stationEta),
135  stationPhi = fill_bitmask<uint32_t>(max_bit(stationEta) + 1, moduleIDBits::stationPhi),
136  };
138  const auto shift = min_bit(static_cast<uint32_t>(prop));
139  if (shift < 0) {
140  throw std::runtime_error("bitshift is negative in NSWSTGTPDecodeBitmaps getIdentifierProperty");
141  }
142  return (mask & static_cast<uint32_t>(prop)) >> shift;
143 
144  }
145  constexpr void encodeIdentifierProperty(const ModuleIDProperty prop, const uint32_t word, uint32_t& buffer) {
146  const auto shift = min_bit(static_cast<uint32_t>(prop));
147  if (shift < 0) {
148  throw std::runtime_error("bitshift is negative in NSWSTGTPDecodeBitmaps encodeIdentifierProperty");
149  }
150  uint32_t shifted_word = (word << shift);
151  buffer = (buffer) | (shifted_word & static_cast<uint32_t>(prop));
152  }
153  }
154  }
155 }
156 
157 #endif // _MUON_NSW_STGTP_DECODE_BITMAPS_H_
Muon::nsw::STGTPL1A::size_l1a_wdw_matching_engines_usage
constexpr int size_l1a_wdw_matching_engines_usage
Definition: NSWSTGTPDecodeBitmaps.h:44
Muon::nsw::STGTPSegments::moduleIDBits::detectorSite
constexpr uint8_t detectorSite
Side 0 for A / 1 for C.
Definition: NSWSTGTPDecodeBitmaps.h:125
Muon::nsw::STGTPSegments::ModuleIDProperty::stationPhi
@ stationPhi
Muon::nsw::STGTPSegments::size_valid_segment_selector
constexpr int size_valid_segment_selector
Definition: NSWSTGTPDecodeBitmaps.h:81
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:129
Muon::nsw::STGTPSegments::encodeIdentifierProperty
constexpr void encodeIdentifierProperty(const ModuleIDProperty prop, const uint32_t word, uint32_t &buffer)
Definition: NSWSTGTPDecodeBitmaps.h:145
Muon::nsw::STGTPSegments::size_output_segment_spare
constexpr int size_output_segment_spare
Definition: NSWSTGTPDecodeBitmaps.h:84
Muon::nsw::STGTPL1A::size_head_EC
constexpr int size_head_EC
Definition: NSWSTGTPDecodeBitmaps.h:20
Muon::nsw::max_bit
constexpr int8_t max_bit(const T &number)
Returns the most left hand bit which is set in a number.
Definition: NSWDecodeHelper.h:144
Muon::nsw::STGTPSegments::MergedSegmentProperty::phiID
@ phiID
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
Muon::nsw::STGTPL1A::version1_anchor_value
constexpr uint32_t version1_anchor_value
Definition: NSWSTGTPDecodeBitmaps.h:46
Muon::nsw::STGTPL1A::size_stream_head_nbits
constexpr int size_stream_head_nbits
Definition: NSWSTGTPDecodeBitmaps.h:50
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
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
Muon::nsw::STGTPL1A::size_head_BCID
constexpr int size_head_BCID
Definition: NSWSTGTPDecodeBitmaps.h:22
Muon::nsw::STGTPL1A::size_l1a_busy_thr
constexpr int size_l1a_busy_thr
Definition: NSWSTGTPDecodeBitmaps.h:38
Muon::nsw::STGTPL1A::size_l1a_timeout_config
constexpr int size_l1a_timeout_config
Definition: NSWSTGTPDecodeBitmaps.h:37
Muon::nsw::STGTPSegments::size_output_segment_dTheta
constexpr int size_output_segment_dTheta
Definition: NSWSTGTPDecodeBitmaps.h:87
Muon::nsw::STGTPL1A::size_l1a_local_req_BCID
constexpr int size_l1a_local_req_BCID
Definition: NSWSTGTPDecodeBitmaps.h:28
Muon::nsw::STGTPL1A::size_l1a_padding
constexpr int size_l1a_padding
Definition: NSWSTGTPDecodeBitmaps.h:41
Muon::nsw::STGTPL1A::size_stream_head_streamID
constexpr int size_stream_head_streamID
Definition: NSWSTGTPDecodeBitmaps.h:53
Muon::nsw::STGTPL1A::size_l1a_close_BCID_offset
constexpr int size_l1a_close_BCID_offset
Definition: NSWSTGTPDecodeBitmaps.h:36
Muon::nsw::STGTPL1A::size_head_flags
constexpr int size_head_flags
Definition: NSWSTGTPDecodeBitmaps.h:21
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
Muon::nsw::STGTPL1A::size_l1a_versionID
constexpr int size_l1a_versionID
Definition: NSWSTGTPDecodeBitmaps.h:27
Muon::nsw::STGTPL1A::size_l1a_req_BCID_offset
constexpr int size_l1a_req_BCID_offset
Definition: NSWSTGTPDecodeBitmaps.h:35
Muon::nsw::STGTPPad::size_coincidence_wedge
constexpr std::size_t size_coincidence_wedge
Definition: NSWSTGTPDecodeBitmaps.h:63
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
Muon::nsw::STGTPL1A::size_l1a_req_BCID
constexpr int size_l1a_req_BCID
Definition: NSWSTGTPDecodeBitmaps.h:31
Muon::nsw::STGTPL1A::size_trailer_CRC
constexpr int size_trailer_CRC
Definition: NSWSTGTPDecodeBitmaps.h:54
Muon::nsw::STGTPSegments::ModuleIDProperty::stationID
@ stationID
Muon::nsw::STGTPSegments::merge_stream_header
constexpr int merge_stream_header
Definition: NSWSTGTPDecodeBitmaps.h:77
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::STGTPPad::n_words
constexpr std::size_t n_words
Definition: NSWSTGTPDecodeBitmaps.h:62
Muon::nsw::STGTPSegments::size_output_segment_phiID
constexpr int size_output_segment_phiID
Definition: NSWSTGTPDecodeBitmaps.h:88
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::STGTPL1A::size_head_spare
constexpr int size_head_spare
Definition: NSWSTGTPDecodeBitmaps.h:24
Muon::nsw::STGTPSegments::MergedSegmentProperty::phiRes
@ phiRes
Muon::nsw::STGTPSegments::size_output_segment_lowRes
constexpr int size_output_segment_lowRes
Definition: NSWSTGTPDecodeBitmaps.h:85
Muon::nsw::STGTPSegments::MergedSegmentProperty
MergedSegmentProperty
Definition: NSWSTGTPDecodeBitmaps.h:94
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
Muon::nsw::STGTPL1A::size_stream_head_fifo_size
constexpr int size_stream_head_fifo_size
Definition: NSWSTGTPDecodeBitmaps.h:52
Muon::nsw::STGTPSegments::ModuleIDProperty::detectorSite
@ detectorSite
Muon::nsw::STGTPSegments::getSegmentProperty
constexpr uint32_t getSegmentProperty(const uint32_t mask, const MergedSegmentProperty prop)
Definition: NSWSTGTPDecodeBitmaps.h:104
Muon::nsw::STGTPPad::size_phiID
constexpr std::size_t size_phiID
Definition: NSWSTGTPDecodeBitmaps.h:64
Muon::nsw::STGTPL1A::size_l1a_link_const
constexpr int size_l1a_link_const
Definition: NSWSTGTPDecodeBitmaps.h:40
Muon::nsw::STGTPSegments::moduleIDBits::stationID
constexpr uint8_t stationID
Large or Small wedge.
Definition: NSWSTGTPDecodeBitmaps.h:123
Muon::nsw::STGTPSegments::n_words
constexpr int n_words
Definition: NSWSTGTPDecodeBitmaps.h:78
Muon::nsw::STGTPSegments::ModuleIDProperty
ModuleIDProperty
Definition: NSWSTGTPDecodeBitmaps.h:131
Muon::nsw::STGTPSegments::size_lut_choice_selection
constexpr int size_lut_choice_selection
Definition: NSWSTGTPDecodeBitmaps.h:79
Muon::nsw::STGTPL1A::size_stream_head_nwords
constexpr int size_stream_head_nwords
Definition: NSWSTGTPDecodeBitmaps.h:51
Muon::nsw::STGTPL1A::loc_version1_anchor
constexpr int loc_version1_anchor
Definition: NSWSTGTPDecodeBitmaps.h:45
NSWDecodeHelper.h
Muon::nsw::STGTPL1A::size_l1a_timeout
constexpr int size_l1a_timeout
Definition: NSWSTGTPDecodeBitmaps.h:33
Muon::nsw::STGTPL1A::size_l1a_open_BCID_offset
constexpr int size_l1a_open_BCID_offset
Definition: NSWSTGTPDecodeBitmaps.h:34
Muon::nsw::STGTPSegments::ModuleIDProperty::stationEta
@ stationEta
Muon::nsw::STGTPL1A::size_head_fragID
constexpr int size_head_fragID
Definition: NSWSTGTPDecodeBitmaps.h:18
Muon::nsw::STGTPSegments::size_output_segment_monitor
constexpr int size_output_segment_monitor
Definition: NSWSTGTPDecodeBitmaps.h:83
Muon::nsw::STGTPL1A::size_l1a_open_BCID
constexpr int size_l1a_open_BCID
Definition: NSWSTGTPDecodeBitmaps.h:30
Muon::nsw::STGTPSegments::getIdentifierProperty
constexpr uint32_t getIdentifierProperty(const uint32_t mask, const ModuleIDProperty prop)
Definition: NSWSTGTPDecodeBitmaps.h:137
Muon::nsw::min_bit
constexpr int8_t min_bit(const T &number)
Returns the most right hand bit which is set in a number.
Definition: NSWDecodeHelper.h:157
Muon::nsw::STGTPL1A::size_head_sectID
constexpr int size_head_sectID
Definition: NSWSTGTPDecodeBitmaps.h:19
Muon::nsw::STGTPPad::size_spare
constexpr std::size_t size_spare
Definition: NSWSTGTPDecodeBitmaps.h:67
Muon::nsw::STGTPPad::pad_stream_header
constexpr std::size_t pad_stream_header
Definition: NSWSTGTPDecodeBitmaps.h:61
Muon::nsw::STGTPL1A::size_l1a_engine_snapshot
constexpr int size_l1a_engine_snapshot
Definition: NSWSTGTPDecodeBitmaps.h:39
Muon::nsw::STGTPSegments::MergedSegmentProperty::dTheta
@ dTheta
Muon::nsw::STGTPSegments::size_bcid
constexpr int size_bcid
Definition: NSWSTGTPDecodeBitmaps.h:91
Muon::nsw::STGTPSegments::MergedSegmentProperty::Monitor
@ Monitor
Muon::nsw::STGTPPad::size_padding
constexpr std::size_t size_padding
Definition: NSWSTGTPDecodeBitmaps.h:69
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:127
Muon::nsw::STGTPSegments::size_nsw_segment_selector
constexpr int size_nsw_segment_selector
Definition: NSWSTGTPDecodeBitmaps.h:80
Muon::nsw::STGTPSegments::size_sectorID
constexpr int size_sectorID
Definition: NSWSTGTPDecodeBitmaps.h:92
Muon::nsw::STGTPL1A::size_L1ID
constexpr int size_L1ID
Definition: NSWSTGTPDecodeBitmaps.h:25
Muon::nsw::STGTPSegments::MergedSegmentProperty::lowRes
@ lowRes
Muon::nsw::STGTPSegments::size_output_segment_rIndex
constexpr int size_output_segment_rIndex
Definition: NSWSTGTPDecodeBitmaps.h:89
Muon::nsw::STGTPSegments::MergedSegmentProperty::Spare
@ Spare
Muon::nsw::STGTPSegments::encodeSegmentProperty
constexpr void encodeSegmentProperty(const MergedSegmentProperty prop, const uint32_t word, uint32_t &buffer)
Definition: NSWSTGTPDecodeBitmaps.h:112
Muon::nsw::STGTPSegments::MergedSegmentProperty::rIndex
@ rIndex
Muon::nsw::STGTPL1A::size_head_orbit
constexpr int size_head_orbit
Definition: NSWSTGTPDecodeBitmaps.h:23
Muon::nsw::STGTPL1A::size_l1a_local_rel_BCID
constexpr int size_l1a_local_rel_BCID
Definition: NSWSTGTPDecodeBitmaps.h:29
Muon::nsw::STGTPL1A::size_l1a_close_BCID
constexpr int size_l1a_close_BCID
Definition: NSWSTGTPDecodeBitmaps.h:32