ATLAS Offline Software
Loading...
Searching...
No Matches
JemRoiSubBlockV2.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 "JemRoiSubBlockV2.h"
9
10namespace LVL1BS {
11
12// Constant definitions
13
15
24
25
29
33
34// Clear all data
35
41
42// Store header
43
45 const int module)
46{
48}
49
50// Store RoI
51
53{
54 const LVL1::JEMTobRoI roiTemp(crate(), module(), 0, 0, 0, 0);
55 if (roi.crate() == roiTemp.crate() && roi.jem() == roiTemp.jem()) {
56 m_roiData.resize(s_frames);
57 const int pos = roi.frame();
58 m_roiData[pos] = roi;
59 }
60}
61
62// Return RoI for given frame
63
65{
66 if (frame >= 0 && frame < s_frames && !m_roiData.empty()) {
67 return m_roiData[frame];
68 } else return LVL1::JEMTobRoI(0);
69}
70
71// Packing/Unpacking routines
72
74{
75 bool rc = false;
76 switch (version()) {
77 case 1: //<< CHECK
78 switch (format()) {
79 case NEUTRAL:
80 rc = packNeutral();
81 break;
82 default:
83 break;
84 }
85 break;
86 default:
87 break;
88 }
89 return rc;
90}
91
93{
94 bool rc = false;
95 switch (version()) {
96 case 2: //<< CHECK
97 switch (format()) {
98 case NEUTRAL:
99 rc = unpackNeutral();
100 break;
101 default:
103 break;
104 }
105 break;
106 default:
108 break;
109 }
110 return rc;
111}
112
113// Pack neutral data
114
116{
117 m_roiData.resize(s_frames);
118 int maxPin = 0;
119 // RoI data
120 for (int frame = 0; frame < s_frames; ++frame) {
121 const LVL1::JEMTobRoI& roi(m_roiData[frame]);
122 const int pin1 = frame / s_framesPerPin;
123 const int pin2 = s_bunchCrossingPin + pin1 + 1;
124 packerNeutral(pin1, roi.energyLarge(), s_energyLargeBits);
125 packerNeutral(pin1, 0, 1);
126 packerNeutral(pin2, roi.energySmall(), s_energySmallBits);
127 packerNeutral(pin2, roi.location(), s_locationBits);
128 maxPin = pin2;
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(s_frames);
144 int maxPin = 0;
145 // RoI data
146 for (int frame = 0; frame < s_frames; ++frame) {
147 const int pin1 = frame / s_framesPerPin;
148 const int pin2 = s_bunchCrossingPin + pin1 + 1;
149 const int enLarge = unpackerNeutral(pin1, s_energyLargeBits);
150 unpackerNeutral(pin1, 1);
151 const int enSmall = unpackerNeutral(pin2, s_energySmallBits);
152 const int loc = unpackerNeutral(pin2, s_locationBits);
154 frame, loc, enLarge, enSmall);
155 maxPin = pin2;
156 }
157 // Bunch Crossing number
160 // G-Link parity
161 for (int pin = 0; pin <= maxPin; ++pin) unpackerNeutralParityError(pin);
162 const bool rc = unpackerSuccess();
164 return rc;
165}
166
167} // end namespace
static Double_t rc
static const int s_energySmallBits
static const int s_framesPerPin
static const int s_wordIdVal
Header word ID.
static const int s_bunchCrossingPin
void clear()
Clear all data.
LVL1::JEMTobRoI roi(int frame) const
Return RoI for given frame.
static const int s_paddingBits
static const int s_bunchCrossingBits
static const int s_locationBits
void fillRoi(LVL1::JEMTobRoI roi)
Store RoI.
bool unpackNeutral()
Unpack neutral data.
bool packNeutral()
Pack neutral data.
void setRoiHeader(int version, int crate, int module)
Store header.
std::vector< LVL1::JEMTobRoI > m_roiData
RoIs.
static const int s_energyLargeBits
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)