ATLAS Offline Software
JemRoiSubBlockV1.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 
7 
8 #include "JemRoiSubBlockV1.h"
9 
10 namespace LVL1BS {
11 
12 // Constant definitions
13 
15 
24 
25 
27 {
28 }
29 
31 {
32 }
33 
34 // Clear all data
35 
37 {
39  m_roiData.clear();
40 }
41 
42 // Store header
43 
44 void JemRoiSubBlockV1::setRoiHeader(const int version, const int crate,
45  const int module)
46 {
48 }
49 
50 // Store RoI
51 
53 {
54  const LVL1::JEMRoI roiTemp(crate(), module(), 0, 0, 0, 0, 0);
55  if (roi.crate() == roiTemp.crate() && roi.jem() == roiTemp.jem()) {
56  m_roiData.resize(2*s_frames);
57  const int pos = roi.frame() + roi.forward()*s_frames;
58  m_roiData[pos] = roi;
59  }
60 }
61 
62 // Return RoI for given frame and forward
63 
64 LVL1::JEMRoI JemRoiSubBlockV1::roi(const int frame, const int forward) const
65 {
66  const int pos = frame + forward*s_frames;
67  if (pos >= 0 && pos < 2*s_frames && !m_roiData.empty()) {
68  return m_roiData[pos];
69  } else return LVL1::JEMRoI(0);
70 }
71 
72 // Packing/Unpacking routines
73 
75 {
76  bool rc = false;
77  switch (version()) {
78  case 1:
79  switch (format()) {
80  case NEUTRAL:
81  rc = packNeutral();
82  break;
83  default:
84  break;
85  }
86  break;
87  default:
88  break;
89  }
90  return rc;
91 }
92 
94 {
95  bool rc = false;
96  switch (version()) {
97  case 1:
98  switch (format()) {
99  case NEUTRAL:
100  rc = unpackNeutral();
101  break;
102  default:
104  break;
105  }
106  break;
107  default:
109  break;
110  }
111  return rc;
112 }
113 
114 // Pack neutral data
115 
117 {
118  m_roiData.resize(2*s_frames);
119  int maxPin = 0;
120  // RoI data
121  for (int pos = 0; pos < 2*s_frames; ++pos) {
122  const LVL1::JEMRoI& roi(m_roiData[pos]);
123  int pin = pos/s_framesPerPin;
124  if (pin >= s_bunchCrossingPin) ++pin; // forward rois
125  packerNeutral(pin, roi.hits(), s_hitsBits);
128  maxPin = pin;
129  }
130  // Bunch Crossing number
133  // G-Link parity
134  for (int pin = 0; pin <= maxPin; ++pin) packerNeutralParity(pin);
135 
136  return true;
137 }
138 
139 // Unpack neutral data
140 
142 {
143  m_roiData.resize(2*s_frames);
144  int maxPin = 0;
145  int forward = 0;
146  int parity = 0;
147  // RoI data
148  for (int pos = 0; pos < 2*s_frames; ++pos) {
149  int pin = pos/s_framesPerPin;
150  if (pin >= s_bunchCrossingPin) {
151  ++pin;
152  forward = 1;
153  }
154  const int hits = unpackerNeutral(pin, s_hitsBits);
155  const int sat = unpackerNeutral(pin, s_saturationBits);
156  const int loc = unpackerNeutral(pin, s_locationBits);
157  const int err = (parity << 1) | sat;
159  forward, hits, err);
160  maxPin = pin;
161  }
162  // Bunch Crossing number
165  // G-Link parity
166  parity = 1;
167  for (int pin = 0; pin <= maxPin; ++pin) {
168  const bool error = unpackerNeutralParityError(pin);
169  if (pin == s_bunchCrossingPin) continue;
170  if (error) {
171  for (int frame = 0; frame < s_framesPerPin; ++frame) {
172  int pos = pin * s_framesPerPin + frame;
173  if (pin > s_bunchCrossingPin) pos -= s_framesPerPin;
174  const LVL1::JEMRoI roi = m_roiData[pos];
175  const int err = (parity << 1) | roi.error();
177  roi.location(), roi.forward(),
178  roi.hits(), err);
179  }
180  }
181  }
182  const bool rc = unpackerSuccess();
184  return rc;
185 }
186 
187 } // end namespace
LVL1BS::L1CaloSubBlock::setBunchCrossing
void setBunchCrossing(int bc)
Set the Bunch Crossing number (neutral format only)
Definition: L1CaloSubBlock.h:328
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
LVL1BS::L1CaloSubBlock::clear
void clear()
Clear all data.
Definition: L1CaloSubBlock.cxx:82
LVL1BS::L1CaloSubBlock::packerNeutral
void packerNeutral(int pin, uint32_t datum, int nbits)
Pack given neutral data from given pin.
Definition: L1CaloSubBlock.cxx:413
LVL1BS::JemRoiSubBlockV1::s_bunchCrossingBits
static const int s_bunchCrossingBits
Definition: JemRoiSubBlockV1.h:58
LVL1BS::JemRoiSubBlockV1::unpackNeutral
bool unpackNeutral()
Unpack neutral data.
Definition: JemRoiSubBlockV1.cxx:141
LVL1BS::JemRoiSubBlockV1::s_locationBits
static const int s_locationBits
Definition: JemRoiSubBlockV1.h:56
LVL1::JEMRoI::location
int location() const
Return location (RoI local coords) (0-3)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:102
LVL1::JEMRoI::forward
int forward() const
Return forward jet flag (0/1)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:107
LVL1BS::JemRoiSubBlockV1::JemRoiSubBlockV1
JemRoiSubBlockV1()
Definition: JemRoiSubBlockV1.cxx:26
LVL1BS::L1CaloSubBlock::NEUTRAL
@ NEUTRAL
Definition: L1CaloSubBlock.h:28
LVL1BS::L1CaloSubBlock::setHeader
void setHeader(int wordId, int version, int format, int seqno, int crate, int module, int slices2, int slices1)
Store header data.
Definition: L1CaloSubBlock.cxx:99
LVL1BS::JemRoiSubBlockV1::s_frames
static const int s_frames
Definition: JemRoiSubBlockV1.h:52
LVL1BS::L1CaloSubBlock::bunchCrossing
int bunchCrossing() const
Return the Bunch Crossing number (neutral format only)
Definition: L1CaloSubBlock.h:333
LVL1BS::L1CaloSubBlock::crate
int crate() const
Definition: L1CaloSubBlock.h:263
python.PyAthena.module
module
Definition: PyAthena.py:131
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
LVL1::JEMRoI::error
int error() const
Return error flags (bit 0 Saturation, bit 1 Parity)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:112
LVL1BS::L1CaloSubBlock::UNPACK_DATA_TRUNCATED
@ UNPACK_DATA_TRUNCATED
Definition: L1CaloSubBlock.h:40
LVL1::JEMRoI::hits
int hits() const
Return Jet hit map (8 bits Main or 4 bits Forward)
Definition: JEMRoI.cxx:64
LVL1BS::L1CaloSubBlock::unpackerNeutralParityError
bool unpackerNeutralParityError(int pin)
Unpack and test G-Link parity bit for given pin.
Definition: L1CaloSubBlock.cxx:464
LVL1BS::L1CaloSubBlock::format
int format() const
Definition: L1CaloSubBlock.h:248
LVL1BS::JemRoiSubBlockV1::roi
LVL1::JEMRoI roi(int frame, int forward) const
Return RoI for given frame and forward.
Definition: JemRoiSubBlockV1.cxx:64
LVL1BS::JemRoiSubBlockV1::s_wordIdVal
static const int s_wordIdVal
Header word ID.
Definition: JemRoiSubBlockV1.h:50
LVL1BS::L1CaloSubBlock::UNPACK_VERSION
@ UNPACK_VERSION
Definition: L1CaloSubBlock.h:38
LVL1BS::JemRoiSubBlockV1::unpack
bool unpack()
Unpack data.
Definition: JemRoiSubBlockV1.cxx:93
LVL1BS::L1CaloSubBlock::version
int version() const
Definition: L1CaloSubBlock.h:243
LVL1BS::JemRoiSubBlockV1::fillRoi
void fillRoi(LVL1::JEMRoI roi)
Store RoI.
Definition: JemRoiSubBlockV1.cxx:52
LVL1::JEMRoI::crate
int crate() const
Return crate number (0-1)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:87
LVL1BS::L1CaloSubBlock::unpackerSuccess
bool unpackerSuccess() const
Return unpacker success flag.
Definition: L1CaloSubBlock.h:354
JEMRoI.h
LVL1BS::JemRoiSubBlockV1::m_roiData
std::vector< LVL1::JEMRoI > m_roiData
RoIs.
Definition: JemRoiSubBlockV1.h:67
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
LVL1BS::L1CaloSubBlock::module
int module() const
Definition: L1CaloSubBlock.h:268
get_generator_info.version
version
Definition: get_generator_info.py:33
LVL1BS::JemRoiSubBlockV1::s_saturationBits
static const int s_saturationBits
Definition: JemRoiSubBlockV1.h:57
LVL1BS::JemRoiSubBlockV1::pack
bool pack()
Pack data.
Definition: JemRoiSubBlockV1.cxx:74
LVL1BS::JemRoiSubBlockV1::s_bunchCrossingPin
static const int s_bunchCrossingPin
Definition: JemRoiSubBlockV1.h:54
LVL1BS::JemRoiSubBlockV1::s_paddingBits
static const int s_paddingBits
Definition: JemRoiSubBlockV1.h:59
LVL1::JEMRoI::jem
int jem() const
Return JEM number (0-15)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:92
LVL1BS
Definition: ZdcModifySlices.h:10
LVL1BS::JemRoiSubBlockV1::s_framesPerPin
static const int s_framesPerPin
Definition: JemRoiSubBlockV1.h:53
JemRoiSubBlockV1.h
LVL1BS::JemRoiSubBlockV1::~JemRoiSubBlockV1
~JemRoiSubBlockV1()
Definition: JemRoiSubBlockV1.cxx:30
LVL1BS::L1CaloSubBlock::setUnpackErrorCode
void setUnpackErrorCode(int code)
Set the unpacking error code.
Definition: L1CaloSubBlock.h:338
LVL1::JEMRoI
JEM RoI data.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:19
LVL1BS::JemRoiSubBlockV1::setRoiHeader
void setRoiHeader(int version, int crate, int module)
Store header.
Definition: JemRoiSubBlockV1.cxx:44
LVL1BS::JemRoiSubBlockV1::s_hitsBits
static const int s_hitsBits
Definition: JemRoiSubBlockV1.h:55
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
LVL1BS::JemRoiSubBlockV1::clear
void clear()
Clear all data.
Definition: JemRoiSubBlockV1.cxx:36
LVL1BS::JemRoiSubBlockV1::packNeutral
bool packNeutral()
Pack neutral data.
Definition: JemRoiSubBlockV1.cxx:116
error
Definition: IImpactPoint3dEstimator.h:70
LVL1::JEMRoI::frame
int frame() const
Return RoI frame number (0-7)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:97
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
xAOD::JEMRoI
JEMRoI_v1 JEMRoI
Define the latest version of the JEMRoI class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/JEMRoI.h:14