CMS 3D CMS Logo

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 
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
TotemTimingDigi::setHardwareSampicId
void setHardwareSampicId(const unsigned int sampicId)
Definition: TotemTimingDigi.h:80
TotemTimingDigi::hwId_
uint8_t hwId_
Definition: TotemTimingDigi.h:112
mps_fire.i
i
Definition: mps_fire.py:355
amcDumpToRaw_cfi.boardId
boardId
Definition: amcDumpToRaw_cfi.py:9
TotemTimingDigi::sampleAt
int sampleAt(const unsigned int i) const
Definition: TotemTimingDigi.h:62
TotemTimingDigi::timestampA
unsigned int timestampA() const
Definition: TotemTimingDigi.h:48
TotemTimingDigi::hardwareBoardId
unsigned int hardwareBoardId() const
Definition: TotemTimingDigi.h:40
TotemTimingDigi::hardwareId
unsigned int hardwareId() const
Return digi values number.
Definition: TotemTimingDigi.h:38
TotemTimingDigi::totemTimingEventInfo_
TotemTimingEventInfo totemTimingEventInfo_
Definition: TotemTimingDigi.h:120
TotemTimingDigi::timestampB_
uint16_t timestampB_
Definition: TotemTimingDigi.h:115
TotemTimingDigi::fpgaTimestamp
unsigned int fpgaTimestamp() const
Definition: TotemTimingDigi.h:46
operator<
bool operator<(const TotemTimingDigi &one, const TotemTimingDigi &other)
Definition: TotemTimingDigi.h:125
TotemTimingDigi::setFPGATimestamp
void setFPGATimestamp(const uint64_t fpgaTimestamp)
Definition: TotemTimingDigi.h:90
TotemTimingDigi::hardwareSampicId
unsigned int hardwareSampicId() const
Definition: TotemTimingDigi.h:42
TotemTimingDigi::~TotemTimingDigi
~TotemTimingDigi()
Definition: TotemTimingDigi.h:30
TotemTimingDigi::setEventInfo
void setEventInfo(const TotemTimingEventInfo &totemTimingEventInfo)
Definition: TotemTimingDigi.h:107
TotemTimingEventInfo.h
TotemTimingDigi::numberOfSamples
unsigned int numberOfSamples() const
Definition: TotemTimingDigi.h:60
TotemTimingDigi::setHardwareBoardId
void setHardwareBoardId(const unsigned int boardId)
Definition: TotemTimingDigi.h:75
TotemTimingDigi::setSamples
void setSamples(const std::vector< uint8_t > &samples)
Definition: TotemTimingDigi.h:98
TotemTimingDigi::samplesEnd
std::vector< uint8_t >::const_iterator samplesEnd() const
Definition: TotemTimingDigi.h:58
TotemTimingDigi
Definition: TotemTimingDigi.h:19
TotemTimingDigi::setHardwareChannelId
void setHardwareChannelId(const unsigned int channelId)
Definition: TotemTimingDigi.h:85
trackingPlots.other
other
Definition: trackingPlots.py:1465
TotemTimingDigi::cellInfo
unsigned int cellInfo() const
Definition: TotemTimingDigi.h:52
TotemTimingDigi::timestampA_
uint16_t timestampA_
Definition: TotemTimingDigi.h:114
TotemTimingDigi::addSample
void addSample(const uint8_t sampleValue)
Definition: TotemTimingDigi.h:100
TotemTimingDigi::samplesBegin
std::vector< uint8_t >::const_iterator samplesBegin() const
Definition: TotemTimingDigi.h:56
TotemTimingDigi::setCellInfo
void setCellInfo(const uint16_t cellInfo)
Definition: TotemTimingDigi.h:96
TotemTimingDigi::samples_
std::vector< uint8_t > samples_
Definition: TotemTimingDigi.h:118
operator<<
std::ostream & operator<<(std::ostream &os, const TotemTimingDigi &digi)
Definition: TotemTimingDigi.h:133
TotemTimingEventInfo
Definition: TotemTimingEventInfo.h:17
TotemTimingDigi::setTimestampB
void setTimestampB(const uint16_t timestampB)
Definition: TotemTimingDigi.h:94
TotemTimingDigi::cellInfo_
uint16_t cellInfo_
Definition: TotemTimingDigi.h:116
TotemTimingDigi::hardwareChannelId
unsigned int hardwareChannelId() const
Definition: TotemTimingDigi.h:44
TotemTimingDigi::TotemTimingDigi
TotemTimingDigi()
Definition: TotemTimingDigi.cc:34
TotemTimingDigi::operator==
bool operator==(const TotemTimingDigi &digi) const
Digis are equal if they have all the same values, NOT checking the samples!
Definition: TotemTimingDigi.cc:37
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
TotemTimingDigi::setTimestampA
void setTimestampA(const uint16_t timestampA)
Definition: TotemTimingDigi.h:92
TotemTimingDigi::timestampB
unsigned int timestampB() const
Definition: TotemTimingDigi.h:50
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
TotemTimingDigi::fpgaTimestamp_
uint64_t fpgaTimestamp_
Definition: TotemTimingDigi.h:113
TotemTimingDigi::setHardwareId
void setHardwareId(const uint8_t hwId)
Definition: TotemTimingDigi.h:73
TotemTimingDigi::eventInfo
TotemTimingEventInfo eventInfo() const
Definition: TotemTimingDigi.h:69
TotemTimingDigi::samples
std::vector< uint8_t > samples() const
Definition: TotemTimingDigi.h:54
TotemTimingDigi::setSampleAt
void setSampleAt(const unsigned int i, const uint8_t sampleValue)
Definition: TotemTimingDigi.h:102