29 #include <evioFileChannel.hxx>
32 extern "C" uint32_t *swap_int32_t(uint32_t *data,
unsigned int length, uint32_t *dest);
52 #define _DBG_DAQ(A) cerr<<__FILE__<<":"<<__LINE__<<" 0x"<<hex<<A<<" cntrl:0x"<<(A&0xF0000000)<<dec<<" slot:"<<((A>>22)&0x1F)<<endl
55 #include <JANA/JApplication.h>
74 cerr <<
"You are trying to use code requiring EVIO when support" << endl;
75 cerr <<
"for EVIO was not built into this binary. Set your" << endl;
76 cerr <<
"EVIOROOT *and* your ETROOT environment variables to" << endl;
77 cerr <<
"point to your EVIO installation and recompile." << endl;
105 evioout.SetTag(
"--- EVIO ---: ");
150 gPARMS->SetDefaultParameter(
"EVIO:AUTODETECT_MODULE_TYPES",
AUTODETECT_MODULE_TYPES,
"Try and guess the module type tag,num values for which there is no module map entry.");
151 gPARMS->SetDefaultParameter(
"EVIO:DUMP_MODULE_MAP",
DUMP_MODULE_MAP,
"Write module map used to file when source is destroyed. n.b. If more than one input file is used, the map file will be overwritten!");
152 gPARMS->SetDefaultParameter(
"EVIO:MAKE_DOM_TREE",
MAKE_DOM_TREE,
"Set this to 0 to disable generation of EVIO DOM Tree and parsing of event. (for benchmarking/debugging)");
153 gPARMS->SetDefaultParameter(
"EVIO:PARSE_EVIO_EVENTS",
PARSE_EVIO_EVENTS,
"Set this to 0 to disable parsing of event but still make the DOM tree, so long as MAKE_DOM_TREE isn't set to 0. (for benchmarking/debugging)");
154 gPARMS->SetDefaultParameter(
"EVIO:PARSE_F250",
PARSE_F250,
"Set this to 0 to disable parsing of data from F250 ADC modules (for benchmarking/debugging)");
155 gPARMS->SetDefaultParameter(
"EVIO:PARSE_F125",
PARSE_F125,
"Set this to 0 to disable parsing of data from F125 ADC modules (for benchmarking/debugging)");
156 gPARMS->SetDefaultParameter(
"EVIO:PARSE_F1TDC",
PARSE_F1TDC,
"Set this to 0 to disable parsing of data from F1TDC modules (for benchmarking/debugging)");
157 gPARMS->SetDefaultParameter(
"EVIO:PARSE_CAEN1290TDC",
PARSE_CAEN1290TDC,
"Set this to 0 to disable parsing of data from CAEN 1290 TDC modules (for benchmarking/debugging)");
158 gPARMS->SetDefaultParameter(
"EVIO:PARSE_CONFIG",
PARSE_CONFIG,
"Set this to 0 to disable parsing of ROC configuration data in the data stream (for benchmarking/debugging)");
159 gPARMS->SetDefaultParameter(
"EVIO:PARSE_BOR",
PARSE_BOR,
"Set this to 0 to disable parsing of BOR events from the data stream (for benchmarking/debugging)");
160 gPARMS->SetDefaultParameter(
"EVIO:PARSE_EPICS",
PARSE_EPICS,
"Set this to 0 to disable parsing of EPICS events from the data stream (for benchmarking/debugging)");
161 gPARMS->SetDefaultParameter(
"EVIO:PARSE_EVENTTAG",
PARSE_EVENTTAG,
"Set this to 0 to disable parsing of event tag data in the data stream (for benchmarking/debugging)");
162 gPARMS->SetDefaultParameter(
"EVIO:PARSE_TRIGGER",
PARSE_TRIGGER,
"Set this to 0 to disable parsing of the built trigger bank from CODA (for benchmarking/debugging)");
164 gPARMS->SetDefaultParameter(
"EVIO:BUFFER_SIZE",
BUFFER_SIZE,
"Size in bytes to allocate for holding a single EVIO event.");
165 gPARMS->SetDefaultParameter(
"EVIO:ET_STATION_NEVENTS",
ET_STATION_NEVENTS,
"Number of events to use if we have to create the ET station. Ignored if station already exists.");
166 gPARMS->SetDefaultParameter(
"EVIO:ET_STATION_CREATE_BLOCKING",
ET_STATION_CREATE_BLOCKING,
"Set this to 0 to create station in non-blocking mode (default is to create it in blocking mode). Ignored if station already exists.");
167 gPARMS->SetDefaultParameter(
"EVIO:ET_DEBUG_WORDS_TO_DUMP",
ET_DEBUG_WORDS_TO_DUMP,
"Number of words to dump to screen from ET buffer (useful for debugging only).");
168 gPARMS->SetDefaultParameter(
"EVIO:LOOP_FOREVER",
LOOP_FOREVER,
"If reading from EVIO file, keep re-opening file and re-reading events forever (only useful for debugging) If reading from ET, this is ignored.");
169 gPARMS->SetDefaultParameter(
"EVIO:VERBOSE",
VERBOSE,
"Set verbosity level for processing and debugging statements while parsing. 0=no debugging messages. 10=all messages");
170 gPARMS->SetDefaultParameter(
"ET:TIMEOUT",
TIMEOUT,
"Set the timeout in seconds for each attempt at reading from ET system (repeated attempts will still be made indefinitely until program quits or the quit_on_et_timeout flag is set.");
171 gPARMS->SetDefaultParameter(
"EVIO:MODTYPE_MAP_FILENAME",
MODTYPE_MAP_FILENAME,
"Optional module type conversion map for use with files generated with the non-standard module types");
172 gPARMS->SetDefaultParameter(
"EVIO:ENABLE_DISENTANGLING",
ENABLE_DISENTANGLING,
"Enable/disable disentangling of multi-block events. Enabled by default. Set to 0 to disable.");
173 gPARMS->SetDefaultParameter(
"EVIO:SPARSE_READ",
EVIO_SPARSE_READ,
"Set to true to enable sparse reading of the EVIO file. This will take some time to map out the entire file prior to event processing. It is typically only useful if the EVIO:EVENT_MASK variable is set.");
174 gPARMS->SetDefaultParameter(
"EVIO:EVENT_MASK",
EVENT_MASK,
"Commas separated list used to set the mask that selects the type of events to read in. Other types will be skipped. Valid values are EPICS,BOR and PHYSICS");
176 gPARMS->SetDefaultParameter(
"EVIO:F250_EMULATION_MODE", f250_emulation_mode,
"Set f250 emulation mode. 0=no emulation, 1=always, 2=auto. Default is 2 (auto).");
177 gPARMS->SetDefaultParameter(
"EVIO:F125_EMULATION_MODE", f125_emulation_mode,
"Set f125 emulation mode. 0=no emulation, 1=always, 2=auto. Default is 2 (auto).");
179 gPARMS->SetDefaultParameter(
"EVIO:RUN_NUMBER",
USER_RUN_NUMBER,
"User-supplied run number. Override run number from other sources with this.(will be ignored if set to zero)");
180 gPARMS->SetDefaultParameter(
"EVIO:F125PULSE_NUMBER_FILTER",
F125PULSE_NUMBER_FILTER,
"Ignore data for DF125XXX objects with a pulse number equal or greater than this.");
181 gPARMS->SetDefaultParameter(
"EVIO:F250PULSE_NUMBER_FILTER",
F250PULSE_NUMBER_FILTER,
"Ignore data for DF250XXX objects with a pulse number equal or greater than this.");
190 if(
VERBOSE>0)
evioout <<
"Attempting to open \""<<this->source_name<<
"\" as EVIO file..." <<endl;
200 jerr <<
"You are attempting to use the CODA Channels library for reading" << endl;
201 jerr <<
"and EVIO file and this mechanism has been disabled from in the" << endl;
202 jerr <<
"DAQ library. Contact davidl@jlab.org if you need this to be" << endl;
203 jerr <<
"reinstated." << endl;
212 }
catch (std::exception &
e) {
217 if(this->source_name.substr(0,3) ==
"ET:"){
218 if(
VERBOSE>0)
evioout <<
"Attempting to open \""<<this->source_name<<
"\" as ET (network) source..." <<endl;
222 if(!
et_connected)
throw JException(
"Failed to open ET system: " + this->source_name);
231 if(this->source_name.substr(0,3) ==
"ET:"){
233 cerr <<
"=== ERROR: ET source specified and this was compiled without ===" << endl;
234 cerr <<
"=== ET support. You need to install ET and set your ===" << endl;
235 cerr <<
"=== ETROOT environment variable appropriately before ===" << endl;
236 cerr <<
"=== recompiling. ===" << endl;
243 if(
VERBOSE>0)
evioout <<
"Success opening event source \"" << this->source_name <<
"\"!" <<endl;
292 size_t pos2 = this->source_name.find_last_of(
'_');
293 if(pos2 != string::npos){
294 size_t pos1 = this->source_name.find_last_of(
'_', pos2-1);
295 if(pos1 != string::npos){
297 string runstr = this->source_name.substr(pos1, pos2-pos1);
305 pthread_rwlock_init(&
BOR_lock, NULL);
322 if(
VERBOSE>0)
evioout <<
"Closing ET connection \"" << this->source_name <<
"\"" <<endl;
329 if(
VERBOSE>0)
evioout <<
"Closing hdevio event source \"" << this->source_name <<
"\"" <<endl;
359 if(!ifs.is_open())
return;
361 cout <<
"Opened JLab module type translation map: " << endl;
365 ifs.getline(line, 256);
366 if(ifs.gcount() < 1)
break;
367 if(line[0] ==
'#')
continue;
369 stringstream ss(line);
370 uint32_t from=10000, to=10000;
374 cout <<
"unable to convert line:" << endl;
386 cout <<
" type " << iter->first <<
" -> type " << iter->second << endl;
428 vector<string> fields;
429 string str = source_name;
430 size_t startpos=0, endpos=0;
431 while((endpos = str.find(
":", startpos)) != str.npos){
432 size_t len = endpos-startpos;
433 fields.push_back(len==0 ?
"":str.substr(startpos, len));
436 if(startpos<str.length()) fields.push_back(str.substr(startpos, str.npos));
438 string session = fields.size()>1 ? fields[1]:
"";
439 string station = fields.size()>2 ? fields[2]:
"";
440 string host = fields.size()>3 ? fields[3]:
"localhost";
441 int port = fields.size()>4 ? atoi(fields[4].c_str()):ET_SERVER_PORT;
443 if(session ==
"") session =
"none";
444 if(station ==
"") station =
"DANA";
445 if(host ==
"") host =
"localhost";
446 string fname = session.at(0)==
'/' ? session:(
string(
"/tmp/et_sys_") + session);
449 jout <<
" Opening ET system:" << endl;
450 if(session!=fname) jout <<
" session: " << session << endl;
451 jout <<
" station: " << station << endl;
452 jout <<
" system file: " << fname << endl;
453 jout <<
" host: " << host << endl;
454 if(port !=0) jout <<
" port: " << port << endl;
457 et_openconfig openconfig;
458 et_open_config_init(&openconfig);
460 if(host.find(
"239.")==0){
461 cout<<__FILE__<<
":"<<__LINE__<<
" Configuring input ET for multicast" << endl;
462 et_open_config_setcast(openconfig, ET_MULTICAST);
463 et_open_config_addmulticast(openconfig, host.c_str());
464 et_open_config_sethost(openconfig, ET_HOST_ANYWHERE);
465 et_open_config_setport(openconfig, port);
466 struct timespec tspec={5,5};
467 et_open_config_settimeout(openconfig, tspec);
468 et_open_config_setwait(openconfig, ET_OPEN_WAIT);
470 cout<<__FILE__<<
":"<<__LINE__<<
" Configuring input ET for direct connection" << endl;
471 et_open_config_setcast(openconfig, ET_DIRECT);
472 et_open_config_setmode(openconfig, ET_HOST_AS_LOCAL);
473 et_open_config_sethost(openconfig, host.c_str());
474 et_open_config_setport(openconfig, ET_BROADCAST_PORT);
475 if(port != 0)et_open_config_setserverport(openconfig, port);
478 int err = et_open(&sys_id,fname.c_str(),openconfig);
480 cerr << __FILE__<<
":"<<__LINE__<<
" Problem opening ET system"<<endl;
481 cerr << et_perror(err);
486 et_statconfig et_station_config;
487 et_station_config_init(&et_station_config);
489 et_station_config_setselect(et_station_config,ET_STATION_SELECT_ALL);
490 et_station_config_setuser(et_station_config,ET_STATION_USER_MULTI);
491 et_station_config_setrestore(et_station_config,ET_STATION_RESTORE_OUT);
493 et_station_config_setprescale(et_station_config,1);
494 cout<<
"ET station configured\n";
497 int status=et_station_create(sys_id,&sta_id,station.c_str(),et_station_config);
498 if((status!=ET_OK)&&(status!=ET_ERROR_EXISTS)) {
500 cerr <<
"Unable to create station " << station << endl;
501 cerr << et_perror(status);
506 et_system_getnumevents(sys_id, &Nevents);
508 jerr <<
"NOTE: The number of events specified for the station cue is equal to" << endl;
509 jerr <<
"or greater than the number of events in the entire ET system:" << endl;
513 jerr <<
"Try re-running with: " << endl;
515 jerr <<
" -PEVIO:ET_STATION_NEVENTS=" << (Nevents+1)/2 << endl;
520 if(status==ET_ERROR_EXISTS){
521 jout <<
" Using existing ET station " << station << endl;
523 jout <<
" ET station " << station <<
" created\n";
527 status=et_station_attach(sys_id,sta_id,&att_id);
530 jerr <<
"Unable to attach to station " << station << endl;
534 jout <<
"...now connected to ET system: " << fname
535 <<
", station: " << station <<
" (station id=" << sta_id <<
", attach id=" << att_id <<
")" << endl;
543 et_system_geteventsize(sys_id, &eventsize);
545 jout<<
" Events in ET system are larger than currently set buffer size:"<<endl;
547 jout<<
" Setting BUFFER_SIZE to "<<eventsize<<endl;
550 jout<<
" ET system event size:"<<eventsize<<
" JEventSource_EVIO.BUFFER_SIZE:"<<
BUFFER_SIZE<<endl;
555 jerr <<
"You are attempting to connect to an ET system using a binary that" <<endl;
556 jerr <<
"was compiled without ET support. Please reconfigure and recompile" <<endl;
557 jerr <<
"To get ET support." << endl;
610 if(
VERBOSE>1)
evioout <<
"GetEvent called for &event = " << hex << &
event << dec << endl;
613 bool no_source =
true;
623 if(no_source)
throw JException(
string(
"Unable to open EVIO channel for \"") + source_name +
"\"");
643 ObjList *objs_ptr = NULL;
658 if(objs_ptr == NULL){
660 uint32_t *buff = NULL;
668 if(err == NO_MORE_EVENTS_IN_SOURCE){
669 _DBG_<<endl<<
"-- No more events in source. Waiting for all buffers to be parsed (" <<
Nunparsed<<
") ..." << endl;
671 while(
Nunparsed>0 && !
japp->GetQuittingStatus()) usleep(1000);
675 return NO_MORE_EVENTS_IN_SOURCE;
686 if(err != NOERROR)
return err;
687 if(objs_ptr == NULL){
688 if(buff == NULL)
return MEMORY_ALLOCATION_ERROR;
689 uint32_t buff_size = ((*buff) + 1)*4;
691 objs_ptr =
new ObjList();
692 objs_ptr->time_evio_read = t2 -
t1;
693 objs_ptr->eviobuff = buff;
694 objs_ptr->eviobuff_size = buff_size;
715 event.SetJEventSource(
this);
716 event.SetEventNumber((uint64_t)objs_ptr->event_number);
717 event.SetRunNumber(objs_ptr->run_number);
718 event.SetRef(objs_ptr);
723 if(objs_ptr->eviobuff)
FindEventType(objs_ptr->eviobuff, event);
727 event.SetSequential();
740 if(
VERBOSE>1)
evioout <<
"FreeEvent called for event: " <<
event.GetEventNumber() << endl;
742 ObjList *objs_ptr = (ObjList*)event.GetRef();
752 if(!objs_ptr->eviobuff_parsed)
ParseEvents(objs_ptr);
754 if(objs_ptr->own_objects){
756 for(
unsigned int i=0; i<objs_ptr->hit_objs.size(); i++){
757 delete objs_ptr->hit_objs[i];
760 for(
unsigned int i=0; i<objs_ptr->config_objs.size(); i++){
761 delete objs_ptr->config_objs[i];
764 for(
unsigned int i=0; i<objs_ptr->misc_objs.size(); i++){
765 delete objs_ptr->misc_objs[i];
769 if(objs_ptr->DOMTree != NULL)
delete objs_ptr->DOMTree;
770 if(objs_ptr->eviobuff){
781 free(objs_ptr->eviobuff);
822 if(
VERBOSE>2)
evioout <<
" Entering ParseEvents() with objs_ptr=" << hex << objs_ptr << dec << endl;
825 if(objs_ptr->eviobuff_parsed){
826 jerr <<
" DAQ event already parsed!! Bug in code. Contact davidl@jlab.org" << endl;
827 return UNKNOWN_ERROR;
831 uint32_t *buff = objs_ptr->eviobuff;
833 jerr <<
" Bad buffer pointer passed to JEventSource_EVIO::ParseEvent()!!" << endl;
834 return RESOURCE_UNAVAILABLE;
841 list<ObjList*> full_events;
847 uint32_t *iptr = &buff[0];
848 uint32_t *iend = &buff[buff[0]+1];
861 iend = &buff[buff[0]];
864 if(
VERBOSE>5)
evioout <<
" Looping event stack with " << *iptr <<
" words" << endl;
868 int Nevents_in_stack=0;
871 double time_dom_tree = 0;
872 double time_evio_parse = 0;
875 evioDOMTree *evt = NULL;
879 evt =
new evioDOMTree(iptr);
880 time_dom_tree =
GetTime() - tstart;
881 }
catch(evioException &e){
882 _DBG_ <<
"Problem creating EVIO DOM Tree!!" << endl;
883 _DBG_ << e.what() << endl;
884 _DBG_ <<
"Binary dump of first 160 words follows:" << endl;
892 list<ObjList*> my_full_events;
897 ParseEVIOEvent(evt, my_full_events);
898 time_evio_parse =
GetTime() - tstart;
899 }
catch(JException &jexception){
900 jerr <<
"Exception thrown from ParseEVIOEvent!" << endl;
901 jerr << jexception.toString() << endl;
906 if(!my_full_events.empty()) {
907 my_full_events.front()->DOMTree = evt;
908 my_full_events.front()->time_dom_tree = time_dom_tree;
909 my_full_events.front()->time_evio_parse = time_evio_parse;
910 full_events.insert( full_events.end(), my_full_events.begin(), my_full_events.end() );
918 ObjList *objs =
new ObjList;
919 full_events.push_back(objs);
927 if(
VERBOSE>5)
evioout <<
" Loop finished. " << full_events.size() <<
" events total found (" << Nevents_in_stack <<
" events in stack)" << endl;
934 bool empty_event = full_events.empty();
935 if(empty_event) full_events.push_back(
new ObjList());
940 list<ObjList*>::iterator iter = full_events.begin();
941 for( ; iter != full_events.end(); iter++ ) (*iter)->eviobuff_parsed =
true;
944 ObjList *objs = full_events.front();
945 full_events.pop_front();
947 objs_ptr->own_objects = objs->own_objects;
948 objs_ptr->hit_objs = objs->hit_objs;
949 objs_ptr->config_objs = objs->config_objs;
950 objs_ptr->misc_objs = objs->misc_objs;
951 objs_ptr->eviobuff_parsed = objs->eviobuff_parsed;
952 objs_ptr->time_dom_tree = objs->time_dom_tree;
953 objs_ptr->time_evio_parse = objs->time_evio_parse;
956 objs_ptr->DOMTree = objs->DOMTree;
972 #define CloneConfigObject(T){ if(confobj->className() == string(#T)){ c = new T(confobj->rocid,confobj->slot_mask); *((T*)c) = *((T*)confobj);} }
973 list<ObjList*>::iterator feiter = full_events.begin();
974 for(; feiter!=full_events.end(); feiter++){
975 ObjList *objs = *feiter;
976 for(uint32_t j=0; j<objs_ptr->config_objs.size(); j++){
977 DDAQConfig *confobj = objs_ptr->config_objs[j];
983 if(c)objs->config_objs.push_back(c);
989 while(!full_events.empty()){
990 objs = full_events.front();
991 full_events.pop_front();
995 objs->run_number = objs_ptr->run_number;
1014 uint32_t *buff = NULL;
1047 if(
VERBOSE>1)
evioout <<
" ReadEVIOEvent() called with &buff=" << hex << &buff << dec << endl;
1051 if(
VERBOSE>3)
evioout <<
" attempting read from EVIO file source ..." << endl;
1075 if(buff) free(buff);
1077 buff =
new uint32_t[buff_size];
1083 if(
VERBOSE>0) cout << endl << mess << endl;
1090 cout <<
"LOOP_FOREVER: reopening " << this->source_name <<endl;
1094 return NO_MORE_EVENTS_IN_SOURCE;
1098 cout << endl << mess << endl;
1102 return NO_MORE_EVENTS_IN_SOURCE;
1110 #endif // USE_HDEVIO
1116 if(
VERBOSE>3)
evioout <<
" attempting read from EVIO ET source ..." << endl;
1120 struct timespec timeout;
1121 timeout.tv_sec = (
unsigned int)floor(
TIMEOUT);
1122 timeout.tv_nsec = (
unsigned int)floor(1.0E9*(
TIMEOUT-(
float)timeout.tv_sec));
1124 while(!
japp->GetQuittingStatus() ){
1125 int err = et_event_get(sys_id, att_id, &pe, ET_TIMED , &timeout);
1127 if( err == ET_OK && pe!=NULL)
break;
1129 if( err == ET_OK && pe==NULL){
1130 evioout <<
" !!! ET returned no error, but event pointer is NULL!!!" << endl;
1131 return NO_MORE_EVENTS_IN_SOURCE;
1134 if( err==ET_ERROR_TIMEOUT ){
1136 }
else if( err!=ET_OK){
1137 evioout <<
" Error reading from ET. This probably means the ET" << endl;
1138 evioout <<
"system has gone away (possibly due to run ending or" << endl;
1139 evioout <<
"DAQ crashing). At any rate, we are quitting now as this" << endl;
1140 evioout <<
"error is currently unrecoverable." << endl;
1141 return NO_MORE_EVENTS_IN_SOURCE;
1147 if(
japp->GetQuittingStatus() && pe==NULL)
return NO_MORE_EVENTS_IN_SOURCE;
1150 uint32_t *et_buff=NULL;
1151 et_event_getdata(pe, (
void**)&et_buff);
1152 if(et_buff == NULL){
1153 jerr <<
" Got event from ET, but pointer to data is NULL!" << endl;
1154 return NO_MORE_EVENTS_IN_SOURCE;
1174 et_event_getlength(pe, &et_len);
1175 if(
VERBOSE>3)
evioout <<
" ET event length: " << et_len <<
" (=" << et_len/4 <<
" words)"<<endl;
1178 vector<uint32_t*> buffs;
1179 while(et_idx < et_len/4){
1182 if(
VERBOSE>3)
evioout <<
" Looking for EVIO block header at et_idx=" << et_idx << endl;
1183 uint32_t *evio_block = &et_buff[et_idx];
1186 bool swap_needed =
false;
1187 uint32_t magic = evio_block[7];
1189 case 0xc0da0100: swap_needed =
false;
break;
1190 case 0x0001dac0: swap_needed =
true;
break;
1192 evioout <<
"EVIO magic word not present!" << endl;
1193 return NO_MORE_EVENTS_IN_SOURCE;
1195 uint32_t len = evio_block[0];
1196 if(swap_needed) len = EVIO_SWAP32(len);
1198 evioout <<
"Swapping is " << (swap_needed ?
"":
"not ") <<
"needed" << endl;
1199 evioout <<
" Num. words in EVIO buffer: "<<len<<endl;
1202 bool is_last_evio_block = (evio_block[5]>>(9+8))&0x1;
1203 if(
VERBOSE>3)
evioout <<
" Is last EVIO block?: " << is_last_evio_block << endl;
1210 uint32_t mylen = swap_needed ? EVIO_SWAP32(evio_block[idx]):evio_block[idx];
1211 uint32_t bufsize_bytes = (mylen+1)*
sizeof(uint32_t);
1213 jerr<<
" ET event larger than our BUFFER_SIZE!!!"<<endl;
1214 jerr<<
" " << bufsize_bytes <<
" > " <<
BUFFER_SIZE << endl;
1215 jerr<<
" Will stop reading from this source now. Try restarting"<<endl;
1216 jerr<<
" with -PEVIO:BUFFER_SIZE=X where X is greater than "<<bufsize_bytes<<endl;
1218 evioout <<
"First few words in case you are trying to debug:" << endl;
1219 for(
unsigned int j=0; j<3; j++){
1221 for(
unsigned int i=0; i<5; i++){
1222 sprintf(str,
" %08x", evio_block[i+j*5]);
1228 return NO_MORE_EVENTS_IN_SOURCE;
1233 if( (idx+mylen) > len ){
1234 _DBG_ <<
"Bad word count while swapping events in ET event stack!" << endl;
1235 _DBG_ <<
"idx="<<idx<<
" mylen="<<mylen<<
" len="<<len<<endl;
1236 _DBG_ <<
"This indicates a problem either with the DAQ system"<<endl;
1237 _DBG_ <<
"or this parser code! Contact davidl@jlab.org x5567 " <<endl;
1248 memcpy(buff, &evio_block[idx], bufsize_bytes);
1250 swap_int32_t(&evio_block[idx], mylen+1, buff);
1255 buffs.push_back(buff);
1260 if(
VERBOSE>3)
evioout <<
" EVIO events found so far: " << buffs.size() << endl;
1261 if(is_last_evio_block){
1262 if(
VERBOSE>3)
evioout <<
" Block flagged as last in ET event. Ignoring last " << (et_len/4 - et_idx) <<
" words" <<endl;
1268 et_event_put(sys_id, att_id, pe);
1270 if(
VERBOSE>3)
evioout <<
" Found " << buffs.size() <<
" events in the ET event stack." << endl;
1273 buff = buffs.empty() ? NULL:buffs[0];
1279 for(uint32_t i=1; i<buffs.size(); i++){
1280 ObjList *objs =
new ObjList();
1281 objs->eviobuff = buffs[i];
1292 evioout <<
"Attempting to read from ET system using binary that" << endl;
1293 evioout <<
"does not have ET support built in! Try recompiling" << endl;
1294 evioout <<
"programs/Utilities/plugins/DAQ with ETROOT defined" << endl;
1295 evioout <<
"and pointing to an ET installation." << endl;
1300 }
catch (evioException &e) {
1301 _DBG_<<e.what()<<endl;
1302 if(e.type == S_EVFILE_TRUNC){
1303 jerr <<
"-- Event buffer truncated --" <<endl;
1304 jerr <<
"---- this could be because the events are too large " << endl;
1305 jerr <<
"---- for the buffer provided (" <<
BUFFER_SIZE <<
" bytes)" <<endl;
1306 jerr <<
"---- you can try giving a larger buffer size by setting" << endl;
1307 jerr <<
"---- the EVIO:BUFFER_SIZE configuration parameter by " << endl;
1308 jerr <<
"---- adding this argument to your command line:" << endl;
1309 jerr <<
"---- -PEVIO:BUFFER_SIZE=X (where X is in bytes)" << endl;
1323 if(
VERBOSE>2)
evioout <<
" GetObjects() called for &event = " << hex << &
event << dec << endl;
1340 ObjList *objs_ptr = (ObjList*)event.GetRef();
1341 if(!objs_ptr)
return RESOURCE_UNAVAILABLE;
1342 if(!objs_ptr->own_objects)
return OBJECT_NOT_AVAILABLE;
1360 vector<const DTranslationTable*> translationTables;
1361 JEventLoop *loop =
event.GetJEventLoop();
1363 if(ttfac) ttfac->Get(translationTables);
1370 if(!objs_ptr->eviobuff_parsed)
ParseEvents(objs_ptr);
1373 string dataClassName = (factory==NULL ?
"N/A":factory->GetDataClassName());
1377 map<string, vector<JObject*> > hit_objs_by_type;
1378 vector<DDAQAddress*> &
hit_objs = objs_ptr->hit_objs;
1379 for(
unsigned int i=0; i<hit_objs.size(); i++){
1380 JObject *hit_obj = hit_objs[i];
1381 hit_objs_by_type[hit_obj->className()].push_back(hit_obj);
1385 map<string, vector<JObject*> > config_objs_by_type;
1386 vector<DDAQConfig*> &config_objs = objs_ptr->config_objs;
1387 for(
unsigned int i=0; i<config_objs.size(); i++){
1388 JObject *config_obj = config_objs[i];
1389 config_objs_by_type[config_obj->className()].push_back(config_obj);
1393 map<string, vector<JObject*> > misc_objs_by_type;
1394 vector<JObject*> &misc_objs = objs_ptr->misc_objs;
1395 for(
unsigned int i=0; i<misc_objs.size(); i++){
1396 JObject *jobj = misc_objs[i];
1397 misc_objs_by_type[jobj->className()].push_back(jobj);
1402 for(
unsigned int j=0; j<config_objs.size(); j++){
1404 for(
unsigned int i=0; i<hit_objs.size(); i++){
1408 hit->AddAssociatedObject(config);
1414 CopyBOR(loop, hit_objs_by_type);
1422 map<string, vector<JObject*> >::iterator hoiter;
1423 for(hoiter=hit_objs_by_type.begin(); hoiter!=hit_objs_by_type.end(); hoiter++){
1428 vector<JObject*> &f250_wrd_objs = hit_objs_by_type[
"Df250WindowRawData"];
1429 vector<JObject*> &f250_pt_objs = hit_objs_by_type[
"Df250PulseTime"];
1430 vector<JObject*> &f250_pp_objs = hit_objs_by_type[
"Df250PulsePedestal"];
1431 vector<JObject*> &f250_pi_objs = hit_objs_by_type[
"Df250PulseIntegral"];
1433 vector<JObject*> &f125_wrd_objs = hit_objs_by_type[
"Df125WindowRawData"];
1434 vector<JObject*> &f125_pt_objs = hit_objs_by_type[
"Df125PulseTime"];
1435 vector<JObject*> &f125_pp_objs = hit_objs_by_type[
"Df125PulsePedestal"];
1436 vector<JObject*> &f125_pi_objs = hit_objs_by_type[
"Df125PulseIntegral"];
1437 vector<JObject*> &f125_cp_objs = hit_objs_by_type[
"Df125CDCPulse"];
1438 vector<JObject*> &f125_fp_objs = hit_objs_by_type[
"Df125FDCPulse"];
1451 vector<Df250PulseIntegral*> f250_ppi_objs;
1452 vector<Df250PulseTime*> f250_ppt_objs;
1453 vector<Df250PulsePedestal*> f250_ppp_objs;
1461 vector<Df125WindowRawData*> f125_pwrd_objs;
1462 vector<Df125PulseIntegral*> f125_ppi_objs;
1463 vector<Df125PulseTime*> f125_ppt_objs;
1464 vector<Df125PulsePedestal*> f125_ppp_objs;
1465 vector<Df125CDCPulse*> f125_pcp_objs;
1466 vector<Df125FDCPulse*> f125_pfp_objs;
1482 set<string>::iterator siter;
1484 if(hit_objs_by_type.find(*siter) == hit_objs_by_type.end()){
1500 vector<JObject*> &vpp125 = hit_objs_by_type[
"Df125PulsePedestal"];
1501 for(
unsigned int i=0; i<vpp125.size(); i++){
1505 pp->GetSingle(conf);
1507 if(conf->
NPED != 0xFFFF){
1522 vector<JObject*> &vpi250 = hit_objs_by_type[
"Df250PulseIntegral"];
1523 for(
unsigned int i=0; i<vpi250.size(); i++){
1529 pi->GetSingle(conf);
1530 pi->GetSingle(BORconf);
1543 if(conf->
NPED != 0xFFFF){
1555 uint16_t NSB = BORconf->
adc_nsb & 0x7F;
1556 uint16_t NSA = BORconf->
adc_nsa & 0x7F;
1564 vector<JObject*> &vpi125 = hit_objs_by_type[
"Df125PulseIntegral"];
1565 for(
unsigned int i=0; i<vpi125.size(); i++){
1570 pi->GetSingle(conf);
1594 vector<JObject*> &vcdcp125 = hit_objs_by_type[
"Df125CDCPulse"];
1595 for(
unsigned int i=0; i<vcdcp125.size(); i++){
1599 cdcp->GetSingle(conf);
1607 int timesample = (int)cdcp->
le_time/10;
1608 int END = ( (timesample + conf->
IE) > (conf->
NW - 20) ) ? (conf->
NW - 20) : (timesample + conf->
IE) ;
1609 int nsamp = END - timesample;
1620 vector<JObject*> &vfdcp125 = hit_objs_by_type[
"Df125FDCPulse"];
1621 for(
unsigned int i=0; i<vfdcp125.size(); i++){
1625 fdcp->GetSingle(conf);
1633 int timesample = (int)fdcp->
le_time/10;
1634 int END = ( (timesample + conf->
IE) > (conf->
NW - 20) ) ? (conf->
NW - 20) : (timesample + conf->
IE) ;
1635 int nsamp = END - timesample;
1648 map<string, vector<JObject*> >::iterator config_iter = config_objs_by_type.begin();
1649 for(; config_iter!=config_objs_by_type.end(); config_iter++){
1650 JFactory_base *fac = loop->GetFactory(config_iter->first,
"",
false);
1651 if(fac) fac->CopyTo(config_iter->second);
1655 map<string, vector<JObject*> >::iterator iter = hit_objs_by_type.begin();
1656 for(; iter!=hit_objs_by_type.end(); iter++){
1657 JFactory_base *fac = loop->GetFactory(iter->first,
"",
false);
1658 fac->CopyTo(iter->second);
1662 map<string, vector<JObject*> >::iterator misc_iter = misc_objs_by_type.begin();
1663 for(; misc_iter!=misc_objs_by_type.end(); misc_iter++){
1664 JFactory_base *fac = loop->GetFactory(misc_iter->first,
"",
false);
1665 fac->CopyTo(misc_iter->second);
1667 objs_ptr->own_objects =
false;
1677 jerror_t err = OBJECT_NOT_AVAILABLE;
1678 if(strlen(factory->Tag()) == 0){
1691 JFactory_base *fac = loop->GetFactory(*dtiter);
1703 string dataClassName = fac->GetDataClassName();
1704 int checkSourceFirst = 1;
1705 if( dataClassName ==
"Df250Config") checkSourceFirst = ((JFactory<Df250Config >*)fac)->GetCheckSourceFirst();
1706 else if(dataClassName ==
"Df250PulseIntegral") checkSourceFirst = ((JFactory<Df250PulseIntegral >*)fac)->GetCheckSourceFirst();
1707 else if(dataClassName ==
"Df250StreamingRawData") checkSourceFirst = ((JFactory<Df250StreamingRawData>*)fac)->GetCheckSourceFirst();
1708 else if(dataClassName ==
"Df250WindowSum") checkSourceFirst = ((JFactory<Df250WindowSum >*)fac)->GetCheckSourceFirst();
1709 else if(dataClassName ==
"Df250PulseRawData") checkSourceFirst = ((JFactory<Df250PulseRawData >*)fac)->GetCheckSourceFirst();
1710 else if(dataClassName ==
"Df250TriggerTime") checkSourceFirst = ((JFactory<Df250TriggerTime >*)fac)->GetCheckSourceFirst();
1711 else if(dataClassName ==
"Df250PulseTime") checkSourceFirst = ((JFactory<Df250PulseTime >*)fac)->GetCheckSourceFirst();
1712 else if(dataClassName ==
"Df250PulsePedestal") checkSourceFirst = ((JFactory<Df250PulsePedestal >*)fac)->GetCheckSourceFirst();
1713 else if(dataClassName ==
"Df250WindowRawData") checkSourceFirst = ((JFactory<Df250WindowRawData >*)fac)->GetCheckSourceFirst();
1714 else if(dataClassName ==
"Df125Config") checkSourceFirst = ((JFactory<Df125Config >*)fac)->GetCheckSourceFirst();
1715 else if(dataClassName ==
"Df125PulseIntegral") checkSourceFirst = ((JFactory<Df125PulseIntegral >*)fac)->GetCheckSourceFirst();
1716 else if(dataClassName ==
"Df125TriggerTime") checkSourceFirst = ((JFactory<Df125TriggerTime >*)fac)->GetCheckSourceFirst();
1717 else if(dataClassName ==
"Df125PulseTime") checkSourceFirst = ((JFactory<Df125PulseTime >*)fac)->GetCheckSourceFirst();
1718 else if(dataClassName ==
"Df125PulsePedestal") checkSourceFirst = ((JFactory<Df125PulsePedestal >*)fac)->GetCheckSourceFirst();
1719 else if(dataClassName ==
"Df125WindowRawData") checkSourceFirst = ((JFactory<Df125WindowRawData >*)fac)->GetCheckSourceFirst();
1720 else if(dataClassName ==
"Df125CDCPulse") checkSourceFirst = ((JFactory<Df125CDCPulse >*)fac)->GetCheckSourceFirst();
1721 else if(dataClassName ==
"Df125FDCPulse") checkSourceFirst = ((JFactory<Df125FDCPulse >*)fac)->GetCheckSourceFirst();
1722 else if(dataClassName ==
"DF1TDCConfig") checkSourceFirst = ((JFactory<DF1TDCConfig >*)fac)->GetCheckSourceFirst();
1723 else if(dataClassName ==
"DF1TDCHit") checkSourceFirst = ((JFactory<DF1TDCHit >*)fac)->GetCheckSourceFirst();
1724 else if(dataClassName ==
"DF1TDCTriggerTime") checkSourceFirst = ((JFactory<DF1TDCTriggerTime >*)fac)->GetCheckSourceFirst();
1725 else if(dataClassName ==
"DCAEN1290TDCConfig") checkSourceFirst = ((JFactory<DCAEN1290TDCConfig >*)fac)->GetCheckSourceFirst();
1726 else if(dataClassName ==
"DCAEN1290TDCHit") checkSourceFirst = ((JFactory<DCAEN1290TDCHit >*)fac)->GetCheckSourceFirst();
1727 else if(dataClassName ==
"DCODAEventInfo") checkSourceFirst = ((JFactory<DCODAEventInfo >*)fac)->GetCheckSourceFirst();
1728 else if(dataClassName ==
"DCODAROCInfo") checkSourceFirst = ((JFactory<DCODAROCInfo >*)fac)->GetCheckSourceFirst();
1729 else if(dataClassName ==
"DTSscalers") checkSourceFirst = ((JFactory<DTSscalers >*)fac)->GetCheckSourceFirst();
1730 else if(dataClassName ==
"Df250BORConfig") checkSourceFirst = ((JFactory<Df250BORConfig >*)fac)->GetCheckSourceFirst();
1731 else if(dataClassName ==
"Df125BORConfig") checkSourceFirst = ((JFactory<Df125BORConfig >*)fac)->GetCheckSourceFirst();
1732 else if(dataClassName ==
"DF1TDCBORConfig") checkSourceFirst = ((JFactory<DF1TDCBORConfig >*)fac)->GetCheckSourceFirst();
1733 else if(dataClassName ==
"DCAEN1290TDCBORConfig") checkSourceFirst = ((JFactory<DCAEN1290TDCBORConfig>*)fac)->GetCheckSourceFirst();
1735 if(checkSourceFirst) {
1736 fac->Set_evnt_called();
1747 for(
unsigned int i=0; i<translationTables.size(); i++){
1748 translationTables[i]->ApplyTranslationTable(loop);
1749 if(translationTables[i]->IsSuppliedType(dataClassName))
1750 if(strlen(factory->Tag()) == 0)err = NOERROR;
1771 map<string, vector<JObject*> > bor_objs_by_type;
1772 for(
unsigned int i=0; i<
BORobjs.size(); i++){
1774 bor_objs_by_type[jobj->className()].push_back(jobj);
1778 map<string, vector<JObject*> >::iterator iter = bor_objs_by_type.begin();
1779 for(; iter!=bor_objs_by_type.end(); iter++){
1780 const string &bor_obj_name = iter->first;
1781 vector<JObject*> &bors = iter->second;
1782 JFactory_base *fac = loop->GetFactory(bor_obj_name,
"",
false);
1785 fac->SetFactoryFlag(JFactory_base::NOT_OBJECT_OWNER);
1789 if(bor_obj_name ==
"Df250BORConfig"){
1790 LinkAssociationsModuleOnlyWithCast<Df250BORConfig,Df250PulseIntegral>(bors, hit_objs_by_type[
"Df250PulseIntegral"]);
1791 LinkAssociationsModuleOnlyWithCast<Df250BORConfig,Df250PulsePedestal>(bors, hit_objs_by_type[
"Df250PulsePedestal"]);
1792 LinkAssociationsModuleOnlyWithCast<Df250BORConfig,Df250PulseTime>(bors, hit_objs_by_type[
"Df250PulseTime"]);
1793 LinkAssociationsModuleOnlyWithCast<Df250BORConfig,Df250WindowRawData>(bors, hit_objs_by_type[
"Df250WindowRawData"]);
1795 if(bor_obj_name ==
"Df125BORConfig"){
1796 LinkAssociationsModuleOnlyWithCast<Df125BORConfig,Df125CDCPulse>(bors, hit_objs_by_type[
"Df125CDCPulse"]);
1797 LinkAssociationsModuleOnlyWithCast<Df125BORConfig,Df125FDCPulse>(bors, hit_objs_by_type[
"Df125FDCPulse"]);
1798 LinkAssociationsModuleOnlyWithCast<Df125BORConfig,Df125PulseIntegral>(bors, hit_objs_by_type[
"Df125PulseIntegral"]);
1799 LinkAssociationsModuleOnlyWithCast<Df125BORConfig,Df125PulsePedestal>(bors, hit_objs_by_type[
"Df125PulsePedestal"]);
1800 LinkAssociationsModuleOnlyWithCast<Df125BORConfig,Df125PulseTime>(bors, hit_objs_by_type[
"Df125PulseTime"]);
1801 LinkAssociationsModuleOnlyWithCast<Df125BORConfig,Df125WindowRawData>(bors, hit_objs_by_type[
"Df125WindowRawData"]);
1803 if(bor_obj_name ==
"DF1TDCBORConfig"){
1804 LinkAssociationsModuleOnlyWithCast<DF1TDCBORConfig,Df250PulseIntegral>(bors, hit_objs_by_type[
"DF1TDCHit"]);
1806 if(bor_obj_name ==
"DCAEN1290TDCBORConfig"){
1807 LinkAssociationsModuleOnlyWithCast<DCAEN1290TDCBORConfig,Df250PulseIntegral>(bors, hit_objs_by_type[
"DCAEN1290TDCHit"]);
1825 JEventLoop::call_stack_t cs;
1826 cs.caller_name =
"<ignore>";
1830 cs.start_time = 0.0;
1832 cs.data_source = JEventLoop::DATA_FROM_SOURCE;
1833 loop->AddToCallStack(cs);
1847 JEventLoop::call_stack_t cs;
1848 cs.caller_name = caller;
1849 cs.callee_name = callee;
1850 cs.data_source = JEventLoop::DATA_FROM_SOURCE;
1851 loop->AddToCallStack(cs);
1852 cs.callee_name = cs.caller_name;
1853 cs.caller_name =
"<ignore>";
1854 cs.data_source = JEventLoop::DATA_FROM_FACTORY;
1855 loop->AddToCallStack(cs);
1864 if(wrd_objs.size() == 0)
return;
1865 if(
VERBOSE>3)
evioout <<
" Entering EmulateDf250Firmware ..." <<endl;
1867 vector <const Df250EmulatorAlgorithm*> f250Emulator_const;
1869 JEventLoop *loop =
event.GetJEventLoop();
1872 f250EmFac->Get(f250Emulator_const);
1874 if (f250Emulator_const.size() != 0) {
1877 jerr <<
"Unable to load Df250EmulatorAlgorithm ! skipping emulation ..." << endl;
1884 for(
unsigned int i=0; i<wrd_objs.size(); i++){
1893 for(uint32_t j=0; j<pt_objs.size(); j++){
1896 if(pt->
slot == f250WindowRawData->
slot){
1899 f250PulseTime->AddAssociatedObject(f250WindowRawData);
1901 jerr <<
"Emulating channel that already has emulated objects!" << endl;
1902 jerr <<
"This likely means there is a bug in JEventSource_EVIO.cc" <<endl;
1903 jerr <<
"PulseTime: rocid="<<pt->
rocid<<
" slot="<<pt->
slot<<
" channel="<<pt->
channel<<endl;
1904 jerr <<
"please report error to davidl@jlab.org" << endl;
1913 for(uint32_t j=0; j<pp_objs.size(); j++){
1916 if(pp->
slot == f250WindowRawData->
slot){
1918 f250PulsePedestal = pp;
1919 f250PulsePedestal->AddAssociatedObject(f250WindowRawData);
1921 jerr <<
"Emulating channel that already has emulated objects!" << endl;
1922 jerr <<
"This likely means there is a bug in JEventSource_EVIO.cc" <<endl;
1923 jerr <<
"PulsePedestal: rocid="<<pp->
rocid<<
" slot="<<pp->
slot<<
" channel="<<pp->
channel<<endl;
1924 jerr <<
"please report error to davidl@jlab.org" << endl;
1933 for(uint32_t j=0; j<pi_objs.size(); j++){
1936 if(pi->
slot == f250WindowRawData->
slot){
1938 f250PulseIntegral = pi;
1939 f250PulseIntegral->AddAssociatedObject(f250WindowRawData);
1941 jerr <<
"Emulating channel that already has emulated objects!" << endl;
1942 jerr <<
"This likely means there is a bug in JEventSource_EVIO.cc" <<endl;
1943 jerr <<
"PulseIntegral: rocid="<<pi->
rocid<<
" slot="<<pi->
slot<<
" channel="<<pi->
channel<<endl;
1944 jerr <<
"please report error to davidl@jlab.org" << endl;
1953 uint32_t pt_emulated = pt_objs.size();
1954 uint32_t pp_emulated = pp_objs.size();
1955 uint32_t pi_emulated = pi_objs.size();
1957 f250Emulator->
EmulateFirmware(f250WindowRawData, pt_objs, pp_objs, pi_objs);
1960 uint32_t pt_hardware = 0;
1961 for (uint32_t i = pt_emulated; i < pt_objs.size(); i++) {
1964 pt_em->GetSingle(rd);
1965 if (rd != f250WindowRawData) {
1966 jerr <<
"Emulated object found that does not belong to WindowRawData object!" << endl;
1967 jerr <<
"This likely means there is a bug in JEventSource_EVIO.cc PulseTime emulation." << endl;
1968 jerr <<
"rocid=" << pt_em->
rocid <<
" slot=" << pt_em->
slot <<
" channel=" << pt_em->
channel << endl;
1969 jerr <<
"Please report error to davidl@jlab.org" << endl;
1972 for (uint32_t j = pt_hardware; j < pt_emulated; j++) {
1974 pt_hw->GetSingle(rd);
1976 pt_hardware = j + 1;
1990 jout <<
" comparing f250 hw and emulation pulse times for ROC/slot/chan "
1995 pt_objs.erase(pt_objs.begin() + i);
2002 if (pt_em != 0 &&
VERBOSE > 3) {
2003 jout <<
" new f250 emulation PulseTime generated for ROC/slot/chan "
2009 uint32_t pp_hardware = 0;
2010 for (uint32_t i = pp_emulated; i < pp_objs.size(); i++) {
2013 pp_em->GetSingle(rd);
2014 if (rd != f250WindowRawData) {
2015 jerr <<
"Emulated object found that does not belong to WindowRawData object!" << endl;
2016 jerr <<
"This likely means there is a bug in JEventSource_EVIO.cc PulsePedestal emulation." << endl;
2017 jerr <<
"rocid=" << pp_em->
rocid <<
" slot=" << pp_em->
slot <<
" channel=" << pp_em->
channel << endl;
2018 jerr <<
"Please report error to davidl@jlab.org" << endl;
2021 for (uint32_t j=pp_hardware; j < pp_emulated; j++) {
2023 pp_hw->GetSingle(rd);
2025 pp_hardware = j + 1;
2034 jout <<
" comparing f250 hw and emulation pulse peaks for ROC/slot/chan "
2037 pp_objs.erase(pp_objs.begin() + i);
2044 if (pp_em != 0 &&
VERBOSE > 3) {
2045 jout <<
" new f250 emulation PulsePedestal generated for ROC/slot/chan "
2052 uint32_t pi_hardware = 0;
2053 for (uint32_t i = pi_emulated; i < pi_objs.size(); i++) {
2056 pi_em->GetSingle(rd);
2057 if (rd != f250WindowRawData) {
2058 jerr <<
"Emulated object found that does not belong to WindowRawData object!" << endl;
2059 jerr <<
"This likely means there is a bug in JEventSource_EVIO.cc PulseIntegral emulation." << endl;
2060 jerr <<
"rocid=" << pi_em->
rocid <<
" slot=" << pi_em->
slot <<
" channel=" << pi_em->
channel << endl;
2061 jerr <<
"Please report error to davidl@jlab.org" << endl;
2064 for (uint32_t j=pi_hardware; j < pi_emulated; j++) {
2066 pi_hw->GetSingle(rd);
2068 pi_hardware = j + 1;
2077 jout <<
" comparing f250 hw and emulation pulse integrals for ROC/slot/chan "
2080 pi_objs.erase(pi_objs.begin() + i);
2087 if (pi_em != 0 &&
VERBOSE > 3) {
2088 jout <<
" new f250 emulation PulseIntegral generated for ROC/slot/chan "
2091 <<
", pedestal " << pi_em->
pedestal << endl;
2113 if(wrd_objs.size() == 0)
return;
2114 if(
VERBOSE>3)
evioout <<
" Entering EmulateDf125Firmware ..." <<endl;
2116 vector <const Df125EmulatorAlgorithm*> f125Emulator_const;
2118 JEventLoop *loop =
event.GetJEventLoop();
2121 f125EmFac->Get(f125Emulator_const);
2123 if (f125Emulator_const.size() != 0) {
2126 jerr <<
"Unable to load Df125EmulatorAlgorithm ! skipping emulation ..." << endl;
2132 for(
unsigned int i=0; i<wrd_objs.size(); i++){
2138 for(uint32_t j=0; j<cp_objs.size(); j++){
2141 if(cp->
slot == f125WindowRawData->
slot){
2144 f125CDCPulse->AddAssociatedObject(f125WindowRawData);
2152 for(uint32_t j=0; j<fp_objs.size(); j++){
2155 if(fp->
slot == f125WindowRawData->
slot){
2158 f125FDCPulse->AddAssociatedObject(f125WindowRawData);
2173 if(f125CDCPulse == NULL && ( f125WindowRawData->
rocid < 30 ) ){
2175 f125CDCPulse->
rocid = f125WindowRawData->
rocid;
2176 f125CDCPulse->
slot = f125WindowRawData->
slot;
2179 f125CDCPulse->AddAssociatedObject(f125WindowRawData);
2180 cp_objs.push_back(f125CDCPulse);
2183 else if(f125FDCPulse == NULL && ( f125WindowRawData->
rocid > 30 ) ){
2185 f125FDCPulse->
rocid = f125WindowRawData->
rocid;
2186 f125FDCPulse->
slot = f125WindowRawData->
slot;
2189 f125FDCPulse->AddAssociatedObject(f125WindowRawData);
2190 cp_objs.push_back(f125FDCPulse);
2195 if(f125CDCPulse!=NULL) f125CDCPulse->
emulated = 1;
2196 if(f125FDCPulse!=NULL) f125FDCPulse->
emulated = 1;
2200 f125Emulator->
EmulateFirmware(f125WindowRawData, f125CDCPulse, f125FDCPulse);
2209 int32_t JEventSource_EVIO::GetRunNumber(evioDOMTree *evt)
2227 evioDOMNodeListP bankList = evt->getNodeList(typeIs<uint64_t>());
2228 evioDOMNodeList::iterator iter = bankList->begin();
2229 const uint64_t *run_number_and_type = NULL;
2230 for(; iter!=bankList->end(); iter++){
2231 evioDOMNodeP bankPtr = *iter;
2232 evioDOMNodeP physics_event_built_trigger_bank = bankPtr->getParent();
2233 if(physics_event_built_trigger_bank == NULL)
continue;
2234 uint32_t tag = physics_event_built_trigger_bank->tag;
2235 const vector<uint64_t> *vec;
2241 vec = bankPtr->getVector<uint64_t>();
2243 if(vec->size()<1)
continue;
2244 run_number_and_type = &((*vec)[vec->size()-1]);
2247 if(run_number_and_type != NULL)
break;
2250 if(run_number_and_type != NULL)
last_run_number = (*run_number_and_type)>>32;
2267 if(
VERBOSE>1)
evioout <<
" .. Searching for run number ..." <<endl;
2274 uint32_t *iend = &iptr[*iptr - 1];
2275 if(*iptr > 2048) iend = &iptr[2048];
2276 bool has_timestamps =
false;
2281 if( (*iptr & 0xff000f) == 0x600001){
2282 if(
VERBOSE>2)
evioout <<
" Found EPICS header. Looking for HD:coda:daq:run_number ..." << endl;
2283 const char *cptr = (
const char*)&iptr[1];
2284 const char *cend = (
const char*)iend;
2285 const char *needle =
"HD:coda:daq:run_number=";
2288 if(!strncmp(cptr, needle, strlen(needle))){
2297 if( (*iptr & 0xffffffff) == 0x00700E01){
2309 if(run_number != 0){
2310 if(
VERBOSE>1)
evioout <<
" Found run number " << run_number <<
" from Epic Quest." <<endl;
2318 switch((*iptr)>>16){
2327 if(
VERBOSE>2)
evioout <<
" ... Trigger bank tag (0x" << hex << ((*iptr)>>16) << dec <<
") does not contain run number" <<endl;
2329 jout <<
"WARNING: setting run number " <<
filename_run_number <<
" based on file name" << endl;
2335 has_timestamps =
true;
2338 if(
VERBOSE>2)
evioout <<
" ... Trigger bank tag (0x" << hex << ((*iptr)>>16) << dec <<
") does contain run number" <<endl;
2345 if( ((*iptr)&0x00FF0000) != 0x000A0000) { iptr--;
continue; }
2346 uint32_t M = iptr[-3] & 0x000000FF;
2347 if(
VERBOSE>2)
evioout <<
" ... Trigger bank " << (has_timestamps ?
"does":
"doesn't") <<
" have timestamps. Nevents in block M=" << M <<endl;
2349 uint64_t *iptr64 = (uint64_t*)iptr;
2353 if(
VERBOSE>3)
evioout <<
" .... Event num: " << event_num <<endl;
2355 if(has_timestamps) iptr64 = &iptr64[M];
2363 uint64_t run64 = (*iptr64)>>32;
2365 run64 = (*iptr64)&0xffffffff;
2367 int32_t
run = (int32_t)run64;
2376 if(run_number != 0){
2377 if(
VERBOSE>1)
evioout <<
" Found run number " << run_number <<
" from Epic Quest." <<endl;
2383 jout <<
"WARNING: setting run number " <<
filename_run_number <<
" based on file name" << endl;
2412 uint32_t buff_len = 4000000;
2413 uint32_t *buff =
new uint32_t[buff_len];
2415 while(hdevio->
read(buff, buff_len)){
2418 uint32_t *iptr = buff;
2419 uint32_t *iend = &iptr[*iptr - 1];
2420 if(*iptr > 2048) iend = &iptr[2048];
2421 bool has_timestamps =
false;
2426 if( (*iptr & 0xff000f) == 0x600001){
2427 if(
VERBOSE>2)
evioout <<
" Found EPICS header. Looking for HD:coda:daq:run_number ..." << endl;
2428 const char *cptr = (
const char*)&iptr[1];
2429 const char *cend = (
const char*)iend;
2430 const char *needle =
"HD:coda:daq:run_number=";
2433 if(!strncmp(cptr, needle, strlen(needle))){
2435 int32_t run_number = atoi(&cptr[strlen(needle)]);
2436 if(hdevio)
delete hdevio;
2437 if(buff)
delete[] buff;
2445 if( (*iptr & 0xffffffff) == 0x00700E01)
continue;
2448 bool not_in_this_buffer =
false;
2449 switch((*iptr)>>16){
2457 not_in_this_buffer =
true;
2461 has_timestamps =
true;
2469 if(not_in_this_buffer)
break;
2472 if( ((*iptr)&0x00FF0000) != 0x000A0000) { iptr--;
continue; }
2473 uint32_t M = iptr[-3] & 0x000000FF;
2474 if(
VERBOSE>2)
evioout <<
" ...(epic quest) Trigger bank " << (has_timestamps ?
"does":
"doesn't") <<
" have timestamps. Nevents in block M=" << M <<endl;
2476 uint64_t *iptr64 = (uint64_t*)iptr;
2478 uint64_t event_num = *iptr64;
2480 if(
VERBOSE>3)
evioout <<
" ....(epic quest) Event num: " << event_num <<endl;
2482 if(has_timestamps) iptr64 = &iptr64[M];
2490 uint64_t run64 = (*iptr64)>>32;
2492 run64 = (*iptr64)&0xffffffff;
2494 int32_t run = (int32_t)run64;
2495 if(
VERBOSE>1)
evioout <<
" .. (epic quest) Found run number: " << run <<endl;
2497 if(hdevio)
delete hdevio;
2498 if(buff)
delete[] buff;
2503 if(hdevio->
Nevents > 500)
break;
2506 if(hdevio)
delete hdevio;
2507 if(buff)
delete[] buff;
2520 if(
VERBOSE>1)
evioout <<
" .. Searching for event number ..." <<endl;
2523 if(
VERBOSE>1)
evioout <<
" Word count(="<<*iptr<<
")<6. Returning Nevents_read+1(=" << Nevents_read+1 <<
") as event number" <<endl;
2524 return Nevents_read+1;
2528 uint32_t mask = 0xFF202000;
2529 if( (iptr[3]&mask) != mask ){
2531 evioout <<
" iptr[3]=" << hex << iptr[3] <<
" does not look like trigger bank tag (" << (iptr[3]&mask) <<
" != " << mask <<
")" << dec <<endl;
2532 evioout <<
" Returning Nevents_read+1(=" << Nevents_read+1 <<
") as event number" <<endl;
2534 return Nevents_read+1;
2537 uint64_t loevent_num = iptr[5];
2538 uint64_t hievent_num = iptr[6];
2540 loevent_num = iptr[6];
2541 hievent_num = iptr[5];
2543 uint64_t event_num = loevent_num + (hievent_num<<32);
2544 if(
VERBOSE>1)
evioout <<
" .. Found event number: " << event_num <<endl;
2556 uint32_t head = iptr[1];
2557 if( (head & 0xff000f) == 0x600001){
2559 }
else if( (head & 0xffffffff) == 0x00700E01){
2561 }
else if( (head & 0xffffff00) == 0xff501000){
2563 }
else if( (head & 0xffffff00) == 0xff701000){
2565 }
else if( (head & 0xfff000ff) == 0xffd00000){
2579 <<
" &events1=" << hex << &events1 << dec <<
"(" << events1.size() <<
" events) "
2580 <<
" &events2=" << hex << &events2 << dec <<
"(" << events2.size() <<
" events) " << endl;
2602 bool justconfig =
false;
2603 if(events1.size()==1){
2604 ObjList *objs1 = events1.front();
2605 justconfig = objs1->hit_objs.size()==0 && objs1->misc_objs.size()==0 && objs1->config_objs.size()!=0;
2606 }
else if(events2.size()==1){
2607 ObjList *objs2 = events2.front();
2608 justconfig = objs2->hit_objs.size()==0 && objs2->misc_objs.size()==0 && objs2->config_objs.size()!=0;
2612 unsigned int Nevents1 = events1.size();
2613 unsigned int Nevents2 = events2.size();
2614 if(Nevents1>0 && Nevents2>0 && !justconfig){
2615 if(Nevents1 != Nevents2){
2616 evioout <<
"Mismatch of number of events passed to MergeObjLists. Throwing exception." << endl;
2617 evioout <<
"Nevents1="<<Nevents1<<
" Nevents2="<<Nevents2<<endl;
2618 throw JException(
"Number of events in JEventSource_EVIO::MergeObjLists do not match!");
2623 if(Nevents1==0 && Nevents2==0)
return;
2629 if(Nevents2==0)
return;
2632 list<ObjList*>::iterator iter = events1.begin();
2633 for(; iter!=events1.end(); iter++){
2634 if(events2.empty())
break;
2635 ObjList *objs1 = *iter;
2636 ObjList *objs2 = events2.front();
2637 events2.pop_front();
2639 objs1->hit_objs.insert(objs1->hit_objs.end(), objs2->hit_objs.begin(), objs2->hit_objs.end());
2640 objs1->config_objs.insert(objs1->config_objs.end(), objs2->config_objs.begin(), objs2->config_objs.end());
2641 objs1->misc_objs.insert(objs1->misc_objs.end(), objs2->misc_objs.begin(), objs2->misc_objs.end());
2650 if(
VERBOSE>5)
evioout <<
" Leaving MergeObjLists(). &events1=" << hex << &events1 <<
" &events2=" << &events2 << dec << endl;
2656 void JEventSource_EVIO::ParseEVIOEvent(evioDOMTree *evt, list<ObjList*> &full_events)
2658 if(
VERBOSE>5)
evioout <<
" Entering ParseEVIOEvent() with evt=" << hex << evt << dec << endl;
2660 if(!evt)
throw RESOURCE_UNAVAILABLE;
2669 list<ObjList*> tmp_events;
2694 evioDOMNodeListP bankList = evt->getNodeList();
2695 evioDOMNodeList::iterator iter = bankList->begin();
2696 if(
VERBOSE>7)
evioout <<
" Looping over " << bankList->size() <<
" banks in EVIO event" << endl;
2697 for(
int ibank=1; iter!=bankList->end(); iter++, ibank++){
2699 if(
VERBOSE>7)
evioout <<
" -------- bank " << ibank <<
"/" << bankList->size() <<
" --------" << endl;
2712 evioDOMNodeP outermostBankPtr = *iter;
2713 while(outermostBankPtr->getParent()) outermostBankPtr = outermostBankPtr->getParent();
2714 if(outermostBankPtr->tag==0x70 && outermostBankPtr->num==1){
2716 if(
VERBOSE>9)
evioout <<
" bank is part of BOR event ... " << endl;
2717 if(outermostBankPtr == *iter){
2718 if(
VERBOSE>9)
evioout <<
" bank is outermost EVIO bank. Parsing BOR event ..." << endl;
2719 ParseBORevent(outermostBankPtr);
2721 if(
VERBOSE>9)
evioout <<
" bank is not outermost EVIO bankin BOR event skipping ..." << endl;
2727 evioDOMNodeP bankPtr = *iter;
2728 evioDOMNodeP data_bank = bankPtr->getParent();
2729 if( data_bank==NULL ) {
2731 if(
VERBOSE>9)
evioout <<
" bank has no parent. Checking if it's an EPICS event ... " << endl;
2732 if(bankPtr->tag==96 && bankPtr->num==1){
2734 ParseEPICSevent(bankPtr, full_events);
2736 if(
VERBOSE>9)
evioout <<
" Not an EPICS event bank. skipping ... " << endl;
2743 evioDOMNodeP physics_event_bank = data_bank->getParent();
2747 if((physics_event_bank != NULL) && (bankPtr != NULL)){
2748 if( (physics_event_bank->tag == 0xff70) && (bankPtr->tag == 0xEE02)){
2749 const vector<uint32_t> *vec = bankPtr->getVector<uint32_t>();
2750 if(vec->size() < 102){
2751 evioout <<
" TS record for SYNC event is inconsistent. Don't parse " << endl;
2753 ParseTSSync(bankPtr, full_events);
2760 if( physics_event_bank==NULL ){
2761 if(
VERBOSE>6)
evioout <<
" bank has no grandparent. Checking if this is a trigger bank ... " << endl;
2766 if((bankPtr->tag & 0xFF00) == 0xFF00){
2767 if(
VERBOSE>6)
evioout <<
" Bank tag="<<hex<<data_bank->tag<<dec<<
" is in reserved CODA range and has correct lineage. Assuming it's a built trigger bank."<< endl;
2768 ParseBuiltTriggerBank(bankPtr, tmp_events);
2769 if(
VERBOSE>5)
evioout <<
" Merging objects in ParseEVIOEvent" << endl;
2773 }
else if(bankPtr->tag == 0x0056){
2774 const vector<uint32_t> *vec = bankPtr->getVector<uint32_t>();
2776 const uint32_t *iptr = &(*vec)[0];
2777 const uint32_t *iend = &(*vec)[vec->size()];
2779 if(
VERBOSE>5)
evioout <<
" Merging DEventTag objects in ParseEVIOEvent" << endl;
2786 if( physics_event_bank->getParent() != NULL ){
2787 if(
VERBOSE>9)
evioout <<
" bank DOES have great-grandparent. skipping ... " << endl;
2791 evioout <<
" Physics Event Bank: tag=" << hex << physics_event_bank->tag <<
" num=" << (int)physics_event_bank->num << dec << endl;
2792 evioout <<
" Data Bank: tag=" << hex << data_bank->tag <<
" num=" << (
int)data_bank->num << dec << endl;
2795 if(
VERBOSE>9)
evioout <<
" bank lineage check OK. Continuing with parsing ... " << endl;
2798 uint32_t rocid = data_bank->tag & 0x0FFF;
2801 const vector<uint32_t> *vec = bankPtr->getVector<uint32_t>();
2803 if(
VERBOSE>6)
evioout <<
" bank is not uint32_t. Skipping..." << endl;
2806 const uint32_t *iptr = &(*vec)[0];
2807 const uint32_t *iend = &(*vec)[vec->size()];
2808 if(
VERBOSE>6)
evioout <<
" uint32_t bank has " << vec->size() <<
" words" << endl;
2813 if(
VERBOSE>4)
evioout <<
" Skipping parsing of rocid="<<rocid<<
" due to it being in ROCIDS_TO_PARSE set." << endl;
2818 if((data_bank->tag & 0xFF00) == 0xFF00){
2819 if(
VERBOSE>6)
evioout <<
" Data Bank tag="<<hex<<data_bank->tag<<dec<<
" is in reserved CODA range. This is probably not ROC data"<< endl;
2824 if(bankPtr->tag == 0xEE02){
2825 if(
VERBOSE>4)
evioout <<
" TS bank tag="<<hex<<bankPtr->tag<<dec<< endl;
2832 if(bankPtr->tag == 0xEE05){
2833 if(
VERBOSE>6)
evioout <<
" SYNC event - f250 pedestals found " << endl;
2834 ParseFA250AsyncPedestals(bankPtr, full_events, rocid);
2840 if(bankPtr->tag == 0xEE10){
2841 if(
VERBOSE>6)
evioout <<
" SYNC event - f250 scalers found "<< endl;
2842 ParseFA250Scalers(bankPtr, full_events, rocid);
2858 uint32_t NumEvents = data_bank->num & 0xFF;
2860 if(
VERBOSE>9)
evioout <<
" bank has less than 1 event (Data Bank num or \"M\" = 0) skipping ... " << endl;
2879 uint32_t det_id = bankPtr->tag & 0x0FFF;
2881 bool bank_parsed =
true;
2912 jerr<<
"Unknown module type ("<<det_id<<
") encountered for tag="<<bankPtr->tag<<
" num="<< (int)bankPtr->num << endl;
2913 bank_parsed =
false;
2916 cout <<
"----- First few words to help with debugging -----" << endl;
2917 cout.flush(); cerr.flush();
2919 for(
const uint32_t *iiptr = iptr; iiptr<iend; iiptr++, i++){
2920 _DBG_ <<
"0x" << hex << *iiptr << dec << endl;
2929 if(
VERBOSE>5)
evioout <<
" Merging objects in ParseEVIOEvent" << endl;
2953 void JEventSource_EVIO::ParseBuiltTriggerBank(evioDOMNodeP trigbank, list<ObjList*> &events)
2957 if(
VERBOSE>5)
evioout <<
" Entering ParseBuiltTriggerBank()" << endl;
2959 uint32_t Mevents = 1;
2960 uint32_t Nrocs = (uint32_t)trigbank->num;
2961 evioDOMNodeP physics_event_bank = trigbank->getParent();
2962 if(physics_event_bank) Mevents = (uint32_t)physics_event_bank->num;
2964 if(
VERBOSE>6)
evioout <<
" Mevents=" << Mevents <<
" Nrocs=" << Nrocs << endl;
2967 vector<uint64_t> avg_timestamps;
2968 uint32_t run_number = 0;
2969 uint32_t run_type = 0;
2970 uint64_t first_event_num = 1;
2971 vector<uint16_t> event_types;
2972 map<uint32_t, vector<DCODAROCInfo*> > rocinfos;
2976 evioDOMNodeListP bankList = trigbank->getChildren();
2977 evioDOMNodeList::iterator iter = bankList->begin();
2978 for(
int ibank=1; iter!=bankList->end(); iter++, ibank++){
2980 if(
VERBOSE>7)
evioout <<
" Looking for data in child banks ..." << endl;
2982 evioDOMNodeP bankPtr = *iter;
2993 vector<uint64_t> *vec64 = bankPtr->getVector<uint64_t>();
2994 vector<uint32_t> *vec32 = bankPtr->getVector<uint32_t>();
2995 vector<uint16_t> *vec16 = bankPtr->getVector<uint16_t>();
3013 if(vec64->size() == 0)
continue;
3015 first_event_num = (*vec64)[0];
3022 uint32_t Ntimestamps = vec64->size()-1;
3023 if(Ntimestamps==0)
continue;
3024 if(trigbank->tag & 0x2) Ntimestamps--;
3025 for(uint32_t i=0; i<Ntimestamps; i++) avg_timestamps.push_back((*vec64)[i+1]);
3028 if(trigbank->tag & 0x02){
3029 run_number = (*vec64)[vec64->size()-1] >> 32;
3030 run_type = (*vec64)[vec64->size()-1] & 0xFFFFFFFF;
3039 for(uint32_t i=0; i<Mevents; i++){
3040 if(i>=vec16->size())
break;
3041 event_types.push_back((*vec16)[i]);
3051 uint32_t rocid = (uint32_t)bankPtr->tag;
3052 uint32_t Nwords_per_event = vec32->size()/Mevents;
3053 if(vec32->size() != Mevents*Nwords_per_event){
3054 _DBG_ <<
"Number of ROC data words in Trigger Bank inconsistent with header" << endl;
3058 uint32_t *iptr = &(*vec32)[0];
3062 codarocinfo->
rocid = rocid;
3064 uint64_t ts_low = *iptr++;
3065 uint64_t ts_high = *iptr++;
3066 codarocinfo->
timestamp = (ts_high<<32) + ts_low;
3067 for(uint32_t i=2; i<Nwords_per_event; i++) codarocinfo->
misc.push_back(*iptr++);
3069 if(
VERBOSE>7)
evioout <<
" Adding DCODAROCInfo for rocid="<<rocid<<
" with timestamp " << codarocinfo->
timestamp << endl;
3070 rocinfos[
ievent].push_back(codarocinfo);
3076 bool Nevent_mismatch =
false;
3077 if(!avg_timestamps.empty()) Nevent_mismatch |= (avg_timestamps.size() != Mevents);
3078 if(!event_types.empty() ) Nevent_mismatch |= (event_types.size() != Mevents);
3079 if(!rocinfos.empty() ) Nevent_mismatch |= (rocinfos.size() != Mevents);
3080 if(Nevent_mismatch){
3081 _DBG_<<
"Mismatch in number of events in Trigger Bank!"<<endl;
3082 _DBG_<<
" Mevents="<<Mevents<<endl;
3083 _DBG_<<
" avg_timestamps.size()="<<avg_timestamps.size()<<endl;
3084 _DBG_<<
" event_types.size()="<<event_types.size()<<endl;
3085 _DBG_<<
" rocinfos.size()="<<rocinfos.size()<<endl;
3090 for(uint32_t i=0; i<Mevents; i++){
3091 while(events.size()<=i){
3093 events.push_back(
new ObjList);
3095 ObjList *objs = events.back();
3099 codaeventinfo->
run_type = run_type;
3101 codaeventinfo->
event_type = event_types.empty() ? 0:event_types[i];
3102 codaeventinfo->
avg_timestamp = avg_timestamps.empty() ? 0:avg_timestamps[i];
3103 objs->misc_objs.push_back(codaeventinfo);
3106 vector<DCODAROCInfo*> &codarocinfos = rocinfos[i];
3107 for(uint32_t i=0; i<codarocinfos.size(); i++) objs->misc_objs.push_back(codarocinfos[i]);
3110 if(
VERBOSE>6)
evioout <<
" Found "<<events.size()<<
" events in Built Trigger Bank"<< endl;
3111 if(
VERBOSE>5)
evioout <<
" Leaving ParseBuiltTriggerBank()" << endl;
3122 if(
VERBOSE>5)
evioout <<
" Entering ParseModuleConfiguration() (events.size()="<<events.size()<<
")" << endl;
3141 uint32_t slot_mask = (*iptr) & 0xFFFFFF;
3142 uint32_t Nvals = ((*iptr) >> 24) & 0xFF;
3151 for(uint32_t i=0; i< Nvals; i++){
3153 _DBG_ <<
"DAQ Configuration bank corrupt! slot_mask=0x" << hex << slot_mask << dec <<
" Nvals="<< Nvals << endl;
3158 uint16_t val = (*iptr) & 0xFFFF;
3160 if(
VERBOSE>6)
evioout <<
" DAQ parameter of type: 0x" << hex << ptype << dec <<
" found with value: " << val << endl;
3168 if( !f250config ) f250config =
new Df250Config(rocid, slot_mask);
3174 default:
_DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
3180 if( !f125config ) f125config =
new Df125Config(rocid, slot_mask);
3200 default:
_DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
3206 if( !f1tdcconfig ) f1tdcconfig =
new DF1TDCConfig(rocid, slot_mask);
3214 default:
_DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
3220 if( !caen1290tdcconfig ) caen1290tdcconfig =
new DCAEN1290TDCConfig(rocid, slot_mask);
3224 default:
_DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
3229 _DBG_ <<
"Unknown module type: 0x" << hex << (ptype>>8) << endl;
3237 case 0x05:
if(!f250config ) f250config =
new Df250Config(rocid, slot_mask);
break;
3238 case 0x0F:
if(!f125config ) f125config =
new Df125Config(rocid, slot_mask);
break;
3239 case 0x06:
if(!f1tdcconfig ) f1tdcconfig =
new DF1TDCConfig(rocid, slot_mask);
break;
3240 case 0x10:
if(!caen1290tdcconfig) caen1290tdcconfig =
new DCAEN1290TDCConfig(rocid, slot_mask);
break;
3242 _DBG_ <<
"Unknown module type: 0x" << hex << (ptype>>8) << endl;
3283 _DBG_ <<
"UNKNOWN DAQ Config Parameter type: 0x" << hex << ptype << dec << endl;
3293 if(events.empty()) events.push_back(
new ObjList());
3294 ObjList *objs = *(events.begin());
3296 if(f250config ) objs->config_objs.push_back(f250config );
3297 if(f125config ) objs->config_objs.push_back(f125config );
3298 if(f1tdcconfig ) objs->config_objs.push_back(f1tdcconfig );
3299 if(caen1290tdcconfig) objs->config_objs.push_back(caen1290tdcconfig);
3302 if(
VERBOSE>5)
evioout <<
" Leaving ParseModuleConfiguration()" << endl;
3312 if(
VERBOSE>5)
evioout <<
" Entering ParseEventTag() (events.size()="<<events.size()<<
")" << endl;
3316 if(events.empty()) events.push_back(
new ObjList());
3317 ObjList *objs = *(events.begin());
3323 uint64_t lo = *iptr++;
3324 uint64_t hi = *iptr++;
3338 objs->misc_objs.push_back(etag);
3349 if(
VERBOSE>5)
evioout <<
" Entering ParseJLabModuleData()" << endl;
3358 if(
VERBOSE>9)
evioout <<
"Parsing word: " << hex << *iptr << dec << endl;
3361 if(*iptr == 0xF800FAFA){
3362 if(
VERBOSE>9)
evioout <<
" 0xf800fafa is a known extra word. Skipping it ..." << endl;
3368 uint32_t mod_id = ((*iptr) >> 18) & 0x000F;
3384 list<ObjList*> tmp_events;
3385 const uint32_t *istart=iptr;
3386 bool module_parsed =
true;
3406 _DBG_ <<
"What the ? ! This data type isn't supposed to be here!!" << endl;
3415 jerr<<
"Unknown module type ("<<mod_id<<
") iptr=0x" << hex << iptr << dec << endl;
3417 while(iptr<iend && ((*iptr) & 0xF8000000) != 0x88000000) iptr++;
3419 while(iptr<iend && *iptr == 0xF8000000) iptr++;
3420 module_parsed =
false;
3421 jerr<<
"...skipping to 0x" << hex << iptr << dec <<
" (discarding " << (((uint64_t)iptr-(uint64_t)istart)/4) << " words)" << endl;
3425 if(
VERBOSE>9)
evioout << "Finished parsing (last word: " << hex << iptr[-1] << dec << ")" << endl;
3428 if(
VERBOSE>5)
evioout <<
" Merging objects in ParseJLabModuleData" << endl;
3433 if(
VERBOSE>5)
evioout <<
" Leaving ParseJLabModuleData()" << endl;
3448 ObjList *objs = NULL;
3461 uint32_t itrigger = -1;
3462 uint32_t last_itrigger = -2;
3465 for(; iptr<iend; iptr++){
3471 if(((*iptr>>31) & 0x1) == 0)
continue;
3475 uint32_t channel = 0;
3477 uint32_t pulse_number = 0;
3478 uint32_t quality_factor = 0;
3479 uint32_t pulse_time = 0;
3481 uint32_t pulse_peak = 0;
3482 uint32_t nsamples_integral = 0;
3483 uint32_t nsamples_pedestal = 0;
3484 bool overflow =
false;
3486 bool found_block_trailer =
false;
3487 uint32_t data_type = (*iptr>>27) & 0x0F;
3490 slot = (*iptr>>22) & 0x1F;
3491 if(
VERBOSE>7)
evioout <<
" FADC250 Block Header: slot="<<slot<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3498 if(
VERBOSE>7)
evioout <<
" FADC250 Block Trailer"<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3499 found_block_trailer =
true;
3503 itrigger = (*iptr>>0) & 0x3FFFFF;
3504 if(
VERBOSE>7)
evioout <<
" FADC250 Event Header: itrigger="<<itrigger<<
" (objs=0x"<<hex<<objs<<dec<<
", last_itrigger="<<last_itrigger<<
", rocid="<<rocid<<
", slot="<<slot<<
")" <<
" ("<<hex<<*iptr<<dec<<
")" <<endl;
3505 if( (itrigger!=last_itrigger) || (objs==NULL) ){
3508 events.push_back(objs);
3512 if(!objs) objs =
new ObjList;
3513 last_itrigger = itrigger;
3517 t = ((*iptr)&0xFFFFFF)<<0;
3518 if(
VERBOSE>7)
evioout <<
" FADC250 Trigger Time: t="<<t<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3520 if(((*iptr>>31) & 0x1) == 0){
3521 t += ((*iptr)&0xFFFFFF)<<24;
3522 if(
VERBOSE>7)
evioout <<
" Trigger time high word="<<(((*iptr)&0xFFFFFF))<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3526 if(objs) objs->hit_objs.push_back(
new Df250TriggerTime(rocid, slot, itrigger, t));
3530 if(
VERBOSE>7)
evioout <<
" FADC250 Window Raw Data"<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3534 channel = (*iptr>>23) & 0x0F;
3535 sum = (*iptr>>0) & 0x3FFFFF;
3536 overflow = (*iptr>>22) & 0x1;
3537 if(
VERBOSE>7)
evioout <<
" FADC250 Window Sum"<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3538 if(objs) objs->hit_objs.push_back(
new Df250WindowSum(rocid, slot, channel, itrigger, sum, overflow));
3542 if(
VERBOSE>7)
evioout <<
" FADC250 Pulse Raw Data"<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3546 channel = (*iptr>>23) & 0x0F;
3547 pulse_number = (*iptr>>21) & 0x03;
3548 quality_factor = (*iptr>>19) & 0x03;
3549 sum = (*iptr>>0) & 0x7FFFF;
3550 nsamples_integral = 0;
3551 nsamples_pedestal = 1;
3553 if(
VERBOSE>7)
evioout <<
" FADC250 Pulse Integral: chan="<<channel<<
" pulse_number="<<pulse_number<<
" sum="<<sum<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3555 objs->hit_objs.push_back(
new Df250PulseIntegral(rocid, slot, channel, itrigger, pulse_number,
3556 quality_factor, sum, pedestal, nsamples_integral, nsamples_pedestal));
3560 channel = (*iptr>>23) & 0x0F;
3561 pulse_number = (*iptr>>21) & 0x03;
3562 quality_factor = (*iptr>>19) & 0x03;
3563 pulse_time = (*iptr>>0) & 0x7FFFF;
3564 if(
VERBOSE>7)
evioout <<
" FADC250 Pulse Time: chan="<<channel<<
" pulse_number="<<pulse_number<<
" pulse_time="<<pulse_time<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3566 objs->hit_objs.push_back(
new Df250PulseTime(rocid, slot, channel, itrigger, pulse_number, quality_factor, pulse_time));
3572 if(
VERBOSE>7)
evioout <<
" FADC250 Streaming Raw Data (unsupported)"<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3575 channel = (*iptr>>23) & 0x0F;
3576 pulse_number = (*iptr>>21) & 0x03;
3577 pedestal = (*iptr>>12) & 0x1FF;
3578 pulse_peak = (*iptr>>0) & 0xFFF;
3579 if(
VERBOSE>7)
evioout <<
" FADC250 Pulse Pedestal chan="<<channel<<
" pulse_number="<<pulse_number<<
" pedestal="<<pedestal<<
" pulse_peak="<<pulse_peak<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3581 objs->hit_objs.push_back(
new Df250PulsePedestal(rocid, slot, channel, itrigger, pulse_number, pedestal, pulse_peak));
3591 if(
VERBOSE>7)
evioout <<
" FADC250 Event Trailer, Data not Valid, or Filler word ("<<data_type<<
")"<<
" ("<<hex<<*iptr<<dec<<
")"<<endl;
3596 if(found_block_trailer){
3603 for(; iptr<iend; iptr++){
3604 if(((*iptr)&0xf8000000) != 0xf8000000)
break;
3608 if(objs)events.push_back(objs);
3615 list<ObjList*>::iterator iter = events.begin();
3616 for(; iter!=events.end(); iter++){
3619 vector<DDAQAddress*> &hit_objs = (*iter)->hit_objs;
3620 vector<Df250TriggerTime*> vtrigt;
3621 vector<Df250WindowRawData*> vwrd;
3622 vector<Df250WindowSum*> vws;
3623 vector<Df250PulseRawData*> vprd;
3624 vector<Df250PulseIntegral*> vpi;
3625 vector<Df250PulseTime*> vpt;
3626 vector<Df250PulsePedestal*> vpp;
3627 for(
unsigned int i=0; i<hit_objs.size(); i++){
3664 uint32_t channel = (*iptr>>23) & 0x0F;
3665 uint32_t window_width = (*iptr>>0) & 0x0FFF;
3669 for(uint32_t isample=0; isample<window_width; isample +=2){
3675 if(((*iptr>>31) & 0x1) != 0x0){
3680 bool invalid_1 = (*iptr>>29) & 0x1;
3681 bool invalid_2 = (*iptr>>13) & 0x1;
3682 uint16_t sample_1 = 0;
3683 uint16_t sample_2 = 0;
3684 if(!invalid_1)sample_1 = (*iptr>>16) & 0x1FFF;
3685 if(!invalid_2)sample_2 = (*iptr>>0) & 0x1FFF;
3688 wrd->
samples.push_back(sample_1);
3690 wrd->
overflow |= (sample_1>>12) & 0x1;
3692 if((isample+2) == window_width && invalid_2)
break;
3695 wrd->
samples.push_back(sample_2);
3697 wrd->
overflow |= (sample_2>>12) & 0x1;
3706 objs->hit_objs.push_back(wrd);
3717 const uint32_t *istart = iptr;
3718 uint32_t channel = (*iptr>>23) & 0x0F;
3719 uint32_t pulse_number = (*iptr>>21) & 0x0003;
3720 uint32_t first_sample_number = (*iptr>>0) & 0x03FF;
3722 if(
VERBOSE>9)
evioout <<
" DF250PulseRawData: iptr=0x" << hex << iptr << dec <<
" channel=" << channel <<
" pulse_number=" << pulse_number <<
" first_sample=" << first_sample_number << endl;
3727 for(uint32_t isample=0; isample<1000; isample +=2){
3733 if(((*iptr>>31) & 0x1) != 0x0)
break;
3735 bool invalid_1 = (*iptr>>29) & 0x1;
3736 bool invalid_2 = (*iptr>>13) & 0x1;
3737 uint16_t sample_1 = 0;
3738 uint16_t sample_2 = 0;
3739 if(!invalid_1)sample_1 = (*iptr>>16) & 0x1FFF;
3740 if(!invalid_2)sample_2 = (*iptr>>0) & 0x1FFF;
3743 prd->
samples.push_back(sample_1);
3745 prd->
overflow |= (sample_1>>12) & 0x1;
3747 bool last_word = (iptr[1]>>31) & 0x1;
3748 if(last_word && invalid_2)
break;
3751 prd->
samples.push_back(sample_2);
3753 prd->
overflow |= (sample_2>>12) & 0x1;
3756 if(
VERBOSE>9)
evioout <<
" number of samples: " << prd->
samples.size() <<
" words processed: " << iptr-istart << endl;
3771 objs->hit_objs.push_back(prd);
3789 if(
VERBOSE>6)
evioout <<
" Entering Parsef125Bank for rocid=" << rocid <<
"..."<<endl;
3794 ObjList *objs = NULL;
3807 uint32_t itrigger = -1;
3808 uint32_t last_itrigger = -2;
3809 uint32_t last_pulse_time_channel=0;
3810 uint32_t last_slot = -1;
3811 uint32_t last_channel = -1;
3814 for(; iptr<iend; iptr++){
3820 if(((*iptr>>31) & 0x1) == 0)
continue;
3824 uint32_t channel = 0;
3826 uint32_t pulse_number = 0;
3827 uint32_t pulse_time = 0;
3828 uint32_t quality_factor = 0;
3829 uint32_t overflow_count = 0;
3830 uint32_t pedestal = 0;
3831 uint32_t pulse_peak = 0;
3832 uint32_t peak_time = 0;
3833 uint32_t nsamples_integral = 0;
3834 uint32_t nsamples_pedestal = 0;
3838 bool found_block_trailer =
false;
3839 uint32_t data_type = (*iptr>>27) & 0x0F;
3842 slot = (*iptr>>22) & 0x1F;
3843 if(
VERBOSE>7)
evioout <<
" FADC125 Block Header: slot="<<slot<<endl;
3850 found_block_trailer =
true;
3854 itrigger = (*iptr>>0) & 0x3FFFFFF;
3855 if(
VERBOSE>7)
evioout <<
" FADC125 Event Header: itrigger="<<itrigger<<
" (objs=0x"<<hex<<objs<<dec<<
", last_itrigger="<<last_itrigger<<
", rocid="<<rocid<<
", slot="<<slot<<
")" <<endl;
3856 if( (itrigger!=last_itrigger) || (objs==NULL) ){
3859 events.push_back(objs);
3863 if(!objs) objs =
new ObjList;
3864 last_itrigger = itrigger;
3868 t = ((*iptr)&0xFFFFFF)<<24;
3870 if(((*iptr>>31) & 0x1) == 0){
3871 t += ((*iptr)&0xFFFFFF)<<0;
3875 if(
VERBOSE>7)
evioout <<
" FADC125 Trigger Time (t="<<t<<
")"<<endl;
3876 if(objs) objs->hit_objs.push_back(
new Df125TriggerTime(rocid, slot, itrigger, t));
3888 channel = (*iptr>>20) & 0x7F;
3889 pulse_number = (*iptr>>15) & 0x1F;
3890 pulse_time = (*iptr>>4 ) & 0x7FF;
3891 quality_factor = (*iptr>>3 ) & 0x1;
3892 overflow_count = (*iptr>>0 ) & 0x7;
3893 if(
VERBOSE>8)
evioout <<
" FADC125 CDC Pulse Data word1: " << hex << (*iptr) << dec << endl;
3894 if(
VERBOSE>7)
evioout <<
" FADC125 CDC Pulse Data (chan="<<channel<<
" pulse="<<pulse_number<<
" time="<<pulse_time<<
" QF="<<quality_factor<<
" OC="<<overflow_count<<
")"<<endl;
3899 jerr <<
" Truncated f125 CDC hit (block ends before continuation word!)" << endl;
3902 if( ((*iptr>>31) & 0x1) != 0 ){
3903 jerr <<
" Truncated f125 CDC hit (missing continuation word!)" << endl;
3907 pedestal = (*iptr>>23) & 0xFF;
3908 sum = (*iptr>>9 ) & 0x3FFF;
3909 pulse_peak = (*iptr>>0 ) & 0x1FF;
3910 if(
VERBOSE>8)
evioout <<
" FADC125 CDC Pulse Data word2: " << hex << (*iptr) << dec << endl;
3911 if(
VERBOSE>7)
evioout <<
" FADC125 CDC Pulse Data (pedestal="<<pedestal<<
" sum="<<sum<<
" peak="<<pulse_peak<<
")"<<endl;
3914 nsamples_integral = 0;
3915 nsamples_pedestal = 1;
3926 objs->hit_objs.push_back(
new Df125CDCPulse(rocid, slot, channel, itrigger
3951 channel = (*iptr>>20) & 0x7F;
3952 pulse_number = (*iptr>>15) & 0x1F;
3953 pulse_time = (*iptr>>4 ) & 0x7FF;
3954 quality_factor = (*iptr>>3 ) & 0x1;
3955 overflow_count = (*iptr>>0 ) & 0x7;
3956 if(
VERBOSE>8)
evioout <<
" FADC125 FDC Pulse Data(integral) word1: " << hex << (*iptr) << dec << endl;
3957 if(
VERBOSE>7)
evioout <<
" FADC125 FDC Pulse Data (chan="<<channel<<
" pulse="<<pulse_number<<
" time="<<pulse_time<<
" QF="<<quality_factor<<
" OC="<<overflow_count<<
")"<<endl;
3962 jerr <<
" Truncated f125 FDC hit (block ends before continuation word!)" << endl;
3965 if( ((*iptr>>31) & 0x1) != 0 ){
3966 jerr <<
" Truncated f125 FDC hit (missing continuation word!)" << endl;
3971 sum = (*iptr>>19) & 0xFFF;
3972 peak_time = (*iptr>>11) & 0xFF;
3973 pedestal = (*iptr>>0 ) & 0x7FF;
3974 if(
VERBOSE>8)
evioout <<
" FADC125 FDC Pulse Data(integral) word2: " << hex << (*iptr) << dec << endl;
3975 if(
VERBOSE>7)
evioout <<
" FADC125 FDC Pulse Data (integral="<<sum<<
" time="<<peak_time<<
" pedestal="<<pedestal<<
")"<<endl;
3978 nsamples_integral = 0;
3979 nsamples_pedestal = 1;
3990 objs->hit_objs.push_back(
new Df125FDCPulse(rocid, slot, channel, itrigger
4014 channel = (*iptr>>20) & 0x7F;
4015 sum = (*iptr>>0) & 0xFFFFF;
4016 nsamples_integral = 0;
4017 nsamples_pedestal = 1;
4019 if (last_slot == slot && last_channel == channel) pulse_number = 1;
4021 last_channel = channel;
4023 objs->hit_objs.push_back(
new Df125PulseIntegral(rocid, slot, channel, itrigger, pulse_number,
4024 quality_factor, sum, pedestal, nsamples_integral, nsamples_pedestal));
4029 channel = (*iptr>>20) & 0x7F;
4030 pulse_number = (*iptr>>18) & 0x03;
4031 pulse_time = (*iptr>>0) & 0xFFFF;
4033 objs->hit_objs.push_back(
new Df125PulseTime(rocid, slot, channel, itrigger, pulse_number, quality_factor, pulse_time));
4035 last_pulse_time_channel = channel;
4042 channel = (*iptr>>20) & 0x7F;
4043 pulse_number = (*iptr>>15) & 0x1F;
4044 pulse_time = (*iptr>>4 ) & 0x7FF;
4045 quality_factor = (*iptr>>3 ) & 0x1;
4046 overflow_count = (*iptr>>0 ) & 0x7;
4047 if(
VERBOSE>8)
evioout <<
" FADC125 FDC Pulse Data(peak) word1: " << hex << (*iptr) << dec << endl;
4048 if(
VERBOSE>7)
evioout <<
" FADC125 FDC Pulse Data (chan="<<channel<<
" pulse="<<pulse_number<<
" time="<<pulse_time<<
" QF="<<quality_factor<<
" OC="<<overflow_count<<
")"<<endl;
4053 jerr <<
" Truncated f125 FDC hit (block ends before continuation word!)" << endl;
4056 if( ((*iptr>>31) & 0x1) != 0 ){
4057 jerr <<
" Truncated f125 FDC hit (missing continuation word!)" << endl;
4061 pulse_peak = (*iptr>>19) & 0xFFF;
4063 peak_time = (*iptr>>11) & 0xFF;
4064 pedestal = (*iptr>>0 ) & 0x7FF;
4065 if(
VERBOSE>8)
evioout <<
" FADC125 FDC Pulse Data(peak) word2: " << hex << (*iptr) << dec << endl;
4066 if(
VERBOSE>7)
evioout <<
" FADC125 FDC Pulse Data (integral="<<sum<<
" time="<<peak_time<<
" pedestal="<<pedestal<<
")"<<endl;
4069 nsamples_integral = 0;
4070 nsamples_pedestal = 1;
4086 objs->hit_objs.push_back(
new Df125CDCPulse(rocid, slot, channel, itrigger
4103 objs->hit_objs.push_back(
new Df125FDCPulse(rocid, slot, channel, itrigger
4129 channel = last_pulse_time_channel;
4130 pulse_number = (*iptr>>21) & 0x03;
4131 pedestal = (*iptr>>12) & 0x1FF;
4132 pulse_peak = (*iptr>>0) & 0xFFF;
4133 nsamples_pedestal = 1;
4135 objs->hit_objs.push_back(
new Df125PulsePedestal(rocid, slot, channel, itrigger, pulse_number, pedestal, pulse_peak, nsamples_pedestal));
4142 if(
VERBOSE>7)
evioout <<
" FADC125 ignored data type: " << data_type <<endl;
4147 if(found_block_trailer){
4154 for(; iptr<iend; iptr++){
4155 if(((*iptr)&0xf8000000) != 0xf8000000)
break;
4159 if(objs)events.push_back(objs);
4166 list<ObjList*>::iterator iter = events.begin();
4167 for(; iter!=events.end(); iter++){
4170 vector<DDAQAddress*> &hit_objs = (*iter)->hit_objs;
4171 vector<Df125TriggerTime*> vtrigt;
4172 vector<Df125WindowRawData*> vwrd;
4173 vector<Df125PulseRawData*> vprd;
4174 vector<Df125PulseIntegral*> vpi;
4175 vector<Df125PulseTime*> vpt;
4176 vector<Df125PulsePedestal*> vpp;
4177 for(
unsigned int i=0; i<hit_objs.size(); i++){
4210 uint32_t channel = (*iptr>>20) & 0x7F;
4211 uint32_t window_width = (*iptr>>0) & 0x0FFF;
4215 for(uint32_t isample=0; isample<window_width; isample +=2){
4221 if(((*iptr>>31) & 0x1) != 0x0)
break;
4223 bool invalid_1 = (*iptr>>29) & 0x1;
4224 bool invalid_2 = (*iptr>>13) & 0x1;
4225 uint16_t sample_1 = 0;
4226 uint16_t sample_2 = 0;
4227 if(!invalid_1)sample_1 = (*iptr>>16) & 0x1FFF;
4228 if(!invalid_2)sample_2 = (*iptr>>0) & 0x1FFF;
4231 wrd->
samples.push_back(sample_1);
4233 wrd->
overflow |= (sample_1>>12) & 0x1;
4235 if((isample+2) == window_width && invalid_2)
break;
4238 wrd->
samples.push_back(sample_2);
4240 wrd->
overflow |= (sample_2>>12) & 0x1;
4251 objs->hit_objs.push_back(wrd);
4262 uint32_t channel = (*iptr>>23) & 0x0F;
4263 uint32_t pulse_number = (*iptr>>21) & 0x000F;
4264 uint32_t first_sample_number = (*iptr>>0) & 0x03FF;
4269 for(uint32_t isample=0; isample<1000; isample +=2){
4275 if(((*iptr>>31) & 0x1) != 0x0)
break;
4277 bool invalid_1 = (*iptr>>29) & 0x1;
4278 bool invalid_2 = (*iptr>>13) & 0x1;
4279 uint16_t sample_1 = 0;
4280 uint16_t sample_2 = 0;
4281 if(!invalid_1)sample_1 = (*iptr>>16) & 0x1FFF;
4282 if(!invalid_2)sample_2 = (*iptr>>0) & 0x1FFF;
4285 prd->
samples.push_back(sample_1);
4287 prd->
overflow |= (sample_1>>12) & 0x1;
4289 bool last_word = (iptr[1]>>31) & 0x1;
4290 if(last_word && invalid_2)
break;
4293 prd->
samples.push_back(sample_2);
4295 prd->
overflow |= (sample_2>>12) & 0x1;
4305 objs->hit_objs.push_back(prd);
4322 if(
VERBOSE>6)
evioout <<
" Entering ParseF1TDCBank (rocid=" << rocid <<
")" << endl;
4324 const uint32_t *istart = iptr;
4327 if(*iptr == 0xf1daffff) iptr++;
4331 if( ((*iptr) & 0xF8000000) != 0x80000000 ){
4332 throw JException(
"F1TDC Block header corrupt! (high 5 bits not set to 0x80000000!)");
4335 uint32_t slot_block_header = (*iptr)>>22 & 0x001F;
4336 uint32_t block_num = (*iptr)>> 8 & 0x03FF;
4337 uint32_t Nevents_block_header = (*iptr)>> 0 & 0x00FF;
4338 int modtype = (*iptr)>>18 & 0x000F;
4339 if(
VERBOSE>5)
evioout <<
" F1 Block Header: slot=" << slot_block_header <<
" block_num=" << block_num <<
" Nevents=" << Nevents_block_header << endl;
4345 ObjList *objs = NULL;
4350 if( ((*iptr) & 0xF8000000) != 0x90000000 ){
4352 _DBG_<<
"Corrupt F1TDC Event header! Data dump follows (\"*\" indicates bad header word):" <<endl;
4355 throw JException(
"F1TDC Event header corrupt! (high 5 bits not set to 0x90000000!)");
4358 uint32_t slot_event_header = (*iptr)>>22 & 0x00000001F;
4359 uint32_t itrigger = (*iptr)>>0 & 0x0003FFFFF;
4360 if(
VERBOSE>5)
evioout <<
" F1 Event Header: slot=" << slot_block_header <<
" itrigger=" << itrigger << endl;
4363 if(slot_event_header != slot_block_header){
4365 sprintf(str,
"F1TDC slot from event header(%d) doesn't match block header(%d)", slot_event_header, slot_block_header);
4366 throw JException(str);
4371 if(iptr>=iend)
throw JException(
"F1TDC data corrupt! Block truncated before timestamp word!");
4376 uint32_t trig_time = ((*iptr)&0xFFFFFF);
4377 if(
VERBOSE>6)
evioout <<
" F1 Trigger time: low 24 bits=" << trig_time << endl;
4379 if(iptr>=iend)
throw JException(
"F1TDC data corrupt! Block truncated before trailer word!");
4380 if(((*iptr>>31) & 0x1) == 0){
4381 trig_time += ((*iptr)&0xFFFF)<<24;
4382 if(
VERBOSE>6)
evioout <<
" F1 Trigger time: high 16 bits=" << ((*iptr)&0xFFFF) <<
" total trig_time=" << trig_time << endl;
4389 events.push_back(objs);
4392 if(!objs) objs =
new ObjList;
4394 if(objs) objs->hit_objs.push_back(
new DF1TDCTriggerTime(rocid, slot_block_header, itrigger, trig_time));
4400 uint32_t chip_f1header=0, chan_on_chip_f1header=0, itrigger_f1header=0, trig_time_f1header=0;
4401 while( iptr<iend && ((*iptr)>>31)==0x1 ){
4405 uint32_t chip, chan_on_chip, time;
4408 switch( (*iptr) & 0xF8000000 ){
4410 chip_f1header = ((*iptr)>> 3) & 0x07;
4411 chan_on_chip_f1header = ((*iptr)>> 0) & 0x07;
4412 itrigger_f1header = ((*iptr)>>16) & 0x3F;
4413 trig_time_f1header = ((*iptr)>> 7) & 0x1FF;
4414 if(
VERBOSE>5)
evioout <<
" Found F1 header: chip=" << chip_f1header <<
" chan=" << chan_on_chip_f1header <<
" itrig=" << itrigger_f1header <<
" trig_time=" << trig_time_f1header << endl;
4418 chip = (*iptr>>19) & 0x07;
4419 chan_on_chip = (*iptr>>16) & 0x07;
4420 time = (*iptr>> 0) & 0xFFFF;
4421 if(
VERBOSE>5)
evioout <<
" Found F1 data : chip=" << chip <<
" chan=" << chan_on_chip <<
" time=" << time <<
" (header: chip=" << chip_f1header <<
")" << endl;
4424 hit =
new DF1TDCHit(rocid, slot_block_header, channel, itrigger, trig_time_f1header, time, *iptr,
MODULE_TYPE(modtype));
4425 if(objs)objs->hit_objs.push_back(hit);
4435 if(
VERBOSE>5)
evioout <<
" Found F1 break word: 0x" << hex << *iptr << dec << endl;
4440 cout.flush(); cerr.flush();
4441 _DBG_<<
"Unknown data word in F1TDC block. Dumping for debugging:" << endl;
4442 for(
const uint32_t *iiptr = istart; iiptr<iend; iiptr++){
4443 _DBG_<<
"0x"<<hex<<*iiptr<<dec;
4444 if(iiptr == iptr)cerr<<
" <----";
4445 switch( (*iiptr) & 0xF8000000 ){
4446 case 0x80000000: cerr <<
" F1 Block Header";
break;
4447 case 0x90000000: cerr <<
" F1 Event Header";
break;
4448 case 0x98000000: cerr <<
" F1 Trigger time";
break;
4449 case 0xC0000000: cerr <<
" F1 Header";
break;
4450 case 0xB8000000: cerr <<
" F1 Data";
break;
4451 case 0x88000000: cerr <<
" F1 Block Trailer";
break;
4452 case 0xF8000000: cerr <<
" Filler word";
break;
4453 case 0xF0000000: cerr <<
" <module has no valid data>";
break;
4457 if(iiptr > (iptr+4))
break;
4460 throw JException(
"Unexpected word type in F1TDC block!");
4471 if( ((*iptr) & 0xF8000000) == 0x88000000)
break;
4476 if(objs)events.push_back(objs);
4478 if( ((*iptr) & 0xF8000000) != 0x88000000 ){
4479 throw JException(
"F1TDC Block Trailer corrupt! (high 5 bits not set to 0x88000000!)");
4486 while(iptr<iend && (*iptr&0xF8000000)==0xF8000000)iptr++;
4490 if(events.size() != Nevents_block_header){
4492 ss <<
"F1TDC missing events in block! (found "<< events.size() <<
" but should have found "<<Nevents_block_header<<
")";
4494 throw JException(ss.str());
4497 if(
VERBOSE>6)
evioout <<
" Leaving ParseF1TDCBank (rocid=" << rocid <<
")" << endl;
4510 uint32_t channel_map[8] = {0, 0, 1, 1, 2, 2, 3, 3};
4513 return (4 * chip) + channel_map[ chan_on_chip&0x7 ];
4515 return (chip <<3) | chan_on_chip;
4518 throw JException(
"F1TDC_channel called for non-F1TDC module type");
4532 uint32_t Nwords = ((uint64_t)iend - (uint64_t)iptr)/
sizeof(uint32_t);
4533 uint32_t Nwords_expected = (6+32+16+32+16);
4534 if(Nwords != Nwords_expected){
4535 _DBG_ <<
"TS bank size does not match expected!!" << endl;
4536 _DBG_ <<
"Found " << Nwords <<
" words. Expected " << Nwords_expected << endl;
4546 for(uint32_t i=0; i<32; i++) s->
gtp_scalers[i] = *iptr++;
4547 for(uint32_t i=0; i<16; i++) s->
fp_scalers[i] = *iptr++;
4548 for(uint32_t i=0; i<32; i++) s->
gtp_rate[i] = *iptr++;
4549 for(uint32_t i=0; i<16; i++) s->
fp_rate[i] = *iptr++;
4551 if(events.empty()) events.push_back(
new ObjList);
4552 ObjList *objs = *(events.begin());
4553 objs->misc_objs.push_back(s);
4564 while(iptr<iend && ((*iptr) & 0xF8000000) != 0x88000000) iptr++;
4566 while(iptr<iend && *iptr == 0xF8000000) iptr++;
4582 uint32_t word_count = 0;
4583 uint32_t trigger_time_tag = 0;
4584 uint32_t tdc_num = 0;
4585 uint32_t event_id = 0;
4586 uint32_t bunch_id = 0;
4599 map<uint32_t, vector<DCAEN1290TDCHit*> > hits_by_event_id;
4600 vector<uint32_t> event_id_order;
4606 if(*iptr == 0xd00dd00d) {
4607 if(
VERBOSE>7)
evioout <<
" CAEN skipping 0xd00dd00d word" << endl;
4612 uint32_t type = (*iptr) >> 27;
4614 uint32_t channel = 0;
4616 uint32_t error_flags = 0;
4618 map<uint32_t, ObjList*>::iterator iter;
4621 slot = (*iptr) & 0x1f;
4622 event_count = ((*iptr)>>5) & 0xffffff;
4623 if(
VERBOSE>7)
evioout <<
" CAEN TDC Global Header (slot=" << slot <<
" , event count=" << event_count <<
")" << endl;
4626 slot = (*iptr) & 0x1f;
4627 word_count = ((*iptr)>>5) & 0x7ffff;
4628 if(
VERBOSE>7)
evioout <<
" CAEN TDC Global Trailer (slot=" << slot <<
" , word count=" << word_count <<
")" << endl;
4629 slot = event_count = word_count = trigger_time_tag = tdc_num = event_id = bunch_id = 0;
4632 trigger_time_tag = ((*iptr)>>5) & 0x7ffffff;
4633 if(
VERBOSE>7)
evioout <<
" CAEN TDC Global Trigger Time Tag (tag=" << trigger_time_tag <<
")" << endl;
4636 tdc_num = ((*iptr)>>24) & 0x03;
4637 event_id = ((*iptr)>>12) & 0x0fff;
4638 bunch_id = (*iptr) & 0x0fff;
4639 if( find(event_id_order.begin(), event_id_order.end(), event_id) == event_id_order.end()){
4640 event_id_order.push_back(event_id);
4642 if(
VERBOSE>7)
evioout <<
" CAEN TDC TDC Header (tdc=" << tdc_num <<
" , event id=" << event_id <<
" , bunch id=" << bunch_id <<
")" << endl;
4645 edge = ((*iptr)>>26) & 0x01;
4646 channel = ((*iptr)>>21) & 0x1f;
4647 tdc = ((*iptr)>>0) & 0x1fffff;
4648 if(
VERBOSE>7)
evioout <<
" CAEN TDC TDC Measurement (" << (edge ?
"trailing":
"leading") <<
" , channel=" << channel <<
" , tdc=" << tdc <<
")" << endl;
4651 caen1290tdchit =
new DCAEN1290TDCHit(rocid, slot, channel, 0, edge, tdc_num, event_id, bunch_id, tdc);
4652 hits_by_event_id[event_id].push_back(caen1290tdchit);
4655 error_flags = (*iptr) & 0x7fff;
4656 if(
VERBOSE>7)
evioout <<
" CAEN TDC TDC Error (err flags=0x" << hex << error_flags << dec <<
")" << endl;
4659 tdc_num = ((*iptr)>>24) & 0x03;
4660 event_id = ((*iptr)>>12) & 0x0fff;
4661 word_count = ((*iptr)>>0) & 0x0fff;
4662 if(
VERBOSE>7)
evioout <<
" CAEN TDC TDC Trailer (tdc=" << tdc_num <<
" , event id=" << event_id <<
" , word count=" << word_count <<
")" << endl;
4663 tdc_num = event_id = bunch_id = 0;
4669 evioout <<
"Unknown datatype: 0x" << hex << type <<
" full word: "<< *iptr << dec << endl;
4677 if(
VERBOSE>2)
evioout <<
" Disentangling disabled. Merging all hits into single event" << endl;
4678 vector<DCAEN1290TDCHit*> &hits1 = hits_by_event_id[event_id_order[0]];
4679 for(uint32_t i=1; i<event_id_order.size(); i++){
4680 vector<DCAEN1290TDCHit*> &hits2 = hits_by_event_id[event_id_order[i]];
4681 hits1.insert(hits1.end(), hits2.begin(), hits2.end());
4682 hits_by_event_id.erase(event_id_order[i]);
4687 for(uint32_t i=0; i<event_id_order.size(); i++){
4690 while(events.size() <= i) events.push_back(
new ObjList);
4691 list<ObjList*>::iterator it = events.begin();
4693 ObjList *objs = *it;
4695 vector<DCAEN1290TDCHit*> &hits = hits_by_event_id[event_id_order[i]];
4696 objs->hit_objs.insert(objs->hit_objs.end(), hits.begin(), hits.end());
4698 if(
VERBOSE>7)
evioout <<
" Added " << hits.size() <<
" hits with event_id=" << event_id_order[i] <<
" to event " << i << endl;
4707 void JEventSource_EVIO::ParseBORevent(evioDOMNodeP bankPtr)
4720 evioDOMNodeListP bankList = bankPtr->getChildren();
4721 evioDOMNodeList::iterator iter = bankList->begin();
4722 if(
VERBOSE>7)
evioout <<
" Looping over " << bankList->size() <<
" banks in BOR event" << endl;
4723 for(
int ibank=1; iter!=bankList->end(); iter++, ibank++){
4724 evioDOMNodeP childBank = *iter;
4726 if(childBank->tag==0x71){
4728 evioDOMNodeListP bankList = childBank->getChildren();
4729 evioDOMNodeList::iterator iter = bankList->begin();
4730 for(; iter!=bankList->end(); iter++){
4731 evioDOMNodeP dataBank = *iter;
4733 uint32_t modType = dataBank->tag&0x1f;
4735 const vector<uint32_t> *vec = dataBank->getVector<uint32_t>();
4737 const uint32_t *src = &(*vec)[0];
4738 uint32_t *dest = NULL;
4739 uint32_t sizeof_dest = 0;
4749 dest = (uint32_t*)&f250conf->
rocid;
4750 sizeof_dest =
sizeof(f250config);
4754 dest = (uint32_t*)&f125conf->
rocid;
4755 sizeof_dest =
sizeof(f125config);
4761 dest = (uint32_t*)&F1TDCconf->
rocid;
4768 dest = (uint32_t*)&caen1190conf->
rocid;
4777 if( vec->size() == (sizeof_dest/
sizeof(uint32_t)) ){
4780 for(uint32_t i=0; i<vec->size(); i++) *dest++ = *src++;
4783 if(f250conf)
BORobjs.push_back(f250conf);
4784 if(f125conf)
BORobjs.push_back(f125conf);
4785 if(F1TDCconf)
BORobjs.push_back(F1TDCconf);
4786 if(caen1190conf)
BORobjs.push_back(caen1190conf);
4788 }
else if(sizeof_dest>0){
4789 if(f250conf)
delete f250conf;
4790 _DBG_ <<
"BOR bank size does not match structure! " << vec->size() <<
" != " << (sizeof_dest/
sizeof(uint32_t)) << endl;
4791 _DBG_ <<
"sizeof(f250config)="<<
sizeof(f250config)<<endl;
4792 _DBG_ <<
"sizeof(f125config)="<<
sizeof(f125config)<<endl;
4811 void JEventSource_EVIO::ParseFA250Scalers(evioDOMNodeP bankPtr, list<ObjList*> &events, uint32_t rocid){
4813 const vector<uint32_t> *vec = bankPtr->getVector<uint32_t>();
4815 if(vec->size() > 0){
4818 sc->
nsync = (*vec)[0];
4824 for(uint32_t ii = 3; ii < vec->size(); ii++){
4825 sc->
fa250_sc.push_back((*vec)[ii]);
4829 events.push_back(
new ObjList());
4832 ObjList *objs = *(events.begin());
4834 objs->misc_objs.push_back(sc);
4836 evioout <<
" SYNC event: inconsistent format for FA250Scalers. Don't parse " << endl;
4847 void JEventSource_EVIO::ParseFA250AsyncPedestals(evioDOMNodeP bankPtr, list<ObjList*> &events, uint32_t rocid){
4850 const vector<uint32_t> *vec = bankPtr->getVector<uint32_t>();
4852 if(vec->size() > 0){
4856 ped->
nsync = (*vec)[0];
4861 for(uint32_t ii = 2; ii < vec->size(); ii++){
4866 events.push_back(
new ObjList());
4869 ObjList *objs = *(events.begin());
4871 objs->misc_objs.push_back(ped);
4873 evioout <<
" SYNC event: inconsistent format for FA250AsyncPedestals. Don't parse " << endl;
4882 void JEventSource_EVIO::ParseTSSync(evioDOMNodeP bankPtr, list<ObjList*> &events)
4889 if((bankPtr->tag & 0xFFFF) == 0xEE02){
4890 const vector<uint32_t> *vec = bankPtr->getVector<uint32_t>();
4894 trig_info->
nsync = (*vec)[0];
4904 for(uint32_t ii = 6; ii < 38; ii++){
4905 trig_info->
gtp_sc.push_back((*vec)[ii]);
4909 for(uint32_t ii = 38; ii < 54; ii++){
4910 trig_info->
fp_sc.push_back((*vec)[ii]);
4914 for(uint32_t ii = 54; ii < 86; ii++){
4915 trig_info->
gtp_rate.push_back((*vec)[ii]);
4919 for(uint32_t ii = 86; ii < 102; ii++){
4920 trig_info->
fp_rate.push_back((*vec)[ii]);
4926 events.push_back(
new ObjList());
4930 ObjList *objs = *(events.begin());
4932 objs->misc_objs.push_back(trig_info);
4940 void JEventSource_EVIO::ParseDVertexBank(evioDOMNodeP bankPtr, list<ObjList*> &events)
4942 const vector<uint32_t> *vec = bankPtr->getVector<uint32_t>();
4944 if(vec->size() != 11) {
4948 uint64_t lo_word = (*vec)[0];
4949 uint64_t hi_word = (*vec)[1];
4950 double vertex_x_pos =
static_cast<double>( lo_word | (hi_word<<32) );
4951 lo_word = (*vec)[2];
4952 hi_word = (*vec)[3];
4953 double vertex_y_pos =
static_cast<double>( lo_word | (hi_word<<32) );
4954 lo_word = (*vec)[4];
4955 hi_word = (*vec)[5];
4956 double vertex_z_pos =
static_cast<double>( lo_word | (hi_word<<32) );
4957 lo_word = (*vec)[6];
4958 hi_word = (*vec)[7];
4959 double vertex_t =
static_cast<double>( lo_word | (hi_word<<32) );
4961 DVector3 vertex_position(vertex_x_pos, vertex_y_pos, vertex_z_pos);
4965 lo_word = (*vec)[9];
4966 hi_word = (*vec)[10];
4967 the_vertex->
dKinFitChiSq =
static_cast<double>( lo_word | (hi_word<<32) );
4969 if(events.empty()) {
4970 events.push_back(
new ObjList());
4973 ObjList *objs = *(events.begin());
4975 objs->misc_objs.push_back(the_vertex);
4978 evioout <<
" DVertex bank: inconsistent bank format. Don't parse " << endl;
4987 void JEventSource_EVIO::ParseEPICSevent(evioDOMNodeP bankPtr, list<ObjList*> &events)
4993 ObjList *objs = NULL;
4995 evioDOMNodeListP bankList = bankPtr->getChildren();
4996 evioDOMNodeList::iterator iter = bankList->begin();
4997 if(
VERBOSE>7)
evioout <<
" Looping over " << bankList->size() <<
" banks in EPICS event" << endl;
4998 for(
int ibank=1; iter!=bankList->end(); iter++, ibank++){
4999 evioDOMNodeP childBank = *iter;
5001 if(childBank->tag == 97){
5003 const vector<uint32_t> *vec = childBank->getVector<uint32_t>();
5005 timestamp = (time_t)(*vec)[0];
5008 }
else if(childBank->tag==98){
5009 const vector<uint8_t> *vec = childBank->getVector<uint8_t>();
5011 string nameval = (
const char*)&((*vec)[0]);
5016 if(events.empty()) events.push_back(
new ObjList);
5017 objs = *(events.begin());
5019 objs->misc_objs.push_back(epicsval);
5038 cout <<
"Dumping binary: istart=" << hex << iptr <<
" iend=" << iend <<
" MaxWords=" << dec << MaxWords << endl;
5040 if(iend==NULL && MaxWords==0) MaxWords=1;
5041 if(MaxWords==0) MaxWords = (uint32_t)0xffffffff;
5044 while(iptr!=iend && Nwords<MaxWords){
5047 stringstream line1, line2;
5052 line1 << setw(5) << Nwords;
5056 for(uint32_t i=0; i<
Ncols; i++, iptr++, Nwords++){
5058 if(iptr == iend)
break;
5059 if(Nwords>=MaxWords)
break;
5061 stringstream iptr_hex;
5062 iptr_hex << hex <<
"0x" << *iptr;
5064 string mark = (iptr==imark ?
"*":
" ");
5066 line1 << setw(12) << iptr_hex.str() << mark;
5067 line2 << setw(12) << *iptr << mark;
5070 cout << line1.str() << endl;
5071 cout << line2.str() << endl;
5088 if(IsF125ADC(istart, iend))
return DModuleType::F125ADC;
5089 if(
IsF1TDC(istart, iend))
return DModuleType::F1TDC;
5091 if(IsTI(istart, iend))
return DModuleType::JLAB_TID;
5101 bool JEventSource_EVIO::IsFADC250(
const uint32_t *istart,
const uint32_t *iend)
5109 if(((*istart>>31) & 0x1) == 1){
5110 uint32_t data_type = (*istart>>27) & 0x0F;
5112 uint32_t slot_header = (*istart>>22) & 0x1F;
5113 uint32_t Nwords = 1;
5114 for(
const uint32_t *iptr=istart; iptr<iend; iptr++, Nwords++){
5115 if(((*iptr>>31) & 0x1) == 1){
5116 uint32_t data_type = (*iptr>>27) & 0x0F;
5118 uint32_t slot_trailer = (*iptr>>22) & 0x1F;
5119 uint32_t Nwords_trailer = (*iptr>>0) & 0x3FFFFF;
5121 if( slot_header == slot_trailer && Nwords == Nwords_trailer ){
5145 uint32_t slot_header = 1000;
5146 uint32_t slot_trailer = 1000;
5148 const uint32_t *iptr=istart;
5151 if(*istart == 0xf1daffff)iptr++
5156 bool looking_for_header =
true;
5162 for(; iptr<iend; iptr++){
5165 if(*iptr == 0xda0000ff)
break;
5167 uint32_t slot = (*iptr>>27) & 0x1F;
5170 if(slot == 30 || slot ==0)
continue;
5172 if(((*iptr>>23) & 0x1) == 0){
5174 if(looking_for_header){
5176 looking_for_header =
false;
5178 slot_trailer = slot;
5179 if(slot_trailer != slot_header)
return false;
5180 looking_for_header =
true;
5193 if(looking_for_header)
return Nvalid>0;
5197 if(slot != slot_header)
return false;
5210 string fname =
"module_map.txt";
5211 ofstream ofs(fname.c_str());
5213 jerr<<
"Unable to open file \""<<fname<<
"\" for writing!"<<endl;
5217 jout<<
"Writing module map to file \""<<fname<<
"\""<<endl;
5220 time_t now = time(NULL);
5221 ofs<<
"# Autogenerated module map"<<endl;
5222 ofs<<
"# Created: "<<ctime(&now);
5226 vector<DModuleType> modules;
5228 ofs<<
"# Known module types:"<<endl;
5229 ofs<<
"# ----------------------"<<endl;
5230 for(
unsigned int i=0; i<modules.size(); i++){
5231 string name = modules[i].GetName();
5232 string space(12-name.size(),
' ');
5233 ofs <<
"# " << name << space <<
" - " << modules[i].GetDescription() <<endl;
5239 ofs<<
"# Format is:"<<endl;
5240 ofs<<
"# tag num type"<<endl;
5243 map<tagNum, MODULE_TYPE>::iterator iter =
module_type.begin();
5246 tagNum tag_num = iter->first;
string MODTYPE_MAP_FILENAME
void Parsef125Bank(int32_t rocid, const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
uint32_t pedestal_emulated
Calculated from raw data (when available)
uint32_t nsamples_integral
number of samples used in integral
EVIOSourceType source_type
void FreeEvent(jana::JEvent &event)
EmulationModeType F125_EMULATION_MODE
F125 emulation mode.
uint32_t nsamples_pedestal
number of samples used in pedestal
uint32_t pedestal
from Pulse Integral Data word (future)
map< tagNum, MODULE_TYPE > module_type
map< MODULE_TYPE, MODULE_TYPE > modtype_translate
if(locHist_BCALShowerPhiVsZ!=NULL)
EmulationModeType F250_EMULATION_MODE
F250 emulation mode.
L3_decision_t
The DL3Trigger object is used to tell the level-3 trigger process whether or not to discard the event...
pthread_mutex_t current_event_count_mutex
uint32_t L3_algorithm
L3 algorithm identifier when event was written.
This class is a base class used for classes that hold DAQ module configuration parameters. A subclass for each type of digitization module exists that has the attributes appropriate for that type of module. (See Df250Config, DF1TDCConfig, ...) This class only holds the rocid and slot_mask fields which are common to all configurations. One of the main purposes of this base class is to allow configuration objects for all module types to be stored in a single container used internally by the DAQ plugin.
void LinkAssociationsWithPulseNumber(vector< T * > &a, vector< U * > &b)
virtual void EmulateFirmware(const Df250WindowRawData *wrd, std::vector< Df250PulseTime * > &pt_objs, std::vector< Df250PulsePedestal * > &pp_objs, std::vector< Df250PulseIntegral * > &pi_objs)=0
int32_t EpicQuestForRunNumber(void)
bool ENABLE_DISENTANGLING
pthread_rwlock_t BOR_lock
uint32_t pulse_number
from Pulse Pedestal Data word
jerror_t GetObjects(jana::JEvent &event, jana::JFactory_base *factory)
void MakeDf125PulseRawData(ObjList *objs, uint32_t rocid, uint32_t slot, uint32_t itrigger, const uint32_t *&iptr)
uint32_t nsamples
number of samples used in pedestal
void ParseTIBank(int32_t rocid, const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
void MakeDf250PulseRawData(ObjList *objs, uint32_t rocid, uint32_t slot, uint32_t itrigger, const uint32_t *&iptr)
bool emulated
true if made from Window Raw Data
DModuleType::type_id_t MODULE_TYPE
sprintf(text,"Post KinFit Cut")
void FindEventType(uint32_t *iptr, JEvent &event)
vector< uint32_t > fa250_sc
uint32_t USER_RUN_NUMBER
Run number supplied by user.
void Parsef250Bank(int32_t rocid, const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
bool emulated
true if made from Window Raw Data
vector< JObject * > BORobjs
void ParseJLabModuleData(int32_t rocid, const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
uint64_t FindEventNumber(uint32_t *iptr)
JEventSource_EVIO(const char *source_name)
jerror_t GetEvent(jana::JEvent &event)
uint32_t pulse_number
from Pulse Time Data word
pthread_mutex_t evio_buffer_pool_mutex
static bool WARN_USER_RUN_FILENAME
static void GetModuleList(std::vector< DModuleType > &modules)
Get a list of all module types currently defined. This will append the full list to the given "module...
bool no_more_events_in_source
uint32_t nsamples_integral
number of samples used in integral
void CopyBOR(JEventLoop *loop, map< string, vector< JObject * > > &hit_objs_by_type)
bool overflow
true if any sample's "overflow" bit set
int ET_DEBUG_WORDS_TO_DUMP
virtual void EmulateFirmware(const Df125WindowRawData *, Df125CDCPulse *, Df125FDCPulse *)=0
vector< uint16_t > samples
TLorentzVector DLorentzVector
bool readSparse(uint32_t *user_buff, uint32_t user_buff_len, bool allow_swap=true)
uint32_t pulse_peak
from Pulse Pedestal Data word
bool quit_on_next_ET_timeout
void DumpBinary(const uint32_t *iptr, const uint32_t *iend=NULL, uint32_t MaxWords=0, const uint32_t *imark=NULL)
uint32_t current_event_count
void ParseTSBank(int32_t rocid, const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
void MakeDf125WindowRawData(ObjList *objs, uint32_t rocid, uint32_t slot, uint32_t itrigger, const uint32_t *&iptr)
bool emulated
true if made from Window Raw Data
uint32_t le_time
from first word
DL3Trigger::L3_decision_t L3_decision
L3 decision when event was written.
void ParseModuleConfiguration(int32_t rocid, const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
void LinkAssociations(vector< T * > &a, vector< U * > &b)
void LinkAssociationsModuleOnly(vector< T * > &a, vector< U * > &b)
uint32_t F125PULSE_NUMBER_FILTER
Discard DF125PulseXXX objects with pulse number equal or greater than this.
bool emulated
true if made from Window Raw Data
vector< uint16_t > samples
from Pulse Raw Data Data words 2-N (each word contains 2 samples)
void ConnectToET(const char *source_name)
uint32_t SetEventMask(uint32_t mask)
uint64_t event_status
JANA event status word when event was written.
uint32_t le_time
from first word
uint32_t quality_factor_emulated
Calculated from raw data if available.
int32_t filename_run_number
bool read(uint32_t *user_buff, uint32_t user_buff_len, bool allow_swap=true)
bool overflow
true if any sample's "overflow" bit set
uint64_t L3_status
L3 status word when event was written.
pthread_mutex_t stored_events_mutex
static DModuleType GetModule(type_id_t id)
Given the type_id of a module type, return a DModuleType object. This is much more efficient than Get...
vector< uint16_t > samples
set< string > event_source_data_types
bool IsF1TDC(const uint32_t *istart, const uint32_t *iend)
uint32_t F1TDC_channel(uint32_t chip, uint32_t chan_on_chip, int modtype)
void AddEmulatedObjectsToCallStack(JEventLoop *loop, string caller, string callee)
void ParseEventTag(const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
uint32_t pulse_number
from Pulse Integral Data word
uint32_t pedestal
from Pulse Pedestal Data word
DLorentzVector dSpacetimeVertex
bool emulated
true if emulated values are copied to the main input
bool AUTODETECT_MODULE_TYPES
void ParseF1TDCBank(int32_t rocid, const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
void PrintFileSummary(void)
virtual const char * className(void)
MODULE_TYPE GuessModuleType(const uint32_t *istart, const uint32_t *iend)
deque< uint32_t * > evio_buffer_pool
This class holds the Crate, Slot, Channel address for a digitized value from the DAQ system...
uint32_t time
from Pulse Time Data word
virtual ~JEventSource_EVIO()
uint32_t time_emulated
Calculated from raw data if available.
uint32_t integral_emulated
Value calculated from raw data (if available)
bool emulated
true if made from Window Raw Data
uint32_t integral
from Pulse Integral Data word
void EmulateDf250Firmware(JEvent &event, vector< JObject * > &wrd_objs, vector< JObject * > &pt_objs, vector< JObject * > &pp_objs, vector< JObject * > &pi_objs)
vector< uint32_t > gtp_sc
string GetName(void) const
void AddSourceObjectsToCallStack(JEventLoop *loop, string className)
uint32_t pedestal
from Pulse Integral Data word (future)
bool invalid_samples
true if any sample's "not valid" bit set
uint32_t pedestal_emulated
Value calculated from raw data (if available)
void ReadOptionalModuleTypeTranslation(void)
uint32_t F250PULSE_NUMBER_FILTER
Discard DF250PulseXXX objects with pulse number equal or greater than this.
void EmulateDf125Firmware(JEvent &event, vector< JObject * > &wrd_objs, vector< JObject * > &cp_objs, vector< JObject * > &fp_objs)
vector< uint32_t > fa250_ped
uint32_t nsamples_integral
number of samples used in pedestal
void MakeDf250WindowRawData(ObjList *objs, uint32_t rocid, uint32_t slot, uint32_t itrigger, const uint32_t *&iptr)
vector< vector< DDAQAddress * > > hit_objs
bool invalid_samples
true if any sample's "not valid" bit set
uint32_t nsamples_integral
number of samples used in pedestal
static void SetStatusBitDescriptions(jana::JApplication *japp)
static TH1I * pedestal[nChan]
uint32_t pulse_peak_emulated
Calculated from raw data (when available)
queue< ObjList * > stored_events
bool ET_STATION_CREATE_BLOCKING
set< uint32_t > ROCIDS_TO_PARSE
uint32_t pedestal
from Pulse Pedestal Data word
int32_t FindRunNumber(uint32_t *iptr)
virtual jerror_t ReadEVIOEvent(uint32_t *&buf)
static string GetName(type_id_t id)
Get the name of a module type based on its id. This can be called without an instance of the class if...
jerror_t ParseEvents(ObjList *objs_ptr)
void MergeObjLists(list< ObjList * > &events1, list< ObjList * > &events2)
vector< uint32_t > fp_rate
uint32_t nsamples_pedestal
number of samples used in pedestal
bool emulated
true if emulated values are copied to the main input
vector< uint16_t > samples
from Pulse Raw Data Data words 2-N (each word contains 2 samples)
uint32_t * GetPoolBuffer(void)
for(auto locVertexInfo:dStepVertexInfos)
vector< uint32_t > gtp_rate
void ParseCAEN1190(int32_t rocid, const uint32_t *&iptr, const uint32_t *iend, list< ObjList * > &events)
void AddIfAppropriate(DDAQAddress *obj, vector< T * > &v)
void CopyContainerElementsWithCast(vector< T * > &a, vector< U * > &b)
A DEPICSvalue object holds information for a single EPICS value read from the data stream...