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 class DCCTBDataMapper;
23 class DCCTBEventBlock;
24 
26 public:
38  DCCTBDataParser(const std::vector<uint32_t> &parserParameters, bool parseInternalData = true, bool debug = true);
39 
43  void parseFile(std::string fileName, bool singleEvent = false);
44 
48  void parseBuffer(const uint32_t *buffer, uint32_t bufferSize, bool singleEvent = false);
49 
54 
59  std::pair<uint32_t, uint32_t> checkEventLength(const uint32_t *pointerToEvent,
60  uint32_t bytesToEnd,
61  bool singleEvent = false);
62 
66  std::vector<uint32_t> parserParameters();
67  uint32_t numbXtalSamples();
68  uint32_t numbTriggerSamples();
69  uint32_t numbTTs();
70  uint32_t numbSRF();
71  uint32_t dccId();
72  uint32_t srpId();
73  uint32_t tcc1Id();
74  uint32_t tcc2Id();
75  uint32_t tcc3Id();
76  uint32_t tcc4Id();
77 
81  void setParameters(const std::vector<uint32_t> &newParameters);
82 
86  uint32_t srpBlockSize();
87  uint32_t tccBlockSize();
88 
92  bool debug();
93 
97  std::vector<DCCTBEventBlock *> &dccEvents();
98 
102  std::map<std::string, uint32_t> &errorCounters();
103 
107  std::vector<std::pair<uint32_t, std::pair<const uint32_t *, uint32_t> > > events();
108 
112  void resetErrorCounters();
113 
117  std::string getDecString(uint32_t data);
118  std::string getHexString(uint32_t data);
119  std::string index(uint32_t position);
120  std::string getIndexedData(uint32_t indexed, uint32_t *pointer);
121 
125  const uint32_t *getBuffer() { return buffer_; }
126 
131 
133  EMPTYEVENTSIZE = 32 //bytes
134  };
135 
136 protected:
137  void computeBlockSizes();
138 
139  const uint32_t *buffer_; //data buffer
140  uint32_t bufferSize_; //buffer size
141 
142  uint32_t srpBlockSize_; //SR block size
143  uint32_t tccBlockSize_; //TCC block size
144 
145  uint32_t processedEvent_;
148 
149  std::vector<DCCTBEventBlock *> dccEvents_;
150 
151  // std::pair< errorMask, std::pair< pointer to event, event size (number of DW)> >
152  std::vector<std::pair<uint32_t, std::pair<const uint32_t *, uint32_t> > > events_;
153 
154  bool parseInternalData_; //parse internal data flag
155  bool debug_; //debug flag
156  std::map<std::string, uint32_t> errors_; //errors map
157  std::vector<uint32_t> parameters; //parameters vector
158 
160  EVENTLENGTHMASK = 0xFFFFFF,
161 
162  BOEBEGIN = 28, //begin of event (on 32 bit string starts at bit 28)
163  BOEMASK = 0xF, //mask is 4 bits (F)
164  BOE = 0x5, //B'0101'
165 
166  EOEBEGIN = 28, //end of event
167  EOEMASK = 0xF, //4 bits
168  EOE = 0xA //B'1010'
169  };
170 };
171 
173 
174 inline std::vector<uint32_t> DCCTBDataParser::parserParameters() { return parameters; }
175 inline uint32_t DCCTBDataParser::numbXtalSamples() { return parameters[0]; }
176 inline uint32_t DCCTBDataParser::numbTriggerSamples() { return parameters[1]; }
177 inline uint32_t DCCTBDataParser::numbTTs() { return parameters[2]; }
178 inline uint32_t DCCTBDataParser::numbSRF() { return parameters[3]; }
179 inline uint32_t DCCTBDataParser::dccId() { return parameters[4]; }
180 inline uint32_t DCCTBDataParser::srpId() { return parameters[5]; }
181 inline uint32_t DCCTBDataParser::tcc1Id() { return parameters[6]; }
182 inline uint32_t DCCTBDataParser::tcc2Id() { return parameters[7]; }
183 inline uint32_t DCCTBDataParser::tcc3Id() { return parameters[8]; }
184 inline uint32_t DCCTBDataParser::tcc4Id() { return parameters[9]; }
185 
186 inline void DCCTBDataParser::setParameters(const std::vector<uint32_t> &newParameters) {
187  parameters = newParameters;
189 }
190 
191 inline uint32_t DCCTBDataParser::srpBlockSize() { return srpBlockSize_; }
192 inline uint32_t DCCTBDataParser::tccBlockSize() { return tccBlockSize_; }
193 
194 inline bool DCCTBDataParser::debug() { return debug_; }
195 inline std::vector<DCCTBEventBlock *> &DCCTBDataParser::dccEvents() { return dccEvents_; }
196 inline std::map<std::string, uint32_t> &DCCTBDataParser::errorCounters() { return errors_; }
197 inline std::vector<std::pair<uint32_t, std::pair<const uint32_t *, uint32_t> > > DCCTBDataParser::events() {
198  return events_;
199 }
200 
201 #endif
const uint32_t * getBuffer()
uint32_t tcc3Id()
std::vector< DCCTBEventBlock * > dccEvents_
uint32_t tccBlockSize()
void resetErrorCounters()
std::map< std::string, uint32_t > & errorCounters()
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< uint32_t > parameters
uint32_t srpBlockSize()
uint32_t srpBlockSize_
void parseFile(std::string fileName, bool singleEvent=false)
const uint32_t * buffer_
uint32_t processedEvent_
uint32_t tcc2Id()
uint32_t numbTTs()
std::vector< std::pair< uint32_t, std::pair< const uint32_t *, uint32_t > > > events()
DCCTBDataMapper * mapper()
std::vector< uint32_t > parserParameters()
std::map< std::string, uint32_t > errors_
std::pair< uint32_t, uint32_t > checkEventLength(const uint32_t *pointerToEvent, uint32_t bytesToEnd, bool singleEvent=false)
uint32_t tcc1Id()
uint32_t numbSRF()
std::string getHexString(uint32_t data)
uint32_t dccId()
uint32_t srpId()
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
std::vector< std::pair< uint32_t, std::pair< const uint32_t *, uint32_t > > > events_
static int position[264][3]
Definition: ReadPGInfo.cc:289
std::string eventErrors_
DCCTBDataMapper * mapper_
DCCTBDataParser(const std::vector< uint32_t > &parserParameters, bool parseInternalData=true, bool debug=true)
Definition: DCCDataParser.cc:7
uint32_t bufferSize_
void parseBuffer(const uint32_t *buffer, uint32_t bufferSize, bool singleEvent=false)
uint32_t tcc4Id()
std::string index(uint32_t position)