ATLAS Offline Software
Loading...
Searching...
No Matches
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
10namespace LVL1BS {
11
12// Constant definitions
13
15
21
22
26
30
31// Clear all data
32
34{
36 m_roiData.clear();
37}
38
39// Store header
40
41void 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
62LVL1::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);
120 packerNeutral(pin, roi.error(), s_errorLen);
121 packerNeutral(pin, roi.location(), s_locationLen);
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
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
static Double_t rc
std::vector< LVL1::CPMRoI > m_roiData
RoI words.
void clear()
Clear all data.
bool unpackNeutral()
Unpack neutral data.
static const int s_glinkPins
static const int s_locationLen
bool unpack()
Unpack data.
void fillRoi(LVL1::CPMRoI roi)
Store RoI.
void setRoiHeader(int version, int crate, int module)
Store header.
static const int s_bunchCrossingBits
bool packNeutral()
Pack neutral data.
static const int s_wordIdVal
Header word ID.
static const int s_hitsLen
static const int s_errorLen
LVL1::CPMRoI roi(int chip, int loc) const
Return RoI for given chip and location (left/right)
void setUnpackErrorCode(int code)
Set the unpacking error code.
bool unpackerSuccess() const
Return unpacker success flag.
void setHeader(int wordId, int version, int format, int seqno, int crate, int module, int slices2, int slices1)
Store header data.
bool unpackerNeutralParityError(int pin)
Unpack and test G-Link parity bit for given pin.
void clear()
Clear all data.
void packerNeutralParity(int pin)
Pack current G-Link parity bit for given pin.
uint32_t unpackerNeutral(int pin, int nbits)
Unpack given number of bits of neutral data for given pin.
int bunchCrossing() const
Return the Bunch Crossing number (neutral format only)
void packerNeutral(int pin, uint32_t datum, int nbits)
Pack given neutral data from given pin.
void setBunchCrossing(int bc)
Set the Bunch Crossing number (neutral format only)
int crate() const
Return crate number (0-1)
int cpm() const
Return CPM number (1-14)