11 #include <arpa/inet.h>
16 #if defined(__linux__) || defined(__APPLE__)
21 #define madvise(x,y,z)
31 #include <daqFormats.h>
33 #include <SFS/sfs_index.h>
36 #include "daqReader.h"
42 #define madvise(x,y,z)
49 static const char cvs_id_string[] =
"$Id: daqReader.cxx,v 1.74 2023/02/13 14:37:41 tonko Exp $" ;
51 static int evtwait(
int task,
ic_msg *m) ;
52 static int ask(
int desc,
ic_msg *m) ;
54 DATAP *getlegacydatap(
char *mem,
int bytes);
58 static const char *getCommand(
void) ;
64 daqReader::daqReader(
char *mem,
int size)
73 evt_offset_in_file = 0;
85 daqReader::daqReader(
const char *name)
87 struct stat64 stat_buf ;
91 map_flags = MAP_SHARED | MAP_NORESERVE;
98 if(reconnect() < 0) status = EVP_STAT_CRIT;
108 if(stat64(fname, &stat_buf) < 0) {
109 LOG(CRIT,
"Can't stat \"%s\" [%s]",fname,strerror(errno),0,0,0);
110 status = EVP_STAT_CRIT;
115 LOG(NOTE,
"Using file \"%s\"...",fname,0,0,0,0) ;
118 if(stat_buf.st_mode & S_IFDIR) {
119 LOG(DBG,
"Running through a directory %s...",fname,0,0,0,0) ;
129 status = EVP_STAT_OK ;
134 file_size = stat_buf.st_size ;
135 evt_offset_in_file = 0;
138 strcpy(file_name,fname) ;
141 LOG(DBG,
"Running through a file %s of %d bytes",fname,file_size,0,0,0) ;
143 desc = open64(fname,O_RDONLY,0444) ;
145 LOG(ERR,
"Can't open %s [%s]",fname,strerror(errno),0,0,0) ;
150 status = EVP_STAT_OK ;
155 int daqReader::getDetectorSize(
const char *det)
161 sfs->getDirSize((
char *)det, &sz);
167 void daqReader::init()
170 EVP_HOSTNAME = (
char *)_EVP_HOSTNAME;
171 static char evp_hostname[100];
172 char *str = getenv((
char *)
"EVP_HOSTNAME");
175 strcpy(evp_hostname, str);
176 EVP_HOSTNAME = evp_hostname;
190 rtsLogOutput(RTS_LOG_STDERR) ;
191 LOG(INFO,
"%s",cvs_id_string) ;
196 LOG(DBG,
"EVP_HOSTNAME set to %s", EVP_HOSTNAME);
206 memset(runconfig,0,
sizeof(
rccnf));
208 memset(dets,0,
sizeof(dets)) ;
209 memset(pseudo_dets,0,
sizeof(pseudo_dets));
214 strcpy(evp_disk,
"") ;
221 last_issued = time(NULL) ;
222 status = EVP_STAT_CRIT ;
234 status = EVP_STAT_OK ;
239 int daqReader::setOpen(
int flg)
249 int daqReader::setMmap(
int flg)
259 int daqReader::setLog(
int flg)
263 rtsLogOutput(RTS_LOG_STDERR|RTS_LOG_NET) ;
266 rtsLogOutput(RTS_LOG_NET) ;
273 char *daqReader::setEvpDisk(
char *name)
275 char *saved = _static_str_return_;
277 strcpy(saved, evp_disk) ;
278 strncpy(evp_disk,name,
sizeof(evp_disk)-1) ;
283 daqReader::~daqReader(
void)
285 LOG(DBG,
"Destructor %s",fname,0,0,0,0) ;
288 if(desc >= 0) close(desc) ;
291 if(input_type == live) {
292 msgNQDelete(evpDesc) ;
295 if(memmap)
delete(memmap);
296 if(sfs)
delete(sfs) ;
297 if(runconfig) free(runconfig) ;
300 for(
int i=0;i<32;i++) {
302 LOG(DBG,
"Will destruct det %d",i) ;
306 LOG(DBG,
"Will destruct pseudo det %d",i) ;
307 delete(pseudo_dets[i]) ;
328 char *daqReader::get(
int num,
int type)
337 memset(trgIds, 0xffffffff,
sizeof(trgIds));
339 trgIdsNotPresent = 0;
342 LOG(DBG,
"processing nth event. n=%d from %s %lld",event_number, getInputType(),evt_offset_in_file);
350 memset(streaming_node, 0,
sizeof(streaming_node));
356 int delay = getStatusBasedEventDelay();
359 LOG(CRIT,
"Exiting because of critical errors");
363 LOG(DBG,
"Delay of %d usec because of previous event status %d",delay, status);
372 if((input_type == dir) ||
373 (input_type == live)) {
375 if(getNextEventFilename(num, type) < 0) {
380 if(openEventFile() < 0) {
381 if(input_type == dir) {
382 LOG(NOTE,
"No File, but didn't see token 0 - stopping...",event_number) ;
383 status = EVP_STAT_EOR ;
409 if(input_type == pointer) {
410 if(event_memory == NULL)
411 event_memory = data_memory;
419 int error = getEventSize();
421 if(status == EVP_STAT_LOG) {
426 LOG(DBG,
"Skipping a non-event SFS file...");
428 lseek64(desc, event_size, SEEK_CUR);
429 evt_offset_in_file += event_size;
442 int inc = addToEventSize(event_size);
445 LOG(DBG,
"No extra increment... event size=%d",event_size);
449 LOG(WARN,
"Found a padding bug. Adding %d to event size",inc);
453 LOG(ERR,
"Error finding next event...");
454 status = EVP_STAT_EOR;
459 LOG(DBG,
"Event size is %d (%d) %d",event_size, error, status);
461 if(status == EVP_STAT_EOR) {
462 LOG(DBG,
"Status = EOR");
468 status = EVP_STAT_EOR;
474 status = EVP_STAT_EVT;
479 if((event_size + evt_offset_in_file) > file_size) {
480 LOG(WARN,
"This event is truncated... Good events %d [%d+%d > %d]...", total_events,evt_offset_in_file,event_size,file_size,0) ;
481 if((input_type == pointer) ||
482 (input_type == dir)) {
483 status = EVP_STAT_EVT ;
486 status = EVP_STAT_EOR ;
493 if(input_type != pointer) {
494 LOG(DBG,
"Mapping event file %s, offset %d, size %d",
495 file_name, evt_offset_in_file, event_size);
497 char *mapmem = memmap->map(desc, evt_offset_in_file, event_size, map_prot, map_flags);
499 LOG(CRIT,
"Error mapping memory for event");
504 memmap->map_real_mem(event_memory, event_size);
507 LOG(DBG,
"Event is now in memory: start=0x%x, length=%d",memmap->mem,event_size);
510 if(input_type == pointer) {
512 LOG(DBG,
"Does this ever get called?");
517 LOG(DBG,
"about to mount sfs file: %s %d 0x%x",file_name, evt_offset_in_file, sfs);
521 LOG(DBG,
"mounting single dir(mem): off=%d sz=%d",evt_offset_in_file, event_size);
525 LOG(DBG,
"[%c%c%c%c]",memmap->mem[0],memmap->mem[1],memmap->mem[2],memmap->mem[3]);
528 ret = sfs->mountSingleDirMem(memmap->mem, event_size, evt_offset_in_file);
532 LOG(ERR,
"Error mounting sfs?");
533 status = EVP_STAT_EVT;
539 fs_dir *fsdir = sfs->opendir(
"/");
543 sfs->closedir(fsdir);
544 LOG(ERR,
"Error finding event directory in sfs?");
547 status = EVP_STAT_EVT;
552 LOG(DBG,
"does dir (%s) satisfy '/#' or '/nnnn'",ent->full_name);
554 if(memcmp(ent->full_name,
"/#", 2) == 0) {
555 LOG(DBG,
"change sfs dir to %s",ent->full_name);
557 seq = atoi(&ent->full_name[2]);
559 sfs->cd(ent->full_name);
560 sfs->closedir(fsdir);
564 if(memcmp(ent->full_name,
"/%", 2) == 0) {
568 memset(_node, 0,
sizeof(_node));
569 memset(_evb, 0,
sizeof(_evb));
570 memset(_idx, 0,
sizeof(_idx));
572 char *s = &ent->full_name[2];
588 strcpy(streaming_node, _node);
589 streaming_evb = atoi(_evb);
590 streaming_seq = atoi(_idx);
592 LOG(DBG,
"change sfs dir to %s (%s) (%s) (%s)",
593 ent->full_name, _node, _evb, _idx);
595 sfs->cd(ent->full_name);
596 sfs->closedir(fsdir);
600 if(allnumeric(&ent->full_name[1])) {
601 seq = atoi(&ent->full_name[1]);
602 sfs->cd(ent->full_name);
603 sfs->closedir(fsdir);
608 LOG(DBG,
"SFS event directory not yet found: %s",ent->full_name);
611 fs_dirent *datap = sfs->opendirent(
"legacy");
613 mem = memmap->mem + datap->offset;
614 LOG(DBG,
"Event has a datap bank at 0x%x",mem);
618 LOG(DBG,
"Event has no DATAP bank");
624 bytes = event_size - (mem - memmap->mem);
625 LOG(DBG,
"size = %d %d",event_size, bytes);
631 fs_dirent *lrhd_ent = sfs->opendirent(
"lrhd");
633 char *lrhd_buff = memmap->mem + lrhd_ent->offset;
635 run = lrhd_rec->lh.run;
637 if(lrhd_rec->lh.byte_order != 0x04030201) {
646 fs_dirent *summary = sfs->opendirent(
"EventSummary");
648 char *buff = memmap->mem + summary->offset;
649 fillSummaryInfo(&info,(
gbPayload *)buff);
650 copySummaryInfoIn(&info);
653 LOG(DBG,
"No EventSummary, search for legacy datap");
654 summary = sfs->opendirent(
"legacy");
656 LOG(DBG,
"No EventSummary and no DATAP... hacking summary info");
660 char *buff = memmap->mem + summary->offset;
661 fillSummaryInfo(&info,(
DATAP *)buff);
662 copySummaryInfoIn(&info);
667 status = EVP_STAT_OK ;
673 long long int endpos = lseek64(desc, 0, SEEK_CUR);
675 long long int nexteventpos = lseek64(desc, event_size, SEEK_CUR) ;
677 LOG(DBG,
"End of event: start_offset=%d end_offset=%lld, file size %lld",endpos,nexteventpos,file_size) ;
679 evt_offset_in_file = nexteventpos;
685 fs_dirent *esum = sfs->opendirent(
"EvbSummary");
687 LOG(DBG,
"We've got an EvbSummary");
688 char *buff = (
char *)memmap->mem + esum->offset;
690 detsinrun = evbsum->detectorsInRun;
691 detsinrun64 = evbsum->detectorsInRun;
692 evpgroupsinrun = 0xffffffff;
694 if(evbsum->version > 2) {
695 triggerFrequency = evbsum->triggerFrequency;
696 triggerFrequency_valid = 1;
699 triggerFrequency = 9.3e6;
700 triggerFrequency_valid = 0;
704 LOG(DBG,
"No EvbSummary Record");
705 if(run != (
unsigned int)runconfig->run) {
706 char rccnf_file[256];
711 if(input_type == live) {
712 sprintf(rccnf_file,
"%s%s/%d/0",evp_disk,_evp_basedir_,run) ;
714 else if(input_type == dir) {
715 sprintf(rccnf_file,
"%s/0",fname);
717 else if (input_type == file) {
718 sprintf(rccnf_file,
"rccnf_%d.txt",run);
721 if(input_type != pointer) {
722 if(getRccnf(rccnf_file, runconfig) < 0) {
723 LOG(DBG,
"No runconfig file %s",rccnf_file,0,0,0,0);
727 if(runconfig->run == 0) {
728 detsinrun = 0xffffffff;
729 detsinrun64 = 0xffffffffffffffff;
730 evpgroupsinrun = 0xffffffff;
733 detsinrun = runconfig->detMask;
734 detsinrun64 = runconfig->detMask;
735 evpgroupsinrun = runconfig->grpMask;
746 if(detectors & (1 << TPX_ID)) {
747 if((run >= 13114025) && (run < 13130030)) {
750 for(
int s=1;s<=24;s++) {
751 for(
int r=1;r<=6;r++) {
753 if((s==5) && (r==1)) continue ;
754 if((s==6) && (r==1)) continue ;
755 if((s==7) && (r==1)) continue ;
756 if((s==14) && (r==3)) continue ;
757 if((s==21) && (r==1)) continue ;
758 if((s==22) && (r==2)) continue ;
763 sprintf(name,
"tpx/sec%02d/cld%02d",s,r) ;
764 if(!get_sfs_name(name)) {
765 detectors &= ~(1<<TPX_ID) ;
766 LOG(WARN,
"run %d, seq %d -- removing TPX due to FY12 UU future-protection bug",run,seq) ;
768 detector_bugs |= (1<<TPX_ID) ;
769 detector_bugs64 |= (1<<TPX_ID);
770 goto bug_check_done ;
809 char *daqReader::skip_then_get(
int numToSkip,
int num,
int type)
812 if(input_type != file) {
813 LOG(CRIT,
"Can't call skip_then_get unless running from file...");
814 status = EVP_STAT_EVT;
822 for(
int i=0;i<numToSkip;i++) {
826 error = getEventSize();
828 if(status == EVP_STAT_LOG) {
829 lseek64(desc, event_size, SEEK_CUR);
830 evt_offset_in_file += event_size;
841 int inc = addToEventSize(event_size);
844 LOG(DBG,
"No extra increment... event size=%d",event_size);
848 LOG(WARN,
"Found a padding bug. Adding %d to event size",inc);
852 LOG(ERR,
"Error finding next event...");
853 status = EVP_STAT_EOR;
858 if(status == EVP_STAT_EOR) {
863 status = EVP_STAT_EOR;
868 status = EVP_STAT_EVT;
872 if((event_size + evt_offset_in_file) > file_size) {
873 LOG(WARN,
"This event is truncated");
874 status = EVP_STAT_EOR;
878 long long int nexteventpos = lseek64(desc, event_size, SEEK_CUR);
879 LOG(DBG,
"skip evt pos = %lld", nexteventpos);
881 evt_offset_in_file += event_size;
885 LOG(DBG,
"out of skip");
886 return get(num, type);
890 int daqReader::addToEventSize(
int sz)
892 if(input_type == pointer)
return 0;
894 long long int orig_offset = lseek64(desc, 0, SEEK_CUR);
896 LOG(DBG,
"orig_offset = %lld sz=%d",orig_offset,sz);
898 lseek64(desc, sz, SEEK_CUR);
901 int ret = read(desc, buff, 8);
903 lseek64(desc, orig_offset, SEEK_SET);
907 if(memcmp(buff,
"LRHD",4) == 0) {
908 lseek64(desc, orig_offset, SEEK_SET);
912 if(memcmp(buff,
"DATAP",4) == 0) {
913 lseek64(desc, orig_offset, SEEK_SET);
917 if(memcmp(buff,
"SFS", 3) == 0) {
918 lseek64(desc, orig_offset, SEEK_SET);
922 if(memcmp(buff,
"FILE", 4) == 0) {
923 lseek64(desc, orig_offset, SEEK_SET);
927 LOG(ERR,
"buff = %c%c%c off=%lld",buff[0],buff[1],buff[2], orig_offset);
929 lseek64(desc, orig_offset, SEEK_SET);
935 int daqReader::getEventSize()
942 long long int offset = 0;
943 long long int space_left;
947 status = EVP_STAT_OK;
950 if(input_type == pointer) {
952 space_left = data_size - (m - data_memory);
958 offset = lseek64(desc, 0, SEEK_CUR);
959 space_left = file_size - offset;
961 if(space_left > 1024) space_left = 1024;
963 LOG(DBG,
"Space left = %d",space_left);
965 if(space_left == 0)
return 0;
966 if(space_left < (
long long int)
sizeof(
LOGREC))
return -1;
968 m = headermap.map(desc, offset, space_left, map_prot, map_flags);
970 LOG(ERR,
"Error mapping header information");
978 if(space_left == 0)
return 0;
979 if(space_left < (
long long int)
sizeof(
LOGREC)) {
980 LOG(NOTE,
"File truncated: only %lld bytes left",space_left);
981 status = EVP_STAT_EOR;
985 LOG(DBG,
"OFFSET = %lld", offset);
988 while((memcmp(m,
"LRHD", 4) != 0) &&
989 (memcmp(m,
"DATAP", 5) != 0)) {
994 int sz = tmp_sfs->getSingleDirSize(file_name, evt_offset_in_file);
1000 tmp_sfs->mountSingleDir(file_name, evt_offset_in_file);
1005 fs_dir *fsdir = tmp_sfs->opendir(
"/");
1006 fs_dirent *ent = tmp_sfs->readdir(fsdir);
1008 tmp_sfs->closedir(fsdir);
1009 LOG(ERR,
"Error finding event directory in sfs?");
1012 status = EVP_STAT_EVT;
1017 LOG(DBG,
"does dir (%s) satisfy '/#' or '/nnnn'",ent->full_name);
1019 if(memcmp(ent->full_name,
"/#", 2) == 0) {
1024 if(memcmp(ent->full_name,
"/%", 2) == 0) {
1028 if(allnumeric(&ent->full_name[1])) {
1032 tmp_sfs->closedir(fsdir);
1035 status = EVP_STAT_LOG;
1045 LOG(ERR,
"Event starts with %c%c%c%c%c not LRHD or DATAP and not a SFS file... bad event",m[0],m[1],m[2],m[3],m[4]);
1047 status = EVP_STAT_EVT;
1061 if(memcmp(m,
"DATAP", 5) == 0) {
1063 int swap = (datap->bh.byte_order == 0x04030201) ? 0 : 1;
1065 event_size = qswap32(swap, datap->len) * 4;
1075 if(memcmp(m,
"LRHD", 4) == 0) {
1078 LOG(DBG,
"record_type = %c%c%c%c",
1079 lrhd->record_type[0],
1080 lrhd->record_type[1],
1081 lrhd->record_type[2],
1082 lrhd->record_type[3]);
1084 if(memcmp(lrhd->record_type,
"DATA", 4) == 0)
break;
1086 if(memcmp(lrhd->record_type,
"ENDR", 4) == 0) {
1088 LOG(DBG,
"Got ENDR record");
1090 status = EVP_STAT_EOR;
1094 LOG(DBG,
"Skipping LRHD record type %c%c%c%c",
1095 lrhd->record_type[0],
1096 lrhd->record_type[1],
1097 lrhd->record_type[2],
1098 lrhd->record_type[3]);
1100 space_left -=
sizeof(
LOGREC);
1101 offset +=
sizeof(
LOGREC);
1103 event_size +=
sizeof(
LOGREC);
1105 if(space_left < (
long long int)
sizeof(
LOGREC)) {
1106 LOG(NOTE,
"File truncated: only %lld bytes left",space_left);
1107 status = EVP_STAT_EOR;
1113 LOG(DBG,
"Corrupted headers: %c%c%c%c%c",
1114 m[0],m[1],m[2],m[3],m[4]);
1128 swap = (lrhd->lh.byte_order == 0x04030201) ? 0 : 1;
1129 event_size += qswap32(swap,lrhd->length) * 4;
1144 const char *daqReader::getInputType()
1146 switch(input_type) {
1162 int daqReader::openEventFile()
1164 struct stat64 stat_buf ;
1174 desc = open64(file_name,O_RDONLY,0666) ;
1176 LOG(NOTE,
"Error opening file %s [%s] - skipping...",file_name,strerror(errno),0,0,0) ;
1177 status = EVP_STAT_EVT ;
1182 int ret = stat64(file_name,&stat_buf) ;
1184 LOG(ERR,
"Can't stat %s",file_name,0,0,0,0) ;
1185 status = EVP_STAT_EVT ;
1191 file_size = stat_buf.st_size ;
1192 evt_offset_in_file = 0;
1197 int daqReader::getNextEventFilename(
int num,
int type)
1199 if((event_number != 1) && (token == 0)) {
1200 LOG(DBG,
"Previous event (%d) was Token 0 in directory - stopping...",event_number,0,0,0,0) ;
1201 status = EVP_STAT_EOR ;
1202 if(input_type == live) {
1208 if(input_type == dir) {
1209 return getNextEventFilenameFromDir(num);
1211 else if (input_type == live) {
1212 return getNextEventFilenameFromLive(type);
1215 LOG(ERR,
"Wrong input type");
1220 int daqReader::copySummaryInfoIn(
SummaryInfo *info)
1223 token = info->token;
1224 evt_time = info->evt_time;
1225 detectors = info->detectors;
1226 detectors64 = info->detectors;
1227 daqbits_l1 = info->daqbits_l1;
1228 daqbits_l2 = info->daqbits_l2;
1229 evpgroups = info->evpgroups;
1230 daqbits = info->daqbits;
1231 evp_daqbits = info->evp_daqbits;
1235 trgword = info->trgword;
1236 trgcmd = info->trgcmd;
1237 daqcmd = info->daqcmd;
1238 flags = info->flags;
1240 memcpy(L1summary, info->L1summary,
sizeof(L1summary));
1241 memcpy(L2summary, info->L2summary,
sizeof(L2summary));
1242 memcpy(L3summary, info->L3summary,
sizeof(L3summary));
1245 daqbits64 = ((u_longlong)L3summary[1]) << 32;
1246 daqbits64 += L3summary[0];
1247 daqbits64_l1 = ((u_longlong)L1summary[1]) << 32;
1248 daqbits64_l1 += L1summary[0];
1249 daqbits64_l2 = ((u_longlong)L2summary[1]) << 32;
1250 daqbits64_l2 += L2summary[0];
1256 int daqReader::hackSummaryInfo()
1278 memset(L1summary, 0,
sizeof(L1summary));
1279 memset(L2summary, 0,
sizeof(L2summary));
1280 memset(L3summary, 0,
sizeof(L3summary));
1289 LOG(DBG,
"pay=0x%x",pay);
1291 u_int
version = pay->gbPayloadVersion;
1293 LOG(DBG,
"version = 0x%x", version);
1295 if(((version & 0xff000000) != 0xda000000) && ((b2h32(version) & 0x000000ff ) != 0x40)) {
1296 LOG(DBG,
"gbPayload version 0x10");
1299 LOG(DBG,
"gbPayload 0x01: v#=0x%x",b2h32(version));
1300 return fillSummaryInfo_v01(info, pv);
1303 if(((version & 0xff000000) != 0xda000000) && ((b2h32(version) & 0x000000ff ) == 0x40)) {
1304 LOG(DBG,
"gbPayload version 0x01a");
1306 LOG(DBG,
"gbPayload 0x01a: v#=0x%x", b2h32(version));
1307 return fillSummaryInfo_v01a(info, pv);
1310 if(version == 0xda000002) {
1311 LOG(DBG,
"gbPayload 0x02: v#=0x%x",version);
1315 if(version == 0xda000003) {
1316 LOG(DBG,
"gbPayload 0x03: v=0x%x", version);
1317 return fillSummaryInfo_v03(info, pay);
1320 LOG(ERR,
"gbPayload Version Unknown: 0x%x vs 0x%x. Using 02", version, GB_PAYLOAD_VERSION);
1321 return fillSummaryInfo_v03(info, pay);
1327 LOG(DBG,
"gbPayloadVersion=0x%x, trgVersion=0x%x", pay->gbPayloadVersion, pay->EventDescriptor.TrgDataFmtVer);
1329 info->token = l2h32(pay->token);
1330 info->evt_time = l2h32(pay->sec);
1331 info->detectors = l2h32(pay->rtsDetMask);
1332 info->detectors64 = l2h32(pay->rtsDetMask);
1333 info->daqbits_l1 = l2h32(pay->L1summary[0]);
1334 info->daqbits_l2 = l2h32(pay->L2summary[0]);
1335 info->evpgroups = l2h32(pay->L3summary[3]);
1336 info->daqbits = l2h32(pay->L3summary[0]);
1337 info->evp_daqbits = daqbits;
1338 info->flags = l2h32(pay->flags);
1342 info->trgcmd = pay->EventDescriptor.actionWdTrgCommand;
1343 info->daqcmd = pay->EventDescriptor.actionWdDaqCommand;
1345 for(
int i=0;i<2;i++) info->L1summary[i] = l2h32(pay->L1summary[i]);
1346 for(
int i=0;i<2;i++) info->L2summary[i] = l2h32(pay->L2summary[i]);
1347 for(
int i=0;i<4;i++) info->L3summary[i] = l2h32(pay->L3summary[i]);
1356 LOG(DBG,
"gbPayloadVersion=0x%x, trgVersion=0x%x", pay->gbPayloadVersion, pay->EventDescriptor.TrgDataFmtVer);
1358 info->token = l2h32(pay->token);
1359 info->evt_time = l2h32(pay->sec);
1360 info->detectors = l2h32(pay->rtsDetMask);
1361 info->detectors64 = l2h32(pay->rtsDetMask);
1362 info->daqbits_l1 = l2h32(pay->L1summary[0]);
1363 info->daqbits_l2 = l2h32(pay->L2summary[0]);
1364 info->evpgroups = l2h32(pay->L3summary[3]);
1365 info->daqbits = l2h32(pay->L3summary[0]);
1366 info->evp_daqbits = daqbits;
1367 info->flags = l2h32(pay->flags);
1371 info->trgcmd = pay->EventDescriptor.actionWdTrgCommand;
1372 info->daqcmd = pay->EventDescriptor.actionWdDaqCommand;
1374 for(
int i=0;i<2;i++) info->L1summary[i] = l2h32(pay->L1summary[i]);
1375 for(
int i=0;i<2;i++) info->L2summary[i] = l2h32(pay->L2summary[i]);
1376 for(
int i=0;i<4;i++) info->L3summary[i] = l2h32(pay->L3summary[i]);
1383 LOG(DBG,
"gbPayloadVersion=0xda000001, trgVersion=0x%x", pay->EventDescriptor.TrgDataFmtVer);
1386 info->token = l2h32(pay->token);
1387 info->evt_time = l2h32(pay->sec);
1388 info->detectors = l2h32(pay->rtsDetMask);
1389 info->detectors64 = l2h32(pay->rtsDetMask);
1390 info->daqbits_l1 = l2h32(pay->L1summary[0]);
1391 info->daqbits_l2 = l2h32(pay->L2summary[0]);
1392 info->evpgroups = l2h32(pay->L3summary[2]);
1393 info->daqbits = l2h32(pay->L3summary[0]);
1394 info->evp_daqbits = daqbits;
1395 info->flags = l2h32(pay->flags);
1398 info->trgword = b2h16(pay->EventDescriptor.TriggerWord);
1399 info->trgcmd = pay->EventDescriptor.actionWdTrgCommand;
1400 info->daqcmd = pay->EventDescriptor.actionWdDaqCommand;
1402 for(
int i=0;i<2;i++) info->L1summary[i] = l2h32(pay->L1summary[i]);
1403 for(
int i=0;i<2;i++) info->L2summary[i] = l2h32(pay->L2summary[i]);
1404 for(
int i=0;i<4;i++) info->L3summary[i] = l2h32(pay->L3summary[i]);
1411 LOG(DBG,
"gbPayloadVersion=0xda000001, trgVersion=0x%x", pay->EventDescriptor.TrgDataFmtVer);
1414 info->token = l2h32(pay->token);
1415 info->evt_time = l2h32(pay->sec);
1416 info->detectors = l2h32(pay->rtsDetMask);
1417 info->detectors64 = l2h32(pay->rtsDetMask);
1418 info->daqbits_l1 = l2h32(pay->L1summary[0]);
1419 info->daqbits_l2 = l2h32(pay->L2summary[0]);
1420 info->evpgroups = l2h32(pay->L3summary[2]);
1421 info->daqbits = l2h32(pay->L3summary[0]);
1422 info->evp_daqbits = daqbits;
1425 info->trgword = b2h16(pay->EventDescriptor.TriggerWord);
1426 info->trgcmd = pay->EventDescriptor.actionWdTrgCommand;
1427 info->daqcmd = pay->EventDescriptor.actionWdDaqCommand;
1429 for(
int i=0;i<2;i++) info->L1summary[i] = l2h32(pay->L1summary[i]);
1430 for(
int i=0;i<2;i++) info->L2summary[i] = l2h32(pay->L2summary[i]);
1431 for(
int i=0;i<4;i++) info->L3summary[i] = l2h32(pay->L3summary[i]);
1439 int swap = (datap->bh.byte_order == 0x04030201) ? 0 : 1;
1441 info->token = qswap32(swap, datap->bh.token);
1442 info->evt_time = qswap32(swap, datap->time);
1443 info->detectors = qswap32(swap, datap->detector);
1444 info->detectors64 = qswap32(swap, datap->detector);
1445 info->seq = qswap32(swap, datap->seq);
1446 info->daqbits_l1 = qswap32(swap, datap->TRG_L1_summary[0]);
1447 info->daqbits_l2 = qswap32(swap, datap->TRG_L2_summary[0]);
1448 info->evpgroups = qswap32(swap, datap->L3_Summary[2]);
1449 info->trgword = qswap32(swap, datap->trg_word);
1451 info->trgcmd = (qswap32(swap, datap->trg_in_word) >> 12) & 0xF ;
1452 info->daqcmd = (qswap32(swap, datap->trg_in_word) >> 8) & 0xF ;
1455 info->daqbits = qswap32(swap, datap->L3_Summary[0]);
1456 info->evp_daqbits = daqbits;
1458 for(
int i=0;i<2;i++) info->L1summary[i] = qswap32(swap, datap->TRG_L1_summary[i]);
1459 for(
int i=0;i<2;i++) info->L2summary[i] = qswap32(swap, datap->TRG_L2_summary[i]);
1460 for(
int i=0;i<4;i++) info->L3summary[i] = qswap32(swap, datap->L3_Summary[i]);
1470 int daqReader::getNextEventFilenameFromDir(
int eventNum)
1472 LOG(DBG,
"Getting next event from dir: event_number=%d eventNum=%d",event_number, eventNum);
1474 if(eventNum==0) eventNum = event_number;
1475 sprintf(file_name,
"%s/%d",fname,eventNum) ;
1477 LOG(DBG,
"Getting next event from dir: event_number=%s",file_name);
1479 event_number = eventNum ;
1483 int daqReader::getNextEventFilenameFromLive(
int type)
1492 if((time(NULL) - last_issued) > 10) {
1493 LOG(DBG,
"Re-issueing request...",0,0,0,0,0) ;
1500 m.ld.dword[0] = htonl(type) ;
1502 LOG(DBG,
"dword[0] is type=%d",type);
1504 ret = ask(evpDesc,&m) ;
1505 if(ret != STAT_OK) {
1507 LOG(ERR,
"Queue error %d - recheck EVP...",ret,0,0,0,0) ;
1509 status = EVP_STAT_EVT ;
1513 last_issued = time(NULL) ;
1519 if(!readall_rundone) {
1522 ret = evtwait(evpDesc, &m) ;
1528 if((ret != STAT_OK) && (ret != STAT_TIMED_OUT)) {
1530 LOG(ERR,
"Queue error %d - recheck EVP...",ret,0,0,0,0) ;
1531 status = EVP_STAT_EVT ;
1535 if(ret == STAT_TIMED_OUT) {
1538 #if defined(__linux__) || defined(__APPLE__)
1544 LOG(DBG,
"Waiting 1 second, no event yet...");
1546 status = EVP_STAT_OK ;
1550 LOG(DBG,
"m.head.status = %d EOR=%d",m.head.status,EVP_STAT_EOR);
1554 switch(m.head.status) {
1558 LOG(DBG,
"End of Run!",0,0,0,0,0) ;
1560 status = EVP_STAT_EOR ;
1570 evb_type = ntohl(m.ld.dword[2]) ;
1571 evb_type_cou = ntohl(m.ld.dword[3]) ;
1572 evb_cou = ntohl(m.ld.dword[4]) ;
1573 run = ntohl(m.ld.dword[0]) ;
1575 readall_lastevt = ntohl(m.ld.dword[1]);
1576 strcpy(_evp_basedir_, (
char *)&m.ld.dword[5]);
1578 event_number = readall_lastevt;
1580 sprintf(_last_evp_dir_,
"%s%s/%d",evp_disk,_evp_basedir_,run);
1588 LOG(WARN,
"Event in error - not stored...",0,0,0,0,0) ;
1589 status = EVP_STAT_EVT ;
1621 sprintf(file_name,
"%s/%d",_last_evp_dir_, event_number) ;
1624 if(stat64(file_name, &s) < 0) {
1625 LOG(DBG,
"No file %s, try _DELETE",file_name);
1626 sprintf(file_name,
"%s_DELETE/%d",_last_evp_dir_,event_number);
1629 LOG(DBG,
"Live Event: file->%s",file_name,0,0,0,0) ;
1633 int daqReader::getOfflineId(
int bit)
1635 if(trgIdsNotPresent)
return -1;
1636 if(bit > 63)
return -1;
1644 fs_dirent *trgid_dir = sfs->opendirent(
"TRGID");
1646 UINT32 *trgid_buff = (UINT32 *)(memmap->mem + trgid_dir->offset);
1647 memset(trgIds,0xffffffff,
sizeof(trgIds));
1649 int sz = trgid_dir->sz;
1651 if(sz > 64) sz = 64;
1653 for(
int i=0;i<sz;i++) {
1654 trgIds[i] = trgid_buff[i];
1658 LOG(ERR,
"Can't find TRGID bank, can't get the offline id");
1659 memset(trgIds, 0xffffffff,
sizeof(trgIds));
1660 trgIdsNotPresent = 1;
1668 char *daqReader::get_sfs_name(
const char *right)
1670 if(sfs == 0)
return 0 ;
1672 if(right == 0) right =
"/" ;
1675 if(d == 0)
return 0 ;
1677 LOG(DBG,
"opendirent(%s) returns %s as full name, %s as d_name ",right,d->full_name,d->d_name) ;
1678 return d->full_name ;
1687 static u_int parse_det_string(
const char *list)
1697 for(
int i=0;i<32;i++) {
1698 const char *name = rts2name(i) ;
1700 if(name==0) continue ;
1704 if(strncasecmp(list,name,strlen(name))==0) {
1714 if(*list ==
' ') got_space = 1 ;
1717 if(got_space)
goto reparse ;
1727 daq_det *daqReader::det(
const char *which)
1733 for(
int i=0;i<DAQ_READER_MAX_DETS;i++) {
1736 if(strcasecmp(which, dets[i]->name)==0)
return dets[i] ;
1738 if(pseudo_dets[i]) {
1739 if(strcasecmp(which, pseudo_dets[i]->name)==0)
return pseudo_dets[i] ;
1743 LOG(DBG,
"det %s not yet created... attempting through factory...",which) ;
1747 for(
int i=0;i<DAQ_READER_MAX_DETS;i++) {
1748 const char *name = rts2name(i) ;
1749 if(name == 0) continue ;
1753 if(strcasecmp(name,which)==0) {
1755 dets[i] = daq_det_factory::make_det(i) ;
1756 dets[i]->managed_by(
this) ;
1763 if(strcasecmp(which,
"emc_pseudo")==0)
id = -BTOW_ID ;
1764 if(strcasecmp(which,
"hlt")==0)
id = -L3_ID ;
1765 if(strcasecmp(which,
"itpc_pseudo")==0)
id = -SVT_ID ;
1769 LOG(CRIT,
"Requested det \"%s\" not created -- check spelling!",which) ;
1770 assert(!
"UNKNOWN DET") ;
1775 pseudo_dets[wh] = daq_det_factory::make_det(
id) ;
1776 pseudo_dets[wh]->managed_by(
this) ;
1778 return pseudo_dets[wh] ;
1781 void daqReader::insert(
class daq_det *which,
int id)
1784 LOG(DBG,
"calling insert(%d): name %s",
id,which->name) ;
1786 if((
id>=0) && (
id<DAQ_READER_MAX_DETS)) {
1792 if(
id >= DAQ_READER_MAX_DETS) ;
1794 pseudo_dets[id] = which ;
1799 LOG(ERR,
"rts_id %d out of bounds for %s",
id,which->name) ;
1803 void daqReader::Make()
1805 for(
int i=0;i<DAQ_READER_MAX_DETS;i++) {
1807 LOG(DBG,
"Calling %s make",dets[i]->name) ;
1813 void daqReader::de_insert(
int id)
1815 LOG(DBG,
"calling de_insert(%d)",
id) ;
1817 if((
id>=0) && (
id<DAQ_READER_MAX_DETS)) {
1819 LOG(DBG,
"Should destruct %d?",
id) ;
1826 if(
id >= DAQ_READER_MAX_DETS) ;
1828 if(pseudo_dets[
id]) LOG(DBG,
"Should destruct %d?",
id) ;
1829 pseudo_dets[id] = 0 ;
1835 LOG(ERR,
"rts_id %d out of bounds",
id) ;
1911 static int evtwait(
int desc,
ic_msg *m)
1914 static int counter = 0 ;
1917 ret = msgNQReceive(desc,(
char *)m,
sizeof(
ic_msg),NO_WAIT) ;
1919 LOG(DBG,
"msgNQReceive returned %d",ret,0,0,0,0) ;
1921 if(ret == MSG_Q_TIMEOUT) {
1922 LOG(DBG,
"read a timeout count=%d",counter);
1924 if(counter >= 100) {
1926 if(msgNQCheck(desc)) {
1927 LOG(DBG,
"check returned ok...");
1928 return STAT_TIMED_OUT ;
1931 LOG(DBG,
"EVP_TASK died",0,0,0,0,0) ;
1936 return STAT_TIMED_OUT ;
1944 LOG(DBG,
"0x%08X 0x%08X 0x%08X; %d %d",*intp,*(intp+1),*(intp+2),m->head.daq_cmd,m->head.status) ;
1947 *(intp+i) = ntohl(*(intp+i)) ;
1949 LOG(DBG,
"0x%08X 0x%08X 0x%08X; %d %d",*intp,*(intp+1),*(intp+2),m->head.daq_cmd,m->head.status) ;
1958 int daqReader::fixDatapSummary(
DATAP *datap)
1962 fs_dirent *ent = sfs->opendirent(
"legacy");
1964 LOG(ERR,
"Can't find legacy data");
1968 sumdatap = (
DATAP *)(memmap->mem + ent->offset);
1970 if(memcmp(sumdatap->bh.bank_type,
"DATAP", 5) != 0) {
1971 char *x = sumdatap->bh.bank_type;
1972 LOG(ERR,
"fixDatapSummary... legacy not DATAP: %c%c%c%c%c",
1973 x[0],x[1],x[2],x[3],x[4]);
1978 datap->len = sumdatap->len;
1979 datap->time = sumdatap->time;
1980 datap->seq = sumdatap->seq;
1981 datap->trg_word = sumdatap->trg_word;
1982 datap->trg_in_word = sumdatap->trg_in_word;
1983 datap->detector = sumdatap->detector;
1984 memcpy(datap->TRG_L1_summary, sumdatap->TRG_L1_summary,
sizeof(datap->TRG_L1_summary));
1985 memcpy(datap->TRG_L2_summary, sumdatap->TRG_L2_summary,
sizeof(datap->TRG_L2_summary));
1986 memcpy(datap->L3_Summary, sumdatap->L3_Summary,
sizeof(datap->L3_Summary));
1987 memcpy(&datap->evtdes, &sumdatap->evtdes,
sizeof(datap->evtdes));
1992 int daqReader::reconnect(
void)
1998 if(evpDesc != -1) close(evpDesc);
2006 evpDesc = msgNQCreate(EVP_HOSTNAME,EVP_PORT,120) ;
2009 LOG(ERR,
"Can't create connection to %s:%d [%s] - will retry...",EVP_HOSTNAME,EVP_PORT,
2010 strerror(errno),0,0) ;
2011 fprintf(stderr,
"CRITICAL: Can't create connection to %s:%d [%s] - will retry...\n",EVP_HOSTNAME,EVP_PORT,
2019 LOG(WARN,
"Connection suceeded!",0,0,0,0,0) ;
2023 LOG(DBG,
"Opened connection to %s, port %d on descriptor %d",EVP_HOSTNAME, EVP_PORT,evpDesc,0,0) ;
2025 msg.head.daq_cmd = RTS_ETHDOOR_ANNOUNCE ;
2026 msg.head.status = 0 ;
2027 msg.ld.dword[0] = htonl(getpid()) ;
2031 struct passwd *passwd = getpwuid(getuid()) ;
2032 if(passwd == NULL) {
2033 LOG(WARN,
"User doesn't exist?",0,0,0,0,0) ;
2034 user = (
char *)
"????" ;
2037 user = passwd->pw_name ;
2041 strncpy((
char *)&msg.ld.dword[1],user,12) ;
2042 strncpy((
char *)&msg.ld.dword[4],getCommand(),12) ;
2043 msg.head.valid_words = 1+7 ;
2049 int *intp = (
int *) &msg ;
2050 for(jj=0;jj<3;jj++) {
2051 *(intp+jj) = htonl(*(intp+jj)) ;
2056 ret = msgNQSend(evpDesc,(
char *)&msg,120,60) ;
2058 LOG(ERR,
"Can't send data to %s! - will reconnect...",EVP_HOSTNAME,0,0,0,0) ;
2059 msgNQDelete(evpDesc) ;
2066 status = EVP_STAT_OK ;
2067 LOG(DBG,
"Returning to caller, status %d",status,0,0,0,0) ;
2077 static int ask(
int desc,
ic_msg *m)
2083 int *intp = (
int *) m ;
2085 m->head.daq_cmd = EVP_REQ_EVENT ;
2086 m->head.status = STAT_OK ;
2087 m->head.dst_task = EVP_TASK ;
2088 m->head.valid_words = 1+1 ;
2089 m->head.source_id = EVP_NODE ;
2090 m->head.src_task = EVP_TASK_READER ;
2092 LOG(DBG,
"Sending request to EVP_TASK",0,0,0,0,0) ;
2096 for(jj=0;jj<3;jj++) {
2097 *(intp+jj) = htonl(*(intp+jj)) ;
2100 ret = msgNQSend(desc, (
char *)m, 120,10) ;
2102 LOG(DBG,
"msgNQSend returned %d in %d seconds",ret,time(NULL)-tm,0,0,0) ;
2113 static const char *getCommand(
void)
2117 static const char *str =
"(no-name)" ;
2118 #if defined(__linux__) || defined(__APPLE__)
2120 static char name[128] ;
2123 file = fopen(
"/proc/self/stat",
"r") ;
2124 if(file==NULL)
return str ;
2126 fscanf(file,
"%d %s",&dummy,name) ;
2128 *(name+strlen(name)-1) = 0 ;
2132 static struct psinfo ps ;
2134 fd = open(
"/proc/self/psinfo",O_RDONLY,0666) ;
2135 if(fd < 0)
return str ;
2137 ret = read(fd,(
char *)&ps,
sizeof(ps)) ;
2140 if(ret !=
sizeof(ps)) {
2144 return ps.pr_fname ;
2176 DATAP *getlegacydatap(
char *mem,
int bytes)
2181 LOG(DBG,
"off = %d bytes = %d", off, bytes);
2182 while(off < bytes) {
2185 if(memcmp(curr,
"LRHD", 4) == 0) {
2186 LOG(DBG,
"hop over LRHD");
2190 else if(memcmp(curr,
"DATAP", 5) == 0) {
2191 LOG(DBG,
"hop over DATAP");
2192 curr +=
sizeof(
DATAP);
2193 off +=
sizeof(
DATAP);
2195 else if(memcmp(curr,
"SFS", 3) == 0) {
2196 LOG(DBG,
"hop over SFS volume spec");
2200 else if(memcmp(curr,
"HEAD", 4) == 0) {
2201 LOG(DBG,
"hop over SFS header");
2205 else if(memcmp(curr,
"FILE", 4) == 0) {
2208 int swap = (file->byte_order == 0x04030201) ? 0 : 1;
2210 if(strstr(file->name,
"legacy")) {
2211 LOG(DBG,
"Found legacy file");
2212 off += file->head_sz;
2213 curr += file->head_sz;
2215 if(memcmp(curr,
"DATAP", 5) != 0) {
2216 LOG(ERR,
"Got to legacy file, but not DATAP? is %c%c%c%c%c",
2217 curr[0],curr[1],curr[2],curr[3],curr[4]);
2221 return (
DATAP *)curr;
2224 LOG(DBG,
"hop over SFS File (%s)", file->name);
2225 off += file->head_sz + ((qswap32(swap, file->sz)+3) & 0xfffffffc);
2226 curr += file->head_sz + ((qswap32(swap, file->sz)+3) & 0xfffffffc);
2230 LOG(DBG,
"There is no legacy datap");
2235 LOG(ERR,
"no legacy datap");
2239 int daqReader::getStatusBasedEventDelay()
2247 LOG(DBG,
"Delaying for %d usec because of error on last event",delay);
2251 LOG(DBG,
"Delaying for %d usec because last event was end of run",delay);
2253 case EVP_STAT_CRIT :
2255 LOG(ERR,
"Delaying for %d usec because last event had critical status",delay);
2259 LOG(ERR,
"That's IT! Bye...",0,0,0,0,0);
2268 if(status != EVP_STAT_CRIT) crit_cou = 0;
2274 int daqReader::writeCurrentEventToDisk(
char *ofilename)
2279 if(memmap->mem == NULL) {
2280 LOG(ERR,
"Can't write current event. No event");
2285 fdo = open(ofilename, O_APPEND | O_WRONLY | O_CREAT, 0666);
2287 LOG(ERR,
"Error opening output file %s (%s)", ofilename, strerror(errno));
2291 ret = write(fdo, memmap->mem, event_size);
2292 if(ret != event_size) {
2293 LOG(ERR,
"Error writing event data (%s)",strerror(errno));
2305 actual_mem_start=NULL;
2309 page_size = sysconf(_SC_PAGESIZE);
2317 char *MemMap::map_real_mem(
char *buffer,
int _size)
2327 void daqReader::setCopyOnWriteMapping() {
2328 map_prot = PROT_READ | PROT_WRITE;
2329 map_flags = MAP_PRIVATE | MAP_NORESERVE;
2332 char *MemMap::map(
int _fd,
long long int _offset,
int _size,
int map_prot,
int map_flags)
2338 LOG(DBG,
"Calling mmap fd=%d offset=%d size=%d",
2339 _fd, _offset, _size);
2341 int excess = offset % page_size;
2342 actual_offset = offset - excess;
2343 actual_size = size + excess;
2345 LOG(DBG,
" mmap excess=%d aoffset=%d asize=%d",
2346 excess, actual_offset, actual_size);
2348 actual_mem_start = (
char *) mmap64(NULL, actual_size, map_prot, map_flags, fd, actual_offset) ;
2349 madvise(actual_mem_start, actual_size, MADV_SEQUENTIAL);
2351 if(((
void *)actual_mem_start) == MAP_FAILED) {
2352 LOG(ERR,
"Error in mmap (%s)",strerror(errno),0,0,0,0) ;
2358 actual_mem_start=NULL;
2363 mem = actual_mem_start + excess;
2367 void MemMap::unmap()
2369 if(mem==NULL)
return;
2375 madvise(actual_mem_start, actual_size, MADV_DONTNEED);
2376 munmap(actual_mem_start, actual_size);
2383 actual_mem_start=NULL;
2393 int daqReader::readNextFutureSummaryInfo(
SummaryInfo *info)
2397 if(input_type != file) {
2398 LOG(ERR,
"Can't read next future evt header unless reading from daq file");
2402 if(sfs->singleDirMount == 0) {
2403 LOG(ERR,
"Need a current file to read the next one...");
2407 LOG(DBG,
"(sfs) singleDirOffset = %d singleDirSize = %d", sfs->singleDirOffset, sfs->singleDirSize);
2409 long long int offset = sfs->singleDirOffset + sfs->singleDirSize;
2413 LOG(ERR,
"Couldn't create sfs_index");
2417 LOG(DBG,
"mounting dir at offset %s:%d",file_name,offset);
2418 int ret = nsfs->mountSingleDir(file_name, offset);
2420 LOG(
"ERR",
"Error mounting dir at offset %s:%d",file_name,offset);
2426 LOG(DBG,
"End of file reading next dir...");
2431 LOG(DBG,
"Mounted dir (nsfs) off: %d sz: %d",nsfs->singleDirOffset, nsfs->singleDirSize);
2435 int fd = open(file_name, O_RDONLY);
2437 LOG(ERR,
"No defined file descriptor");
2443 char *mymem = nmem->map(fd, nsfs->singleDirOffset, nsfs->singleDirSize, map_prot, map_flags);
2445 LOG(ERR,
"Couldn't map memory");
2452 LOG(DBG,
"mapped off=%d sz=%d into 0x%x",nsfs->singleDirOffset, nsfs->singleDirSize, mymem);
2454 fs_dir *rootdir = nsfs->opendir(
"/");
2456 fs_dirent *ent = nsfs->readdir(rootdir);
2458 nsfs->closedir(rootdir);
2459 LOG(ERR,
"Error finding event directory in sfs?");
2462 nsfs->closedir(rootdir);
2469 if(memcmp(ent->full_name,
"/#", 2) == 0) {
2470 info->seq = atoi(&ent->full_name[2]);
2472 nsfs->cd(ent->full_name);
2473 nsfs->closedir(rootdir);
2477 if(allnumeric(&ent->full_name[1])) {
2478 info->seq = atoi(&ent->full_name[1]);
2479 nsfs->cd(ent->full_name);
2480 nsfs->closedir(rootdir);
2484 LOG(DBG,
"SFS event directory not yet found: %s",ent->full_name);
2487 fs_dirent *summary = nsfs->opendirent(
"EventSummary");
2492 int mem_offset = summary->offset-nsfs->singleDirOffset;
2493 LOG(DBG,
"found summary %d: file[%d-%d] sz=%d corr=%d)",summary->offset,nsfs->singleDirOffset, nsfs->singleDirOffset+nsfs->singleDirSize,nsfs->singleDirSize, summary->offset-nsfs->singleDirOffset);
2495 char *buff = mymem + mem_offset;
2496 fillSummaryInfo(info,(
gbPayload *)buff);
2499 LOG(NOTE,
"No EventSummary, search for legacy datap");
2500 summary = nsfs->opendirent(
"legacy");
2502 LOG(NOTE,
"No EventSummary and no DATAP... hacking summary info");
2505 long long int mem_offset = summary->offset - nsfs->singleDirOffset;
2506 char *buff = mymem + mem_offset;
2507 fillSummaryInfo(info,(
DATAP *)buff);
2508 copySummaryInfoIn(info);
void version(std::ostream &os=std::cout)
print HepMC version