10 buffer_(0),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 buffer_ =
new uint32_t[dataVector.size()];
88 uint32_t *myData_ = (uint32_t *)
buffer_;
91 for(uint32_t
i = 1;
i <= dataVector.size() ;
i++, myData_++ ){
92 sscanf((dataVector[
i-1]).c_str(),
"%x",(
unsigned int *)myData_);
123 std::vector<DCCTBEventBlock *>::iterator it;
135 fatalError +=
"\n ======================================================================";
137 fatalError +=
"\n Buffer Size of = "+
getDecString(bufferSize) +
"[bytes] is not divisible by 8 ... ";
138 fatalError +=
"\n ======================================================================";
143 fatalError +=
"\n ======================================================================";
145 fatalError +=
"\n Buffer Size of = "+
getDecString(bufferSize) +
"[bytes] is less than an empty event ... ";
146 fatalError +=
"\n ======================================================================";
153 uint32_t processedBytes(0), wordIndex(0), eventLength(0), errorMask(0);
165 uint32_t bytesToEnd = bufferSize - processedBytes;
166 std::pair<uint32_t,uint32_t> eventD =
checkEventLength(myPointer,bytesToEnd,singleEvent);
167 eventLength = eventD.second;
168 errorMask = eventD.first;
192 std::pair<uint32_t *, uint32_t> eventPointer(myPointer,eventLength);
193 std::pair<uint32_t, std::pair<uint32_t*, uint32_t> > eventPointerWithErrorMask(errorMask,eventPointer);
194 events_.push_back(eventPointerWithErrorMask);
198 processedBytes += eventLength*8;
202 myPointer += eventLength*2;
203 wordIndex += eventLength*2;
220 std::pair<uint32_t,uint32_t>
result;
221 uint32_t errorMask(0);
225 uint32_t *boePointer = pointerToEvent + 1;
227 (
errors_[
"DCC::BOE"])++; errorMask = 1;
232 uint32_t * myPointer = pointerToEvent + 2;
237 bool eoeError =
false;
240 if( singleEvent && eventLength != bytesToEnd/8 ){
241 eventLength = bytesToEnd/8;
242 (
errors_[
"DCC::EVENT LENGTH"])++;
243 errorMask = errorMask | (1<<1);
246 else if( eventLength == 0 || eventLength > (bytesToEnd / 8) || eventLength < (
EMPTYEVENTSIZE/8) ){
252 fatalError +=
"\n ======================================================================";
254 fatalError +=
"\n Decoded event length = " +
getDecString(eventLength);
255 fatalError +=
"\n bytes to buffer end = " +
getDecString(bytesToEnd);
256 fatalError +=
"\n Unable to procead the data decoding ...";
258 if(eventLength > (bytesToEnd / 8)){ fatalError +=
" (eventLength > (bytesToEnd / 8)";}
259 else{ fatalError +=
"\n event length not big enough heaven to build an empty event ( 4x8 bytes)";}
261 fatalError +=
"\n ======================================================================";
268 uint32_t *endOfEventPointer = pointerToEvent + eventLength*2 -1;
269 if ( ( ((*endOfEventPointer) >>
EOEBEGIN &
EOEMASK ) != EOEMASK) && !eoeError ){
271 errorMask = errorMask | (1<<2);
275 result.first = errorMask;
276 result.second = eventLength;
289 char indexBuffer[20];
291 sprintf(indexBuffer,
"W[%08lu]",pos);
304 long unsigned int data = dat;
305 sprintf(buffer,
"%lu",data);
318 sprintf(buffer,
"0x%08x",(uint16_t)(data));
350 std::vector<DCCTBEventBlock *>::iterator it;
std::vector< DCCTBEventBlock * > dccEvents_
tuple ret
prodAgent to be discontinued
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()
std::vector< std::pair< uint32_t, std::pair< uint32_t *, uint32_t > > > events_
void parseFile(std::string fileName, bool singleEvent=false)
std::pair< uint32_t, uint32_t > checkEventLength(uint32_t *pointerToEvent, uint32_t bytesToEnd, bool singleEvent=false)
std::string getHexString(uint32_t data)
void parseBuffer(uint32_t *buffer, uint32_t bufferSize, bool singleEvent=false)
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)
std::string index(uint32_t position)