CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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);
32 
34  bool operator==(const TotemTimingEventInfo& eventInfo) const;
35 
37 
39  inline unsigned int hardwareId() const { return hwId_; }
40 
41  inline unsigned int hardwareBoardId() const { return (hwId_ & 0xE0) >> 5; }
42 
43  inline unsigned int hardwareSampicId() const { return (hwId_ & 0x10) >> 4; }
44 
45  inline unsigned int hardwareChannelId() const { return (hwId_ & 0x0F); }
46 
47  inline unsigned int l1ATimestamp() const { return l1ATimestamp_; }
48 
49  inline unsigned int bunchNumber() const { return bunchNumber_; }
50 
51  inline unsigned int orbitNumber() const { return orbitNumber_; }
52 
53  inline unsigned int eventNumber() const { return eventNumber_; }
54 
55  inline uint16_t channelMap() const { return channelMap_; }
56 
57  inline unsigned int l1ALatency() const { return l1ALatency_; }
58 
59  inline unsigned int numberOfSamples() const { return numberOfSamples_; }
60 
61  inline unsigned int offsetOfSamples() const { return offsetOfSamples_; }
62 
63  inline uint8_t pllInfo() const { return pllInfo_; }
64 
67  inline void setHardwareId(const uint8_t hwId) { hwId_ = hwId; }
68 
69  inline void setHardwareBoardId(const unsigned int boardId) {
70  hwId_ &= 0x1F; // Set board bits to 0
71  hwId_ |= ((boardId & 0x07) << 5) & 0xE0;
72  }
73 
74  inline void setHardwareSampicId(const unsigned int sampicId) {
75  hwId_ &= 0xEF; // set Sampic bit to 0
76  hwId_ |= ((sampicId & 0x01) << 4) & 0x10;
77  }
78 
79  inline void setHardwareChannelId(const unsigned int channelId) {
80  hwId_ &= 0xF0; // set Sampic bit to 0
81  hwId_ |= (channelId & 0x0F) & 0x0F;
82  }
83 
84  inline void setL1ATimestamp(const uint64_t l1ATimestamp) { l1ATimestamp_ = l1ATimestamp; }
85 
86  inline void setBunchNumber(const uint16_t bunchNumber) { bunchNumber_ = bunchNumber; }
87 
88  inline void setOrbitNumber(const uint32_t orbitNumber) { orbitNumber_ = orbitNumber; }
89 
90  inline void setEventNumber(const uint32_t eventNumber) { eventNumber_ = eventNumber; }
91 
92  inline void setChannelMap(const uint16_t channelMap) { channelMap_ = channelMap; }
93 
94  inline void setL1ALatency(const uint16_t l1ALatency) { l1ALatency_ = l1ALatency; }
95 
96  inline void setNumberOfSamples(const uint8_t numberOfSamples) { numberOfSamples_ = numberOfSamples; }
97 
98  inline void setOffsetOfSamples(const uint8_t offsetOfSamples) { offsetOfSamples_ = offsetOfSamples; }
99 
100  inline void setPLLInfo(const uint8_t pllInfo) { pllInfo_ = pllInfo; }
101 
102 private:
103  uint8_t hwId_;
105  uint16_t bunchNumber_;
106  uint32_t orbitNumber_;
107  uint32_t eventNumber_;
108  uint16_t channelMap_;
109  uint16_t l1ALatency_;
112  uint8_t pllInfo_;
113 };
114 
115 #include <iostream>
116 
117 inline bool operator<(const TotemTimingEventInfo& one, const TotemTimingEventInfo& other) {
118  if (one.eventNumber() < other.eventNumber())
119  return true;
120  if (one.l1ATimestamp() < other.l1ATimestamp())
121  return true;
122  if (one.hardwareId() < other.hardwareId())
123  return true;
124  return false;
125 }
126 
127 inline std::ostream& operator<<(std::ostream& o, const TotemTimingEventInfo& digi) {
128  std::bitset<16> bitsPLLInfo(digi.pllInfo());
129  return o << "TotemTimingEventInfo:"
130  << "\nHardwareId:\t" << std::hex << digi.hardwareId() << "\nDB: " << std::dec << digi.hardwareBoardId()
131  << "\tSampic: " << digi.hardwareSampicId() << "\tChannel: " << digi.hardwareChannelId()
132  << "\nL1A Timestamp:\t" << std::dec << digi.l1ATimestamp() << "\nL1A Latency:\t" << std::dec
133  << digi.l1ALatency() << "\nBunch Number:\t" << std::dec << digi.bunchNumber() << "\nOrbit Number:\t"
134  << std::dec << digi.orbitNumber() << "\nEvent Number:\t" << std::dec << digi.eventNumber()
135  << "\nChannels fired:\t" << std::hex << digi.channelMap() << "\nNumber of Samples:\t" << std::dec
136  << digi.numberOfSamples() << "\nOffset of Samples:\t" << std::dec << digi.offsetOfSamples()
137  << "\nPLL Info:\t" << bitsPLLInfo.to_string() << std::endl;
138 }
139 
140 #endif
unsigned int hardwareSampicId() const
void setHardwareBoardId(const unsigned int boardId)
void setNumberOfSamples(const uint8_t numberOfSamples)
unsigned int hardwareId() const
Return digi values number.
unsigned int offsetOfSamples() const
unsigned int l1ALatency() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
unsigned int hardwareBoardId() const
void setOffsetOfSamples(const uint8_t offsetOfSamples)
unsigned int hardwareChannelId() const
void setHardwareId(const uint8_t hwId)
void setEventNumber(const uint32_t eventNumber)
unsigned int l1ATimestamp() const
unsigned int numberOfSamples() const
void setHardwareChannelId(const unsigned int channelId)
bool operator==(const TotemTimingEventInfo &eventInfo) const
Digis are equal if they have all the same values, NOT checking the samples!
unsigned int eventNumber() const
uint8_t pllInfo() const
unsigned long long uint64_t
Definition: Time.h:13
void setPLLInfo(const uint8_t pllInfo)
bool operator<(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:70
void setOrbitNumber(const uint32_t orbitNumber)
unsigned int bunchNumber() const
void setBunchNumber(const uint16_t bunchNumber)
void setL1ATimestamp(const uint64_t l1ATimestamp)
void setChannelMap(const uint16_t channelMap)
void setL1ALatency(const uint16_t l1ALatency)
unsigned int orbitNumber() const
uint16_t channelMap() const
void setHardwareSampicId(const unsigned int sampicId)