CMS 3D CMS Logo

DCCDataParser.h
Go to the documentation of this file.
1 /*----------------------------------------------------------*/
2 /* DCC DATA PARSER */
3 /* */
4 /* Author : N.Almeida (LIP) Date : 30/05/2004 */
5 /*----------------------------------------------------------*/
6 
7 #ifndef DCCTBDATAPARSER_HH
8 #define DCCTBDATAPARSER_HH
9 
10 #include <fstream> //STL
11 #include <iostream>
12 #include <string>
13 #include <vector>
14 #include <map>
15 
16 #include <cstdio> //C
17 
18 #include "ECALParserException.h" //DATA DECODER
19 #include "DCCEventBlock.h"
20 #include "DCCDataMapper.h"
21 
22 
23 class DCCTBDataMapper;
24 class DCCTBEventBlock;
25 
26 
28 
29 public :
30 
42  DCCTBDataParser( const std::vector<uint32_t>& parserParameters , bool parseInternalData = true, bool debug = true);
43 
47  void parseFile( std::string fileName, bool singleEvent = false);
48 
52  void parseBuffer( uint32_t * buffer, uint32_t bufferSize, bool singleEvent = false);
53 
58 
63  std::pair<uint32_t,uint32_t> checkEventLength(uint32_t * pointerToEvent, uint32_t bytesToEnd, bool singleEvent = false);
64 
68  std::vector<uint32_t> parserParameters();
69  uint32_t numbXtalSamples();
70  uint32_t numbTriggerSamples();
71  uint32_t numbTTs();
72  uint32_t numbSRF();
73  uint32_t dccId();
74  uint32_t srpId();
75  uint32_t tcc1Id();
76  uint32_t tcc2Id();
77  uint32_t tcc3Id();
78  uint32_t tcc4Id();
79 
80 
84  void setParameters( const std::vector<uint32_t>& newParameters );
85 
86 
90  uint32_t srpBlockSize();
91  uint32_t tccBlockSize();
92 
96  bool debug();
97 
101  std::vector<DCCTBEventBlock *> & dccEvents();
102 
106  std::map<std::string,uint32_t> & errorCounters();
107 
111  std::vector< std::pair< uint32_t, std::pair<uint32_t *, uint32_t> > > events();
112 
113 
117  void resetErrorCounters();
118 
119 
123  std::string getDecString(uint32_t data);
124  std::string getHexString(uint32_t data);
125  std::string index(uint32_t position);
126  std::string getIndexedData( uint32_t indexed, uint32_t * pointer);
127 
131  uint32_t *getBuffer() { return buffer_;}
132 
137 
139  EMPTYEVENTSIZE = 32 //bytes
140  };
141 
142 protected :
143  void computeBlockSizes();
144 
145  uint32_t *buffer_; //data buffer
146  uint32_t bufferSize_; //buffer size
147 
148  uint32_t srpBlockSize_; //SR block size
149  uint32_t tccBlockSize_; //TCC block size
150 
151  uint32_t processedEvent_;
154 
155  std::vector<DCCTBEventBlock *> dccEvents_;
156 
157  // std::pair< errorMask, std::pair< pointer to event, event size (number of DW)> >
158  std::vector< std::pair< uint32_t, std::pair<uint32_t *, uint32_t> > > events_;
159 
160  bool parseInternalData_; //parse internal data flag
161  bool debug_; //debug flag
162  std::map<std::string,uint32_t> errors_; //errors map
163  std::vector<uint32_t> parameters; //parameters vector
164 
166  EVENTLENGTHMASK = 0xFFFFFF,
167 
168  BOEBEGIN = 28, //begin of event (on 32 bit string starts at bit 28)
169  BOEMASK = 0xF, //mask is 4 bits (F)
170  BOE =0x5, //B'0101'
171 
172  EOEBEGIN = 28, //end of event
173  EOEMASK = 0xF, //4 bits
174  EOE =0xA //B'1010'
175  };
176 
177 };
178 
180 
181 inline std::vector<uint32_t> DCCTBDataParser::parserParameters() { return parameters; }
182 inline uint32_t DCCTBDataParser::numbXtalSamples() { return parameters[0]; }
183 inline uint32_t DCCTBDataParser::numbTriggerSamples() { return parameters[1]; }
184 inline uint32_t DCCTBDataParser::numbTTs() { return parameters[2]; }
185 inline uint32_t DCCTBDataParser::numbSRF() { return parameters[3]; }
186 inline uint32_t DCCTBDataParser::dccId() { return parameters[4]; }
187 inline uint32_t DCCTBDataParser::srpId() { return parameters[5]; }
188 inline uint32_t DCCTBDataParser::tcc1Id() { return parameters[6]; }
189 inline uint32_t DCCTBDataParser::tcc2Id() { return parameters[7]; }
190 inline uint32_t DCCTBDataParser::tcc3Id() { return parameters[8]; }
191 inline uint32_t DCCTBDataParser::tcc4Id() { return parameters[9]; }
192 
193 inline void DCCTBDataParser::setParameters( const std::vector<uint32_t>& newParameters ){ parameters = newParameters; computeBlockSizes();}
194 
195 inline uint32_t DCCTBDataParser::srpBlockSize() { return srpBlockSize_; }
196 inline uint32_t DCCTBDataParser::tccBlockSize() { return tccBlockSize_; }
197 
198 inline bool DCCTBDataParser::debug() { return debug_; }
199 inline std::vector<DCCTBEventBlock *> &DCCTBDataParser::dccEvents() { return dccEvents_; }
200 inline std::map<std::string,uint32_t> &DCCTBDataParser::errorCounters() { return errors_; }
201 inline std::vector< std::pair< uint32_t, std::pair<uint32_t *, uint32_t> > > DCCTBDataParser::events() { return events_; }
202 
203 
204 #endif
205 
uint32_t tcc3Id()
std::vector< DCCTBEventBlock * > dccEvents_
uint32_t * getBuffer()
uint32_t tccBlockSize()
void resetErrorCounters()
std::vector< std::pair< uint32_t, std::pair< uint32_t *, uint32_t > > > events()
std::map< std::string, uint32_t > & errorCounters()
std::map< std::string, uint32_t > errors_
void computeBlockSizes()
std::string getDecString(uint32_t data)
std::vector< DCCTBEventBlock * > & dccEvents()
std::string getIndexedData(uint32_t indexed, uint32_t *pointer)
void setParameters(const std::vector< uint32_t > &newParameters)
uint32_t tccBlockSize_
uint32_t numbTriggerSamples()
uint32_t numbXtalSamples()
std::vector< std::pair< uint32_t, std::pair< uint32_t *, uint32_t > > > events_
std::vector< uint32_t > parameters
uint32_t srpBlockSize()
uint32_t srpBlockSize_
void parseFile(std::string fileName, bool singleEvent=false)
std::pair< uint32_t, uint32_t > checkEventLength(uint32_t *pointerToEvent, uint32_t bytesToEnd, bool singleEvent=false)
uint32_t processedEvent_
uint32_t tcc2Id()
uint32_t numbTTs()
DCCTBDataMapper * mapper()
std::vector< uint32_t > parserParameters()
uint32_t tcc1Id()
uint32_t numbSRF()
std::string getHexString(uint32_t data)
uint32_t dccId()
void parseBuffer(uint32_t *buffer, uint32_t bufferSize, bool singleEvent=false)
uint32_t srpId()
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::string eventErrors_
DCCTBDataMapper * mapper_
DCCTBDataParser(const std::vector< uint32_t > &parserParameters, bool parseInternalData=true, bool debug=true)
Definition: DCCDataParser.cc:9
uint32_t bufferSize_
uint32_t tcc4Id()
std::string index(uint32_t position)
uint32_t * buffer_