CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalHTRData.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef HcalHTRData_H
3 #define HcalHTRData_H
4 
5 #include <cstdint>
6 
16 class HcalHTRData {
17 public:
18  static const int CHANNELS_PER_SPIGOT = 24;
19  static const int MAXIMUM_SAMPLES_PER_CHANNEL = 20;
20  static const int FORMAT_VERSION_COMPACT_DATA = 6;
21 
22  HcalHTRData();
24  if (m_ownData != nullptr)
25  delete[] m_ownData;
26  }
27  HcalHTRData(int version_to_create);
28  HcalHTRData(const unsigned short* data, int length);
29  HcalHTRData(const HcalHTRData&);
30 
32  void allocate(int version_to_create = 0);
33  void adoptData(const unsigned short* data, int length);
34 
36  inline int getFormatVersion() const { return m_formatVersion; }
37 
39  inline const unsigned short* getRawData() const { return m_rawConst; }
40 
42  inline const int getRawLength() const { return m_rawLength; }
43 
47  bool check() const;
48 
49  bool isEmptyEvent() const;
50  bool isOverflowWarning() const;
51  bool isBusy() const;
52 
60  void dataPointers(const unsigned short** daq_first,
61  const unsigned short** daq_last,
62  const unsigned short** tp_first,
63  const unsigned short** tp_last) const;
64 
72  void unpack(unsigned char* daq_lengths,
73  unsigned short* daq_samples,
74  unsigned char* tp_lengths,
75  unsigned short* tp_samples) const;
76 
84  bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short* histogram) const;
85 
88  static bool unpack_per_channel_header(unsigned short, int& flav, int& error_flags, int& capid0, int& channelid);
89 
92  static bool is_channel_header(unsigned short value) { return (value & 0x8000) != 0; }
93 
100  void pack(unsigned char* daq_lengths,
101  unsigned short* daq_samples,
102  unsigned char* tp_lengths,
103  unsigned short* tp_samples,
104  bool do_capid = false);
106  void packHeaderTrailer(int L1Anumber,
107  int bcn,
108  int submodule,
109  int orbitn,
110  int pipeline,
111  int ndd,
112  int nps,
113  int firmwareRev = 0,
114  int firmwareFlav = 0);
115 
117  void packUnsuppressed(const bool* mp);
118 
120  inline unsigned int getL1ANumber() const { return (m_rawConst[0] & 0xFF) + (m_rawConst[1] << 8); }
122  inline unsigned int getBunchNumber() const { return (m_rawConst[4] & 0xFFF); }
124  unsigned int getOrbitNumber() const;
126  unsigned int getSubmodule() const;
128  // get the htr slot
129  unsigned int htrSlot() const;
131  // get the htr top/bottom (1=top/0=bottom)
132  unsigned int htrTopBottom() const;
134  // get the readout VME crate number
135  unsigned int readoutVMECrateId() const;
137  bool isCalibrationStream() const;
139  bool isUnsuppressed() const;
141  bool wasMarkAndPassZS(int fiber, int fiberchan) const;
143  bool wasMarkAndPassZSTP(int slb, int slbchan) const;
145  uint32_t zsBunchMask() const;
146 
148  bool isPatternRAMEvent() const;
151  bool isHistogramEvent() const;
154  void getHistogramFibers(int& a, int& b) const;
156  unsigned int getPipelineLength() const;
158  unsigned int getFirmwareRevision() const;
160  int getFirmwareFlavor() const;
162  inline unsigned int getErrorsWord() const { return m_rawConst[2] & 0xFFFF; }
164  int getNPrecisionWords() const;
166  int getNDD() const;
169  int getNTP() const;
171  int getNPS() const;
172 
174  inline unsigned int getDLLunlock() const { return (m_rawConst[5] >> 1) & 0x3; }
175 
177  inline unsigned int getTTCready() const { return m_rawConst[5] & 0x1; }
178 
180  inline unsigned int getFibOrbMsgBCN(int fiber) const {
181  return (m_formatVersion == -1 || fiber < 1 || fiber > 8) ? (0)
182  : (m_rawConst[m_rawLength - 12 + (fiber - 1)] & 0xFFF);
183  }
184 
186  inline unsigned int getFib1OrbMsgBCN() const {
187  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 12] & 0xFFF);
188  }
189  inline unsigned int getFib2OrbMsgBCN() const {
190  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 11] & 0xFFF);
191  }
192 
193  inline unsigned int getFib3OrbMsgBCN() const {
194  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 10] & 0xFFF);
195  }
196 
197  inline unsigned int getFib4OrbMsgBCN() const {
198  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 9] & 0xFFF);
199  }
200 
201  inline unsigned int getFib5OrbMsgBCN() const {
202  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 8] & 0xFFF);
203  }
204 
205  inline unsigned int getFib6OrbMsgBCN() const {
206  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 7] & 0xFFF);
207  }
208 
209  inline unsigned int getFib7OrbMsgBCN() const {
210  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 6] & 0xFFF);
211  }
212 
213  inline unsigned int getFib8OrbMsgBCN() const {
214  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 5] & 0xFFF);
215  }
216 
218  inline unsigned int getExtHdr1() const { return (m_rawConst[0]); }
219  inline unsigned int getExtHdr2() const { return (m_rawConst[1]); }
220  inline unsigned int getExtHdr3() const { return (m_rawConst[2]); }
221  inline unsigned int getExtHdr4() const { return (m_rawConst[3]); }
222  inline unsigned int getExtHdr5() const { return (m_rawConst[4]); }
223  inline unsigned int getExtHdr6() const { return (m_rawConst[5]); }
224  inline unsigned int getExtHdr7() const { return (m_rawConst[6]); }
225  inline unsigned int getExtHdr8() const { return (m_rawConst[7]); }
226 
227  /* unsigned int getFib1OrbMsgBCN() const;
228  unsigned int getFib2OrbMsgBCN() const;
229  unsigned int getFib3OrbMsgBCN() const;
230  unsigned int getFib4OrbMsgBCN() const;
231  unsigned int getFib5OrbMsgBCN() const;
232  unsigned int getFib6OrbMsgBCN() const;
233  unsigned int getFib7OrbMsgBCN() const;
234  unsigned int getFib8OrbMsgBCN() const;
235  */
236 
239  bool wasHistogramError(int ifiber) const;
240 
241 protected:
242  void determineSectionLengths(int& tpWords, int& daqWords, int& headerWords, int& trailerWords) const;
243  void determineStaticLengths(int& headerWords, int& trailerWords) const;
246  const unsigned short* m_rawConst;
247  unsigned short* m_ownData;
248 };
249 
250 #endif
unsigned short * m_ownData
Definition: HcalHTRData.h:247
unsigned int getFib6OrbMsgBCN() const
Definition: HcalHTRData.h:205
int getNDD() const
Get the number of daq data samples per channel when not zero-suppressed.
Definition: HcalHTRData.cc:412
unsigned int getFib1OrbMsgBCN() const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:186
unsigned int getTTCready() const
Get TTCready bit.
Definition: HcalHTRData.h:177
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:63
static int slb(const HcalTriggerPrimitiveSample &theSample)
int m_formatVersion
Definition: HcalHTRData.h:244
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
Definition: HcalHTRData.cc:369
void packUnsuppressed(const bool *mp)
pack trailer with Mark and Pass bits
Definition: HcalHTRData.cc:327
unsigned int getExtHdr2() const
Definition: HcalHTRData.h:219
unsigned int getExtHdr5() const
Definition: HcalHTRData.h:222
unsigned int getExtHdr4() const
Definition: HcalHTRData.h:221
bool isPatternRAMEvent() const
Is this event a pattern-ram event?
Definition: HcalHTRData.cc:408
const unsigned short * m_rawConst
Definition: HcalHTRData.h:246
unsigned int getExtHdr6() const
Definition: HcalHTRData.h:223
unsigned int getFib8OrbMsgBCN() const
Definition: HcalHTRData.h:213
void determineStaticLengths(int &headerWords, int &trailerWords) const
Definition: HcalHTRData.cc:148
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
Definition: HcalHTRData.cc:379
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:180
bool wasHistogramError(int ifiber) const
Was there an error on the given fiber for this event (only in histogram mode!)
Definition: HcalHTRData.cc:447
unsigned int getDLLunlock() const
Get DLLunlock bits.
Definition: HcalHTRData.h:174
static const int CHANNELS_PER_SPIGOT
Definition: HcalHTRData.h:18
static bool unpack_per_channel_header(unsigned short, int &flav, int &error_flags, int &capid0, int &channelid)
Unpack a per-channel header word (compact format)
Definition: HcalHTRData.cc:455
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: HcalHTRData.h:19
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!) ...
Definition: HcalHTRData.cc:435
unsigned int getOrbitNumber() const
Get the HTR orbit number.
Definition: HcalHTRData.cc:345
int getFormatVersion() const
Get the version number of this event.
Definition: HcalHTRData.h:36
HcalHTRData & operator=(const HcalHTRData &)
Definition: HcalHTRData.cc:37
int getNPrecisionWords() const
Get the total number of precision data 16-bit words.
Definition: HcalHTRData.cc:423
bool isCalibrationStream() const
Is this event a calibration-stream event?
Definition: HcalHTRData.cc:377
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:378
unsigned int getExtHdr1() const
Get the HTR Ext Header words.
Definition: HcalHTRData.h:218
void allocate(int version_to_create=0)
Definition: HcalHTRData.cc:25
unsigned int getPipelineLength() const
Get the pipeline length used for this event.
Definition: HcalHTRData.cc:427
bool isOverflowWarning() const
Definition: HcalHTRData.cc:115
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
Definition: HcalHTRData.cc:365
void unpack(unsigned char *daq_lengths, unsigned short *daq_samples, unsigned char *tp_lengths, unsigned short *tp_samples) const
Unpack the HTR data into TP and DAQ data sorted by channel.
Definition: HcalHTRData.cc:178
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
Definition: HcalHTRData.cc:464
static bool is_channel_header(unsigned short value)
check top bit to see if this is a compact format channel header word
Definition: HcalHTRData.h:92
unsigned int getFib7OrbMsgBCN() const
Definition: HcalHTRData.h:209
unsigned int getExtHdr8() const
Definition: HcalHTRData.h:225
int getNTP() const
Get the number of trigger data samples when not zero-suppressed (not available after FW 4) ...
Definition: HcalHTRData.cc:415
bool isEmptyEvent() const
Definition: HcalHTRData.cc:107
const int getRawLength() const
Get the length of the raw data.
Definition: HcalHTRData.h:42
unsigned int getFib3OrbMsgBCN() const
Definition: HcalHTRData.h:193
void pack(unsigned char *daq_lengths, unsigned short *daq_samples, unsigned char *tp_lengths, unsigned short *tp_samples, bool do_capid=false)
Unpack the HTR data into TP and DAQ data sorted by channel.
Definition: HcalHTRData.cc:233
unsigned int getFib5OrbMsgBCN() const
Definition: HcalHTRData.h:201
const unsigned short * getRawData() const
Get a pointer to the raw data.
Definition: HcalHTRData.h:39
void dataPointers(const unsigned short **daq_first, const unsigned short **daq_last, const unsigned short **tp_first, const unsigned short **tp_last) const
Obtain the starting and ending pointers for external unpacking of the data.
Definition: HcalHTRData.cc:161
unsigned int getErrorsWord() const
Get the errors word.
Definition: HcalHTRData.h:162
unsigned int getExtHdr3() const
Definition: HcalHTRData.h:220
unsigned int getExtHdr7() const
Definition: HcalHTRData.h:224
double b
Definition: hdecay.h:118
int getNPS() const
Get the number of presamples in daq data.
Definition: HcalHTRData.cc:426
static const int FORMAT_VERSION_COMPACT_DATA
Definition: HcalHTRData.h:20
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:433
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
Definition: HcalHTRData.cc:373
unsigned int getFib4OrbMsgBCN() const
Definition: HcalHTRData.h:197
void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int orbitn, int pipeline, int ndd, int nps, int firmwareRev=0, int firmwareFlav=0)
pack header and trailer (call after pack)
Definition: HcalHTRData.cc:294
void adoptData(const unsigned short *data, int length)
Definition: HcalHTRData.cc:46
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
Definition: HcalHTRData.cc:389
double a
Definition: hdecay.h:119
unsigned int getBunchNumber() const
Get the HTR bunch number.
Definition: HcalHTRData.h:122
unsigned int getFib2OrbMsgBCN() const
Definition: HcalHTRData.h:189
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:400
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:355
bool isBusy() const
Definition: HcalHTRData.cc:123
unsigned int getFirmwareRevision() const
Get the HTR firmware version.
Definition: HcalHTRData.cc:430
unsigned int getL1ANumber() const
Get the HTR event number.
Definition: HcalHTRData.h:120
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:409
void determineSectionLengths(int &tpWords, int &daqWords, int &headerWords, int &trailerWords) const
Definition: HcalHTRData.cc:131