18 using namespace std::chrono;
27 ,list<DParsedEvent*> &parsed_events
28 ,uint32_t &MAX_PARSED_EVENTS
29 ,mutex &PARSED_EVENTS_MUTEX
30 ,condition_variable &PARSED_EVENTS_CV
33 event_source(event_source)
34 ,parsed_events(parsed_events)
35 ,MAX_PARSED_EVENTS(MAX_PARSED_EVENTS)
36 ,PARSED_EVENTS_MUTEX(PARSED_EVENTS_MUTEX)
37 ,PARSED_EVENTS_CV(PARSED_EVENTS_CV)
38 ,ROCIDS_TO_PARSE(ROCIDS_TO_PARSE)
91 unique_lock<std::mutex> lck(
mtx);
96 cv.wait_for(lck, std::chrono::milliseconds(1));
117 parsed_event_pool.clear();
119 jerr <<
"Data format error exception caught" << endl;
120 jerr <<
"Stack trace follows:" << endl;
121 jerr << e.getStackTrace() << endl;
122 jerr << e.what() << endl;
124 }
catch (exception &e) {
125 jerr << e.what() << endl;
127 parsed_event_pool.clear();
156 if(wait_to_complete) {
184 for(
auto pe : tmp_events) {
207 if(!
current_parsed_events.empty())
throw JException(
"Attempting call to DEVIOWorkerThread::MakeEvents when current_parsed_events not empty!!", __FILE__, __LINE__);
209 uint32_t *iptr =
buff;
215 uint32_t mask = 0xFF001000;
216 if( (*iptr)>>16 == 0xFF32){
220 }
else if( (*iptr)>>16 == 0xFF33){
226 uint64_t eventnum_lo = iptr[6];
227 uint64_t eventnum_hi = 0;
228 event_num = (eventnum_hi<<32) + (eventnum_lo);
229 }
else if( ((*iptr)&mask) == mask ){
232 uint64_t eventnum_lo = iptr[4];
233 uint64_t eventnum_hi = iptr[5];
234 event_num = (eventnum_hi<<32) + (eventnum_lo);
239 if(pe->in_use)
continue;
248 parsed_event_pool.push_back(pe);
260 pe->event_number = event_num++;
261 pe->sync_flag =
false;
263 pe->copied_to_factories =
false;
264 pe->event_status_bits = 0;
276 for(
auto pe : current_parsed_events){
277 if( ++pe->Nrecycled%pe->MAX_RECYCLES == 0) pe->Prune();
303 bool inserted =
false;
327 uint32_t *iptr =
buff;
331 uint32_t event_len = iptr[0];
332 uint32_t event_head = iptr[1];
333 uint32_t tag = (event_head >> 16) & 0xFFFF;
355 _DBG_ <<
"Unknown outer EVIO bank tag: " << hex << tag << dec << endl;
356 iptr = &iptr[event_len+1];
357 if(event_len<1) iptr = iend;
374 uint64_t evt_status_lo = *iptr++;
375 uint64_t evt_status_hi = *iptr++;
376 uint64_t l3_status_lo = *iptr++;
377 uint64_t l3_status_hi = *iptr++;
379 uint32_t l3_algorithm = *iptr++;
380 uint32_t mva_encoded = *iptr++;
382 uint64_t evt_status = evt_status_lo + (evt_status_hi<<32);
383 uint64_t l3_status = l3_status_lo + ( l3_status_hi<<32);
386 pe->NEW_DEventTag(evt_status, l3_decision, l3_status, l3_algorithm, mva_encoded);
401 uint32_t *istart = iptr;
402 uint32_t epics_bank_len = *iptr++;
403 if(epics_bank_len < 1){
404 _DBG_ <<
"bank_len<1 in EPICS event!" << endl;
409 uint32_t *iend_epics = &iptr[epics_bank_len];
419 while( iptr < iend_epics ){
421 uint32_t bank_len = (*iptr)&0xFFFF;
422 uint32_t tag = ((*iptr)>>24)&0xFF;
428 }
else if(tag == 0x62){
430 string nameval = (
const char*)iptr;
431 pe->NEW_DEPICSvalue(timestamp, nameval);
434 _DBG_ <<
"Unknown tag 0x" << hex << tag << dec <<
" in EPICS event!" <<endl;
435 DumpBinary(istart, iend_epics, 32, &iptr[-1]);
439 iptr = &iptr[bank_len];
476 if(!
PARSE_BOR){ iptr = &iptr[(*iptr) + 1];
return; }
477 if(
VERBOSE>1) jout <<
"--- Parsing BOR Bank" << endl;
482 ss <<
"DEVIOWorkerThread::ParseBORbank called for EVIO event with " <<
current_parsed_events.size() <<
" events in it. (Should be exactly 1!)";
483 jerr << ss.str() << endl;
484 jerr <<
"EVIO length=" << hex << iptr[0] <<
" header=" << iptr[1] << endl;
496 uint32_t borevent_len = *iptr++;
497 uint32_t bank_len = (uint32_t)((uint64_t)iend - (uint64_t)iptr)/
sizeof(uint32_t);
498 if(borevent_len > bank_len){
500 ss <<
"BOR: Size of bank doesn't match amount of data given (" << borevent_len <<
" > " << bank_len <<
")";
503 iend = &iptr[borevent_len];
506 uint32_t bor_header = *iptr++;
507 if( (bor_header!=0x700e01) && (bor_header!=0x700e34) ){
509 ss <<
"Bad BOR header: 0x" << hex << bor_header;
510 _DBG_<< ss.str() << endl;
517 uint32_t crate_len = *iptr++;
518 uint32_t *iend_crate = &iptr[crate_len];
519 uint32_t crate_header = *iptr++;
523 if( (crate_header>>16) != 0x71 ){
525 ss <<
"Bad BOR crate header: 0x" << hex << (crate_header>>16);
526 _DBG_<< ss.str() << endl;
531 while(iptr<iend_crate){
532 uint32_t module_header = *iptr++;
533 uint32_t module_len = module_header&0xFFFF;
534 uint32_t modType = (module_header>>20)&0x1f;
538 uint32_t *src = iptr;
539 uint32_t *dest = NULL;
540 uint32_t sizeof_dest = 0;
551 dest = (uint32_t*)&f250conf->
rocid;
552 sizeof_dest =
sizeof(
f250config)/
sizeof(uint32_t);
556 dest = (uint32_t*)&f125conf->
rocid;
557 sizeof_dest =
sizeof(
f125config)/
sizeof(uint32_t);
563 dest = (uint32_t*)&F1TDCconf->
rocid;
564 sizeof_dest =
sizeof(
F1TDCconfig)/
sizeof(uint32_t);
570 dest = (uint32_t*)&caen1190conf->
rocid;
580 for(uint32_t i=0; i<module_len; i++) tsgconf->
misc_words.push_back(src[i]);
582 sizeof_dest = module_len;
589 ss <<
"Unknown BOR module type: " << modType <<
" (module_header=0x"<<hex<<module_header<<
")";
590 jerr << ss.str() << endl;
596 if( module_len > sizeof_dest ){
598 ss <<
"BOR module bank size does not match structure! " << module_len <<
" > " << sizeof_dest <<
" for modType " << modType;
599 _DBG_<< ss.str() << endl;
606 for(uint32_t i=0; i<sizeof_dest; i++) *dest++ = i<module_len ? (*src++):0;
612 if(f250conf ) borptrs->vDf250BORConfig.push_back(f250conf);
613 if(f125conf ) borptrs->vDf125BORConfig.push_back(f125conf);
614 if(F1TDCconf ) borptrs->vDF1TDCBORConfig.push_back(F1TDCconf);
615 if(caen1190conf) borptrs->vDCAEN1290TDCBORConfig.push_back(caen1190conf);
616 if(tsgconf ) borptrs->vDTSGBORConfig.push_back(tsgconf);
618 iptr = &iptr[module_len];
633 uint32_t Nwords = ((uint64_t)iend - (uint64_t)iptr)/
sizeof(uint32_t);
634 uint32_t Nwords_expected = (6+32+16+32+16);
635 if(Nwords != Nwords_expected){
636 _DBG_ <<
"TS bank size does not match expected!!" << endl;
637 _DBG_ <<
"Found " << Nwords <<
" words. Expected " << Nwords_expected << endl;
643 DL1Info *s = pe->NEW_DL1Info();
650 for(uint32_t i=0; i<32; i++) s->
gtp_sc.push_back ( *iptr++ );
651 for(uint32_t i=0; i<16; i++) s->
fp_sc.push_back ( *iptr++ );
652 for(uint32_t i=0; i<32; i++) s->
gtp_rate.push_back( *iptr++ );
653 for(uint32_t i=0; i<16; i++) s->
fp_rate.push_back ( *iptr++ );
665 uint32_t Nwords = ((uint64_t)iend - (uint64_t)iptr)/
sizeof(uint32_t);
668 _DBG_ <<
"250Scaler bank size does not match expected!!" << endl;
669 _DBG_ <<
"Found " << Nwords << endl;
699 time_t t = (time_t)iptr[2];
700 string tstr = ctime(&t);
701 if(tstr.size()>1) tstr.erase(tstr.size()-1);
703 string type =
"Control";
705 case 0XFFD0: type =
"Sync";
break;
706 case 0XFFD1: type =
"Prestart";
break;
707 case 0XFFD2: type =
"Go";
break;
708 case 0XFFD3: type =
"Pause";
break;
709 case 0XFFD4: type =
"End";
break;
712 jout <<
"Control event: " << type <<
" - " << tstr << endl;
716 auto controlevent = pe->NEW_DCODAControlEvent();
717 controlevent->event_type = iptr[1]>>16;
718 controlevent->unix_time = t;
719 for(
auto p = iptr; p!=iend; p++) controlevent->words.push_back(*p);
722 iptr = &iptr[(*iptr) + 1];
733 uint32_t physics_event_len = *iptr++;
734 uint32_t *iend_physics_event = &iptr[physics_event_len];
738 uint32_t built_trigger_bank_len = *iptr;
739 uint32_t *iend_built_trigger_bank = &iptr[built_trigger_bank_len+1];
741 iptr = iend_built_trigger_bank;
744 while( iptr < iend_physics_event ) {
746 uint32_t data_bank_len = *iptr;
747 uint32_t *iend_data_bank = &iptr[data_bank_len+1];
751 iptr = iend_data_bank;
754 iptr = iend_physics_event;
763 if(
VERBOSE>1) jout <<
"-- Parsing CDAQ Event" << endl;
766 if( (iptr[1]&0xFFFF0000) == 0xFF320000 ){
770 }
catch(JException &
e){
782 uint32_t physics_event_len = *iptr++;
783 uint32_t *iend_physics_event = &iptr[physics_event_len];
787 while( iptr < iend_physics_event ) {
789 uint32_t data_bank_len = *iptr;
790 uint32_t *iend_data_bank = &iptr[data_bank_len+1];
794 iptr = iend_data_bank;
797 iptr = iend_physics_event;
808 uint32_t mask = 0xFF202000;
809 if( ((*iptr) & mask) != mask ){
811 ss <<
"Bad header word in Built Trigger Bank: " << hex << *iptr;
815 uint32_t tag = (*iptr)>>16;
816 uint32_t Nrocs = (*iptr++) & 0xFF;
822 ss <<
"DEVIOWorkerThread::ParseBuiltTriggerBank() called with zero events! "<<endl;
828 uint32_t common_header64 = *iptr++;
829 uint32_t common_header64_len = common_header64 & 0xFFFF;
830 uint64_t *iptr64 = (uint64_t*)iptr;
831 iptr = &iptr[common_header64_len];
834 uint64_t first_event_num = *iptr64++;
842 uint32_t Ntimestamps = (common_header64_len/2)-1;
843 if(tag & 0x2) Ntimestamps--;
844 vector<uint64_t> avg_timestamps;
845 for(uint32_t i=0; i<Ntimestamps; i++) avg_timestamps.push_back(*iptr64++);
848 uint32_t run_number = 0;
849 uint32_t run_type = 0;
851 run_number = (*iptr64) >> 32;
852 run_type = (*iptr64) & 0xFFFFFFFF;
857 uint32_t common_header16 = *iptr++;
858 uint32_t common_header16_len = common_header16 & 0xFFFF;
859 uint16_t *iptr16 = (uint16_t*)iptr;
860 iptr = &iptr[common_header16_len];
862 vector<uint16_t> event_types;
863 for(uint32_t i=0; i<Mevents; i++) event_types.push_back(*iptr16++);
866 for(uint32_t iroc=0; iroc<Nrocs; iroc++){
867 uint32_t common_header32 = *iptr++;
868 uint32_t common_header32_len = common_header32 & 0xFFFF;
869 uint32_t rocid = common_header32 >> 24;
871 uint32_t Nwords_per_event = common_header32_len/Mevents;
875 codarocinfo->
rocid = rocid;
877 uint64_t ts_low = *iptr++;
878 uint64_t ts_high = *iptr++;
879 codarocinfo->
timestamp = (ts_high<<32) + ts_low;
880 codarocinfo->
misc.clear();
881 for(uint32_t i=2; i<Nwords_per_event; i++) codarocinfo->
misc.push_back(*iptr++);
893 pe->run_number = run_number;
921 uint32_t segment_header = *iptr++;
922 uint32_t segment_len = segment_header&0xFFFF;
923 uint32_t *iend_segment = &iptr[segment_len];
925 uint32_t event_number = *iptr++;
926 uint64_t ts_low = *iptr++;
927 uint64_t ts_high = *iptr++;
930 codarocinfo->
rocid = rocid;
931 codarocinfo->
timestamp = (ts_high<<32) + ts_low;
932 codarocinfo->
misc.clear();
935 for(uint32_t i=3; i<segment_len; i++) codarocinfo->
misc.push_back(*iptr++);
937 if( iptr != iend_segment){
950 uint32_t rocid = ((*iptr)>>16) & 0xFFF;
960 uint32_t data_block_bank_len = *iptr++;
961 uint32_t *iend_data_block_bank = &iptr[data_block_bank_len];
962 uint32_t data_block_bank_header = *iptr++;
965 while( (*iptr==0xF800FAFA) && (iptr<iend) ) iptr++;
967 uint32_t det_id = (data_block_bank_header>>16) & 0xFFF;
971 if(
VERBOSE>3) jout <<
" -- CAEN1190 rocid="<< rocid << endl;
976 if(
VERBOSE>3) jout <<
" -- Module Configuration rocid="<< rocid << endl;
981 if(
VERBOSE>3) jout <<
" -- Event Tag rocid="<< rocid << endl;
991 if(
VERBOSE>3) jout <<
" -- JLab Module rocid="<< rocid << endl;
997 if(
VERBOSE>3) jout <<
" -- SSP rocid="<< rocid << endl;
1007 if(
VERBOSE>3) jout <<
" -- TSscaler rocid="<< rocid << endl;
1020 if(
VERBOSE>3) jout <<
"Raw Trigger bank rocid="<< rocid << endl;
1042 jerr<<
"Unknown module type ("<<det_id<<
" = 0x" << hex << det_id << dec <<
" ) encountered" << endl;
1044 cout <<
"----- First few words to help with debugging -----" << endl;
1045 cout.flush(); cerr.flush();
1052 iptr = iend_data_block_bank;
1062 while(iptr<iend && ((*iptr) & 0xF8000000) != 0x88000000) iptr++;
1064 while(iptr<iend && *iptr == 0xF8000000) iptr++;
1080 uint32_t word_count = 0;
1081 uint32_t trigger_time_tag = 0;
1082 uint32_t tdc_num = 0;
1083 uint32_t event_id = 0;
1084 uint32_t bunch_id = 0;
1097 map<uint32_t, DParsedEvent*> events_by_event_id;
1106 if(*iptr == 0xd00dd00d) {
1107 if(
VERBOSE>7) cout <<
" CAEN skipping 0xd00dd00d word" << endl;
1112 uint32_t type = (*iptr) >> 27;
1114 uint32_t channel = 0;
1116 uint32_t error_flags = 0;
1119 slot = (*iptr) & 0x1f;
1120 event_count = ((*iptr)>>5) & 0xffffff;
1121 if(
VERBOSE>7) cout <<
" CAEN TDC Global Header (slot=" << slot <<
" , event count=" << event_count <<
")" << endl;
1124 slot = (*iptr) & 0x1f;
1125 word_count = ((*iptr)>>5) & 0x7ffff;
1126 if(
VERBOSE>7) cout <<
" CAEN TDC Global Trailer (slot=" << slot <<
" , word count=" << word_count <<
")" << endl;
1127 slot = event_count = word_count = trigger_time_tag = tdc_num = event_id = bunch_id = 0;
1130 trigger_time_tag = ((*iptr)>>5) & 0x7ffffff;
1131 if(
VERBOSE>7) cout <<
" CAEN TDC Global Trigger Time Tag (tag=" << trigger_time_tag <<
")" << endl;
1134 tdc_num = ((*iptr)>>24) & 0x03;
1135 event_id = ((*iptr)>>12) & 0x0fff;
1136 bunch_id = (*iptr) & 0x0fff;
1137 if(events_by_event_id.find(event_id) == events_by_event_id.end()){
1140 for(
auto p : events_by_event_id) cout <<
"id=" << p.first << endl;
1142 throw JExceptionDataFormat(
"CAEN1290TDC parser sees more events than CODA header", __FILE__, __LINE__);
1145 events_by_event_id[event_id] = pe;
1147 pe = events_by_event_id[event_id];
1149 if(
VERBOSE>7) cout <<
" CAEN TDC TDC Header (tdc=" << tdc_num <<
" , event id=" << event_id <<
" , bunch id=" << bunch_id <<
")" << endl;
1152 edge = ((*iptr)>>26) & 0x01;
1153 channel = ((*iptr)>>21) & 0x1f;
1154 tdc = ((*iptr)>>0) & 0x1fffff;
1155 if(
VERBOSE>7) cout <<
" CAEN TDC TDC Measurement (" << (edge ?
"trailing":
"leading") <<
" , channel=" << channel <<
" , tdc=" << tdc <<
")" << endl;
1158 if(pe) pe->NEW_DCAEN1290TDCHit(rocid, slot, channel, 0, edge, tdc_num, event_id, bunch_id, tdc);
1161 error_flags = (*iptr) & 0x7fff;
1162 if(
VERBOSE>7) cout <<
" CAEN TDC TDC Error (err flags=0x" << hex << error_flags << dec <<
")" << endl;
1165 tdc_num = ((*iptr)>>24) & 0x03;
1166 event_id = ((*iptr)>>12) & 0x0fff;
1167 word_count = ((*iptr)>>0) & 0x0fff;
1168 if(
VERBOSE>7) cout <<
" CAEN TDC TDC Trailer (tdc=" << tdc_num <<
" , event id=" << event_id <<
" , word count=" << word_count <<
")" << endl;
1169 tdc_num = event_id = bunch_id = 0;
1172 if(
VERBOSE>7) cout <<
" CAEN TDC Filler Word" << endl;
1175 cout <<
"Unknown datatype: 0x" << hex << type <<
" full word: "<< *iptr << dec << endl;
1189 if(!
PARSE_CONFIG){ iptr = &iptr[(*iptr) + 1];
return; }
1206 uint32_t slot_mask = (*iptr) & 0xFFFFFF;
1207 uint32_t Nvals = ((*iptr) >> 24) & 0xFF;
1221 for(uint32_t i=0; i< Nvals; i++){
1223 _DBG_ <<
"DAQ Configuration bank corrupt! slot_mask=0x" << hex << slot_mask << dec <<
" Nvals="<< Nvals << endl;
1228 uint16_t val = (*iptr) & 0xFFFF;
1230 if(
VERBOSE>6) cout <<
" DAQ parameter of type: 0x" << hex << ptype << dec <<
" found with value: " << val << endl;
1238 if( !f250config ) f250config = pe->NEW_Df250Config(rocid, slot_mask);
1244 default:
_DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
1250 if( !f125config ) f125config = pe->NEW_Df125Config(rocid, slot_mask);
1270 default:
_DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
1276 if( !f1tdcconfig ) f1tdcconfig = pe->NEW_DF1TDCConfig(rocid, slot_mask);
1284 default:
_DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
1290 if( !caen1290tdcconfig ) caen1290tdcconfig = pe->NEW_DCAEN1290TDCConfig(rocid, slot_mask);
1294 default:
_DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
1299 _DBG_ <<
"Unknown module type: 0x" << hex << (ptype>>8) << endl;
1310 if(tpe == pe)
continue;
1312 if(f250config ) tpe->NEW_Df250Config(f250config);
1313 if(f125config ) tpe->NEW_Df125Config(f125config);
1314 if(f1tdcconfig ) tpe->NEW_DF1TDCConfig(f1tdcconfig);
1315 if(caen1290tdcconfig) tpe->NEW_DCAEN1290TDCConfig(caen1290tdcconfig);
1329 uint32_t mod_id = ((*iptr) >> 18) & 0x000F;
1363 jerr<<
"Unknown module type ("<<mod_id<<
") iptr=0x" << hex << iptr << dec << endl;
1365 while(iptr<iend && ((*iptr) & 0xF8000000) != 0x88000000) iptr++;
1367 while(iptr<iend && *iptr == 0xF8000000) iptr++;
1380 if(!
PARSE_F250){ iptr = &iptr[(*iptr) + 1];
return; }
1386 uint32_t itrigger = -1;
1389 for(; iptr<iend; iptr++){
1395 if(((*iptr>>31) & 0x1) == 0)
continue;
1397 uint32_t data_type = (*iptr>>27) & 0x0F;
1400 slot = (*iptr>>22) & 0x1F;
1401 if(
VERBOSE>7) cout <<
" FADC250 Block Header: slot="<<slot<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1406 if(
VERBOSE>7) cout <<
" FADC250 Block Trailer"<<
" (0x"<<hex<<*iptr<<dec<<
") iptr=0x"<<hex<<iptr<<dec<<endl;
1409 itrigger = (*iptr>>0) & 0x3FFFFF;
1411 if(
VERBOSE>7) cout <<
" FADC250 Event Header: itrigger="<<itrigger<<
", rocid="<<rocid<<
", slot="<<slot<<
")" <<
" (0x"<<hex<<*iptr<<dec<<
")" <<endl;
1415 uint64_t t = ((*iptr)&0xFFFFFF)<<0;
1416 if(
VERBOSE>7) cout <<
" FADC250 Trigger time low word="<<(((*iptr)&0xFFFFFF))<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1418 if(((*iptr>>31) & 0x1) == 0){
1419 t += ((*iptr)&0xFFFFFF)<<24;
1420 if(
VERBOSE>7) cout <<
" FADC250 Trigger time high word="<<(((*iptr)&0xFFFFFF))<<
" (0x"<<hex<<*iptr<<dec<<
") iptr=0x"<<hex<<iptr<<dec<<endl;
1424 if(
VERBOSE>7) cout <<
" FADC250 Trigger Time: t="<<t<<endl;
1425 if(pe) pe->NEW_Df250TriggerTime(rocid, slot, itrigger, t);
1430 if(
VERBOSE>7) cout <<
" FADC250 Window Raw Data"<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1435 uint32_t channel = (*iptr>>23) & 0x0F;
1436 uint32_t
sum = (*iptr>>0) & 0x3FFFFF;
1437 uint32_t overflow = (*iptr>>22) & 0x1;
1438 if(
VERBOSE>7) cout <<
" FADC250 Window Sum"<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1439 if(pe) pe->NEW_Df250WindowSum(rocid, slot, channel, itrigger, sum, overflow);
1444 if(
VERBOSE>7) cout <<
" FADC250 Pulse Raw Data"<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1448 uint32_t channel = (*iptr>>23) & 0x0F;
1449 uint32_t pulse_number = (*iptr>>21) & 0x03;
1450 uint32_t quality_factor = (*iptr>>19) & 0x03;
1451 uint32_t
sum = (*iptr>>0) & 0x7FFFF;
1452 uint32_t nsamples_integral = 0;
1453 uint32_t nsamples_pedestal = 1;
1455 if(
VERBOSE>7) cout <<
" FADC250 Pulse Integral: chan="<<channel<<
" pulse_number="<<pulse_number<<
" sum="<<sum<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1456 if(pe) pe->NEW_Df250PulseIntegral(rocid, slot, channel, itrigger, pulse_number, quality_factor, sum, pedestal, nsamples_integral, nsamples_pedestal);
1461 uint32_t channel = (*iptr>>23) & 0x0F;
1462 uint32_t pulse_number = (*iptr>>21) & 0x03;
1463 uint32_t quality_factor = (*iptr>>19) & 0x03;
1464 uint32_t pulse_time = (*iptr>>0) & 0x7FFFF;
1465 if(
VERBOSE>7) cout <<
" FADC250 Pulse Time: chan="<<channel<<
" pulse_number="<<pulse_number<<
" pulse_time="<<pulse_time<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1466 if(pe) pe->NEW_Df250PulseTime(rocid, slot, channel, itrigger, pulse_number, quality_factor, pulse_time);
1472 uint32_t event_number_within_block = (*iptr>>19) & 0xFF;
1473 uint32_t channel = (*iptr>>15) & 0x0F;
1474 bool QF_pedestal = (*iptr>>14) & 0x01;
1475 uint32_t
pedestal = (*iptr>>0 ) & 0x3FFF;
1476 if(
VERBOSE>7) cout <<
" FADC250 Pulse Data (0x"<<hex<<*iptr<<dec<<
") channel=" << channel <<
" pedestal="<<pedestal <<
" event within block=" << event_number_within_block <<endl;
1479 if(event_number_within_block==0){
1480 _DBG_<<
"event_number_within_block==0. This indicates a bug in firmware." << endl;
1485 if( (event_number_within_block >
current_parsed_events.size()) ) { jerr <<
"Bad f250 event number for rocid="<<rocid<<
" slot="<<slot<<
" channel="<<channel<<endl;
throw JException(
"Bad f250 event number", __FILE__, __LINE__);}
1487 advance( pe_iter, event_number_within_block-1 );
1490 itrigger = event_number_within_block;
1491 uint32_t pulse_number = 0;
1493 while( (*++iptr>>31) == 0 ){
1495 if( (*iptr>>30) != 0x01) { jerr <<
"Bad f250 Pulse Data for rocid="<<rocid<<
" slot="<<slot<<
" channel="<<channel<<endl;
throw JException(
"Bad f250 Pulse Data!", __FILE__, __LINE__);}
1498 uint32_t integral = (*iptr>>12) & 0x3FFFF;
1499 bool QF_NSA_beyond_PTW = (*iptr>>11) & 0x01;
1500 bool QF_overflow = (*iptr>>10) & 0x01;
1501 bool QF_underflow = (*iptr>>9 ) & 0x01;
1502 uint32_t nsamples_over_threshold = (*iptr>>0 ) & 0x1FF;
1503 if(
VERBOSE>7) cout <<
" FADC250 Pulse Data word 2(0x"<<hex<<*iptr<<dec<<
") integral="<<integral<<endl;
1506 if( (*iptr>>30) != 0x00)
throw JException(
"Bad f250 Pulse Data!", __FILE__, __LINE__);
1509 uint32_t course_time = (*iptr>>21) & 0x1FF;
1510 uint32_t fine_time = (*iptr>>15) & 0x3F;
1511 uint32_t pulse_peak = (*iptr>>3 ) & 0xFFF;
1512 bool QF_vpeak_beyond_NSA = (*iptr>>2 ) & 0x01;
1513 bool QF_vpeak_not_found = (*iptr>>1 ) & 0x01;
1514 bool QF_bad_pedestal = (*iptr>>0 ) & 0x01;
1515 if(
VERBOSE>7) cout <<
" FADC250 Pulse Data word 3(0x"<<hex<<*iptr<<dec<<
") course_time="<<course_time<<
" fine_time="<<fine_time<<
" pulse_peak="<<pulse_peak<<endl;
1518 pe->NEW_Df250PulseData(rocid, slot, channel, itrigger
1519 , event_number_within_block
1526 , nsamples_over_threshold
1530 , QF_vpeak_beyond_NSA
1531 , QF_vpeak_not_found
1542 uint32_t channel = (*iptr>>23) & 0x0F;
1543 uint32_t pulse_number = (*iptr>>21) & 0x03;
1544 uint32_t
pedestal = (*iptr>>12) & 0x1FF;
1545 uint32_t pulse_peak = (*iptr>>0) & 0xFFF;
1546 if(
VERBOSE>7) cout <<
" FADC250 Pulse Pedestal chan="<<channel<<
" pulse_number="<<pulse_number<<
" pedestal="<<pedestal<<
" pulse_peak="<<pulse_peak<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1547 if(pe) pe->NEW_Df250PulsePedestal(rocid, slot, channel, itrigger, pulse_number, pedestal, pulse_peak);
1557 if(
VERBOSE>7) cout <<
" FADC250 Event Trailer, Data not Valid, or Filler word ("<<data_type<<
")"<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1560 if(
VERBOSE>7) cout <<
" FADC250 unknown data type ("<<data_type<<
")"<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1566 for(; iptr<iend; iptr++){
1567 if(((*iptr)&0xf8000000) != 0xf8000000)
break;
1576 uint32_t channel = (*iptr>>23) & 0x0F;
1577 uint32_t window_width = (*iptr>>0) & 0x0FFF;
1579 Df250WindowRawData *wrd = pe->NEW_Df250WindowRawData(rocid, slot, channel, itrigger);
1581 for(uint32_t isample=0; isample<window_width; isample +=2){
1587 if(((*iptr>>31) & 0x1) != 0x0){
1592 bool invalid_1 = (*iptr>>29) & 0x1;
1593 bool invalid_2 = (*iptr>>13) & 0x1;
1594 uint16_t sample_1 = 0;
1595 uint16_t sample_2 = 0;
1596 if(!invalid_1)sample_1 = (*iptr>>16) & 0x1FFF;
1597 if(!invalid_2)sample_2 = (*iptr>>0) & 0x1FFF;
1600 wrd->
samples.push_back(sample_1);
1602 wrd->
overflow |= (sample_1>>12) & 0x1;
1604 if(((isample+2) == window_width) && invalid_2)
break;
1607 wrd->
samples.push_back(sample_2);
1609 wrd->
overflow |= (sample_2>>12) & 0x1;
1618 if(!
PARSE_F125){ iptr = &iptr[(*iptr) + 1];
return; }
1624 uint32_t itrigger = -1;
1625 uint32_t last_itrigger = -2;
1626 uint32_t last_pulse_time_channel=0;
1627 uint32_t last_slot = -1;
1628 uint32_t last_channel = -1;
1631 for(; iptr<iend; iptr++){
1637 if(((*iptr>>31) & 0x1) == 0)
continue;
1639 uint32_t data_type = (*iptr>>27) & 0x0F;
1642 slot = (*iptr>>22) & 0x1F;
1643 if(
VERBOSE>7) cout <<
" FADC125 Block Header: slot="<<slot<<endl;
1651 itrigger = (*iptr>>0) & 0x3FFFFFF;
1653 if(
VERBOSE>7) cout <<
" FADC125 Event Header: itrigger="<<itrigger<<
" last_itrigger="<<last_itrigger<<
", rocid="<<rocid<<
", slot="<<slot <<endl;
1657 uint64_t t = ((*iptr)&0xFFFFFF)<<0;
1659 if(((*iptr>>31) & 0x1) == 0){
1660 t += ((*iptr)&0xFFFFFF)<<24;
1664 if(
VERBOSE>7) cout <<
" FADC125 Trigger Time (t="<<t<<
")"<<endl;
1665 if(pe) pe->NEW_Df125TriggerTime(rocid, slot, itrigger, t);
1670 if(
VERBOSE>7) cout <<
" FADC125 Window Raw Data"<<endl;
1677 uint32_t word1 = *iptr;
1678 uint32_t channel = (*iptr>>20) & 0x7F;
1679 uint32_t pulse_number = (*iptr>>15) & 0x1F;
1680 uint32_t pulse_time = (*iptr>>4 ) & 0x7FF;
1681 uint32_t quality_factor = (*iptr>>3 ) & 0x1;
1682 uint32_t overflow_count = (*iptr>>0 ) & 0x7;
1684 cout <<
" FADC125 CDC Pulse Data word1: " << hex << (*iptr) << dec << endl;
1685 cout <<
" FADC125 CDC Pulse Data (chan="<<channel<<
" pulse="<<pulse_number<<
" time="<<pulse_time<<
" QF="<<quality_factor<<
" OC="<<overflow_count<<
")"<<endl;
1691 jerr <<
" Truncated f125 CDC hit (block ends before continuation word!)" << endl;
1694 if( ((*iptr>>31) & 0x1) != 0 ){
1695 jerr <<
" Truncated f125 CDC hit (missing continuation word!)" << endl;
1698 uint32_t word2 = *iptr;
1699 uint32_t
pedestal = (*iptr>>23) & 0xFF;
1700 uint32_t
sum = (*iptr>>9 ) & 0x3FFF;
1701 uint32_t pulse_peak = (*iptr>>0 ) & 0x1FF;
1703 cout <<
" FADC125 CDC Pulse Data word2: " << hex << (*iptr) << dec << endl;
1704 cout <<
" FADC125 CDC Pulse Data (pedestal="<<pedestal<<
" sum="<<sum<<
" peak="<<pulse_peak<<
")"<<endl;
1708 uint32_t nsamples_integral = 0;
1709 uint32_t nsamples_pedestal = 1;
1712 pe->NEW_Df125CDCPulse(rocid, slot, channel, itrigger
1732 uint32_t word1 = *iptr;
1733 uint32_t channel = (*iptr>>20) & 0x7F;
1734 uint32_t pulse_number = (*iptr>>15) & 0x1F;
1735 uint32_t pulse_time = (*iptr>>4 ) & 0x7FF;
1736 uint32_t quality_factor = (*iptr>>3 ) & 0x1;
1737 uint32_t overflow_count = (*iptr>>0 ) & 0x7;
1739 cout <<
" FADC125 FDC Pulse Data(integral) word1: " << hex << (*iptr) << dec << endl;
1740 cout <<
" FADC125 FDC Pulse Data (chan="<<channel<<
" pulse="<<pulse_number<<
" time="<<pulse_time<<
" QF="<<quality_factor<<
" OC="<<overflow_count<<
")"<<endl;
1746 jerr <<
" Truncated f125 FDC hit (block ends before continuation word!)" << endl;
1749 if( ((*iptr>>31) & 0x1) != 0 ){
1750 jerr <<
" Truncated f125 FDC hit (missing continuation word!)" << endl;
1753 uint32_t word2 = *iptr;
1754 uint32_t pulse_peak = 0;
1755 uint32_t
sum = (*iptr>>19) & 0xFFF;
1756 uint32_t peak_time = (*iptr>>11) & 0xFF;
1757 uint32_t
pedestal = (*iptr>>0 ) & 0x7FF;
1759 cout <<
" FADC125 FDC Pulse Data(integral) word2: " << hex << (*iptr) << dec << endl;
1760 cout <<
" FADC125 FDC Pulse Data (integral="<<sum<<
" time="<<peak_time<<
" pedestal="<<pedestal<<
")"<<endl;
1764 uint32_t nsamples_integral = 0;
1765 uint32_t nsamples_pedestal = 1;
1768 pe->NEW_Df125FDCPulse(rocid, slot, channel, itrigger
1788 if(
VERBOSE>7) cout <<
" FADC125 Pulse Integral"<<endl;
1789 uint32_t channel = (*iptr>>20) & 0x7F;
1790 uint32_t
sum = (*iptr>>0) & 0xFFFFF;
1791 uint32_t quality_factor = 0;
1792 uint32_t nsamples_integral = 0;
1793 uint32_t nsamples_pedestal = 1;
1795 uint32_t pulse_number = 0;
1796 if (last_slot == slot && last_channel == channel) pulse_number = 1;
1798 last_channel = channel;
1799 if( pe ) pe->NEW_Df125PulseIntegral(rocid, slot, channel, itrigger, pulse_number, quality_factor, sum, pedestal, nsamples_integral, nsamples_pedestal);
1804 if(
VERBOSE>7) cout <<
" FADC125 Pulse Time"<<endl;
1805 uint32_t channel = (*iptr>>20) & 0x7F;
1806 uint32_t pulse_number = (*iptr>>18) & 0x03;
1807 uint32_t pulse_time = (*iptr>>0) & 0xFFFF;
1808 uint32_t quality_factor = 0;
1809 if( pe ) pe->NEW_Df125PulseTime(rocid, slot, channel, itrigger, pulse_number, quality_factor, pulse_time);
1810 last_pulse_time_channel = channel;
1817 uint32_t word1 = *iptr;
1818 uint32_t channel = (*iptr>>20) & 0x7F;
1819 uint32_t pulse_number = (*iptr>>15) & 0x1F;
1820 uint32_t pulse_time = (*iptr>>4 ) & 0x7FF;
1821 uint32_t quality_factor = (*iptr>>3 ) & 0x1;
1822 uint32_t overflow_count = (*iptr>>0 ) & 0x7;
1824 cout <<
" FADC125 FDC Pulse Data(peak) word1: " << hex << (*iptr) << dec << endl;
1825 cout <<
" FADC125 FDC Pulse Data (chan="<<channel<<
" pulse="<<pulse_number<<
" time="<<pulse_time<<
" QF="<<quality_factor<<
" OC="<<overflow_count<<
")"<<endl;
1831 jerr <<
" Truncated f125 FDC hit (block ends before continuation word!)" << endl;
1834 if( ((*iptr>>31) & 0x1) != 0 ){
1835 jerr <<
" Truncated f125 FDC hit (missing continuation word!)" << endl;
1838 uint32_t word2 = *iptr;
1839 uint32_t pulse_peak = (*iptr>>19) & 0xFFF;
1841 uint32_t peak_time = (*iptr>>11) & 0xFF;
1842 uint32_t
pedestal = (*iptr>>0 ) & 0x7FF;
1844 cout <<
" FADC125 FDC Pulse Data(peak) word2: " << hex << (*iptr) << dec << endl;
1845 cout <<
" FADC125 FDC Pulse Data (integral="<<sum<<
" time="<<peak_time<<
" pedestal="<<pedestal<<
")"<<endl;
1849 uint32_t nsamples_integral = 0;
1850 uint32_t nsamples_pedestal = 1;
1863 pe->NEW_Df125CDCPulse(rocid, slot, channel, itrigger
1879 pe->NEW_Df125FDCPulse(rocid, slot, channel, itrigger
1900 if(
VERBOSE>7) cout <<
" FADC125 Pulse Pedestal"<<endl;
1902 uint32_t channel = last_pulse_time_channel;
1903 uint32_t pulse_number = (*iptr>>21) & 0x03;
1904 uint32_t
pedestal = (*iptr>>12) & 0x1FF;
1905 uint32_t pulse_peak = (*iptr>>0) & 0xFFF;
1906 uint32_t nsamples_pedestal = 1;
1907 if( pe ) pe->NEW_Df125PulsePedestal(rocid, slot, channel, itrigger, pulse_number, pedestal, pulse_peak, nsamples_pedestal);
1914 if(
VERBOSE>7) cout <<
" FADC125 ignored data type: " << data_type <<endl;
1917 if(
VERBOSE>7) cout <<
" FADC125 unknown data type ("<<data_type<<
")"<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
1924 for(; iptr<iend; iptr++){
1925 if(((*iptr)&0xf8000000) != 0xf8000000)
break;
1934 uint32_t channel = (*iptr>>20) & 0x7F;
1935 uint32_t window_width = (*iptr>>0) & 0x0FFF;
1937 Df125WindowRawData *wrd = pe->NEW_Df125WindowRawData(rocid, slot, channel, itrigger);
1939 for(uint32_t isample=0; isample<window_width; isample +=2){
1945 if(((*iptr>>31) & 0x1) != 0x0)
break;
1947 bool invalid_1 = (*iptr>>29) & 0x1;
1948 bool invalid_2 = (*iptr>>13) & 0x1;
1949 uint16_t sample_1 = 0;
1950 uint16_t sample_2 = 0;
1951 if(!invalid_1)sample_1 = (*iptr>>16) & 0x1FFF;
1952 if(!invalid_2)sample_2 = (*iptr>>0) & 0x1FFF;
1955 wrd->
samples.push_back(sample_1);
1957 wrd->
overflow |= (sample_1>>12) & 0x1;
1959 if((isample+2) == window_width && invalid_2)
break;
1962 wrd->
samples.push_back(sample_2);
1964 wrd->
overflow |= (sample_2>>12) & 0x1;
1973 if(!
PARSE_F1TDC){ iptr = &iptr[(*iptr) + 1];
return; }
1975 uint32_t *istart = iptr;
1981 uint32_t modtype = 0;
1982 uint32_t itrigger = -1;
1983 uint32_t trig_time_f1header = 0;
1986 if(*iptr == 0xf1daffff) iptr++;
1989 for(; iptr<iend; iptr++){
1995 if(((*iptr>>31) & 0x1) == 0)
continue;
1997 uint32_t data_type = (*iptr>>27) & 0x0F;
2000 slot = (*iptr)>>22 & 0x001F;
2001 modtype = (*iptr)>>18 & 0x000F;
2002 if(
VERBOSE>7) cout <<
" F1 Block Header: slot=" << slot <<
" modtype=" << modtype << endl;
2008 if(
VERBOSE>7) cout <<
" F1 Block Trailer" << endl;
2014 itrigger = (*iptr)>>0 & 0x0003FFFFF;
2016 uint32_t slot_event_header = (*iptr)>>22 & 0x00000001F;
2017 cout <<
" F1 Event Header: slot=" << slot_event_header <<
" itrigger=" << itrigger << endl;
2024 uint64_t t = ((*iptr)&0xFFFFFF)<<0;
2026 if(((*iptr>>31) & 0x1) == 0){
2027 t += ((*iptr)&0xFFFFFF)<<24;
2031 if(
VERBOSE>7) cout <<
" F1TDC Trigger Time (t="<<t<<
")"<<endl;
2032 if(pe) pe->NEW_DF1TDCTriggerTime(rocid, slot, itrigger, t);
2037 trig_time_f1header = ((*iptr)>> 7) & 0x1FF;
2039 uint32_t chip_f1header = ((*iptr)>> 3) & 0x07;
2040 uint32_t chan_on_chip_f1header = ((*iptr)>> 0) & 0x07;
2041 uint32_t itrigger_f1header = ((*iptr)>>16) & 0x3F;
2042 cout <<
" Found F1 header: chip=" << chip_f1header <<
" chan=" << chan_on_chip_f1header <<
" itrig=" << itrigger_f1header <<
" trig_time=" << trig_time_f1header << endl;
2048 uint32_t chip = (*iptr>>19) & 0x07;
2049 uint32_t chan_on_chip = (*iptr>>16) & 0x07;
2050 uint32_t time = (*iptr>> 0) & 0xFFFF;
2051 uint32_t channel =
F1TDC_channel(chip, chan_on_chip, modtype);
2052 if(
VERBOSE>7) cout <<
" Found F1 data : chip=" << chip <<
" chan=" << chan_on_chip <<
" time=" << time << endl;
2054 auto hit = pe->NEW_DF1TDCHit(rocid, slot, channel, itrigger, trig_time_f1header, time, *iptr,
MODULE_TYPE(modtype));
2055 if(hit->res_status==0){
2056 static uint32_t Nwarnings=0;
2057 if(Nwarnings<10) jerr <<
"ERROR: F1 TDC chip \"unlocked\" flag set!" << ((++Nwarnings == 10) ?
" -- last warning":
"") << endl;
2064 if(
VERBOSE>7) cout <<
" F1 filler word" << endl;
2070 cout.flush(); cerr.flush();
2071 _DBG_<<
"Unknown data word in F1TDC block. Dumping for debugging:" << endl;
2072 for(
const uint32_t *iiptr = istart; iiptr<iend; iiptr++){
2073 _DBG_<<
"0x"<<hex<<*iiptr<<dec;
2074 if(iiptr == iptr)cerr<<
" <----";
2075 switch( (*iiptr) & 0xF8000000 ){
2076 case 0x80000000: cerr <<
" F1 Block Header";
break;
2077 case 0x90000000: cerr <<
" F1 Event Header";
break;
2078 case 0x98000000: cerr <<
" F1 Trigger time";
break;
2079 case 0xC0000000: cerr <<
" F1 Header";
break;
2080 case 0xB8000000: cerr <<
" F1 Data";
break;
2081 case 0x88000000: cerr <<
" F1 Block Trailer";
break;
2082 case 0xF8000000: cerr <<
" Filler word";
break;
2083 case 0xF0000000: cerr <<
" <module has no valid data>";
break;
2087 if(iiptr > (iptr+4))
break;
2095 while(iptr<iend && (*iptr&0xF8000000)==0xF8000000)iptr++;
2103 if(!
PARSE_SSP){ iptr = &iptr[(*iptr) + 1];
return; }
2108 uint32_t slot_bh = 0xFFFFFFFF;
2109 uint32_t slot = 0xFFFFFFFF;
2110 uint32_t itrigger = 0xFFFFFFFF;
2111 uint32_t dev_id = 0xFFFFFFFF;
2112 uint32_t ievent_cnt = 0xFFFFFFFF;
2114 for( ; iptr<iend; iptr++){
2115 if(((*iptr>>31) & 0x1) == 0)
continue;
2117 uint32_t data_type = (*iptr>>27) & 0x0F;
2121 slot_bh = ((*iptr)>>22) & 0x1F;
2122 uint32_t block_num = ((*iptr)>> 8) & 0x3FF;
2124 if(
VERBOSE>7) cout <<
" SSP/DIRC Block Header: slot=" << slot_bh <<
" block_num="<<block_num <<
" block_size=" << block_size << endl;
2130 if(
VERBOSE>7) cout <<
" SSP/DIRC Block Trailer" << endl;
2133 slot = ((*iptr)>>22) & 0x1F;
2134 itrigger = ((*iptr)>> 0) & 0x3FFFFF;
2138 if(
VERBOSE>7) cout <<
" SSP/DIRC Event Header: slot=" << slot <<
" itrigger=" << itrigger << endl;
2139 if( slot != slot_bh ){
2140 jerr <<
"Slot from SSP/DIRC event header does not match slot from last block header (" <<slot<<
" != " << slot_bh <<
")" <<endl;
2145 uint64_t t = ((*iptr)&0xFFFFFF)<<0;
2146 if(
VERBOSE>7) cout <<
" SSP Trigger time low word="<<(((*iptr)&0xFFFFFF))<<
" (0x"<<hex<<*iptr<<dec<<
")"<<endl;
2148 if(((*iptr>>31) & 0x1) == 0){
2149 t += ((*iptr)&0xFFFFFF)<<24;
2150 if(
VERBOSE>7) cout <<
" SSP Trigger time high word="<<(((*iptr)&0xFFFFFF))<<
" (0x"<<hex<<*iptr<<dec<<
") iptr=0x"<<hex<<iptr<<dec<<endl;
2154 if(
VERBOSE>7) cout <<
" SSP Trigger Time: t="<<t<<endl;
2155 if(pe) pe->NEW_DDIRCTriggerTime(rocid, slot, itrigger, t);
2165 if(
VERBOSE>7) cout <<
" SSP/DIRC Reserved Word" << endl;
2168 dev_id = ((*iptr)>>22) & 0x1F;
2169 ievent_cnt = ((*iptr)>>0 ) & 0x3FFFFF;
2170 if(
VERBOSE>7) cout <<
" SSP/DIRC Device ID: dev_id=" << dev_id <<
" ievent_cnt=" << ievent_cnt << endl;
2174 uint32_t edge = (*iptr>>26) & 0x01;
2175 uint32_t channel_fpga = (*iptr>>16) & 0xFF;
2176 uint32_t time = (*iptr>>0 ) & 0xFFFF;
2177 uint32_t channel = (dev_id<<8) + channel_fpga;
2178 if(
VERBOSE>7) cout <<
" SSP/DIRC TDC Hit: edge=" << edge <<
"channel_fpga=" << channel_fpga <<
"time=" << time <<
" channel=" << channel << endl;
2179 if( pe ) pe->NEW_DDIRCTDCHit(rocid, slot, channel, itrigger, dev_id, ievent_cnt, channel_fpga, edge, time);
2184 if(
VERBOSE>7) cout <<
" SSP/DIRC ADC data"<<endl;
2185 uint32_t adc_hold2 = (*iptr>>16) & 0xFF;
2186 uint32_t adc_hold1 = (*iptr>>8 ) & 0xFF;
2187 uint32_t adc_max_bits = (*iptr>>4 ) & 0x0F;
2188 uint32_t maroc_id = (*iptr>>0 ) & 0x03;
2189 for(uint32_t i=0; i<32; i++){
2190 if(((*++iptr>>31) & 0x1) != 0){ iptr--;
break;}
2191 uint32_t channel_lower = (dev_id<<8) + (maroc_id<<6) + (i*2 + 0);
2192 uint32_t channel_upper = (dev_id<<8) + (maroc_id<<6) + (i*2 + 1);
2193 uint32_t adc_lower = (*iptr>>0 ) & 0xFFF;
2194 uint32_t adc_upper = (*iptr>>16 ) & 0xFFF;
2195 switch(adc_max_bits){
2207 jerr <<
"Bad value for adc_max_bits (" << adc_max_bits <<
") from SSP/DIRC with rocid=" << rocid <<
" slot=" << slot <<
"channel=" << channel_lower <<
"," << channel_upper << endl;
2211 pe->NEW_DDIRCADCHit(rocid, slot, channel_lower, itrigger, dev_id, ievent_cnt, adc_hold1, adc_hold2, adc_max_bits, maroc_id, adc_lower);
2212 pe->NEW_DDIRCADCHit(rocid, slot, channel_upper, itrigger, dev_id, ievent_cnt, adc_hold1, adc_hold2, adc_max_bits, maroc_id, adc_upper);
2218 if(
VERBOSE>7) cout <<
" SSP/DIRC Data not Valid" << endl;
2221 if(
VERBOSE>7) cout <<
" SSP/DIRC Filler Word" << endl;
2234 uint32_t Nwords = ((uint64_t)iend - (uint64_t)iptr)/
sizeof(uint32_t);
2235 uint32_t Nwords_expected = 6;
2236 if(Nwords != Nwords_expected){
2237 _DBG_ <<
"RFTime size does not match expected!!" << endl;
2238 _DBG_ <<
"Found " << Nwords <<
" words. Expected " << Nwords_expected << endl;
2246 uint64_t in_word = *iptr++;
2247 uint64_t in_word_hi = *iptr++;
2248 in_word |= in_word_hi<<32;
2250 memcpy(&rftime, &in_word,
sizeof(
double));
2251 in_word = *iptr++; in_word_hi = *iptr++;
2252 in_word |= in_word_hi<<32;
2254 memcpy(&rftime_var, &in_word,
sizeof(
double));
2256 the_rftime->
dTime = rftime;
2267 uint32_t Nwords = ((uint64_t)iend - (uint64_t)iptr)/
sizeof(uint32_t);
2268 uint32_t Nwords_expected = 11;
2269 if(Nwords != Nwords_expected){
2270 _DBG_ <<
"DVertex size does not match expected!!" << endl;
2271 _DBG_ <<
"Found " << Nwords <<
" words. Expected " << Nwords_expected << endl;
2274 DVertex *the_vertex = pe->NEW_DVertex();
2276 uint64_t in_word = *iptr++;
2277 uint64_t in_word_hi = *iptr++;
2278 in_word |= in_word_hi<<32;
2280 double vertex_x_pos;
2281 memcpy(&vertex_x_pos, &in_word,
sizeof(
double));
2282 in_word = *iptr++; in_word_hi = *iptr++;
2283 in_word |= in_word_hi<<32;
2284 double vertex_y_pos;
2285 memcpy(&vertex_y_pos, &in_word,
sizeof(
double));
2286 in_word = *iptr++; in_word_hi = *iptr++;
2287 in_word |= in_word_hi<<32;
2288 double vertex_z_pos;
2289 memcpy(&vertex_z_pos, &in_word,
sizeof(
double));
2290 in_word = *iptr++; in_word_hi = *iptr++;
2291 in_word |= in_word_hi<<32;
2293 memcpy(&vertex_t, &in_word,
sizeof(
double));
2295 DVector3 vertex_position(vertex_x_pos, vertex_y_pos, vertex_z_pos);
2299 in_word = *iptr++; in_word_hi = *iptr++;
2300 in_word |= in_word_hi<<32;
2301 memcpy(&(the_vertex->
dKinFitChiSq), &in_word,
sizeof(
double));
2319 if(pe->vDf250PulseData.size()>1 ) sort(pe->vDf250PulseData.begin(), pe->vDf250PulseData.end(), SortByPulseNumber<Df250PulseData> );
2320 if(pe->vDf250PulseIntegral.size()>1) sort(pe->vDf250PulseIntegral.begin(), pe->vDf250PulseIntegral.end(), SortByPulseNumber<Df250PulseIntegral> );
2321 if(pe->vDf250PulseTime.size()>1 ) sort(pe->vDf250PulseTime.begin(), pe->vDf250PulseTime.end(), SortByPulseNumber<Df250PulseTime> );
2322 if(pe->vDf250PulsePedestal.size()>1) sort(pe->vDf250PulsePedestal.begin(), pe->vDf250PulsePedestal.end(), SortByPulseNumber<Df250PulsePedestal> );
2323 if(pe->vDf250WindowRawData.size()>1) sort(pe->vDf250WindowRawData.begin(), pe->vDf250WindowRawData.end(), SortByChannel<Df250WindowRawData> );
2326 if(pe->vDf125PulseIntegral.size()>1) sort(pe->vDf125PulseIntegral.begin(), pe->vDf125PulseIntegral.end(), SortByPulseNumber<Df125PulseIntegral> );
2327 if(pe->vDf125CDCPulse.size()>1 ) sort(pe->vDf125CDCPulse.begin(), pe->vDf125CDCPulse.end(), SortByChannel<Df125CDCPulse> );
2328 if(pe->vDf125FDCPulse.size()>1 ) sort(pe->vDf125FDCPulse.begin(), pe->vDf125FDCPulse.end(), SortByChannel<Df125FDCPulse> );
2329 if(pe->vDf125PulseTime.size()>1 ) sort(pe->vDf125PulseTime.begin(), pe->vDf125PulseTime.end(), SortByPulseNumber<Df125PulseTime> );
2330 if(pe->vDf125PulsePedestal.size()>1) sort(pe->vDf125PulsePedestal.begin(), pe->vDf125PulsePedestal.end(), SortByPulseNumber<Df125PulsePedestal> );
2331 if(pe->vDf125WindowRawData.size()>1) sort(pe->vDf125WindowRawData.begin(), pe->vDf125WindowRawData.end(), SortByChannel<Df125WindowRawData> );
2334 if(pe->vDF1TDCHit.size()>1 ) sort(pe->vDF1TDCHit.begin(), pe->vDF1TDCHit.end(), SortByModule<DF1TDCHit> );
2337 if(pe->vDCAEN1290TDCHit.size()>1 ) sort(pe->vDCAEN1290TDCHit.begin(), pe->vDCAEN1290TDCHit.end(), SortByModule<DCAEN1290TDCHit> );
2343 LinkPulse(pe->vDf250PulseTime, pe->vDf250PulseIntegral);
2347 LinkPulse(pe->vDf125PulseTime, pe->vDf125PulseIntegral);
2351 if(!pe->vDf250WindowRawData.empty()){
2352 LinkConfig(pe->vDf250Config, pe->vDf250WindowRawData);
2353 LinkModule(pe->vDf250TriggerTime, pe->vDf250WindowRawData);
2354 LinkChannel(pe->vDf250WindowRawData, pe->vDf250PulseIntegral);
2355 LinkChannel(pe->vDf250WindowRawData, pe->vDf250PulseTime);
2356 LinkChannel(pe->vDf250WindowRawData, pe->vDf250PulsePedestal);
2357 LinkChannel(pe->vDf250WindowRawData, pe->vDf250PulseData);
2361 if(!pe->vDf125WindowRawData.empty()){
2362 LinkConfig(pe->vDf125Config, pe->vDf125WindowRawData);
2363 LinkModule(pe->vDf125TriggerTime, pe->vDf125WindowRawData);
2364 LinkChannel(pe->vDf125WindowRawData, pe->vDf125PulseIntegral);
2365 LinkChannel(pe->vDf125WindowRawData, pe->vDf125PulseTime);
2366 LinkChannel(pe->vDf125WindowRawData, pe->vDf125PulsePedestal);
2367 LinkChannel(pe->vDf125WindowRawData, pe->vDf125CDCPulse);
2368 LinkChannel(pe->vDf125WindowRawData, pe->vDf125FDCPulse);
2373 if(pe->vDf250Config.size()>1 ) sort(pe->vDf250Config.begin(), pe->vDf250Config.end(), SortByROCID<Df250Config> );
2374 if(pe->vDf125Config.size()>1 ) sort(pe->vDf125Config.begin(), pe->vDf125Config.end(), SortByROCID<Df125Config> );
2375 if(pe->vDF1TDCConfig.size()>1 ) sort(pe->vDF1TDCConfig.begin(), pe->vDF1TDCConfig.end(), SortByROCID<DF1TDCConfig> );
2376 if(pe->vDCAEN1290TDCConfig.size()>1) sort(pe->vDCAEN1290TDCConfig.begin(), pe->vDCAEN1290TDCConfig.end(), SortByROCID<DCAEN1290TDCConfig> );
2383 LinkConfig(pe->vDF1TDCConfig, pe->vDF1TDCHit);
2384 LinkConfig(pe->vDCAEN1290TDCConfig, pe->vDCAEN1290TDCHit);
2389 if(pe->vDf250TriggerTime.size()>1 ) sort(pe->vDf250TriggerTime.begin(), pe->vDf250TriggerTime.end(), SortByModule<Df250TriggerTime> );
2390 if(pe->vDf125TriggerTime.size()>1 ) sort(pe->vDf125TriggerTime.begin(), pe->vDf125TriggerTime.end(), SortByModule<Df125TriggerTime> );
2391 if(pe->vDF1TDCTriggerTime.size()>1 ) sort(pe->vDF1TDCTriggerTime.begin(), pe->vDF1TDCTriggerTime.end(), SortByModule<DF1TDCTriggerTime> );
2393 LinkModule(pe->vDf250TriggerTime, pe->vDf250PulseIntegral);
2394 LinkModule(pe->vDf125TriggerTime, pe->vDf125PulseIntegral);
2395 LinkModule(pe->vDf125TriggerTime, pe->vDf125CDCPulse);
2396 LinkModule(pe->vDf125TriggerTime, pe->vDf125FDCPulse);
2397 LinkModule(pe->vDF1TDCTriggerTime, pe->vDF1TDCHit);
2415 cout <<
"Dumping binary: istart=" << hex << iptr <<
" iend=" << iend <<
" MaxWords=" << dec << MaxWords << endl;
2417 if(iend==NULL && MaxWords==0) MaxWords=1;
2418 if(MaxWords==0) MaxWords = (uint32_t)0xffffffff;
2421 while(iptr!=iend && Nwords<MaxWords){
2424 stringstream line1, line2;
2429 line1 << setw(5) << Nwords;
2433 for(uint32_t i=0; i<
Ncols; i++, iptr++, Nwords++){
2435 if(iptr == iend)
break;
2436 if(Nwords>=MaxWords)
break;
2438 stringstream iptr_hex;
2439 iptr_hex << hex <<
"0x" << *iptr;
2441 string mark = (iptr==imark ?
"*":
" ");
2443 line1 << setw(12) << iptr_hex.str() << mark;
2444 line2 << setw(12) << *iptr << mark;
2447 cout << line1.str() << endl;
2448 cout << line2.str() << endl;
void Finish(bool wait_to_complete=true)
void ParseRawTriggerBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
uint32_t swap_bank(uint32_t *outbuff, uint32_t *inbuff, uint32_t len)
void LinkChannel(vector< T * > &a, vector< U * > &b)
uint32_t F1TDC_channel(uint32_t chip, uint32_t chan_on_chip, int modtype)
L3_decision_t
The DL3Trigger object is used to tell the level-3 trigger process whether or not to discard the event...
set< uint32_t > & ROCIDS_TO_PARSE
DEVIOWorkerThread(JEventSource_EVIOpp *event_source, list< DParsedEvent * > &parsed_events, uint32_t &MAX_PARSED_EVENTS, mutex &PARSED_EVENTS_MUTEX, condition_variable &PARSED_EVENTS_CV, set< uint32_t > &ROCIDS_TO_PARSE)
DModuleType::type_id_t MODULE_TYPE
vector< uint32_t > fa250_sc
void ParseDataBank(uint32_t *&iptr, uint32_t *iend)
uint64_t event_status_bits
void FillDerived(void)
Extract values as read from config registers and fill in the derived members defined above...
uint32_t & MAX_PARSED_EVENTS
condition_variable & PARSED_EVENTS_CV
void LinkConfigSamplesCopy(vector< T * > &a, vector< U * > &b)
void ParseControlEvent(uint32_t *&iptr, uint32_t *iend)
vector< uint16_t > samples
TLorentzVector DLorentzVector
void LinkConfig(vector< T * > &a, vector< U * > &b)
uint64_t MAX_EVENT_RECYCLES
void LinkPulse(vector< T * > &a, vector< U * > &b)
vector< uint32_t > misc_words
list< DParsedEvent * > & parsed_events
void ParseDEventRFBunchBank(uint32_t *&iptr, uint32_t *iend)
void ParseSSPBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
JEventSource_EVIOpp * event_source
void Parsef250scalerBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
void ParseCDAQBank(uint32_t *&iptr, uint32_t *iend)
void ParseDVertexBank(uint32_t *&iptr, uint32_t *iend)
void ParsePhysicsBank(uint32_t *&iptr, uint32_t *iend)
How this Event Source Works
void ParseEventTagBank(uint32_t *&iptr, uint32_t *iend)
vector< uint16_t > samples
void MakeDf250WindowRawData(DParsedEvent *pe, uint32_t rocid, uint32_t slot, uint32_t itrigger, uint32_t *&iptr)
void DumpBinary(const uint32_t *iptr, const uint32_t *iend, uint32_t MaxWords=0, const uint32_t *imark=NULL)
void ParseTIBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
void LinkPulsePedCopy(vector< T * > &a, vector< U * > &b)
void LinkAllAssociations(void)
void ParseCAEN1190(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
void MakeDf125WindowRawData(DParsedEvent *pe, uint32_t rocid, uint32_t slot, uint32_t itrigger, uint32_t *&iptr)
DLorentzVector dSpacetimeVertex
void ParseF1TDCBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
void Parsef125Bank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
void ParseJLabModuleData(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
void ParseBuiltTriggerBank(uint32_t *&iptr, uint32_t *iend)
EVIOSourceType source_type
vector< uint32_t > gtp_sc
void ParseTSscalerBank(uint32_t *&iptr, uint32_t *iend)
static const size_t block_size
vector< DParsedEvent * > parsed_event_pool
DetectorSystem_t dTimeSource
static TH1I * pedestal[nChan]
set< uint32_t > ROCIDS_TO_PARSE
mutex & PARSED_EVENTS_MUTEX
virtual ~DEVIOWorkerThread()
unsigned int dNumParticleVotes
list< DParsedEvent * > current_parsed_events
vector< uint32_t > fp_rate
void ParseModuleConfiguration(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
void ParseBORbank(uint32_t *&iptr, uint32_t *iend)
void ParseEPICSbank(uint32_t *&iptr, uint32_t *iend)
vector< uint32_t > gtp_rate
std::atomic< uint_fast64_t > NPARSER_STALLED
void Parsef250Bank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend)
void LinkModule(vector< T * > &a, vector< U * > &b)
uint64_t MAX_OBJECT_RECYCLES