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()];
87 uint32_t *
const myDataBeginning = myData;
90 for(uint32_t
i = 1;
i <= dataVector.size() ;
i++, myData++ ){
91 sscanf((dataVector[
i-1]).c_str(),
"%x",myData);
100 delete [] myDataBeginning;
122 std::vector<DCCTBEventBlock *>::iterator it;
134 fatalError +=
"\n ======================================================================";
136 fatalError +=
"\n Buffer Size of = "+
getDecString(bufferSize) +
"[bytes] is not divisible by 8 ... ";
137 fatalError +=
"\n ======================================================================";
142 fatalError +=
"\n ======================================================================";
144 fatalError +=
"\n Buffer Size of = "+
getDecString(bufferSize) +
"[bytes] is less than an empty event ... ";
145 fatalError +=
"\n ======================================================================";
149 const uint32_t *myPointer =
buffer_;
152 uint32_t processedBytes(0), wordIndex(0), eventLength(0), errorMask(0);
164 uint32_t bytesToEnd = bufferSize - processedBytes;
165 std::pair<uint32_t,uint32_t> eventD =
checkEventLength(myPointer,bytesToEnd,singleEvent);
166 eventLength = eventD.second;
167 errorMask = eventD.first;
191 std::pair<const uint32_t *, uint32_t> eventPointer(myPointer,eventLength);
192 std::pair<uint32_t, std::pair<const uint32_t*, uint32_t> > eventPointerWithErrorMask(errorMask,eventPointer);
193 events_.push_back(eventPointerWithErrorMask);
197 processedBytes += eventLength*8;
201 myPointer += eventLength*2;
202 wordIndex += eventLength*2;
219 std::pair<uint32_t,uint32_t>
result;
220 uint32_t errorMask(0);
224 const uint32_t *boePointer = pointerToEvent + 1;
226 (
errors_[
"DCC::BOE"])++; errorMask = 1;
231 const uint32_t * myPointer = pointerToEvent + 2;
236 bool eoeError =
false;
239 if( singleEvent && eventLength != bytesToEnd/8 ){
240 eventLength = bytesToEnd/8;
241 (
errors_[
"DCC::EVENT LENGTH"])++;
242 errorMask = errorMask | (1<<1);
245 else if( eventLength == 0 || eventLength > (bytesToEnd / 8) || eventLength < (
EMPTYEVENTSIZE/8) ){
251 fatalError +=
"\n ======================================================================";
253 fatalError +=
"\n Decoded event length = " +
getDecString(eventLength);
254 fatalError +=
"\n bytes to buffer end = " +
getDecString(bytesToEnd);
255 fatalError +=
"\n Unable to procead the data decoding ...";
257 if(eventLength > (bytesToEnd / 8)){ fatalError +=
" (eventLength > (bytesToEnd / 8)";}
258 else{ fatalError +=
"\n event length not big enough heaven to build an empty event ( 4x8 bytes)";}
260 fatalError +=
"\n ======================================================================";
267 const uint32_t *endOfEventPointer = pointerToEvent + eventLength*2 -1;
268 if ( ( ((*endOfEventPointer) >>
EOEBEGIN &
EOEMASK ) != EOEMASK) && !eoeError ){
270 errorMask = errorMask | (1<<2);
274 result.first = errorMask;
275 result.second = eventLength;
288 char indexBuffer[20];
290 snprintf(indexBuffer,
sizeof(indexBuffer),
"W[%08lu]",pos);
303 long unsigned int data = dat;
304 snprintf(buffer,
sizeof(buffer),
"%lu",data);
317 snprintf(buffer,
sizeof(buffer),
"0x%08x",(uint16_t)(data));
349 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)