CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalHTRData.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef HcalHTRData_H
3 #define HcalHTRData_H
4 
5 #include <stdint.h>
6 
18 class HcalHTRData {
19  public:
20  static const int CHANNELS_PER_SPIGOT = 24;
21  static const int MAXIMUM_SAMPLES_PER_CHANNEL = 20;
22  static const int FORMAT_VERSION_COMPACT_DATA = 6;
23 
24  HcalHTRData();
25  ~HcalHTRData() { if (m_ownData!=0) delete [] m_ownData; }
26  HcalHTRData(int version_to_create);
27  HcalHTRData(const unsigned short* data, int length);
28  HcalHTRData(const HcalHTRData&);
29 
31  void allocate(int version_to_create=0);
32  void adoptData(const unsigned short* data, int length);
33 
35  inline int getFormatVersion() const { return m_formatVersion; }
36 
38  inline const unsigned short* getRawData() const { return m_rawConst; }
39 
41  inline const int getRawLength() const { return m_rawLength; }
42 
46  bool check() const;
47 
48  bool isEmptyEvent() const;
49  bool isOverflowWarning() const;
50  bool isBusy() const;
51 
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 
65 
73  void unpack(unsigned char* daq_lengths, unsigned short* daq_samples,
74  unsigned char* tp_lengths, unsigned short* tp_samples) const;
75 
83  bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned
84  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, unsigned short* daq_samples,
101  unsigned char* tp_lengths, unsigned short* tp_samples, bool
102  do_capid=false);
104  void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int
105  orbitn, int pipeline, int ndd, int nps, int firmwareRev=0);
106 
108  void packUnsuppressed(const bool* mp);
109 
110 
112  inline unsigned int getL1ANumber() const {
113  return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8);
114  }
116  inline unsigned int getBunchNumber() const {
117  return (m_rawConst[4]&0xFFF);
118  }
120  unsigned int getOrbitNumber() const;
122  unsigned int getSubmodule() const;
124  // get the htr slot
125  unsigned int htrSlot() const;
127  // get the htr top/bottom (1=top/0=bottom)
128  unsigned int htrTopBottom() const;
130  // get the readout VME crate number
131  unsigned int readoutVMECrateId() const;
133  bool isCalibrationStream() const;
135  bool isUnsuppressed() const;
137  bool wasMarkAndPassZS(int fiber, int fiberchan) const;
139  bool wasMarkAndPassZSTP(int slb, int slbchan) const;
141  uint32_t zsBunchMask() const;
142 
144  bool isPatternRAMEvent() const;
147  bool isHistogramEvent() const;
150  void getHistogramFibers(int& a, int& b) const;
152  unsigned int getPipelineLength() const;
154  unsigned int getFirmwareRevision() const;
156  int getFirmwareFlavor() const;
158  inline unsigned int getErrorsWord() const {
159  return m_rawConst[2]&0xFFFF; }
161  int getNPrecisionWords() const;
163  int getNDD() const;
166  int getNTP() const;
168  int getNPS() const;
169 
171  inline unsigned int getDLLunlock() const {
172  return (m_rawConst[5]>>1)&0x3; }
173 
175  inline unsigned int getTTCready() const {
176  return m_rawConst[5]&0x1; }
177 
179  inline unsigned int getFibOrbMsgBCN(int fiber) const {
180  return (m_formatVersion==-1 || fiber<1 || fiber>8)?(0):(m_rawConst[m_rawLength-12+(fiber-1)]&0xFFF);
181  }
182 
184  inline unsigned int getFib1OrbMsgBCN() const {
185  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
186 }
187  inline unsigned int getFib2OrbMsgBCN() const {
188  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
189 }
190 
191  inline unsigned int getFib3OrbMsgBCN() const {
192  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
193 }
194 
195  inline unsigned int getFib4OrbMsgBCN() const {
196  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
197 }
198 
199  inline unsigned int getFib5OrbMsgBCN() const {
200  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
201 }
202 
203  inline unsigned int getFib6OrbMsgBCN() const {
204  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
205 }
206 
207  inline unsigned int getFib7OrbMsgBCN() const {
208  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
209 }
210 
211  inline unsigned int getFib8OrbMsgBCN() const {
212  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
213 }
214 
215 
216 
218  inline unsigned int getExtHdr1() const {
219  return (m_rawConst[0]);}
220  inline unsigned int getExtHdr2() const {
221  return (m_rawConst[1]); }
222  inline unsigned int getExtHdr3() const {
223  return (m_rawConst[2]);}
224  inline unsigned int getExtHdr4() const {
225  return (m_rawConst[3]); }
226  inline unsigned int getExtHdr5() const {
227  return (m_rawConst[4]);}
228  inline unsigned int getExtHdr6() const {
229  return (m_rawConst[5]);}
230  inline unsigned int getExtHdr7() const {
231  return (m_rawConst[6]);}
232  inline unsigned int getExtHdr8() const {
233  return (m_rawConst[7]);}
234 
235  /* unsigned int getFib1OrbMsgBCN() const;
236  unsigned int getFib2OrbMsgBCN() const;
237  unsigned int getFib3OrbMsgBCN() const;
238  unsigned int getFib4OrbMsgBCN() const;
239  unsigned int getFib5OrbMsgBCN() const;
240  unsigned int getFib6OrbMsgBCN() const;
241  unsigned int getFib7OrbMsgBCN() const;
242  unsigned int getFib8OrbMsgBCN() const;
243  */
244 
247  bool wasHistogramError(int ifiber) const;
248 
249 protected:
250  void determineSectionLengths(int& tpWords, int& daqWords, int&
251  headerWords, int& trailerWords) const;
252  void determineStaticLengths(int& headerWords, int& trailerWords) const;
255  const unsigned short* m_rawConst;
256  unsigned short* m_ownData;
257 };
258 
259 #endif
260 
unsigned short * m_ownData
Definition: HcalHTRData.h:256
unsigned int getFib6OrbMsgBCN() const
Definition: HcalHTRData.h:203
int getNDD() const
Get the number of daq data samples per channel when not zero-suppressed.
Definition: HcalHTRData.cc:390
unsigned int getFib1OrbMsgBCN() const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:184
unsigned int getTTCready() const
Get TTCready bit.
Definition: HcalHTRData.h:175
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:64
int m_formatVersion
Definition: HcalHTRData.h:253
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
Definition: HcalHTRData.cc:344
void packUnsuppressed(const bool *mp)
pack trailer with Mark and Pass bits
Definition: HcalHTRData.cc:310
unsigned int getExtHdr2() const
Definition: HcalHTRData.h:220
unsigned int getExtHdr5() const
Definition: HcalHTRData.h:226
unsigned int getExtHdr4() const
Definition: HcalHTRData.h:224
bool isPatternRAMEvent() const
Is this event a pattern-ram event?
Definition: HcalHTRData.cc:384
const unsigned short * m_rawConst
Definition: HcalHTRData.h:255
unsigned int getExtHdr6() const
Definition: HcalHTRData.h:228
unsigned int getFib8OrbMsgBCN() const
Definition: HcalHTRData.h:211
void determineStaticLengths(int &headerWords, int &trailerWords) const
Definition: HcalHTRData.cc:142
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
Definition: HcalHTRData.cc:358
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:179
bool wasHistogramError(int ifiber) const
Was there an error on the given fiber for this event (only in histogram mode!)
Definition: HcalHTRData.cc:427
unsigned int getDLLunlock() const
Get DLLunlock bits.
Definition: HcalHTRData.h:171
static const int CHANNELS_PER_SPIGOT
Definition: HcalHTRData.h:20
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:435
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: HcalHTRData.h:21
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:415
unsigned int getOrbitNumber() const
Get the HTR orbit number.
Definition: HcalHTRData.cc:326
int getFormatVersion() const
Get the version number of this event.
Definition: HcalHTRData.h:35
HcalHTRData & operator=(const HcalHTRData &)
Definition: HcalHTRData.cc:40
int getNPrecisionWords() const
Get the total number of precision data 16-bit words.
Definition: HcalHTRData.cc:399
bool isCalibrationStream() const
Is this event a calibration-stream event?
Definition: HcalHTRData.cc:352
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:355
unsigned int getExtHdr1() const
Get the HTR Ext Header words.
Definition: HcalHTRData.h:218
void allocate(int version_to_create=0)
Definition: HcalHTRData.cc:28
unsigned int getPipelineLength() const
Get the pipeline length used for this event.
Definition: HcalHTRData.cc:405
bool isOverflowWarning() const
Definition: HcalHTRData.cc:111
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
Definition: HcalHTRData.cc:340
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:174
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
Definition: HcalHTRData.cc:443
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:207
unsigned int getExtHdr8() const
Definition: HcalHTRData.h:232
int getNTP() const
Get the number of trigger data samples when not zero-suppressed (not available after FW 4) ...
Definition: HcalHTRData.cc:393
bool isEmptyEvent() const
Definition: HcalHTRData.cc:102
const int getRawLength() const
Get the length of the raw data.
Definition: HcalHTRData.h:41
unsigned int getFib3OrbMsgBCN() const
Definition: HcalHTRData.h:191
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:226
unsigned int getFib5OrbMsgBCN() const
Definition: HcalHTRData.h:199
const unsigned short * getRawData() const
Get a pointer to the raw data.
Definition: HcalHTRData.h:38
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:155
unsigned int getErrorsWord() const
Get the errors word.
Definition: HcalHTRData.h:158
unsigned int getExtHdr3() const
Definition: HcalHTRData.h:222
unsigned int getExtHdr7() const
Definition: HcalHTRData.h:230
double b
Definition: hdecay.h:120
int getNPS() const
Get the number of presamples in daq data.
Definition: HcalHTRData.cc:402
static const int FORMAT_VERSION_COMPACT_DATA
Definition: HcalHTRData.h:22
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:411
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
Definition: HcalHTRData.cc:348
unsigned int getFib4OrbMsgBCN() const
Definition: HcalHTRData.h:195
void adoptData(const unsigned short *data, int length)
Definition: HcalHTRData.cc:49
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&amp;Pass ZS?
Definition: HcalHTRData.cc:366
void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int orbitn, int pipeline, int ndd, int nps, int firmwareRev=0)
pack header and trailer (call after pack)
Definition: HcalHTRData.cc:285
double a
Definition: hdecay.h:121
unsigned int getBunchNumber() const
Get the HTR bunch number.
Definition: HcalHTRData.h:116
unsigned int getFib2OrbMsgBCN() const
Definition: HcalHTRData.h:187
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:375
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:333
bool isBusy() const
Definition: HcalHTRData.cc:119
unsigned int getFirmwareRevision() const
Get the HTR firmware version.
Definition: HcalHTRData.cc:408
unsigned int getL1ANumber() const
Get the HTR event number.
Definition: HcalHTRData.h:112
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:387
void determineSectionLengths(int &tpWords, int &daqWords, int &headerWords, int &trailerWords) const
Definition: HcalHTRData.cc:127