CMS 3D CMS Logo

TotemTimingEventInfo.h
Go to the documentation of this file.
1 #ifndef CTPPSDigi_TotemTimingEventInfo_h
2 #define CTPPSDigi_TotemTimingEventInfo_h
3 
14 #include <cstdint>
15 #include <bitset>
16 
18 public:
19  TotemTimingEventInfo(const uint8_t hwId,
20  const uint64_t l1ATimestamp,
21  const uint16_t bunchNumber,
22  const uint32_t orbitNumber,
23  const uint32_t eventNumber,
24  const uint16_t channelMap,
25  const uint16_t l1ALatency,
26  const uint8_t numberOfSamples,
27  const uint8_t offsetOfSamples,
28  const uint8_t pllInfo);
30 
32  bool operator==(const TotemTimingEventInfo& eventInfo) const;
33 
35 
37  inline unsigned int hardwareId() const { return hwId_; }
38 
39  inline unsigned int hardwareBoardId() const { return (hwId_ & 0xE0) >> 5; }
40 
41  inline unsigned int hardwareSampicId() const { return (hwId_ & 0x10) >> 4; }
42 
43  inline unsigned int hardwareChannelId() const { return (hwId_ & 0x0F); }
44 
45  inline unsigned int l1ATimestamp() const { return l1ATimestamp_; }
46 
47  inline unsigned int bunchNumber() const { return bunchNumber_; }
48 
49  inline unsigned int orbitNumber() const { return orbitNumber_; }
50 
51  inline unsigned int eventNumber() const { return eventNumber_; }
52 
53  inline uint16_t channelMap() const { return channelMap_; }
54 
55  inline unsigned int l1ALatency() const { return l1ALatency_; }
56 
57  inline unsigned int numberOfSamples() const { return numberOfSamples_; }
58 
59  inline unsigned int offsetOfSamples() const { return offsetOfSamples_; }
60 
61  inline uint8_t pllInfo() const { return pllInfo_; }
62 
65  inline void setHardwareId(const uint8_t hwId) { hwId_ = hwId; }
66 
67  inline void setHardwareBoardId(const unsigned int boardId) {
68  hwId_ &= 0x1F; // Set board bits to 0
69  hwId_ |= ((boardId & 0x07) << 5) & 0xE0;
70  }
71 
72  inline void setHardwareSampicId(const unsigned int sampicId) {
73  hwId_ &= 0xEF; // set Sampic bit to 0
74  hwId_ |= ((sampicId & 0x01) << 4) & 0x10;
75  }
76 
77  inline void setHardwareChannelId(const unsigned int channelId) {
78  hwId_ &= 0xF0; // set Sampic bit to 0
79  hwId_ |= (channelId & 0x0F) & 0x0F;
80  }
81 
83 
84  inline void setBunchNumber(const uint16_t bunchNumber) { bunchNumber_ = bunchNumber; }
85 
86  inline void setOrbitNumber(const uint32_t orbitNumber) { orbitNumber_ = orbitNumber; }
87 
88  inline void setEventNumber(const uint32_t eventNumber) { eventNumber_ = eventNumber; }
89 
90  inline void setChannelMap(const uint16_t channelMap) { channelMap_ = channelMap; }
91 
92  inline void setL1ALatency(const uint16_t l1ALatency) { l1ALatency_ = l1ALatency; }
93 
95 
97 
98  inline void setPLLInfo(const uint8_t pllInfo) { pllInfo_ = pllInfo; }
99 
100 private:
101  uint8_t hwId_;
103  uint16_t bunchNumber_;
104  uint32_t orbitNumber_;
105  uint32_t eventNumber_;
106  uint16_t channelMap_;
107  uint16_t l1ALatency_;
110  uint8_t pllInfo_;
111 };
112 
113 #include <iostream>
114 
116  if (one.eventNumber() < other.eventNumber())
117  return true;
118  if (one.l1ATimestamp() < other.l1ATimestamp())
119  return true;
120  if (one.hardwareId() < other.hardwareId())
121  return true;
122  return false;
123 }
124 
125 inline std::ostream& operator<<(std::ostream& o, const TotemTimingEventInfo& digi) {
126  std::bitset<16> bitsPLLInfo(digi.pllInfo());
127  return o << "TotemTimingEventInfo:"
128  << "\nHardwareId:\t" << std::hex << digi.hardwareId() << "\nDB: " << std::dec << digi.hardwareBoardId()
129  << "\tSampic: " << digi.hardwareSampicId() << "\tChannel: " << digi.hardwareChannelId()
130  << "\nL1A Timestamp:\t" << std::dec << digi.l1ATimestamp() << "\nL1A Latency:\t" << std::dec
131  << digi.l1ALatency() << "\nBunch Number:\t" << std::dec << digi.bunchNumber() << "\nOrbit Number:\t"
132  << std::dec << digi.orbitNumber() << "\nEvent Number:\t" << std::dec << digi.eventNumber()
133  << "\nChannels fired:\t" << std::hex << digi.channelMap() << "\nNumber of Samples:\t" << std::dec
134  << digi.numberOfSamples() << "\nOffset of Samples:\t" << std::dec << digi.offsetOfSamples()
135  << "\nPLL Info:\t" << bitsPLLInfo.to_string() << std::endl;
136 }
137 
138 #endif
unsigned int hardwareSampicId() const
void setHardwareBoardId(const unsigned int boardId)
void setNumberOfSamples(const uint8_t numberOfSamples)
unsigned int l1ALatency() const
unsigned int bunchNumber() const
unsigned int hardwareId() const
Return digi values number.
std::ostream & operator<<(std::ostream &o, const TotemTimingEventInfo &digi)
void setOffsetOfSamples(const uint8_t offsetOfSamples)
unsigned int l1ATimestamp() const
unsigned int hardwareBoardId() const
unsigned int offsetOfSamples() const
unsigned int numberOfSamples() const
void setHardwareId(const uint8_t hwId)
void setEventNumber(const uint32_t eventNumber)
bool operator==(const TotemTimingEventInfo &eventInfo) const
Digis are equal if they have all the same values, NOT checking the samples!
bool operator<(const TotemTimingEventInfo &one, const TotemTimingEventInfo &other)
uint16_t channelMap() const
void setHardwareChannelId(const unsigned int channelId)
unsigned int orbitNumber() const
unsigned int eventNumber() const
unsigned long long uint64_t
Definition: Time.h:13
void setPLLInfo(const uint8_t pllInfo)
void setOrbitNumber(const uint32_t orbitNumber)
void setBunchNumber(const uint16_t bunchNumber)
void setL1ATimestamp(const uint64_t l1ATimestamp)
void setChannelMap(const uint16_t channelMap)
void setL1ALatency(const uint16_t l1ALatency)
eventInfo
add run, event number and lumi section
void setHardwareSampicId(const unsigned int sampicId)
unsigned int hardwareChannelId() const