File indexing completed on 2024-04-06 12:10:42
0001
0002 #ifndef HcalDTCHeader_H
0003 #define HcalDTCHeader_H
0004
0005 #include <iostream>
0006 #include <cstdint>
0007 #include "DataFormats/HcalDigi/interface/HcalCalibrationEventTypes.h"
0008 class HcalHTRData;
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 class HcalDTCHeader {
0019 public:
0020 static const int SLOT_COUNT;
0021 static const int MINIMUM_SLOT;
0022 static const int MAXIMUM_SLOT;
0023
0024 HcalDTCHeader();
0025
0026
0027 unsigned int getTotalLengthBytes() const;
0028
0029
0030
0031 inline bool thereIsASecondCDFHeaderWord() const { return ((commondataformat0 >> 3) & 0x0001); }
0032
0033 inline short getCDFversionNumber() const { return ((commondataformat0 >> 4) & 0x0F); }
0034
0035 inline int getSourceId() const { return (commondataformat0 >> 8) & 0xFFF; }
0036
0037 inline int getBunchId() const { return (commondataformat0 >> 20) & 0xFFF; }
0038
0039 inline unsigned long getDTCEventNumber() const { return (commondataformat1 & 0x00FFFFFF); }
0040
0041 inline unsigned short getCDFEventType() const { return ((commondataformat1 >> 24) & 0x0F); }
0042
0043 inline unsigned short BOEshouldBe5Always() const { return ((commondataformat1 >> 28) & 0x0F); }
0044
0045
0046
0047 inline bool thereIsAThirdCDFHeaderWord() const { return ((commondataformat2 >> 3) & 0x0001); }
0048
0049 inline unsigned int getOrbitNumber() const { return (((commondataformat3 & 0xF) << 28) + (commondataformat2 >> 4)); }
0050
0051 inline unsigned int getSlink64ReservedBits() const { return ((commondataformat3 >> 4) & 0x00FFFFFF); }
0052
0053 inline short BOEshouldBeZeroAlways() const { return ((commondataformat3 >> 28) & 0x0F); }
0054
0055
0056 inline bool isCalibType() const { return (0 != getCalibType()); }
0057 inline HcalCalibrationEventType getCalibType() const {
0058 return HcalCalibrationEventType((commondataformat3 >> 24) & 0x0000000F);
0059 }
0060
0061
0062 inline short getDTCDataFormatVersion() const { return (dcch0 & 0xFF); }
0063 inline int nSlotWords() const { return ((dcch0 >> 20) & 0x0000000F); }
0064 inline int nDTCWords() const { return ((dcch0 >> 8) & 0x00000FFF); }
0065
0066
0067 inline int getSlotSummary(int nslot) const { return slotInfo[nslot]; }
0068
0069
0070
0071
0072
0073 int getSlotData(int nslot, HcalHTRData& decodeTool, int validSize) const;
0074
0075
0076 inline unsigned int getSlotDataLength(int nslot) const {
0077 return (nslot < 1 || nslot > 12) ? (0) : (slotInfo[nslot - 1] & 0xfff);
0078 }
0079
0080
0081 inline bool getSlotEnabled(unsigned int nslot) const {
0082 return (nslot < 1 || nslot > 12) ? (false) : (slotInfo[nslot - 1] & 0x8000);
0083 }
0084
0085 inline bool getSlotPresent(unsigned int nslot) const {
0086 return (nslot < 1 || nslot > 12) ? (false) : (slotInfo[nslot - 1] & 0x4000);
0087 }
0088
0089 inline bool getSlotValid(unsigned int nslot) const {
0090 return (nslot < 1 || nslot > 12) ? (false) : (slotInfo[nslot - 1] & 0x2000);
0091 }
0092
0093 inline bool getSlotCRCError(unsigned int nslot) const {
0094 return (nslot < 1 || nslot > 12) ? (false) : (slotInfo[nslot - 1] & 0x1000);
0095 }
0096
0097
0098
0099
0100
0101
0102
0103
0104 void copySlotData(unsigned int slot_id, const HcalHTRData& data, bool valid = true);
0105
0106
0107 void clear();
0108
0109 void setHeader(int sourceid, int bcn, int l1aN, int orbN);
0110
0111 private:
0112
0113 uint32_t commondataformat0;
0114 uint32_t commondataformat1;
0115 uint32_t commondataformat2;
0116 uint32_t commondataformat3;
0117 uint32_t dcch0;
0118 uint32_t dcch1;
0119 uint16_t slotInfo[12];
0120 };
0121
0122 std::ostream& operator<<(std::ostream&, const HcalDTCHeader& head);
0123
0124 #endif