CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TotemTimingDigi.h
Go to the documentation of this file.
1 #ifndef CTPPSDigi_TotemTimingDigi_h
2 #define CTPPSDigi_TotemTimingDigi_h
3 
14 #include <cstdint>
15 #include <vector>
16 
18 
20 public:
21  TotemTimingDigi(const uint8_t hwId,
22  const uint64_t fpgaTimestamp,
23  const uint16_t timestampA,
24  const uint16_t timestampB,
25  const uint16_t cellInfo,
26  const std::vector<uint8_t>& samples,
27  const TotemTimingEventInfo& totemTimingEventInfo);
28  TotemTimingDigi(const TotemTimingDigi& digi);
31 
33  bool operator==(const TotemTimingDigi& digi) const;
34 
36 
38  inline unsigned int hardwareId() const { return hwId_; }
39 
40  inline unsigned int hardwareBoardId() const { return (hwId_ & 0xE0) >> 5; }
41 
42  inline unsigned int hardwareSampicId() const { return (hwId_ & 0x10) >> 4; }
43 
44  inline unsigned int hardwareChannelId() const { return (hwId_ & 0x0F); }
45 
46  inline unsigned int fpgaTimestamp() const { return fpgaTimestamp_; }
47 
48  inline unsigned int timestampA() const { return timestampA_; }
49 
50  inline unsigned int timestampB() const { return timestampB_; }
51 
52  inline unsigned int cellInfo() const { return cellInfo_; }
53 
54  inline std::vector<uint8_t> samples() const { return samples_; }
55 
56  inline std::vector<uint8_t>::const_iterator samplesBegin() const { return samples_.cbegin(); }
57 
58  inline std::vector<uint8_t>::const_iterator samplesEnd() const { return samples_.cend(); }
59 
60  inline unsigned int numberOfSamples() const { return samples_.size(); }
61 
62  inline int sampleAt(const unsigned int i) const {
63  int sampleValue = -1;
64  if (i < samples_.size())
65  sampleValue = (int)samples_.at(i);
66  return sampleValue;
67  }
68 
70 
73  inline void setHardwareId(const uint8_t hwId) { hwId_ = hwId; }
74 
75  inline void setHardwareBoardId(const unsigned int boardId) {
76  hwId_ &= 0x1F; // set board bits to 0
77  hwId_ |= ((boardId & 0x07) << 5) & 0xE0;
78  }
79 
80  inline void setHardwareSampicId(const unsigned int sampicId) {
81  hwId_ &= 0xEF; // set Sampic bit to 0
82  hwId_ |= ((sampicId & 0x01) << 4) & 0x10;
83  }
84 
85  inline void setHardwareChannelId(const unsigned int channelId) {
86  hwId_ &= 0xF0; // Set Sampic bit to 0
87  hwId_ |= (channelId & 0x0F) & 0x0F;
88  }
89 
90  inline void setFPGATimestamp(const uint64_t fpgaTimestamp) { fpgaTimestamp_ = fpgaTimestamp; }
91 
92  inline void setTimestampA(const uint16_t timestampA) { timestampA_ = timestampA; }
93 
94  inline void setTimestampB(const uint16_t timestampB) { timestampB_ = timestampB; }
95 
96  inline void setCellInfo(const uint16_t cellInfo) { cellInfo_ = cellInfo & 0x3F; }
97 
98  inline void setSamples(const std::vector<uint8_t>& samples) { samples_ = samples; }
99 
100  inline void addSample(const uint8_t sampleValue) { samples_.emplace_back(sampleValue); }
101 
102  inline void setSampleAt(const unsigned int i, const uint8_t sampleValue) {
103  if (i < samples_.size())
104  samples_.at(i) = sampleValue;
105  }
106 
107  inline void setEventInfo(const TotemTimingEventInfo& totemTimingEventInfo) {
108  totemTimingEventInfo_ = totemTimingEventInfo;
109  }
110 
111 private:
112  uint8_t hwId_;
114  uint16_t timestampA_;
115  uint16_t timestampB_;
116  uint16_t cellInfo_;
117 
118  std::vector<uint8_t> samples_;
119 
121 };
122 
123 #include <iostream>
124 
125 inline bool operator<(const TotemTimingDigi& one, const TotemTimingDigi& other) {
126  if (one.eventInfo() < other.eventInfo())
127  return true;
128  if (one.hardwareId() < other.hardwareId())
129  return true;
130  return false;
131 }
132 
133 inline std::ostream& operator<<(std::ostream& os, const TotemTimingDigi& digi) {
134  return os << "TotemTimingDigi:"
135  << "\nHardwareId:\t" << std::hex << digi.hardwareId() << "\nDB: " << std::dec << digi.hardwareBoardId()
136  << "\tSampic: " << digi.hardwareSampicId() << "\tChannel: " << digi.hardwareChannelId()
137  << "\nFPGATimestamp:\t" << std::dec << digi.fpgaTimestamp() << "\nTimestampA:\t" << std::dec
138  << digi.timestampA() << "\nTimestampB:\t" << std::dec << digi.timestampB() << "\nCellInfo:\t" << std::hex
139  << digi.cellInfo() << "\nNumberOfSamples:\t" << std::dec << digi.numberOfSamples() << std::endl
140  << digi.eventInfo() << std::endl;
141 }
142 
143 #endif
void setFPGATimestamp(const uint64_t fpgaTimestamp)
void setSamples(const std::vector< uint8_t > &samples)
void setEventInfo(const TotemTimingEventInfo &totemTimingEventInfo)
TotemTimingEventInfo eventInfo() const
int sampleAt(const unsigned int i) const
TotemTimingEventInfo totemTimingEventInfo_
unsigned int numberOfSamples() const
unsigned int timestampA() const
bool operator==(const TotemTimingDigi &digi) const
Digis are equal if they have all the same values, NOT checking the samples!
void setHardwareChannelId(const unsigned int channelId)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
void setHardwareId(const uint8_t hwId)
std::vector< uint8_t >::const_iterator samplesBegin() const
void setHardwareBoardId(const unsigned int boardId)
unsigned int hardwareSampicId() const
std::vector< uint8_t > samples() const
std::vector< uint8_t >::const_iterator samplesEnd() const
unsigned int hardwareId() const
Return digi values number.
void setCellInfo(const uint16_t cellInfo)
unsigned int cellInfo() const
unsigned int hardwareBoardId() const
unsigned int fpgaTimestamp() const
void setSampleAt(const unsigned int i, const uint8_t sampleValue)
void setHardwareSampicId(const unsigned int sampicId)
unsigned long long uint64_t
Definition: Time.h:13
uint64_t fpgaTimestamp_
void setTimestampB(const uint16_t timestampB)
std::vector< uint8_t > samples_
bool operator<(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:70
unsigned int hardwareChannelId() const
void addSample(const uint8_t sampleValue)
void setTimestampA(const uint16_t timestampA)
unsigned int timestampB() const