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 {
21  public:
22  TotemTimingDigi( const uint8_t hwId, const uint64_t fpgaTimestamp, const uint16_t timestampA, const uint16_t timestampB, const uint16_t cellInfo, const std::vector<uint8_t>& samples, const TotemTimingEventInfo& totemTimingEventInfo );
23  TotemTimingDigi( const TotemTimingDigi& digi );
26 
28  bool operator==( const TotemTimingDigi& digi ) const;
29 
31 
33  inline unsigned int getHardwareId() const
34  {
35  return hwId_;
36  }
37 
38  inline unsigned int getHardwareBoardId() const
39  {
40  return ( hwId_ & 0xE0 ) >> 5;
41  }
42 
43  inline unsigned int getHardwareSampicId() const
44  {
45  return ( hwId_ & 0x10 ) >> 4;
46  }
47 
48  inline unsigned int getHardwareChannelId() const
49  {
50  return ( hwId_ & 0x0F );
51  }
52 
53  inline unsigned int getFPGATimestamp() const
54  {
55  return fpgaTimestamp_;
56  }
57 
58  inline unsigned int getTimestampA() const
59  {
60  return timestampA_;
61  }
62 
63  inline unsigned int getTimestampB() const
64  {
65  return timestampB_;
66  }
67 
68  inline unsigned int getCellInfo() const
69  {
70  return cellInfo_;
71  }
72 
73  inline std::vector<uint8_t> getSamples() const
74  {
75  return samples_;
76  }
77 
78  inline std::vector<uint8_t>::const_iterator getSamplesBegin() const
79  {
80  return samples_.cbegin();
81  }
82 
83  inline std::vector<uint8_t>::const_iterator getSamplesEnd() const
84  {
85  return samples_.cend();
86  }
87 
88  inline unsigned int getNumberOfSamples() const
89  {
90  return samples_.size();
91  }
92 
93  inline int getSampleAt( const unsigned int i ) const
94  {
95  int sampleValue = -1;
96  if ( i < samples_.size() )
97  sampleValue = (int) samples_.at( i );
98  return sampleValue;
99  }
100 
102  {
103  return totemTimingEventInfo_;
104  }
105 
108  inline void setHardwareId( const uint8_t hwId )
109  {
110  hwId_ = hwId;
111  }
112 
113  inline void setHardwareBoardId( const unsigned int boardId )
114  {
115  hwId_ &= 0x1F; // set board bits to 0
116  hwId_ |= ( ( boardId & 0x07 ) << 5 ) & 0xE0;
117  }
118 
119  inline void setHardwareSampicId( const unsigned int sampicId )
120  {
121  hwId_ &= 0xEF; // set Sampic bit to 0
122  hwId_ |= ( ( sampicId & 0x01 ) << 4 ) & 0x10;
123  }
124 
125  inline void setHardwareChannelId( const unsigned int channelId )
126  {
127  hwId_ &= 0xF0; // Set Sampic bit to 0
128  hwId_ |= ( channelId & 0x0F ) & 0x0F;
129  }
130 
131  inline void setFPGATimestamp( const uint64_t fpgaTimestamp )
132  {
133  fpgaTimestamp_ = fpgaTimestamp;
134  }
135 
136  inline void setTimestampA( const uint16_t timestampA )
137  {
138  timestampA_ = timestampA;
139  }
140 
141  inline void setTimestampB( const uint16_t timestampB )
142  {
143  timestampB_ = timestampB;
144  }
145 
146  inline void setCellInfo( const uint16_t cellInfo )
147  {
148  cellInfo_ = cellInfo & 0x3F;
149  }
150 
151  inline void setSamples( const std::vector<uint8_t>& samples )
152  {
153  samples_ = samples;
154  }
155 
156  inline void addSample( const uint8_t sampleValue )
157  {
158  samples_.emplace_back( sampleValue );
159  }
160 
161  inline void setSampleAt( const unsigned int i, const uint8_t sampleValue )
162  {
163  if ( i < samples_.size() )
164  samples_.at(i) = sampleValue;
165  }
166 
167  inline void setEventInfo( const TotemTimingEventInfo& totemTimingEventInfo )
168  {
169  totemTimingEventInfo_ = totemTimingEventInfo;
170  }
171 
172  private:
173  uint8_t hwId_;
175  uint16_t timestampA_;
176  uint16_t timestampB_;
177  uint16_t cellInfo_;
178 
179  std::vector<uint8_t> samples_;
180 
182 };
183 
184 #include <iostream>
185 
186 inline bool operator<( const TotemTimingDigi& one, const TotemTimingDigi& other )
187 {
188  if ( one.getEventInfo() < other.getEventInfo() )
189  return true;
190  if ( one.getHardwareId() < other.getHardwareId() )
191  return true;
192  return false;
193 }
194 
195 inline std::ostream& operator<<( std::ostream& os, const TotemTimingDigi& digi )
196 {
197  return os << "TotemTimingDigi:"
198  << "\nHardwareId:\t" << std::hex << digi.getHardwareId()
199  << "\nDB: " << std::dec << digi.getHardwareBoardId() << "\tSampic: " << digi.getHardwareSampicId() << "\tChannel: " << digi.getHardwareChannelId()
200  << "\nFPGATimestamp:\t" << std::dec << digi.getFPGATimestamp()
201  << "\nTimestampA:\t" << std::dec << digi.getTimestampA()
202  << "\nTimestampB:\t" << std::dec << digi.getTimestampB()
203  << "\nCellInfo:\t" << std::hex << digi.getCellInfo()
204  << "\nNumberOfSamples:\t" << std::dec << digi.getNumberOfSamples()
205  << std::endl << digi.getEventInfo() << std::endl;
206 }
207 
208 #endif
209 
void setFPGATimestamp(const uint64_t fpgaTimestamp)
std::ostream & operator<<(std::ostream &os, const TotemTimingDigi &digi)
void setSamples(const std::vector< uint8_t > &samples)
void setEventInfo(const TotemTimingEventInfo &totemTimingEventInfo)
TotemTimingEventInfo getEventInfo() const
TotemTimingEventInfo totemTimingEventInfo_
std::vector< uint8_t >::const_iterator getSamplesBegin() 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::vector< uint8_t >::const_iterator getSamplesEnd() const
unsigned int getTimestampA() const
unsigned int getHardwareId() const
Return digi values number.
void setHardwareId(const uint8_t hwId)
void setHardwareBoardId(const unsigned int boardId)
std::vector< uint8_t > getSamples() const
unsigned int getFPGATimestamp() const
void setCellInfo(const uint16_t cellInfo)
unsigned int getTimestampB() const
unsigned int getCellInfo() const
unsigned int getNumberOfSamples() 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:15
unsigned int getHardwareChannelId() const
uint64_t fpgaTimestamp_
void setTimestampB(const uint16_t timestampB)
std::vector< uint8_t > samples_
unsigned int getHardwareBoardId() const
int getSampleAt(const unsigned int i) const
bool operator<(const TotemTimingDigi &one, const TotemTimingDigi &other)
unsigned int getHardwareSampicId() const
void addSample(const uint8_t sampleValue)
void setTimestampA(const uint16_t timestampA)