1 #ifndef UCTCTP7RawData_hh
2 #define UCTCTP7RawData_hh
15 if(sof() != 0xA110CA7E) {
16 LogError(
"UCTCTP7RawData") <<
"Failed to see 0xA110CA7E at start - but continuing" << std::endl;
25 const uint32_t *
dataPtr()
const {
return myDataPtr;}
27 uint32_t
sof() {
return myDataPtr[0];}
31 uint32_t
nBXPerL1A() {
return ((myDataPtr[1] & 0x000F0000) >> 16);}
34 uint32_t
index = 0xDEADBEEF;
35 if(cType == EBEE || cType == HBHE) {
37 LogError(
"UCTCTP7RawData") <<
"Incorrect iPhi; iPhi = " << iPhi <<
"; should be in [0,3]" << std::endl;
40 if(cEta < 1 || cEta > 28) {
41 LogError(
"UCTCTP7RawData") <<
"Incorrect caloEta; cEta = " << cEta <<
"; should be in [1-28]" << std::endl;
48 index = 2 + ( ((cEta - 1) / 2) * (3 + 3) + ((cEta - 1) % 2) );
55 index += (6 * (3 + 3));
63 index += ((14 * (3 + 3) + (2 * 4)));
67 if(cType == HBHE) index += 3;
69 else if(cType ==
HF) {
71 LogError(
"UCTCTP7RawData") <<
"HF iPhi should be 0 or 1 (for a , b) - invalid iPhi = " << iPhi << std::endl;
74 if(cEta < 30 || cEta > 41) {
75 LogError(
"UCTCTP7RawData") <<
"HF cEta should be between 30 and 41 - invalid cEta = " << cEta << std::endl;
83 index = 2 + 20 * (3 + 3) + ((cEta - 30) / 4);
87 index = 2 + 20 * (3 + 3) + 1 * 4 + ((cEta - 30) / 4);
93 index = 2 + 2 * 14 * (3 + 3) + 2 * 4 + ((cEta - 30) / 4);
97 index = 2 + 2 * 14 * (3 + 3) + 3 * 4 + ((cEta - 30) / 4);
102 LogError(
"UCTCTP7RawData") <<
"Unknown CaloType " << cType << std::endl;
110 uint32_t
index = getIndex(cType, negativeEta, cEta, iPhi);
111 if(cType == EBEE || cType == HBHE) {
114 if(((cEta - 1) % 2) == 0) {
125 else if(cType ==
HF) {
135 index += (3 - ((cEta - 30) / 4));
143 uint32_t
getET(
CaloType cType,
bool negativeEta, uint32_t cEta, uint32_t iPhi) {
144 uint32_t
index = getIndex(cType, negativeEta, cEta, iPhi);
146 uint32_t et = 0xDEADBEEF;
150 if(cEta == 41) et = ((data >> 16) & 0xFF);
151 else et = ((data >> ((cEta - 30) % 4) * 8) & 0xFF);
155 et = ((data >> (iPhi * 8)) & 0xFF);
160 uint32_t
getFB(
CaloType cType,
bool negativeEta, uint32_t cEta, uint32_t iPhi) {
161 uint32_t
index = getFeatureIndex(cType, negativeEta, cEta, iPhi);
165 fb = getHFFeatureBits(negativeEta, cEta, iPhi);
169 uint32_t tower = iPhi;
170 if(((cEta - 1) % 2) == 1) {
173 fb = ((data & (0x1 << tower)) != 0) ? 1 : 0;
179 uint32_t
index = getFeatureIndex(
HF, negativeEta, cEta, iPhi);
181 const uint32_t
data = ((myDataPtr[
index] & 0x3FFF) << 8) + (myDataPtr[index - 1] >> 24);
182 uint32_t
shift = (cEta - 30) * 2;
183 if(cEta == 41) shift = 20;
184 return ((data >> shift) & 0x3);
188 uint32_t
index = getFeatureIndex(cType, negativeEta, cEta, iPhi);
194 uint32_t
index = 2 + 2 * 14 * (3 + 3) + 4 * 4 + (region / 2);
195 if(negativeEta) index += 4;
200 uint32_t
index = getSummaryIndex(negativeEta, region);
202 return ((data >> (16 * (region % 2))) & 0xFFFF);
206 return (getRegionSummary(negativeEta, region) & 0x3FF);
210 return (getRegionSummary(negativeEta, region) & 0x0400);
214 return (getRegionSummary(negativeEta, region) & 0x0800);
218 return ((getRegionSummary(negativeEta, region) & 0xF000) >> 12);
222 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
223 uint32_t tower = iPhi;
224 if(((cEta - 1) % 2) == 1) tower += 4;
227 if(cEta == 41) tower = 10;
229 return ((linkStatus & (0x1 << tower)) != 0);
233 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
234 return ((linkStatus & 0x00001000) != 0);
238 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
239 return ((linkStatus & 0x00002000) != 0);
243 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
244 return ((linkStatus & 0x00004000) != 0);
248 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
249 return ((linkStatus & 0x00008000) != 0);
254 LogError(
"UCTCTP7RawData") <<
"CTP7 Payload Header:" << endl;
255 LogError(
"UCTCTP7RawData") <<
"No BX per L1A = " <<
dec << nBXPerL1A() << endl;
256 LogError(
"UCTCTP7RawData") <<
"Calo BX ID = " <<
dec << caloLinkBXID() << endl;
258 bool negativeEta =
false;
260 for(uint32_t
i = 0;
i < 2;
i++) {
261 if(
i != 0) negativeEta =
true;
264 for(uint32_t cEta = 1; cEta <= 28; cEta++) {
265 for(uint32_t iPhi = 0; iPhi < 4; iPhi++) {
266 if(getLinkStatus(cType, negativeEta, cEta, iPhi) != 0 ||
267 getET(cType, negativeEta, cEta, iPhi) != 0) {
268 if(
first)
LogError(
"UCTCTP7RawData") <<
"EcalET FG LinkStatus" << endl;
270 LogError(
"UCTCTP7RawData") <<
dec << setfill(
' ') << setw(6) << getET(cType, negativeEta, cEta, iPhi) <<
" "
271 << getFB(cType, negativeEta, cEta, iPhi) <<
" "
272 << showbase <<
internal << setfill(
'0') << setw(10) << hex << getLinkStatus(cType, negativeEta, cEta, iPhi)
273 <<
" (" <<
dec << getIndex(cType, negativeEta, cEta, iPhi) <<
", " << negativeEta <<
", " << cEta <<
", " << iPhi <<
")"
280 for(uint32_t cEta = 1; cEta <= 28; cEta++) {
281 for(uint32_t iPhi = 0; iPhi < 4; iPhi++) {
282 if(getLinkStatus(cType, negativeEta, cEta, iPhi) != 0 ||
283 getET(cType, negativeEta, cEta, iPhi) != 0) {
284 if(
first)
LogError(
"UCTCTP7RawData") <<
"HcalET Feature LinkStatus" << endl;
286 LogError(
"UCTCTP7RawData") <<
dec << setfill(
' ') << setw(6) << getET(cType, negativeEta, cEta, iPhi) <<
" "
287 << getFB(cType, negativeEta, cEta, iPhi) <<
" "
288 << showbase <<
internal << setfill(
'0') << setw(10) << hex << getLinkStatus(cType, negativeEta, cEta, iPhi)
289 <<
" (" <<
dec << getIndex(cType, negativeEta, cEta, iPhi) <<
", " << negativeEta <<
", " << cEta <<
", " << iPhi <<
")"
296 for(uint32_t cEta = 30; cEta <= 40; cEta++) {
297 for(uint32_t iPhi = 0; iPhi < 2; iPhi++) {
298 if(iPhi == 1 && cEta == 40) cEta = 41;
299 if(getLinkStatus(cType, negativeEta, cEta, iPhi) != 0 ||
300 getET(cType, negativeEta, cEta, iPhi) != 0) {
301 if(
first)
LogError(
"UCTCTP7RawData") <<
"HF-ET Feature LinkStatus" << endl;
303 LogError(
"UCTCTP7RawData") <<
dec << setfill(
' ') << setw(6) << getET(cType, negativeEta, cEta, iPhi) <<
" "
304 <<
dec << setfill(
' ') << setw(2) << getHFFeatureBits(negativeEta, cEta, iPhi) <<
" "
305 << showbase <<
internal << setfill(
'0') << setw(10) << hex << getLinkStatus(cType, negativeEta, cEta, iPhi)
306 <<
" (" <<
dec << getIndex(cType, negativeEta, cEta, iPhi) <<
", " << negativeEta <<
", " << cEta <<
", " << iPhi <<
")"
313 if(
first)
LogError(
"UCTCTP7RawData") <<
"Region ET EGVeto TauVeto HitLocation" << endl;
316 <<
" " << hex << showbase <<
internal << setfill(
'0') << setw(6) << getRegionET(negativeEta,
region) <<
dec
317 <<
" " << getRegionEGVeto(negativeEta,
region)
318 <<
" " << getRegionTauVeto(negativeEta,
region)
319 <<
" " << showbase <<
internal << setfill(
'0') << setw(3) << hex << getRegionHitLocation(negativeEta,
region)
uint32_t getFB(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool getRegionTauVeto(bool negativeEta, uint32_t region)
uint32_t getSummaryIndex(bool negativeEta, uint32_t region)
uint32_t getHFFeatureBits(bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isLinkMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
const uint32_t * myDataPtr
bool isLinkDown(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool getRegionEGVeto(bool negativeEta, uint32_t region)
bool isLinkInError(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isTowerMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
uint32_t getLinkStatus(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
uint32_t getIndex(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
UCTCTP7RawData(const uint32_t *d)
uint32_t getRegionET(bool negativeEta, uint32_t region)
uint32_t getET(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
const uint32_t * dataPtr() const
static unsigned int const shift
virtual ~UCTCTP7RawData()
T first(std::pair< T, U > const &p)
uint32_t getRegionSummary(bool negativeEta, uint32_t region)
uint32_t getRegionHitLocation(bool negativeEta, uint32_t region)
uint32_t getFeatureIndex(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isLinkMisaligned(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)