ATLAS Offline Software
CmmJetSubBlock.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "CmmJetSubBlock.h"
7 
8 namespace LVL1BS {
9 
10 // Constant definitions
11 
13 
27 
35 
36 
38 {
39 }
40 
42 {
43 }
44 
45 // Clear all data
46 
48 {
50  m_hitsData.clear();
51 }
52 
53 // Return jet hit counts for given jem or source ID
54 
55 unsigned int CmmJetSubBlock::jetHits(const int slice, const int source) const
56 {
57  unsigned int hits = 0;
58  if (slice >= 0 && slice < timeslices() &&
59  source >= 0 && source < s_maxHits && !m_hitsData.empty()) {
60  if (source <= TOTAL_MAIN) {
62  } else if (source >= REMOTE_FORWARD) {
64  }
65  }
66  return hits;
67 }
68 
69 // Return jet hit error for given jem or source ID
70 
71 int CmmJetSubBlock::jetHitsError(const int slice, const int source) const
72 {
73  int error = 0;
74  if (slice >= 0 && slice < timeslices() &&
75  source >= 0 && source < s_maxHits && !m_hitsData.empty()) {
76  if (source <= TOTAL_MAIN) {
78  & s_errorMask;
79  } else if (source == REMOTE_FORWARD) {
81  }
82  }
83  return error;
84 }
85 
86 // Return jet ET map
87 
88 unsigned int CmmJetSubBlock::jetEtMap(const int slice) const
89 {
90  unsigned int map = 0;
91  if (slice >= 0 && slice < timeslices() && !m_hitsData.empty()) {
93  }
94  return map;
95 }
96 
97 // Store jet hit counts and error for given jem or source ID
98 
99 void CmmJetSubBlock::setJetHits(const int slice, const int source,
100  const unsigned int hits, const int error)
101 {
102  if (slice >= 0 && slice < timeslices() &&
103  source >= 0 && source < s_maxHits && (hits || error)) {
104  resize();
106  if (source <= TOTAL_MAIN) {
107  word |= (hits & s_threshMask) << s_threshBit;
108  word |= (error & s_errorMask) << s_threshErrorBit;
109  } else {
110  word |= (hits & s_fwdMask) << s_threshBit;
111  word |= (error & s_errorMask) << s_fwdErrorBit;
112  }
113  word |= (source & s_sourceIdMask) << s_sourceIdBit;
114  word |= (s_dataWordId) << s_dataWordIdBit;
115  m_hitsData[index(slice, source)] = word;
116  }
117 }
118 
119 // Store jet ET map
120 
121 void CmmJetSubBlock::setJetEtMap(const int slice, const unsigned int map)
122 {
123  if (slice >= 0 && slice < timeslices() && map) {
124  resize();
126  word |= (map & s_etMapMask) << s_etMapBit;
128  word |= (s_dataWordId) << s_dataWordIdBit;
130  }
131 }
132 
133 // Packing/Unpacking routines
134 
136 {
137  bool rc = false;
138  switch (version()) {
139  case 1:
140  switch (format()) {
141  case NEUTRAL:
142  rc = packNeutral();
143  break;
144  case UNCOMPRESSED:
145  rc = packUncompressed();
146  break;
147  default:
148  break;
149  }
150  break;
151  default:
152  break;
153  }
154  return rc;
155 }
156 
158 {
159  bool rc = false;
160  switch (version()) {
161  case 1:
162  switch (format()) {
163  case NEUTRAL:
164  rc = unpackNeutral();
165  break;
166  case UNCOMPRESSED:
167  rc = unpackUncompressed();
168  break;
169  default:
171  break;
172  }
173  break;
174  default:
176  break;
177  }
178  return rc;
179 }
180 
181 // Return data index appropriate to format
182 
183 int CmmJetSubBlock::index(const int slice, const int source) const
184 {
185  int ix = source;
186  if (format() == NEUTRAL) ix += slice * s_maxHits;
187  return ix;
188 }
189 
190 // Resize the hits vector according to format
191 
193 {
194  if (m_hitsData.empty()) {
195  int size = s_maxHits;
196  if (format() == NEUTRAL) size *= timeslices();
197  m_hitsData.resize(size);
198  }
199 }
200 
201 // Pack neutral data
202 
204 {
205  resize();
206  const int slices = timeslices();
207  for (int slice = 0; slice < slices; ++slice) {
208  for (int pin = 0; pin <= TOTAL_MAIN; ++pin) {
209  // Jem hits; remote, local and total main hits; parity error
212  // Bunch crossing number; Fifo overflow
213  if (pin < s_bunchCrossingBits) {
214  packerNeutral(pin, bunchCrossing() >> pin, 1);
215  } else if (pin == s_fifoOverflowPin) {
216  packerNeutral(pin, daqOverflow(), 1);
217  } else packerNeutral(pin, 0, 1);
218  // Padding
219  if (pin < REMOTE_MAIN) packerNeutral(pin, 0, s_paddingBits);
220  }
221  // ET Map + padding
223  // Total forward (left + right)
226  s_paddingBits);
227  // Remote + Local forward
228  const int lastpin = TOTAL_MAIN + 1;
232  packerNeutral(lastpin, 0, 1);
234  // G-Link parity
235  for (int pin = 0; pin <= lastpin; ++pin) packerNeutralParity(pin);
236  }
237  return true;
238 }
239 
240 // Pack uncompressed data
241 
243 {
244  std::vector<uint32_t>::const_iterator pos;
245  for (pos = m_hitsData.begin(); pos != m_hitsData.end(); ++pos) {
246  if (*pos) packer(*pos, s_wordLength);
247  }
248  packerFlush();
249  return true;
250 }
251 
252 // Unpack neutral data
253 
255 {
256  resize();
257  int bunchCrossing = 0;
258  int overflow = 0;
259  int parity = 0;
260  const int slices = timeslices();
261  for (int slice = 0; slice < slices; ++slice) {
262  unsigned int hits = 0;
263  int error = 0;
264  for (int pin = 0; pin <= TOTAL_MAIN; ++pin) {
265  // Jem hits; remote, local and total main hits; parity error
268  setJetHits(slice, pin, hits, error);
269  // Bunch crossing number; Fifo overflow
270  if (pin < s_bunchCrossingBits) {
271  bunchCrossing |= unpackerNeutral(pin, 1) << pin;
272  } else if (pin == s_fifoOverflowPin) {
273  overflow |= unpackerNeutral(pin, 1);
274  } else unpackerNeutral(pin, 1);
275  // Padding
276  if (pin < REMOTE_MAIN) unpackerNeutral(pin, s_paddingBits);
277  }
278  // ET Map + padding
280  // Total forward (left + right)
284  // Remote + Local forward
285  const int lastpin = TOTAL_MAIN + 1;
286  hits = unpackerNeutral(lastpin, s_fwdHitsBits);
289  unpackerNeutral(lastpin, 1);
291  unpackerNeutral(lastpin, s_fwdHitsBits), 0);
292  // G-Link parity errors
293  for (int pin = 0; pin <= lastpin; ++pin) {
294  parity |= unpackerNeutralParityError(pin);
295  }
296  }
298  setDaqOverflow(overflow);
299  setGlinkParity(parity);
300 
301  const bool rc = unpackerSuccess();
303  return rc;
304 }
305 
306 // Unpack uncompressed data
307 
309 {
310  resize();
311  unpackerInit();
313  while (unpackerSuccess()) {
314  const int source = sourceId(word);
315  if (source < s_maxHits && m_hitsData[source] == 0) m_hitsData[source] = word;
316  else {
318  return false;
319  }
320  word = unpacker(s_wordLength);
321  }
322  return true;
323 }
324 
325 } // end namespace
LVL1BS::L1CaloSubBlock::setBunchCrossing
void setBunchCrossing(int bc)
Set the Bunch Crossing number (neutral format only)
Definition: L1CaloSubBlock.h:328
LVL1BS::CmmJetSubBlock::TOTAL_MAIN
@ TOTAL_MAIN
Definition: CmmJetSubBlock.h:26
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
LVL1BS::L1CaloSubBlock::clear
void clear()
Clear all data.
Definition: L1CaloSubBlock.cxx:82
LVL1BS::CmmJetSubBlock::s_rightBit
static const int s_rightBit
Definition: CmmJetSubBlock.h:77
LVL1BS::CmmJetSubBlock::s_threshBit
static const int s_threshBit
Definition: CmmJetSubBlock.h:58
LVL1BS::L1CaloSubBlock::packerNeutral
void packerNeutral(int pin, uint32_t datum, int nbits)
Pack given neutral data from given pin.
Definition: L1CaloSubBlock.cxx:413
LVL1BS::CmmJetSubBlock::index
int index(int slice, int source) const
Definition: CmmJetSubBlock.cxx:183
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LVL1BS::CmmJetSubBlock::s_etMapBit
static const int s_etMapBit
Definition: CmmJetSubBlock.h:60
LVL1BS::CmmJetSubBlock::sourceId
int sourceId(uint32_t word) const
Definition: CmmJetSubBlock.h:98
LVL1BS::CmmJetSubBlock::jetEtMap
unsigned int jetEtMap(int slice) const
Return jet ET map.
Definition: CmmJetSubBlock.cxx:88
LVL1BS::L1CaloSubBlock::setGlinkParity
void setGlinkParity(int bit=1)
Set G-Link Parity bit in Sub-status word.
Definition: L1CaloSubBlock.cxx:217
LVL1BS::L1CaloSubBlock::unpackerInit
void unpackerInit()
Initialise unpacker.
Definition: L1CaloSubBlock.cxx:393
LVL1BS::CmmJetSubBlock::CmmJetSubBlock
CmmJetSubBlock()
Definition: CmmJetSubBlock.cxx:37
LVL1BS::CmmJetSubBlock::packNeutral
bool packNeutral()
Pack neutral data.
Definition: CmmJetSubBlock.cxx:203
LVL1BS::CmmSubBlock::timeslices
int timeslices() const
Definition: CmmSubBlock.cxx:48
LVL1BS::L1CaloSubBlock::NEUTRAL
@ NEUTRAL
Definition: L1CaloSubBlock.h:28
LVL1BS::L1CaloSubBlock::UNPACK_SOURCE_ID
@ UNPACK_SOURCE_ID
Definition: L1CaloSubBlock.h:41
CmmJetSubBlock.h
LVL1BS::CmmJetSubBlock::m_hitsData
std::vector< uint32_t > m_hitsData
JEM hits and sums data.
Definition: CmmJetSubBlock.h:94
LVL1BS::L1CaloSubBlock::slice
int slice() const
Definition: L1CaloSubBlock.h:258
LVL1BS::L1CaloSubBlock::packerFlush
void packerFlush()
Flush the current data word padded with zeros.
Definition: L1CaloSubBlock.cxx:331
LVL1BS::L1CaloSubBlock::bunchCrossing
int bunchCrossing() const
Return the Bunch Crossing number (neutral format only)
Definition: L1CaloSubBlock.h:333
LVL1BS::CmmJetSubBlock::unpackNeutral
bool unpackNeutral()
Unpack neutral data.
Definition: CmmJetSubBlock.cxx:254
LVL1BS::CmmJetSubBlock::LOCAL_FORWARD
@ LOCAL_FORWARD
Definition: CmmJetSubBlock.h:27
LVL1BS::CmmJetSubBlock::s_errorMask
static const uint32_t s_errorMask
Definition: CmmJetSubBlock.h:69
LVL1BS::CmmJetSubBlock::s_dataWordIdBit
static const int s_dataWordIdBit
Definition: CmmJetSubBlock.h:63
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
LVL1BS::L1CaloSubBlock::packer
void packer(uint32_t datum, int nbits)
Pack given data into given number of bits.
Definition: L1CaloSubBlock.cxx:302
LVL1BS::CmmJetSubBlock::s_jetHitsErrorBits
static const int s_jetHitsErrorBits
Definition: CmmJetSubBlock.h:73
LVL1BS::CmmJetSubBlock::REMOTE_FORWARD
@ REMOTE_FORWARD
Definition: CmmJetSubBlock.h:27
LVL1BS::CmmJetSubBlock::clear
void clear()
Clear all data.
Definition: CmmJetSubBlock.cxx:47
LVL1BS::CmmJetSubBlock::LOCAL_MAIN
@ LOCAL_MAIN
Definition: CmmJetSubBlock.h:26
perfmonmt-refit.slice
slice
Definition: perfmonmt-refit.py:52
LVL1BS::L1CaloSubBlock::UNPACK_DATA_TRUNCATED
@ UNPACK_DATA_TRUNCATED
Definition: L1CaloSubBlock.h:40
LVL1BS::CmmJetSubBlock::packUncompressed
bool packUncompressed()
Pack uncompressed data.
Definition: CmmJetSubBlock.cxx:242
LVL1BS::L1CaloSubBlock::setDaqOverflow
void setDaqOverflow(int bit=1)
Set DAQ FIFO Overflow bit in Sub-status word.
Definition: L1CaloSubBlock.cxx:206
LVL1BS::CmmJetSubBlock::s_fwdHitsBits
static const int s_fwdHitsBits
Definition: CmmJetSubBlock.h:74
LVL1BS::L1CaloSubBlock::unpackerNeutralParityError
bool unpackerNeutralParityError(int pin)
Unpack and test G-Link parity bit for given pin.
Definition: L1CaloSubBlock.cxx:464
LVL1BS::CmmJetSubBlock::s_sourceIdBit
static const int s_sourceIdBit
Definition: CmmJetSubBlock.h:62
LVL1BS::CmmJetSubBlock::s_paddingBits
static const int s_paddingBits
Definition: CmmJetSubBlock.h:76
LVL1BS::CmmJetSubBlock::jetHits
unsigned int jetHits(int slice, int source) const
Return jet hit counts for given jem or source ID.
Definition: CmmJetSubBlock.cxx:55
LVL1BS::L1CaloSubBlock::format
int format() const
Definition: L1CaloSubBlock.h:248
LVL1BS::CmmJetSubBlock::s_maxHits
static const int s_maxHits
Definition: CmmJetSubBlock.h:65
LVL1BS::L1CaloSubBlock::unpacker
uint32_t unpacker(int nbits)
Unpack given number of bits of data.
Definition: L1CaloSubBlock.cxx:345
LVL1BS::L1CaloSubBlock::daqOverflow
bool daqOverflow() const
Definition: L1CaloSubBlock.h:303
LVL1BS::L1CaloSubBlock::UNPACK_VERSION
@ UNPACK_VERSION
Definition: L1CaloSubBlock.h:38
LVL1BS::CmmJetSubBlock::s_dataWordId
static const int s_dataWordId
Definition: CmmJetSubBlock.h:64
LVL1BS::CmmJetSubBlock::s_threshMask
static const uint32_t s_threshMask
Definition: CmmJetSubBlock.h:66
LVL1BS::CmmJetSubBlock::TOTAL_FORWARD
@ TOTAL_FORWARD
Definition: CmmJetSubBlock.h:27
LVL1BS::CmmJetSubBlock::s_fifoOverflowPin
static const int s_fifoOverflowPin
Definition: CmmJetSubBlock.h:78
LVL1BS::CmmJetSubBlock::unpack
bool unpack()
Unpack data.
Definition: CmmJetSubBlock.cxx:157
LVL1BS::L1CaloSubBlock::version
int version() const
Definition: L1CaloSubBlock.h:243
LVL1BS::CmmJetSubBlock::s_wordLength
static const int s_wordLength
Data word length.
Definition: CmmJetSubBlock.h:56
LVL1BS::CmmJetSubBlock::setJetHits
void setJetHits(int slice, int source, unsigned int hits, int error)
Store jet hit counts and error for given jem or source ID.
Definition: CmmJetSubBlock.cxx:99
LVL1BS::L1CaloSubBlock::unpackerSuccess
bool unpackerSuccess() const
Return unpacker success flag.
Definition: L1CaloSubBlock.h:354
LVL1BS::CmmJetSubBlock::s_sourceIdMask
static const uint32_t s_sourceIdMask
Definition: CmmJetSubBlock.h:70
LVL1BS::CmmJetSubBlock::setJetEtMap
void setJetEtMap(int slice, unsigned int map)
Store jet ET map.
Definition: CmmJetSubBlock.cxx:121
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
LVL1BS::CmmJetSubBlock::unpackUncompressed
bool unpackUncompressed()
Unpack uncompressed data.
Definition: CmmJetSubBlock.cxx:308
LVL1BS::CmmJetSubBlock::s_fwdErrorBit
static const int s_fwdErrorBit
Definition: CmmJetSubBlock.h:59
LVL1BS::CmmJetSubBlock::s_jetHitsBits
static const int s_jetHitsBits
Definition: CmmJetSubBlock.h:72
LVL1BS::CmmJetSubBlock::s_threshErrorBit
static const int s_threshErrorBit
Definition: CmmJetSubBlock.h:61
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
LVL1BS::L1CaloSubBlock::setUnpackErrorCode
void setUnpackErrorCode(int code)
Set the unpacking error code.
Definition: L1CaloSubBlock.h:338
LVL1BS::CmmJetSubBlock::s_bunchCrossingBits
static const int s_bunchCrossingBits
Definition: CmmJetSubBlock.h:75
copySelective.source
string source
Definition: copySelective.py:32
LVL1BS::CmmJetSubBlock::REMOTE_MAIN
@ REMOTE_MAIN
Definition: CmmJetSubBlock.h:26
LVL1BS::L1CaloSubBlock::unpackerNeutral
uint32_t unpackerNeutral(int pin, int nbits)
Unpack given number of bits of neutral data for given pin.
Definition: L1CaloSubBlock.cxx:445
get_generator_info.error
error
Definition: get_generator_info.py:40
LVL1BS::CmmJetSubBlock::s_fwdMask
static const uint32_t s_fwdMask
Definition: CmmJetSubBlock.h:67
LVL1BS::CmmJetSubBlock::~CmmJetSubBlock
~CmmJetSubBlock()
Definition: CmmJetSubBlock.cxx:41
error
Definition: IImpactPoint3dEstimator.h:70
LVL1BS::CmmJetSubBlock::resize
void resize()
Definition: CmmJetSubBlock.cxx:192
LVL1BS::CmmJetSubBlock::s_etMapMask
static const uint32_t s_etMapMask
Definition: CmmJetSubBlock.h:68
LVL1BS::CmmJetSubBlock::pack
bool pack()
Pack data.
Definition: CmmJetSubBlock.cxx:135
keylayer_zslicemap.slices
slices
Definition: keylayer_zslicemap.py:112
LVL1BS::L1CaloSubBlock::UNCOMPRESSED
@ UNCOMPRESSED
Definition: L1CaloSubBlock.h:28
LVL1BS::CmmJetSubBlock::jetHitsError
int jetHitsError(int slice, int source) const
Return jet hit error for given jem or source ID.
Definition: CmmJetSubBlock.cxx:71
LVL1BS::L1CaloSubBlock::UNPACK_FORMAT
@ UNPACK_FORMAT
Definition: L1CaloSubBlock.h:39
LVL1BS::L1CaloSubBlock::packerNeutralParity
void packerNeutralParity(int pin)
Pack current G-Link parity bit for given pin.
Definition: L1CaloSubBlock.cxx:434