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 
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!=0) 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 
106  void packUnsuppressed(const bool* mp);
107 
108 
110  inline unsigned int getL1ANumber() const {
111  return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8);
112  }
114  inline unsigned int getBunchNumber() const {
115  return (m_rawConst[4]&0xFFF);
116  }
118  unsigned int getOrbitNumber() const;
120  unsigned int getSubmodule() const;
122  // get the htr slot
123  unsigned int htrSlot() const;
125  // get the htr top/bottom (1=top/0=bottom)
126  unsigned int htrTopBottom() const;
128  // get the readout VME crate number
129  unsigned int readoutVMECrateId() const;
131  bool isCalibrationStream() const;
133  bool isUnsuppressed() const;
135  bool wasMarkAndPassZS(int fiber, int fiberchan) const;
137  bool wasMarkAndPassZSTP(int slb, int slbchan) const;
139  uint32_t zsBunchMask() const;
140 
142  bool isPatternRAMEvent() const;
145  bool isHistogramEvent() const;
148  void getHistogramFibers(int& a, int& b) const;
150  unsigned int getPipelineLength() const;
152  unsigned int getFirmwareRevision() const;
154  int getFirmwareFlavor() const;
156  inline unsigned int getErrorsWord() const {
157  return m_rawConst[2]&0xFFFF; }
159  int getNPrecisionWords() const;
161  int getNDD() const;
164  int getNTP() const;
166  int getNPS() const;
167 
169  inline unsigned int getDLLunlock() const {
170  return (m_rawConst[5]>>1)&0x3; }
171 
173  inline unsigned int getTTCready() const {
174  return m_rawConst[5]&0x1; }
175 
177  inline unsigned int getFibOrbMsgBCN(int fiber) const {
178  return (m_formatVersion==-1 || fiber<1 || fiber>8)?(0):(m_rawConst[m_rawLength-12+(fiber-1)]&0xFFF);
179  }
180 
182  inline unsigned int getFib1OrbMsgBCN() const {
183  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
184 }
185  inline unsigned int getFib2OrbMsgBCN() const {
186  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
187 }
188 
189  inline unsigned int getFib3OrbMsgBCN() const {
190  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
191 }
192 
193  inline unsigned int getFib4OrbMsgBCN() const {
194  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
195 }
196 
197  inline unsigned int getFib5OrbMsgBCN() const {
198  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
199 }
200 
201  inline unsigned int getFib6OrbMsgBCN() const {
202  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
203 }
204 
205  inline unsigned int getFib7OrbMsgBCN() const {
206  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
207 }
208 
209  inline unsigned int getFib8OrbMsgBCN() const {
210  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
211 }
212 
213 
214 
216  inline unsigned int getExtHdr1() const {
217  return (m_rawConst[0]);}
218  inline unsigned int getExtHdr2() const {
219  return (m_rawConst[1]); }
220  inline unsigned int getExtHdr3() const {
221  return (m_rawConst[2]);}
222  inline unsigned int getExtHdr4() const {
223  return (m_rawConst[3]); }
224  inline unsigned int getExtHdr5() const {
225  return (m_rawConst[4]);}
226  inline unsigned int getExtHdr6() const {
227  return (m_rawConst[5]);}
228  inline unsigned int getExtHdr7() const {
229  return (m_rawConst[6]);}
230  inline unsigned int getExtHdr8() const {
231  return (m_rawConst[7]);}
232 
233  /* unsigned int getFib1OrbMsgBCN() const;
234  unsigned int getFib2OrbMsgBCN() const;
235  unsigned int getFib3OrbMsgBCN() const;
236  unsigned int getFib4OrbMsgBCN() const;
237  unsigned int getFib5OrbMsgBCN() const;
238  unsigned int getFib6OrbMsgBCN() const;
239  unsigned int getFib7OrbMsgBCN() const;
240  unsigned int getFib8OrbMsgBCN() const;
241  */
242 
245  bool wasHistogramError(int ifiber) const;
246 
247 protected:
248  void determineSectionLengths(int& tpWords, int& daqWords, int&
249  headerWords, int& trailerWords) const;
250  void determineStaticLengths(int& headerWords, int& trailerWords) const;
253  const unsigned short* m_rawConst;
254  unsigned short* m_ownData;
255 };
256 
257 #endif
258 
unsigned short * m_ownData
Definition: HcalHTRData.h:254
unsigned int getFib6OrbMsgBCN() const
Definition: HcalHTRData.h:201
int getNDD() const
Get the number of daq data samples per channel when not zero-suppressed.
Definition: HcalHTRData.cc:388
unsigned int getFib1OrbMsgBCN() const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:182
unsigned int getTTCready() const
Get TTCready bit.
Definition: HcalHTRData.h:173
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:251
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
Definition: HcalHTRData.cc:342
void packUnsuppressed(const bool *mp)
pack trailer with Mark and Pass bits
Definition: HcalHTRData.cc:308
unsigned int getExtHdr2() const
Definition: HcalHTRData.h:218
unsigned int getExtHdr5() const
Definition: HcalHTRData.h:224
unsigned int getExtHdr4() const
Definition: HcalHTRData.h:222
bool isPatternRAMEvent() const
Is this event a pattern-ram event?
Definition: HcalHTRData.cc:382
const unsigned short * m_rawConst
Definition: HcalHTRData.h:253
unsigned int getExtHdr6() const
Definition: HcalHTRData.h:226
unsigned int getFib8OrbMsgBCN() const
Definition: HcalHTRData.h:209
void determineStaticLengths(int &headerWords, int &trailerWords) const
Definition: HcalHTRData.cc:140
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
Definition: HcalHTRData.cc:356
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:177
bool wasHistogramError(int ifiber) const
Was there an error on the given fiber for this event (only in histogram mode!)
Definition: HcalHTRData.cc:425
unsigned int getDLLunlock() const
Get DLLunlock bits.
Definition: HcalHTRData.h:169
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:433
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:413
unsigned int getOrbitNumber() const
Get the HTR orbit number.
Definition: HcalHTRData.cc:324
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:397
bool isCalibrationStream() const
Is this event a calibration-stream event?
Definition: HcalHTRData.cc:350
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:353
unsigned int getExtHdr1() const
Get the HTR Ext Header words.
Definition: HcalHTRData.h:216
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:403
bool isOverflowWarning() const
Definition: HcalHTRData.cc:109
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
Definition: HcalHTRData.cc:338
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:172
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
Definition: HcalHTRData.cc:441
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:205
unsigned int getExtHdr8() const
Definition: HcalHTRData.h:230
int getNTP() const
Get the number of trigger data samples when not zero-suppressed (not available after FW 4) ...
Definition: HcalHTRData.cc:391
bool isEmptyEvent() const
Definition: HcalHTRData.cc:100
const int getRawLength() const
Get the length of the raw data.
Definition: HcalHTRData.h:39
unsigned int getFib3OrbMsgBCN() const
Definition: HcalHTRData.h:189
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:224
unsigned int getFib5OrbMsgBCN() const
Definition: HcalHTRData.h:197
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:153
unsigned int getErrorsWord() const
Get the errors word.
Definition: HcalHTRData.h:156
unsigned int getExtHdr3() const
Definition: HcalHTRData.h:220
unsigned int getExtHdr7() const
Definition: HcalHTRData.h:228
double b
Definition: hdecay.h:120
int getNPS() const
Get the number of presamples in daq data.
Definition: HcalHTRData.cc:400
static const int FORMAT_VERSION_COMPACT_DATA
Definition: HcalHTRData.h:20
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:409
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
Definition: HcalHTRData.cc:346
unsigned int getFib4OrbMsgBCN() const
Definition: HcalHTRData.h:193
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&amp;Pass ZS?
Definition: HcalHTRData.cc:364
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:283
double a
Definition: hdecay.h:121
unsigned int getBunchNumber() const
Get the HTR bunch number.
Definition: HcalHTRData.h:114
unsigned int getFib2OrbMsgBCN() const
Definition: HcalHTRData.h:185
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:373
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:331
bool isBusy() const
Definition: HcalHTRData.cc:117
unsigned int getFirmwareRevision() const
Get the HTR firmware version.
Definition: HcalHTRData.cc:406
unsigned int getL1ANumber() const
Get the HTR event number.
Definition: HcalHTRData.h:110
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:385
void determineSectionLengths(int &tpWords, int &daqWords, int &headerWords, int &trailerWords) const
Definition: HcalHTRData.cc:125