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 {
19  public:
20  TotemTimingEventInfo( const uint8_t hwId, const uint64_t l1ATimestamp, const uint16_t bunchNumber, const uint32_t orbitNumber, const uint32_t eventNumber, const uint16_t channelMap, const uint16_t l1ALatency, const uint8_t numberOfSamples, const uint8_t offsetOfSamples, const uint8_t pllInfo );
24 
26  bool operator==( const TotemTimingEventInfo& eventInfo ) const;
27 
29 
31  inline unsigned int getHardwareId() const
32  {
33  return hwId_;
34  }
35 
36  inline unsigned int getHardwareBoardId() const
37  {
38  return ( hwId_ & 0xE0 ) >> 5;
39  }
40 
41  inline unsigned int getHardwareSampicId() const
42  {
43  return ( hwId_ & 0x10 ) >> 4;
44  }
45 
46  inline unsigned int getHardwareChannelId() const
47  {
48  return ( hwId_ & 0x0F );
49  }
50 
51  inline unsigned int getL1ATimestamp() const
52  {
53  return l1ATimestamp_;
54  }
55 
56  inline unsigned int getBunchNumber() const
57  {
58  return bunchNumber_;
59  }
60 
61  inline unsigned int getOrbitNumber() const
62  {
63  return orbitNumber_;
64  }
65 
66  inline unsigned int getEventNumber() const
67  {
68  return eventNumber_;
69  }
70 
71  inline uint16_t getChannelMap() const
72  {
73  return channelMap_;
74  }
75 
76  inline unsigned int getL1ALatency() const
77  {
78  return l1ALatency_;
79  }
80 
81  inline unsigned int getNumberOfSamples() const
82  {
83  return numberOfSamples_;
84  }
85 
86  inline unsigned int getOffsetOfSamples() const
87  {
88  return offsetOfSamples_;
89  }
90 
91  inline uint8_t getPLLInfo() const
92  {
93  return pllInfo_;
94  }
95 
98  inline void setHardwareId( const uint8_t hwId )
99  {
100  hwId_ = hwId;
101  }
102 
103  inline void setHardwareBoardId( const unsigned int boardId )
104  {
105  hwId_ &= 0x1F; // Set board bits to 0
106  hwId_ |= ( ( boardId & 0x07 ) << 5 ) & 0xE0;
107  }
108 
109  inline void setHardwareSampicId( const unsigned int sampicId )
110  {
111  hwId_ &= 0xEF; // set Sampic bit to 0
112  hwId_ |= ( ( sampicId & 0x01 ) << 4 ) & 0x10;
113  }
114 
115  inline void setHardwareChannelId( const unsigned int channelId )
116  {
117  hwId_ &= 0xF0; // set Sampic bit to 0
118  hwId_ |= ( channelId & 0x0F ) & 0x0F;
119  }
120 
121  inline void setL1ATimestamp( const uint64_t l1ATimestamp )
122  {
123  l1ATimestamp_ = l1ATimestamp;
124  }
125 
126  inline void setBunchNumber( const uint16_t bunchNumber )
127  {
128  bunchNumber_ = bunchNumber;
129  }
130 
131  inline void setOrbitNumber( const uint32_t orbitNumber )
132  {
133  orbitNumber_ = orbitNumber;
134  }
135 
136  inline void setEventNumber( const uint32_t eventNumber )
137  {
138  eventNumber_ = eventNumber;
139  }
140 
141  inline void setChannelMap( const uint16_t channelMap )
142  {
143  channelMap_ = channelMap;
144  }
145 
146  inline void setL1ALatency( const uint16_t l1ALatency )
147  {
148  l1ALatency_ = l1ALatency;
149  }
150 
151  inline void setNumberOfSamples( const uint8_t numberOfSamples )
152  {
154  }
155 
156  inline void setOffsetOfSamples( const uint8_t offsetOfSamples )
157  {
158  offsetOfSamples_ = offsetOfSamples;
159  }
160 
161  inline void setPLLInfo( const uint8_t pllInfo )
162  {
163  pllInfo_ = pllInfo;
164  }
165 
166  private:
167  uint8_t hwId_;
169  uint16_t bunchNumber_;
170  uint32_t orbitNumber_;
171  uint32_t eventNumber_;
172  uint16_t channelMap_;
173  uint16_t l1ALatency_;
176  uint8_t pllInfo_;
177 };
178 
179 #include <iostream>
180 
182 {
183  if ( one.getEventNumber() < other.getEventNumber() )
184  return true;
185  if ( one.getL1ATimestamp() < other.getL1ATimestamp() )
186  return true;
187  if ( one.getHardwareId() < other.getHardwareId() )
188  return true;
189  return false;
190 }
191 
192 inline std::ostream& operator<<( std::ostream& o, const TotemTimingEventInfo& digi )
193 {
194  std::bitset<16> bitsPLLInfo( digi.getPLLInfo() );
195  return o << "TotemTimingEventInfo:"
196  << "\nHardwareId:\t" << std::hex << digi.getHardwareId()
197  << "\nDB: " << std::dec << digi.getHardwareBoardId() << "\tSampic: " << digi.getHardwareSampicId() << "\tChannel: " << digi.getHardwareChannelId()
198  << "\nL1A Timestamp:\t" << std::dec << digi.getL1ATimestamp()
199  << "\nL1A Latency:\t" << std::dec << digi.getL1ALatency()
200  << "\nBunch Number:\t" << std::dec << digi.getBunchNumber()
201  << "\nOrbit Number:\t" << std::dec << digi.getOrbitNumber()
202  << "\nEvent Number:\t" << std::dec << digi.getEventNumber()
203  << "\nChannels fired:\t" << std::hex << digi.getChannelMap()
204  << "\nNumber of Samples:\t" << std::dec << digi.getNumberOfSamples()
205  << "\nOffset of Samples:\t" << std::dec << digi.getOffsetOfSamples()
206  << "\nPLL Info:\t" << bitsPLLInfo.to_string()
207  << std::endl;
208 }
209 
210 #endif
211 
unsigned int getEventNumber() const
void setHardwareBoardId(const unsigned int boardId)
unsigned int getNumberOfSamples() const
void setNumberOfSamples(const uint8_t numberOfSamples)
unsigned int getBunchNumber() const
std::ostream & operator<<(std::ostream &o, const TotemTimingEventInfo &digi)
void setOffsetOfSamples(const uint8_t offsetOfSamples)
void setHardwareId(const uint8_t hwId)
void setEventNumber(const uint32_t eventNumber)
uint8_t getPLLInfo() const
unsigned int getHardwareId() const
Return digi values number.
unsigned int getL1ALatency() const
bool operator<(const TotemTimingEventInfo &one, const TotemTimingEventInfo &other)
unsigned int getHardwareSampicId() const
uint16_t getChannelMap() const
unsigned int getHardwareChannelId() 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 getL1ATimestamp() const
unsigned long long uint64_t
Definition: Time.h:15
unsigned int getOrbitNumber() const
void setPLLInfo(const uint8_t pllInfo)
void setOrbitNumber(const uint32_t orbitNumber)
void setBunchNumber(const uint16_t bunchNumber)
unsigned int getHardwareBoardId() const
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 getOffsetOfSamples() const