ATLAS Offline Software
CpmRoiSubBlock.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 "CpmRoiSubBlock.h"
9 
10 namespace LVL1BS {
11 
12 // Constant definitions
13 
15 
21 
22 
24 {
25 }
26 
28 {
29 }
30 
31 // Clear all data
32 
34 {
36  m_roiData.clear();
37 }
38 
39 // Store header
40 
41 void CpmRoiSubBlock::setRoiHeader(const int version, const int crate,
42  const int module)
43 {
45 }
46 
47 // Store RoI
48 
50 {
51  const LVL1::CPMRoI roiTemp(crate(), module(), 0, 0, 0, 0);
52  if (roi.crate() == roiTemp.crate() && roi.cpm() == roiTemp.cpm()) {
53  m_roiData.resize(s_glinkPins);
54  const int pin = (roi.chip() << 1) |
55  ((roi.location() >> s_locationLen) & 0x1);
56  m_roiData[pin] = roi;
57  }
58 }
59 
60 // Return RoI for given chip and location (left/right)
61 
62 LVL1::CPMRoI CpmRoiSubBlock::roi(const int chip, const int loc) const
63 {
64  const int pin = (chip << 1) | (loc & 0x1);
65  if (pin < s_glinkPins && !m_roiData.empty()) return m_roiData[pin];
66  else return LVL1::CPMRoI(0);
67 }
68 
69 // Packing/Unpacking routines
70 
72 {
73  bool rc = false;
74  switch (version()) {
75  case 1:
76  switch (format()) {
77  case NEUTRAL:
78  rc = packNeutral();
79  break;
80  default:
81  break;
82  }
83  break;
84  default:
85  break;
86  }
87  return rc;
88 }
89 
91 {
92  bool rc = false;
93  switch (version()) {
94  case 1:
95  switch (format()) {
96  case NEUTRAL:
97  rc = unpackNeutral();
98  break;
99  default:
101  break;
102  }
103  break;
104  default:
106  break;
107  }
108  return rc;
109 }
110 
111 // Pack neutral data
112 
114 {
115  m_roiData.resize(s_glinkPins);
116  for (int pin = 0; pin < s_glinkPins; ++pin) {
117  // RoI data
118  const LVL1::CPMRoI& roi(m_roiData[pin]);
119  packerNeutral(pin, roi.hits(), s_hitsLen);
122  // Bunch Crossing number
123  if (pin < s_bunchCrossingBits) {
124  packerNeutral(pin, bunchCrossing() >> pin, 1);
125  } else packerNeutral(pin, 0, 1);
126  // G-Link parity
127  packerNeutralParity(pin);
128  }
129  return true;
130 }
131 
132 // Unpack neutral data
133 
135 {
136  m_roiData.resize(s_glinkPins);
137  int bunchCrossing = 0;
138  for (int pin = 0; pin < s_glinkPins; ++pin) {
139  // RoI data
140  const int hits = unpackerNeutral(pin, s_hitsLen);
141  const int error = unpackerNeutral(pin, s_errorLen);
142  const int loc = unpackerNeutral(pin, s_locationLen) |
143  ((pin & 0x1) << s_locationLen);
144  const int chip = pin >> 1;
145  m_roiData[pin] = LVL1::CPMRoI(crate(), module(), chip, loc, hits, error);
146  // Bunch Crossing number
147  if (pin < s_bunchCrossingBits) {
148  bunchCrossing |= unpackerNeutral(pin, 1) << pin;
149  } else unpackerNeutral(pin, 1);
150  // G-Link parity error
152  }
154  const bool rc = unpackerSuccess();
156  return rc;
157 }
158 
159 } // end namespace
LVL1BS::L1CaloSubBlock::setBunchCrossing
void setBunchCrossing(int bc)
Set the Bunch Crossing number (neutral format only)
Definition: L1CaloSubBlock.h:328
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
LVL1::CPMRoI::location
int location() const
Return location (RoI local coords) (0-7)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:96
LVL1BS::CpmRoiSubBlock::m_roiData
std::vector< LVL1::CPMRoI > m_roiData
RoI words.
Definition: CpmRoiSubBlock.h:64
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
LVL1::CPMRoI::chip
int chip() const
Return CP chip number (0-7)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:91
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::CpmRoiSubBlock::unpack
bool unpack()
Unpack data.
Definition: CpmRoiSubBlock.cxx:90
LVL1BS::CpmRoiSubBlock::packNeutral
bool packNeutral()
Pack neutral data.
Definition: CpmRoiSubBlock.cxx:113
LVL1BS::CpmRoiSubBlock::s_bunchCrossingBits
static const int s_bunchCrossingBits
Definition: CpmRoiSubBlock.h:56
LVL1BS::CpmRoiSubBlock::s_wordIdVal
static const int s_wordIdVal
Header word ID.
Definition: CpmRoiSubBlock.h:50
LVL1BS::CpmRoiSubBlock::~CpmRoiSubBlock
~CpmRoiSubBlock()
Definition: CpmRoiSubBlock.cxx:27
LVL1BS::CpmRoiSubBlock::roi
LVL1::CPMRoI roi(int chip, int loc) const
Return RoI for given chip and location (left/right)
Definition: CpmRoiSubBlock.cxx:62
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::CpmRoiSubBlock::s_errorLen
static const int s_errorLen
Definition: CpmRoiSubBlock.h:54
LVL1::CPMRoI::hits
int hits() const
Return hit thresholds map.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:101
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
LVL1BS::CpmRoiSubBlock::s_locationLen
static const int s_locationLen
Definition: CpmRoiSubBlock.h:55
python.PyAthena.module
module
Definition: PyAthena.py:131
CpmRoiSubBlock.h
LVL1::CPMRoI::cpm
int cpm() const
Return CPM number (1-14)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:86
LVL1BS::L1CaloSubBlock::UNPACK_DATA_TRUNCATED
@ UNPACK_DATA_TRUNCATED
Definition: L1CaloSubBlock.h:40
LVL1BS::CpmRoiSubBlock::clear
void clear()
Clear all data.
Definition: CpmRoiSubBlock.cxx:33
LVL1BS::CpmRoiSubBlock::s_hitsLen
static const int s_hitsLen
Definition: CpmRoiSubBlock.h:53
LVL1BS::CpmRoiSubBlock::CpmRoiSubBlock
CpmRoiSubBlock()
Definition: CpmRoiSubBlock.cxx:23
LVL1BS::L1CaloSubBlock::unpackerNeutralParityError
bool unpackerNeutralParityError(int pin)
Unpack and test G-Link parity bit for given pin.
Definition: L1CaloSubBlock.cxx:464
LVL1::CPMRoI
CPM RoI data.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:20
LVL1BS::L1CaloSubBlock::format
int format() const
Definition: L1CaloSubBlock.h:248
LVL1BS::L1CaloSubBlock::UNPACK_VERSION
@ UNPACK_VERSION
Definition: L1CaloSubBlock.h:38
LVL1::CPMRoI::error
int error() const
Return error flags (bit 0 Saturation, bit 1 Parity)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:106
CPMRoI.h
LVL1BS::L1CaloSubBlock::version
int version() const
Definition: L1CaloSubBlock.h:243
LVL1BS::L1CaloSubBlock::unpackerSuccess
bool unpackerSuccess() const
Return unpacker success flag.
Definition: L1CaloSubBlock.h:354
LVL1BS::CpmRoiSubBlock::pack
bool pack()
Pack data.
Definition: CpmRoiSubBlock.cxx:71
LVL1BS::L1CaloSubBlock::module
int module() const
Definition: L1CaloSubBlock.h:268
get_generator_info.version
version
Definition: get_generator_info.py:33
LVL1BS::CpmRoiSubBlock::fillRoi
void fillRoi(LVL1::CPMRoI roi)
Store RoI.
Definition: CpmRoiSubBlock.cxx:49
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
LVL1BS::L1CaloSubBlock::setUnpackErrorCode
void setUnpackErrorCode(int code)
Set the unpacking error code.
Definition: L1CaloSubBlock.h:338
LVL1BS::CpmRoiSubBlock::s_glinkPins
static const int s_glinkPins
Definition: CpmRoiSubBlock.h:52
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::CpmRoiSubBlock::setRoiHeader
void setRoiHeader(int version, int crate, int module)
Store header.
Definition: CpmRoiSubBlock.cxx:41
error
Definition: IImpactPoint3dEstimator.h:70
LVL1::CPMRoI::crate
int crate() const
Return crate number (0-1)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:81
xAOD::CPMRoI
CPMRoI_v1 CPMRoI
Define the latest version of the CPMRoI class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMRoI.h:14
LVL1BS::CpmRoiSubBlock::unpackNeutral
bool unpackNeutral()
Unpack neutral data.
Definition: CpmRoiSubBlock.cxx:134
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