CMS 3D CMS Logo

CastorCORData.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef CastorCORData_H
3 #define CastorCORData_H
4 
15  public:
16  static const int CHANNELS_PER_SPIGOT ;// = 36;
17  static const int MAXIMUM_SAMPLES_PER_CHANNEL;// = 20;
18 
19  CastorCORData();
20  ~CastorCORData() { if (m_ownData!=nullptr) delete [] m_ownData; }
21  CastorCORData(int version_to_create);
22  CastorCORData(const unsigned short* data, int length);
24 
26  void allocate(int version_to_create=0);
27  void adoptData(const unsigned short* data, int length);
28 
30  inline int getFormatVersion() const { return m_formatVersion; }
31 
33  inline const unsigned short* getRawData() const { return m_rawConst; }
34 
36  inline const int getRawLength() const { return m_rawLength; }
37 
41  bool check() const;
42 
50  //void dataPointers(const unsigned short** daq_first,
51  //const unsigned short** daq_last,
52  //const unsigned short** tp_first,
53  //const unsigned short** tp_last);
54 
55 
63  void unpack(unsigned char* daq_lengths, unsigned short* daq_samples,
64  unsigned char* tp_lengths, unsigned short* tp_samples) const;
65 
73  bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned
74  short* histogram) const;
75 
82  void pack(unsigned char* daq_lengths, unsigned short* daq_samples,
83  unsigned char* tp_lengths, unsigned short* tp_samples, bool
84  do_capid=false);
86  void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int
87  orbitn, int pipeline, int ndd, int nps, int firmwareRev=0);
88 
90  inline unsigned int getL1ANumber() const {
91  return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8);
92  }
94  inline unsigned int getBunchNumber() const {
95  return (m_rawConst[4]&0xFFF);
96  }
98  unsigned int getOrbitNumber() const;
100  unsigned int getSubmodule() const;
102  // get the htr slot
103  unsigned int htrSlot() const;
105  // get the htr top/bottom (1=top/0=bottom)
106  unsigned int htrTopBottom() const;
108  // get the readout VME crate number
109  unsigned int readoutVMECrateId() const;
111  bool isCalibrationStream() const;
113  bool isUnsuppressed() const;
115  bool wasMarkAndPassZS(int fiber, int fiberchan) const;
116 
118  bool isPatternRAMEvent() const;
121  bool isHistogramEvent() const;
124  void getHistogramFibers(int& a, int& b) const;
126  unsigned int getPipelineLength() const;
128  unsigned int getFirmwareRevision() const;
130  inline unsigned int getErrorsWord() const {
131  return m_rawConst[2]&0xFFFF; }
133  int getNPrecisionWords() const;
135  int getNDD() const;
138  int getNTP() const;
140  int getNPS() const;
141 
143  inline unsigned int getDLLunlock() const {
144  return (m_rawConst[5]>>2)&0x3; }
145 
147  inline unsigned int getTTCready() const {
148  return m_rawConst[5]&0x3; }
149 
151  inline unsigned int getFib1OrbMsgBCN() const {
152  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
153 }
154  inline unsigned int getFib2OrbMsgBCN() const {
155  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
156 }
157 
158  inline unsigned int getFib3OrbMsgBCN() const {
159  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
160 }
161 
162  inline unsigned int getFib4OrbMsgBCN() const {
163  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
164 }
165 
166  inline unsigned int getFib5OrbMsgBCN() const {
167  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
168 }
169 
170  inline unsigned int getFib6OrbMsgBCN() const {
171  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
172 }
173 
174  inline unsigned int getFib7OrbMsgBCN() const {
175  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
176 }
177 
178  inline unsigned int getFib8OrbMsgBCN() const {
179  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
180 }
181 
182 
183 
185  inline unsigned int getExtHdr1() const {
186  return (m_rawConst[0]);}
187  inline unsigned int getExtHdr2() const {
188  return (m_rawConst[1]); }
189  inline unsigned int getExtHdr3() const {
190  return (m_rawConst[2]);}
191  inline unsigned int getExtHdr4() const {
192  return (m_rawConst[3]); }
193  inline unsigned int getExtHdr5() const {
194  return (m_rawConst[4]);}
195  inline unsigned int getExtHdr6() const {
196  return (m_rawConst[5]);}
197  inline unsigned int getExtHdr7() const {
198  return (m_rawConst[6]);}
199  inline unsigned int getExtHdr8() const {
200  return (m_rawConst[7]);}
201 
202  /* unsigned int getFib1OrbMsgBCN() const;
203  unsigned int getFib2OrbMsgBCN() const;
204  unsigned int getFib3OrbMsgBCN() const;
205  unsigned int getFib4OrbMsgBCN() const;
206  unsigned int getFib5OrbMsgBCN() const;
207  unsigned int getFib6OrbMsgBCN() const;
208  unsigned int getFib7OrbMsgBCN() const;
209  unsigned int getFib8OrbMsgBCN() const;
210  */
211 
214  // bool wasHistogramError(int ifiber) const;
215 
216 protected:
217  void determineSectionLengths(int& tpWords, int& daqWords, int&
218  headerWords, int& trailerWords, int& triggerWords) const;
219  void determineStaticLengths(int& headerWords, int& trailerWords, int& triggerWords) const;
222  const unsigned short* m_rawConst; // pointer to actual raw data
223  unsigned short* m_ownData; // local block in raw data format
224  unsigned short* m_unpackedData; // local data in usable format
225 
226 };
227 
228 #endif
229 
CastorCORData & operator=(const CastorCORData &)
int getNPS() const
Get the number of presamples in daq data.
unsigned int getExtHdr2() const
bool isCalibrationStream() const
Is this event a calibration-stream event?
unsigned int getExtHdr1() const
Get the COR Ext Header words.
static const int CHANNELS_PER_SPIGOT
Definition: CastorCORData.h:16
void adoptData(const unsigned short *data, int length)
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.
int getNDD() const
Get the number of daq data samples per channel when not zero-suppressed.
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)
void unpack(unsigned char *daq_lengths, unsigned short *daq_samples, unsigned char *tp_lengths, unsigned short *tp_samples) const
Obtain the starting and ending pointers for external unpacking of the data.
unsigned int getFirmwareRevision() const
Get the COR firmware version.
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
unsigned int getErrorsWord() const
Get the errors word.
unsigned int getSubmodule() const
Get the HTR submodule number.
unsigned int getFib1OrbMsgBCN() const
Get the BCN of the Fiber Orbit Messages.
unsigned int getOrbitNumber() const
Get the HTR orbit number.
unsigned int getFib7OrbMsgBCN() const
int getNTP() const
Get the number of trigger data samples when not zero-suppressed (not available after FW 4) ...
unsigned int getFib2OrbMsgBCN() const
unsigned int getFib3OrbMsgBCN() const
unsigned int getFib8OrbMsgBCN() const
unsigned int getExtHdr8() const
int getFormatVersion() const
Get the version number of this event.
Definition: CastorCORData.h:30
unsigned int getFib5OrbMsgBCN() const
int getNPrecisionWords() const
Get the total number of precision data 16-bit words.
unsigned int getBunchNumber() const
Get the HTR bunch number.
Definition: CastorCORData.h:94
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: CastorCORData.h:17
bool isUnsuppressed() const
Is this event an unsuppresed event?
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
unsigned int getPipelineLength() const
Get the pipeline length used for this event.
unsigned short * m_ownData
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
unsigned int getExtHdr3() const
unsigned short * m_unpackedData
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!) ...
void allocate(int version_to_create=0)
unsigned int getFib4OrbMsgBCN() const
const int getRawLength() const
Get the length of the raw data.
Definition: CastorCORData.h:36
const unsigned short * getRawData() const
Get a pointer to the raw data.
Definition: CastorCORData.h:33
double b
Definition: hdecay.h:120
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
unsigned int getDLLunlock() const
Get DLLunlock bits.
unsigned int getExtHdr4() const
unsigned int getExtHdr5() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
double a
Definition: hdecay.h:121
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
bool isPatternRAMEvent() const
Is this event a pattern-ram event?
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
unsigned int getExtHdr7() const
unsigned int getL1ANumber() const
Get the HTR event number.
Definition: CastorCORData.h:90
void determineStaticLengths(int &headerWords, int &trailerWords, int &triggerWords) const
const unsigned short * m_rawConst
unsigned int getFib6OrbMsgBCN() const
unsigned int getTTCready() const
Get TTCready bits.
unsigned int getExtHdr6() const
void determineSectionLengths(int &tpWords, int &daqWords, int &headerWords, int &trailerWords, int &triggerWords) const
Was there an error on the given fiber for this event (only in histogram mode!)