File indexing completed on 2024-04-06 12:10:37
0001
0002
0003
0004
0005
0006
0007 #ifndef DCCTBDATAPARSER_HH
0008 #define DCCTBDATAPARSER_HH
0009
0010 #include <fstream> //STL
0011 #include <iostream>
0012 #include <string>
0013 #include <vector>
0014 #include <map>
0015
0016 #include <cstdio> //C
0017
0018 #include "ECALParserException.h" //DATA DECODER
0019 #include "DCCEventBlock.h"
0020 #include "DCCDataMapper.h"
0021
0022 class DCCTBDataMapper;
0023 class DCCTBEventBlock;
0024
0025 class DCCTBDataParser {
0026 public:
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 DCCTBDataParser(const std::vector<uint32_t> &parserParameters, bool parseInternalData = true, bool debug = true);
0039
0040
0041
0042
0043 void parseFile(std::string fileName, bool singleEvent = false);
0044
0045
0046
0047
0048 void parseBuffer(const uint32_t *buffer, uint32_t bufferSize, bool singleEvent = false);
0049
0050
0051
0052
0053 DCCTBDataMapper *mapper();
0054
0055
0056
0057
0058
0059 std::pair<uint32_t, uint32_t> checkEventLength(const uint32_t *pointerToEvent,
0060 uint32_t bytesToEnd,
0061 bool singleEvent = false);
0062
0063
0064
0065
0066 std::vector<uint32_t> parserParameters();
0067 uint32_t numbXtalSamples();
0068 uint32_t numbTriggerSamples();
0069 uint32_t numbTTs();
0070 uint32_t numbSRF();
0071 uint32_t dccId();
0072 uint32_t srpId();
0073 uint32_t tcc1Id();
0074 uint32_t tcc2Id();
0075 uint32_t tcc3Id();
0076 uint32_t tcc4Id();
0077
0078
0079
0080
0081 void setParameters(const std::vector<uint32_t> &newParameters);
0082
0083
0084
0085
0086 uint32_t srpBlockSize();
0087 uint32_t tccBlockSize();
0088
0089
0090
0091
0092 bool debug();
0093
0094
0095
0096
0097 std::vector<DCCTBEventBlock *> &dccEvents();
0098
0099
0100
0101
0102 std::map<std::string, uint32_t> &errorCounters();
0103
0104
0105
0106
0107 std::vector<std::pair<uint32_t, std::pair<const uint32_t *, uint32_t> > > events();
0108
0109
0110
0111
0112 void resetErrorCounters();
0113
0114
0115
0116
0117 std::string getDecString(uint32_t data);
0118 std::string getHexString(uint32_t data);
0119 std::string index(uint32_t position);
0120 std::string getIndexedData(uint32_t indexed, uint32_t *pointer);
0121
0122
0123
0124
0125 const uint32_t *getBuffer() { return buffer_; }
0126
0127
0128
0129
0130 ~DCCTBDataParser();
0131
0132 enum DCCDataParserGlobalFields {
0133 EMPTYEVENTSIZE = 32
0134 };
0135
0136 protected:
0137 void computeBlockSizes();
0138
0139 const uint32_t *buffer_;
0140 uint32_t bufferSize_;
0141
0142 uint32_t srpBlockSize_;
0143 uint32_t tccBlockSize_;
0144
0145 uint32_t processedEvent_;
0146 std::string eventErrors_;
0147 DCCTBDataMapper *mapper_;
0148
0149 std::vector<DCCTBEventBlock *> dccEvents_;
0150
0151
0152 std::vector<std::pair<uint32_t, std::pair<const uint32_t *, uint32_t> > > events_;
0153
0154 bool parseInternalData_;
0155 bool debug_;
0156 std::map<std::string, uint32_t> errors_;
0157 std::vector<uint32_t> parameters;
0158
0159 enum DCCTBDataParserFields {
0160 EVENTLENGTHMASK = 0xFFFFFF,
0161
0162 BOEBEGIN = 28,
0163 BOEMASK = 0xF,
0164 BOE = 0x5,
0165
0166 EOEBEGIN = 28,
0167 EOEMASK = 0xF,
0168 EOE = 0xA
0169 };
0170 };
0171
0172 inline DCCTBDataMapper *DCCTBDataParser::mapper() { return mapper_; }
0173
0174 inline std::vector<uint32_t> DCCTBDataParser::parserParameters() { return parameters; }
0175 inline uint32_t DCCTBDataParser::numbXtalSamples() { return parameters[0]; }
0176 inline uint32_t DCCTBDataParser::numbTriggerSamples() { return parameters[1]; }
0177 inline uint32_t DCCTBDataParser::numbTTs() { return parameters[2]; }
0178 inline uint32_t DCCTBDataParser::numbSRF() { return parameters[3]; }
0179 inline uint32_t DCCTBDataParser::dccId() { return parameters[4]; }
0180 inline uint32_t DCCTBDataParser::srpId() { return parameters[5]; }
0181 inline uint32_t DCCTBDataParser::tcc1Id() { return parameters[6]; }
0182 inline uint32_t DCCTBDataParser::tcc2Id() { return parameters[7]; }
0183 inline uint32_t DCCTBDataParser::tcc3Id() { return parameters[8]; }
0184 inline uint32_t DCCTBDataParser::tcc4Id() { return parameters[9]; }
0185
0186 inline void DCCTBDataParser::setParameters(const std::vector<uint32_t> &newParameters) {
0187 parameters = newParameters;
0188 computeBlockSizes();
0189 }
0190
0191 inline uint32_t DCCTBDataParser::srpBlockSize() { return srpBlockSize_; }
0192 inline uint32_t DCCTBDataParser::tccBlockSize() { return tccBlockSize_; }
0193
0194 inline bool DCCTBDataParser::debug() { return debug_; }
0195 inline std::vector<DCCTBEventBlock *> &DCCTBDataParser::dccEvents() { return dccEvents_; }
0196 inline std::map<std::string, uint32_t> &DCCTBDataParser::errorCounters() { return errors_; }
0197 inline std::vector<std::pair<uint32_t, std::pair<const uint32_t *, uint32_t> > > DCCTBDataParser::events() {
0198 return events_;
0199 }
0200
0201 #endif