10 buffer_(
nullptr),parseInternalData_(parseInternalData),debug_(debug),
parameters(parserParameters){
27 errors_[
"DCC::EVENT LENGTH"] = 0;
40 uint32_t tf(0), srf(0);
42 if( (nTT*tSamples)<4 || (nTT*tSamples)%4 ) tf=1;
46 if( srf<16 || srf%16 ) srf=1;
64 inputFile.open(fileName.c_str());
74 if( !inputFile.fail() ){
77 std::vector<std::string> dataVector;
80 while( inputFile >> myWord ){
81 dataVector.push_back( myWord );
86 uint32_t *myData =
new uint32_t[dataVector.size()];
89 for(uint32_t
i = 1;
i <= dataVector.size() ;
i++, myData++ ){
90 sscanf((dataVector[
i-1]).c_str(),
"%x",myData);
121 std::vector<DCCTBEventBlock *>::iterator it;
133 fatalError +=
"\n ======================================================================";
135 fatalError +=
"\n Buffer Size of = "+
getDecString(bufferSize) +
"[bytes] is not divisible by 8 ... ";
136 fatalError +=
"\n ======================================================================";
141 fatalError +=
"\n ======================================================================";
143 fatalError +=
"\n Buffer Size of = "+
getDecString(bufferSize) +
"[bytes] is less than an empty event ... ";
144 fatalError +=
"\n ======================================================================";
148 const uint32_t *myPointer =
buffer_;
151 uint32_t processedBytes(0), wordIndex(0), eventLength(0), errorMask(0);
163 uint32_t bytesToEnd = bufferSize - processedBytes;
164 std::pair<uint32_t,uint32_t> eventD =
checkEventLength(myPointer,bytesToEnd,singleEvent);
165 eventLength = eventD.second;
166 errorMask = eventD.first;
190 std::pair<const uint32_t *, uint32_t> eventPointer(myPointer,eventLength);
191 std::pair<uint32_t, std::pair<const uint32_t*, uint32_t> > eventPointerWithErrorMask(errorMask,eventPointer);
192 events_.push_back(eventPointerWithErrorMask);
196 processedBytes += eventLength*8;
200 myPointer += eventLength*2;
201 wordIndex += eventLength*2;
218 std::pair<uint32_t,uint32_t>
result;
219 uint32_t errorMask(0);
223 const uint32_t *boePointer = pointerToEvent + 1;
225 (
errors_[
"DCC::BOE"])++; errorMask = 1;
230 const uint32_t * myPointer = pointerToEvent + 2;
235 bool eoeError =
false;
238 if( singleEvent && eventLength != bytesToEnd/8 ){
239 eventLength = bytesToEnd/8;
240 (
errors_[
"DCC::EVENT LENGTH"])++;
241 errorMask = errorMask | (1<<1);
244 else if( eventLength == 0 || eventLength > (bytesToEnd / 8) || eventLength < (
EMPTYEVENTSIZE/8) ){
250 fatalError +=
"\n ======================================================================";
252 fatalError +=
"\n Decoded event length = " +
getDecString(eventLength);
253 fatalError +=
"\n bytes to buffer end = " +
getDecString(bytesToEnd);
254 fatalError +=
"\n Unable to procead the data decoding ...";
256 if(eventLength > (bytesToEnd / 8)){ fatalError +=
" (eventLength > (bytesToEnd / 8)";}
257 else{ fatalError +=
"\n event length not big enough heaven to build an empty event ( 4x8 bytes)";}
259 fatalError +=
"\n ======================================================================";
266 const uint32_t *endOfEventPointer = pointerToEvent + eventLength*2 -1;
267 if ( ( ((*endOfEventPointer) >>
EOEBEGIN &
EOEMASK ) != EOEMASK) && !eoeError ){
269 errorMask = errorMask | (1<<2);
273 result.first = errorMask;
274 result.second = eventLength;
287 char indexBuffer[20];
289 snprintf(indexBuffer,
sizeof(indexBuffer),
"W[%08lu]",pos);
302 long unsigned int data = dat;
303 snprintf(buffer,
sizeof(buffer),
"%lu",data);
316 snprintf(buffer,
sizeof(buffer),
"0x%08x",(uint16_t)(data));
348 std::vector<DCCTBEventBlock *>::iterator it;
std::vector< DCCTBEventBlock * > dccEvents_
void resetErrorCounters()
std::map< std::string, uint32_t > errors_
std::string getDecString(uint32_t data)
std::string getIndexedData(uint32_t indexed, uint32_t *pointer)
uint32_t numbTriggerSamples()
void parseFile(std::string fileName, bool singleEvent=false)
std::pair< uint32_t, uint32_t > checkEventLength(const uint32_t *pointerToEvent, uint32_t bytesToEnd, bool singleEvent=false)
std::string getHexString(uint32_t data)
std::vector< std::pair< uint32_t, std::pair< const uint32_t *, uint32_t > > > events_
char data[epos_bytes_allocation]
static int position[264][3]
DCCTBDataMapper * mapper_
DCCTBDataParser(const std::vector< uint32_t > &parserParameters, bool parseInternalData=true, bool debug=true)
void parseBuffer(const uint32_t *buffer, uint32_t bufferSize, bool singleEvent=false)
std::string index(uint32_t position)