CMS 3D CMS Logo

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();
23  ~HcalHTRData() { if (m_ownData!=nullptr) delete [] m_ownData; }
24  HcalHTRData(int version_to_create);
25  HcalHTRData(const unsigned short* data, int length);
26  HcalHTRData(const HcalHTRData&);
27 
29  void allocate(int version_to_create=0);
30  void adoptData(const unsigned short* data, int length);
31 
33  inline int getFormatVersion() const { return m_formatVersion; }
34 
36  inline const unsigned short* getRawData() const { return m_rawConst; }
37 
39  inline const int getRawLength() const { return m_rawLength; }
40 
44  bool check() const;
45 
46  bool isEmptyEvent() const;
47  bool isOverflowWarning() const;
48  bool isBusy() const;
49 
50 
58  void dataPointers(const unsigned short** daq_first,
59  const unsigned short** daq_last,
60  const unsigned short** tp_first,
61  const unsigned short** tp_last) const;
62 
63 
71  void unpack(unsigned char* daq_lengths, unsigned short* daq_samples,
72  unsigned char* tp_lengths, unsigned short* tp_samples) const;
73 
81  bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned
82  short* histogram) const;
83 
86  static bool unpack_per_channel_header(unsigned short, int& flav, int& error_flags, int& capid0, int& channelid);
87 
90  static bool is_channel_header(unsigned short value) { return (value&0x8000)!=0; }
91 
98  void pack(unsigned char* daq_lengths, unsigned short* daq_samples,
99  unsigned char* tp_lengths, unsigned short* tp_samples, bool
100  do_capid=false);
102  void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int
103  orbitn, int pipeline, int ndd, int nps, int firmwareRev=0,
104  int firmwareFlav=0);
105 
107  void packUnsuppressed(const bool* mp);
108 
109 
111  inline unsigned int getL1ANumber() const {
112  return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8);
113  }
115  inline unsigned int getBunchNumber() const {
116  return (m_rawConst[4]&0xFFF);
117  }
119  unsigned int getOrbitNumber() const;
121  unsigned int getSubmodule() const;
123  // get the htr slot
124  unsigned int htrSlot() const;
126  // get the htr top/bottom (1=top/0=bottom)
127  unsigned int htrTopBottom() const;
129  // get the readout VME crate number
130  unsigned int readoutVMECrateId() const;
132  bool isCalibrationStream() const;
134  bool isUnsuppressed() const;
136  bool wasMarkAndPassZS(int fiber, int fiberchan) const;
138  bool wasMarkAndPassZSTP(int slb, int slbchan) const;
140  uint32_t zsBunchMask() const;
141 
143  bool isPatternRAMEvent() const;
146  bool isHistogramEvent() const;
149  void getHistogramFibers(int& a, int& b) const;
151  unsigned int getPipelineLength() const;
153  unsigned int getFirmwareRevision() const;
155  int getFirmwareFlavor() const;
157  inline unsigned int getErrorsWord() const {
158  return m_rawConst[2]&0xFFFF; }
160  int getNPrecisionWords() const;
162  int getNDD() const;
165  int getNTP() const;
167  int getNPS() const;
168 
170  inline unsigned int getDLLunlock() const {
171  return (m_rawConst[5]>>1)&0x3; }
172 
174  inline unsigned int getTTCready() const {
175  return m_rawConst[5]&0x1; }
176 
178  inline unsigned int getFibOrbMsgBCN(int fiber) const {
179  return (m_formatVersion==-1 || fiber<1 || fiber>8)?(0):(m_rawConst[m_rawLength-12+(fiber-1)]&0xFFF);
180  }
181 
183  inline unsigned int getFib1OrbMsgBCN() const {
184  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
185 }
186  inline unsigned int getFib2OrbMsgBCN() const {
187  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
188 }
189 
190  inline unsigned int getFib3OrbMsgBCN() const {
191  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
192 }
193 
194  inline unsigned int getFib4OrbMsgBCN() const {
195  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
196 }
197 
198  inline unsigned int getFib5OrbMsgBCN() const {
199  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
200 }
201 
202  inline unsigned int getFib6OrbMsgBCN() const {
203  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
204 }
205 
206  inline unsigned int getFib7OrbMsgBCN() const {
207  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
208 }
209 
210  inline unsigned int getFib8OrbMsgBCN() const {
211  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
212 }
213 
214 
215 
217  inline unsigned int getExtHdr1() const {
218  return (m_rawConst[0]);}
219  inline unsigned int getExtHdr2() const {
220  return (m_rawConst[1]); }
221  inline unsigned int getExtHdr3() const {
222  return (m_rawConst[2]);}
223  inline unsigned int getExtHdr4() const {
224  return (m_rawConst[3]); }
225  inline unsigned int getExtHdr5() const {
226  return (m_rawConst[4]);}
227  inline unsigned int getExtHdr6() const {
228  return (m_rawConst[5]);}
229  inline unsigned int getExtHdr7() const {
230  return (m_rawConst[6]);}
231  inline unsigned int getExtHdr8() const {
232  return (m_rawConst[7]);}
233 
234  /* unsigned int getFib1OrbMsgBCN() const;
235  unsigned int getFib2OrbMsgBCN() const;
236  unsigned int getFib3OrbMsgBCN() const;
237  unsigned int getFib4OrbMsgBCN() const;
238  unsigned int getFib5OrbMsgBCN() const;
239  unsigned int getFib6OrbMsgBCN() const;
240  unsigned int getFib7OrbMsgBCN() const;
241  unsigned int getFib8OrbMsgBCN() const;
242  */
243 
246  bool wasHistogramError(int ifiber) const;
247 
248 protected:
249  void determineSectionLengths(int& tpWords, int& daqWords, int&
250  headerWords, int& trailerWords) const;
251  void determineStaticLengths(int& headerWords, int& trailerWords) const;
254  const unsigned short* m_rawConst;
255  unsigned short* m_ownData;
256 };
257 
258 #endif
259 
unsigned short * m_ownData
Definition: HcalHTRData.h:255
unsigned int getFib6OrbMsgBCN() const
Definition: HcalHTRData.h:202
int getNDD() const
Get the number of daq data samples per channel when not zero-suppressed.
Definition: HcalHTRData.cc:389
unsigned int getFib1OrbMsgBCN() const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:183
unsigned int getTTCready() const
Get TTCready bit.
Definition: HcalHTRData.h:174
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:62
static int slb(const HcalTriggerPrimitiveSample &theSample)
int m_formatVersion
Definition: HcalHTRData.h:252
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
Definition: HcalHTRData.cc:343
void packUnsuppressed(const bool *mp)
pack trailer with Mark and Pass bits
Definition: HcalHTRData.cc:309
unsigned int getExtHdr2() const
Definition: HcalHTRData.h:219
unsigned int getExtHdr5() const
Definition: HcalHTRData.h:225
unsigned int getExtHdr4() const
Definition: HcalHTRData.h:223
bool isPatternRAMEvent() const
Is this event a pattern-ram event?
Definition: HcalHTRData.cc:383
const unsigned short * m_rawConst
Definition: HcalHTRData.h:254
unsigned int getExtHdr6() const
Definition: HcalHTRData.h:227
unsigned int getFib8OrbMsgBCN() const
Definition: HcalHTRData.h:210
void determineStaticLengths(int &headerWords, int &trailerWords) const
Definition: HcalHTRData.cc:141
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
Definition: HcalHTRData.cc:357
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:178
bool wasHistogramError(int ifiber) const
Was there an error on the given fiber for this event (only in histogram mode!)
Definition: HcalHTRData.cc:426
unsigned int getDLLunlock() const
Get DLLunlock bits.
Definition: HcalHTRData.h:170
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:434
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:414
unsigned int getOrbitNumber() const
Get the HTR orbit number.
Definition: HcalHTRData.cc:325
int getFormatVersion() const
Get the version number of this event.
Definition: HcalHTRData.h:33
HcalHTRData & operator=(const HcalHTRData &)
Definition: HcalHTRData.cc:38
int getNPrecisionWords() const
Get the total number of precision data 16-bit words.
Definition: HcalHTRData.cc:398
bool isCalibrationStream() const
Is this event a calibration-stream event?
Definition: HcalHTRData.cc:351
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:354
unsigned int getExtHdr1() const
Get the HTR Ext Header words.
Definition: HcalHTRData.h:217
void allocate(int version_to_create=0)
Definition: HcalHTRData.cc:26
unsigned int getPipelineLength() const
Get the pipeline length used for this event.
Definition: HcalHTRData.cc:404
bool isOverflowWarning() const
Definition: HcalHTRData.cc:109
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
Definition: HcalHTRData.cc:339
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:173
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
Definition: HcalHTRData.cc:442
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:90
unsigned int getFib7OrbMsgBCN() const
Definition: HcalHTRData.h:206
unsigned int getExtHdr8() const
Definition: HcalHTRData.h:231
int getNTP() const
Get the number of trigger data samples when not zero-suppressed (not available after FW 4) ...
Definition: HcalHTRData.cc:392
bool isEmptyEvent() const
Definition: HcalHTRData.cc:100
const int getRawLength() const
Get the length of the raw data.
Definition: HcalHTRData.h:39
Definition: value.py:1
unsigned int getFib3OrbMsgBCN() const
Definition: HcalHTRData.h:190
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:225
unsigned int getFib5OrbMsgBCN() const
Definition: HcalHTRData.h:198
const unsigned short * getRawData() const
Get a pointer to the raw data.
Definition: HcalHTRData.h:36
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:154
unsigned int getErrorsWord() const
Get the errors word.
Definition: HcalHTRData.h:157
unsigned int getExtHdr3() const
Definition: HcalHTRData.h:221
unsigned int getExtHdr7() const
Definition: HcalHTRData.h:229
double b
Definition: hdecay.h:120
int getNPS() const
Get the number of presamples in daq data.
Definition: HcalHTRData.cc:401
static const int FORMAT_VERSION_COMPACT_DATA
Definition: HcalHTRData.h:20
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:410
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
Definition: HcalHTRData.cc:347
unsigned int getFib4OrbMsgBCN() const
Definition: HcalHTRData.h:194
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:284
void adoptData(const unsigned short *data, int length)
Definition: HcalHTRData.cc:47
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&Pass ZS?
Definition: HcalHTRData.cc:365
double a
Definition: hdecay.h:121
unsigned int getBunchNumber() const
Get the HTR bunch number.
Definition: HcalHTRData.h:115
unsigned int getFib2OrbMsgBCN() const
Definition: HcalHTRData.h:186
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:374
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:332
bool isBusy() const
Definition: HcalHTRData.cc:117
unsigned int getFirmwareRevision() const
Get the HTR firmware version.
Definition: HcalHTRData.cc:407
unsigned int getL1ANumber() const
Get the HTR event number.
Definition: HcalHTRData.h:111
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:386
void determineSectionLengths(int &tpWords, int &daqWords, int &headerWords, int &trailerWords) const
Definition: HcalHTRData.cc:125