CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorCORData.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef CastorCORData_H
3 #define CastorCORData_H
4 
17  public:
18  static const int CHANNELS_PER_SPIGOT ;// = 36;
19  static const int MAXIMUM_SAMPLES_PER_CHANNEL;// = 20;
20 
21  CastorCORData();
22  ~CastorCORData() { if (m_ownData!=0) delete [] m_ownData; }
23  CastorCORData(int version_to_create);
24  CastorCORData(const unsigned short* data, int length);
26 
28  void allocate(int version_to_create=0);
29  void adoptData(const unsigned short* data, int length);
30 
32  inline int getFormatVersion() const { return m_formatVersion; }
33 
35  inline const unsigned short* getRawData() const { return m_rawConst; }
36 
38  inline const int getRawLength() const { return m_rawLength; }
39 
43  bool check() const;
44 
52  //void dataPointers(const unsigned short** daq_first,
53  //const unsigned short** daq_last,
54  //const unsigned short** tp_first,
55  //const unsigned short** tp_last);
56 
57 
65  void unpack(unsigned char* daq_lengths, unsigned short* daq_samples,
66  unsigned char* tp_lengths, unsigned short* tp_samples) const;
67 
75  bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned
76  short* histogram) const;
77 
84  void pack(unsigned char* daq_lengths, unsigned short* daq_samples,
85  unsigned char* tp_lengths, unsigned short* tp_samples, bool
86  do_capid=false);
88  void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int
89  orbitn, int pipeline, int ndd, int nps, int firmwareRev=0);
90 
92  inline unsigned int getL1ANumber() const {
93  return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8);
94  }
96  inline unsigned int getBunchNumber() const {
97  return (m_rawConst[4]&0xFFF);
98  }
100  unsigned int getOrbitNumber() const;
102  unsigned int getSubmodule() const;
104  // get the htr slot
105  unsigned int htrSlot() const;
107  // get the htr top/bottom (1=top/0=bottom)
108  unsigned int htrTopBottom() const;
110  // get the readout VME crate number
111  unsigned int readoutVMECrateId() const;
113  bool isCalibrationStream() const;
115  bool isUnsuppressed() const;
117  bool wasMarkAndPassZS(int fiber, int fiberchan) const;
118 
120  bool isPatternRAMEvent() const;
123  bool isHistogramEvent() const;
126  void getHistogramFibers(int& a, int& b) const;
128  unsigned int getPipelineLength() const;
130  unsigned int getFirmwareRevision() const;
132  inline unsigned int getErrorsWord() const {
133  return m_rawConst[2]&0xFFFF; }
135  int getNPrecisionWords() const;
137  int getNDD() const;
140  int getNTP() const;
142  int getNPS() const;
143 
145  inline unsigned int getDLLunlock() const {
146  return (m_rawConst[5]>>2)&0x3; }
147 
149  inline unsigned int getTTCready() const {
150  return m_rawConst[5]&0x3; }
151 
153  inline unsigned int getFib1OrbMsgBCN() const {
154  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
155 }
156  inline unsigned int getFib2OrbMsgBCN() const {
157  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
158 }
159 
160  inline unsigned int getFib3OrbMsgBCN() const {
161  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
162 }
163 
164  inline unsigned int getFib4OrbMsgBCN() const {
165  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
166 }
167 
168  inline unsigned int getFib5OrbMsgBCN() const {
169  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
170 }
171 
172  inline unsigned int getFib6OrbMsgBCN() const {
173  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
174 }
175 
176  inline unsigned int getFib7OrbMsgBCN() const {
177  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
178 }
179 
180  inline unsigned int getFib8OrbMsgBCN() const {
181  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
182 }
183 
184 
185 
187  inline unsigned int getExtHdr1() const {
188  return (m_rawConst[0]);}
189  inline unsigned int getExtHdr2() const {
190  return (m_rawConst[1]); }
191  inline unsigned int getExtHdr3() const {
192  return (m_rawConst[2]);}
193  inline unsigned int getExtHdr4() const {
194  return (m_rawConst[3]); }
195  inline unsigned int getExtHdr5() const {
196  return (m_rawConst[4]);}
197  inline unsigned int getExtHdr6() const {
198  return (m_rawConst[5]);}
199  inline unsigned int getExtHdr7() const {
200  return (m_rawConst[6]);}
201  inline unsigned int getExtHdr8() const {
202  return (m_rawConst[7]);}
203 
204  /* unsigned int getFib1OrbMsgBCN() const;
205  unsigned int getFib2OrbMsgBCN() const;
206  unsigned int getFib3OrbMsgBCN() const;
207  unsigned int getFib4OrbMsgBCN() const;
208  unsigned int getFib5OrbMsgBCN() const;
209  unsigned int getFib6OrbMsgBCN() const;
210  unsigned int getFib7OrbMsgBCN() const;
211  unsigned int getFib8OrbMsgBCN() const;
212  */
213 
216  // bool wasHistogramError(int ifiber) const;
217 
218 protected:
219  void determineSectionLengths(int& tpWords, int& daqWords, int&
220  headerWords, int& trailerWords, int& triggerWords) const;
221  void determineStaticLengths(int& headerWords, int& trailerWords, int& triggerWords) const;
224  const unsigned short* m_rawConst; // pointer to actual raw data
225  unsigned short* m_ownData; // local block in raw data format
226  unsigned short* m_unpackedData; // local data in usable format
227 
228 };
229 
230 #endif
231 
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:18
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:32
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:96
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: CastorCORData.h:19
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:38
const unsigned short * getRawData() const
Get a pointer to the raw data.
Definition: CastorCORData.h:35
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&amp;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:92
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!)