File indexing completed on 2024-04-06 12:04:01
0001 #ifndef CTPPSDigi_TotemTimingEventInfo_h
0002 #define CTPPSDigi_TotemTimingEventInfo_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <cstdint>
0015 #include <bitset>
0016
0017 class TotemTimingEventInfo {
0018 public:
0019 TotemTimingEventInfo(const uint8_t hwId,
0020 const uint64_t l1ATimestamp,
0021 const uint16_t bunchNumber,
0022 const uint32_t orbitNumber,
0023 const uint32_t eventNumber,
0024 const uint16_t channelMap,
0025 const uint16_t l1ALatency,
0026 const uint8_t numberOfSamples,
0027 const uint8_t offsetOfSamples,
0028 const uint8_t pllInfo);
0029 TotemTimingEventInfo();
0030
0031
0032 bool operator==(const TotemTimingEventInfo& eventInfo) const;
0033
0034
0035
0036
0037 inline unsigned int hardwareId() const { return hwId_; }
0038
0039 inline unsigned int hardwareBoardId() const { return (hwId_ & 0xE0) >> 5; }
0040
0041 inline unsigned int hardwareSampicId() const { return (hwId_ & 0x10) >> 4; }
0042
0043 inline unsigned int hardwareChannelId() const { return (hwId_ & 0x0F); }
0044
0045 inline unsigned int l1ATimestamp() const { return l1ATimestamp_; }
0046
0047 inline unsigned int bunchNumber() const { return bunchNumber_; }
0048
0049 inline unsigned int orbitNumber() const { return orbitNumber_; }
0050
0051 inline unsigned int eventNumber() const { return eventNumber_; }
0052
0053 inline uint16_t channelMap() const { return channelMap_; }
0054
0055 inline unsigned int l1ALatency() const { return l1ALatency_; }
0056
0057 inline unsigned int numberOfSamples() const { return numberOfSamples_; }
0058
0059 inline unsigned int offsetOfSamples() const { return offsetOfSamples_; }
0060
0061 inline uint8_t pllInfo() const { return pllInfo_; }
0062
0063
0064
0065 inline void setHardwareId(const uint8_t hwId) { hwId_ = hwId; }
0066
0067 inline void setHardwareBoardId(const unsigned int boardId) {
0068 hwId_ &= 0x1F;
0069 hwId_ |= ((boardId & 0x07) << 5) & 0xE0;
0070 }
0071
0072 inline void setHardwareSampicId(const unsigned int sampicId) {
0073 hwId_ &= 0xEF;
0074 hwId_ |= ((sampicId & 0x01) << 4) & 0x10;
0075 }
0076
0077 inline void setHardwareChannelId(const unsigned int channelId) {
0078 hwId_ &= 0xF0;
0079 hwId_ |= (channelId & 0x0F) & 0x0F;
0080 }
0081
0082 inline void setL1ATimestamp(const uint64_t l1ATimestamp) { l1ATimestamp_ = l1ATimestamp; }
0083
0084 inline void setBunchNumber(const uint16_t bunchNumber) { bunchNumber_ = bunchNumber; }
0085
0086 inline void setOrbitNumber(const uint32_t orbitNumber) { orbitNumber_ = orbitNumber; }
0087
0088 inline void setEventNumber(const uint32_t eventNumber) { eventNumber_ = eventNumber; }
0089
0090 inline void setChannelMap(const uint16_t channelMap) { channelMap_ = channelMap; }
0091
0092 inline void setL1ALatency(const uint16_t l1ALatency) { l1ALatency_ = l1ALatency; }
0093
0094 inline void setNumberOfSamples(const uint8_t numberOfSamples) { numberOfSamples_ = numberOfSamples; }
0095
0096 inline void setOffsetOfSamples(const uint8_t offsetOfSamples) { offsetOfSamples_ = offsetOfSamples; }
0097
0098 inline void setPLLInfo(const uint8_t pllInfo) { pllInfo_ = pllInfo; }
0099
0100 private:
0101 uint8_t hwId_;
0102 uint64_t l1ATimestamp_;
0103 uint16_t bunchNumber_;
0104 uint32_t orbitNumber_;
0105 uint32_t eventNumber_;
0106 uint16_t channelMap_;
0107 uint16_t l1ALatency_;
0108 uint8_t numberOfSamples_;
0109 uint8_t offsetOfSamples_;
0110 uint8_t pllInfo_;
0111 };
0112
0113 #include <iostream>
0114
0115 inline bool operator<(const TotemTimingEventInfo& one, const TotemTimingEventInfo& other) {
0116 if (one.eventNumber() < other.eventNumber())
0117 return true;
0118 if (one.l1ATimestamp() < other.l1ATimestamp())
0119 return true;
0120 if (one.hardwareId() < other.hardwareId())
0121 return true;
0122 return false;
0123 }
0124
0125 inline std::ostream& operator<<(std::ostream& o, const TotemTimingEventInfo& digi) {
0126 std::bitset<16> bitsPLLInfo(digi.pllInfo());
0127 return o << "TotemTimingEventInfo:"
0128 << "\nHardwareId:\t" << std::hex << digi.hardwareId() << "\nDB: " << std::dec << digi.hardwareBoardId()
0129 << "\tSampic: " << digi.hardwareSampicId() << "\tChannel: " << digi.hardwareChannelId()
0130 << "\nL1A Timestamp:\t" << std::dec << digi.l1ATimestamp() << "\nL1A Latency:\t" << std::dec
0131 << digi.l1ALatency() << "\nBunch Number:\t" << std::dec << digi.bunchNumber() << "\nOrbit Number:\t"
0132 << std::dec << digi.orbitNumber() << "\nEvent Number:\t" << std::dec << digi.eventNumber()
0133 << "\nChannels fired:\t" << std::hex << digi.channelMap() << "\nNumber of Samples:\t" << std::dec
0134 << digi.numberOfSamples() << "\nOffset of Samples:\t" << std::dec << digi.offsetOfSamples()
0135 << "\nPLL Info:\t" << bitsPLLInfo.to_string() << std::endl;
0136 }
0137
0138 #endif