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 bool getFB(
CaloType cType,
bool negativeEta, uint32_t cEta, uint32_t iPhi) {
161 uint32_t
index = getFeatureIndex(cType, negativeEta, cEta, iPhi);
166 fb = (getHFFeatureBits(negativeEta, cEta, iPhi) != 0);
170 uint32_t tower = iPhi;
171 if(((cEta - 1) % 2) == 1) {
174 fb = ((data & (0x1 << tower)) != 0);
180 uint32_t
index = getFeatureIndex(
HF, negativeEta, cEta, iPhi);
182 const uint32_t
data = ((myDataPtr[
index] & 0x3FFF) << 8) + (myDataPtr[index - 1] >> 24);
183 uint32_t
shift = (cEta - 30) * 2;
184 if(cEta == 41) shift = 20;
185 return ((data >> shift) & 0x3);
189 uint32_t
index = getFeatureIndex(cType, negativeEta, cEta, iPhi);
195 uint32_t
index = 2 + 2 * 14 * (3 + 3) + 4 * 4 + (region / 2);
196 if(negativeEta) index += 4;
201 uint32_t
index = getSummaryIndex(negativeEta, region);
203 return (data >> (16 * (region % 2)));
207 return (getRegionSummary(negativeEta, region) & 0x3FF);
211 return (getRegionSummary(negativeEta, region) & 0x0400);
215 return (getRegionSummary(negativeEta, region) & 0x0800);
219 return ((getRegionSummary(negativeEta, region) & 0xF000) >> 12);
223 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
224 uint32_t tower = iPhi;
225 if(((cEta - 1) % 2) == 1) tower += 4;
228 if(cEta == 41) tower = 10;
230 return ((linkStatus & (0x1 << tower)) != 0);
234 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
235 return ((linkStatus & 0x00001000) != 0);
239 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
240 return ((linkStatus & 0x00002000) != 0);
244 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
245 return ((linkStatus & 0x00004000) != 0);
249 uint32_t linkStatus = getLinkStatus(cType, negativeEta, cEta, iPhi);
250 return ((linkStatus & 0x00008000) != 0);
255 cout <<
"CTP7 Payload Header:" << endl;
256 cout <<
"No BX per L1A = " <<
dec << nBXPerL1A() << endl;
257 cout <<
"Calo BX ID = " <<
dec << caloLinkBXID() << endl;
259 bool negativeEta =
false;
261 for(uint32_t
i = 0;
i < 2;
i++) {
262 if(
i != 0) negativeEta =
true;
265 for(uint32_t cEta = 1; cEta <= 28; cEta++) {
266 for(uint32_t iPhi = 0; iPhi < 4; iPhi++) {
267 if(getLinkStatus(cType, negativeEta, cEta, iPhi) != 0 ||
268 getET(cType, negativeEta, cEta, iPhi) != 0) {
269 if(
first)
cout <<
"EcalET FG LinkStatus" << endl;
271 cout <<
dec << setfill(
' ') << setw(6) << getET(cType, negativeEta, cEta, iPhi) <<
" "
272 << getFB(cType, negativeEta, cEta, iPhi) <<
" "
273 << showbase <<
internal << setfill(
'0') << setw(10) << hex << getLinkStatus(cType, negativeEta, cEta, iPhi)
274 <<
" (" <<
dec << getIndex(cType, negativeEta, cEta, iPhi) <<
", " << negativeEta <<
", " << cEta <<
", " << iPhi <<
")"
281 for(uint32_t cEta = 1; cEta <= 28; cEta++) {
282 for(uint32_t iPhi = 0; iPhi < 4; iPhi++) {
283 if(getLinkStatus(cType, negativeEta, cEta, iPhi) != 0 ||
284 getET(cType, negativeEta, cEta, iPhi) != 0) {
285 if(
first)
cout <<
"HcalET Feature LinkStatus" << endl;
287 cout <<
dec << setfill(
' ') << setw(6) << getET(cType, negativeEta, cEta, iPhi) <<
" "
288 << getFB(cType, negativeEta, cEta, iPhi) <<
" "
289 << showbase <<
internal << setfill(
'0') << setw(10) << hex << getLinkStatus(cType, negativeEta, cEta, iPhi)
290 <<
" (" <<
dec << getIndex(cType, negativeEta, cEta, iPhi) <<
", " << negativeEta <<
", " << cEta <<
", " << iPhi <<
")"
297 for(uint32_t cEta = 30; cEta <= 40; cEta++) {
298 for(uint32_t iPhi = 0; iPhi < 2; iPhi++) {
299 if(iPhi == 1 && cEta == 40) cEta = 41;
300 if(getLinkStatus(cType, negativeEta, cEta, iPhi) != 0 ||
301 getET(cType, negativeEta, cEta, iPhi) != 0) {
302 if(
first)
cout <<
"HF-ET Feature LinkStatus" << endl;
304 cout <<
dec << setfill(
' ') << setw(6) << getET(cType, negativeEta, cEta, iPhi) <<
" "
305 <<
dec << setfill(
' ') << setw(2) << getHFFeatureBits(negativeEta, cEta, iPhi) <<
" "
306 << showbase <<
internal << setfill(
'0') << setw(10) << hex << getLinkStatus(cType, negativeEta, cEta, iPhi)
307 <<
" (" <<
dec << getIndex(cType, negativeEta, cEta, iPhi) <<
", " << negativeEta <<
", " << cEta <<
", " << iPhi <<
")"
314 if(
first)
cout <<
"Region ET EGVeto TauVeto HitLocation" << endl;
317 <<
dec << setfill(
' ') << setw(8) << getRegionET(negativeEta,
region)
318 <<
" " << getRegionEGVeto(negativeEta,
region)
319 <<
" " << getRegionTauVeto(negativeEta,
region)
320 <<
" " << showbase <<
internal << setfill(
'0') << setw(3) << hex << getRegionHitLocation(negativeEta,
region)
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)
bool getFB(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)