34 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
40 if(hdr==NULL || hdr->
keyNr<2) {
44 if(verbose>0) {printf(
"%s()\n", __func__); fflush(stdout);}
62 printf(
"found '%s' at ii=%d\n", hdr->
item[ii].
value, ii);
68 statusSet(status, __func__, __FILE__, __LINE__, ret);
77 strcpy(tac->
c[0].
name,
"Singles");
78 strcpy(tac->
c[1].
name,
"Coincidents");
79 strcpy(tac->
c[2].
name,
"Singles-count-rate");
80 strcpy(tac->
c[3].
name,
"Coincidents-count-rate");
81 strcpy(tac->
c[4].
name,
"Singles-count-rate-DTC");
82 strcpy(tac->
c[5].
name,
"Coincidents-count-rate-DTC");
83 strcpy(tac->
c[6].
name,
"Singles-DTC-decay");
84 strcpy(tac->
c[7].
name,
"Coincidents-DTC-decay");
89 for(; ii<hdr->
keyNr; ii++) {
97 char scan_start_time[32];
98 if(strftime(scan_start_time, 20,
"%Y-%m-%d %H:%M:%S", &start_time)==0) {
104 if(verbose>2) {printf(
" reading data lines...\n"); fflush(stdout);}
105 int i=0, n, stopped=0;
106 while(ii<hdr->keyNr && i<tac->_sampleNr) {
107 if(stopped) {
iftDelete(hdr, ii);
continue;}
108 if(hdr->
item[ii].
value[0]==
'#') {ii++;
continue;}
117 n=sscanf(hdr->
item[ii].
value+20,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
119 &tac->
c[0].
y[i], &tac->
c[1].
y[i], &tac->
c[2].
y[i], &tac->
c[3].
y[i],
120 &tac->
c[4].
y[i], &tac->
c[5].
y[i], &tac->
c[6].
y[i], &tac->
c[7].
y[i]
122 if(n==9) i++;
else stopped=1;
126 if(verbose>2) printf(
" %d data line(s) read.\n", i);
134 tac->
x2[i]=tac->
x1[i+1];
135 tac->
x[i]=0.5*(tac->
x1[i]+tac->
x2[i]);
139 tac->
x2[i]=tac->
x1[i]+(tac->
x2[i-1]-tac->
x1[i-1]);
141 tac->
x2[i]=tac->
x1[i]+1.0;
143 tac->
x[i]=0.5*(tac->
x1[i]+tac->
x2[i]);
181 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
187 if(hdr==NULL || hdr->
keyNr<2) {
191 if(verbose>0) {printf(
"%s()\n", __func__); fflush(stdout);}
203 char scan_start_time[32];
204 int n, year, month, day, hour, min, sec;
206 for(ii=0; ii<hdr->
keyNr; ii++) {
209 n=sscanf(scan_start_time,
"%d-%d-%d %d:%d:%d",
210 &year, &month, &day, &hour, &min, &sec);
213 if(n<8 || n>10)
continue;
215 n=sscanf(hdr->
item[ii].
value,
"%d-%d-%d", &year, &month, &day);
217 if(n==3 || n==6)
break;
226 for(ii=0; ii<hdr->
keyNr; ii++) {
241 sprintf(scan_start_time,
"%04d-%02d-%02d %02d:%02d:%02d",
242 year, month, day, hour, min, sec);
243 if(verbose>11) printf(
" scan_start_time := %s\n", buf);
249 statusSet(status, __func__, __FILE__, __LINE__, ret);
258 strcpy(tac->
c[0].
name,
"Singles");
259 strcpy(tac->
c[1].
name,
"Coincidents");
263 if(verbose>2) printf(
" reading data lines...\n");
266 while(ii<hdr->keyNr && i<tac->_sampleNr) {
270 n=sscanf(hdr->
item[ii].
value,
"%lf %lf %lf",
271 &tac->
x2[i], &tac->
c[0].
y[i], &tac->
c[1].
y[i]);
276 if(verbose>2) printf(
" %d data line(s) read.\n", i);
284 tac->
x1[i]=tac->
x2[i-1];
285 tac->
x[i]=0.5*(tac->
x1[i]+tac->
x2[i]);
290 tac->
x1[i]=tac->
x2[i]-(tac->
x2[i+1]-tac->
x1[i+1]);
294 tac->
x[i]=0.5*(tac->
x1[i]+tac->
x2[i]);
334 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
340 if(hdr==NULL || hdr->
keyNr<2) {
344 if(verbose>0) {printf(
"%s()\n", __func__); fflush(stdout);}
359 struct tm start_time; start_time.tm_mday=0;
361 for(ii=0; ii<hdr->
keyNr; ii++) {
364 if(n<10 || n>19)
continue;
373 if(ii==hdr->
keyNr) printf(
" header does not contain date and time.\n");
374 else printf(
"found '%s' at ii=%d\n", hdr->
item[ii].
value, ii);
381 statusSet(status, __func__, __FILE__, __LINE__, ret);
390 strcpy(tac->
c[0].
name,
"Detector1-Coinc");
391 strcpy(tac->
c[1].
name,
"Detector1-Singl1");
392 strcpy(tac->
c[2].
name,
"Detector1-Singl2");
393 strcpy(tac->
c[3].
name,
"Detector2-Coinc");
394 strcpy(tac->
c[4].
name,
"Detector2-Singl1");
395 strcpy(tac->
c[5].
name,
"Detector2-Singl2");
396 strcpy(tac->
c[6].
name,
"AUX-counts");
400 if(verbose>2) printf(
" reading data lines...\n");
403 double time_of_day, first_tod=0.0, time_since_start, meas_interval;
404 while(ii<hdr->keyNr && i<tac->_sampleNr) {
405 if(stopped) {
iftDelete(hdr, ii);
continue;}
410 n=sscanf(hdr->
item[ii].
value,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
411 &time_of_day, &time_since_start, &meas_interval,
412 &tac->
c[0].
y[i], &tac->
c[1].
y[i], &tac->
c[2].
y[i], &tac->
c[3].
y[i],
413 &tac->
c[4].
y[i], &tac->
c[5].
y[i], &tac->
c[6].
y[i]);
417 if(i==0) {ii++;
continue;}
421 if(time_of_day==0.0 && meas_interval==0.0) {
422 stopped=1;
iftDelete(hdr, ii);
continue;}
423 if(i==0) first_tod=time_of_day;
424 tac->
x1[i]=time_since_start;
425 tac->
x2[i]=time_since_start+meas_interval;
430 if(verbose>2) printf(
" %d data line(s) read.\n", i);
435 if(verbose>4) printf(
" first_tod := %.1lf\n", first_tod);
438 for(i=0; i<tac->
sampleNr; i++) tac->
x[i]=0.5*(tac->
x1[i]+tac->
x2[i]);
441 char scan_start_time[32], sampler_start_time[32];
442 time_t tim=(time_t)first_tod;
449 if(tmtim.tm_year<73) {
450 if(verbose>0) printf(
"data is not Scanditronics but GEMS format\n");
452 strftime(scan_start_time, 32,
"%Y-%m-%d %H:%M:%S", &tmtim)!=0) {
453 printf(
"first_sample_time := %s\n", scan_start_time);
459 if(strftime(scan_start_time, 32,
"%Y-%m-%d %H:%M:%S", &tmtim)==0) {
465 if(start_time.tm_mday==0) {
466 strcpy(sampler_start_time, scan_start_time);
470 if(start_time.tm_hour==0 && start_time.tm_min==0 && start_time.tm_sec==0) {
471 start_time.tm_hour=tmtim.tm_hour;
472 start_time.tm_min=tmtim.tm_min;
473 start_time.tm_sec=tmtim.tm_sec;
475 if(strftime(sampler_start_time, 32,
"%Y-%m-%d %H:%M:%S", &start_time)==0)
476 strcpy(sampler_start_time, scan_start_time);
488 if(sampler_start_time[0])
489 (void)
iftPut(&tac->
h,
"sampler_start_time", sampler_start_time, 1, NULL);
524 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
530 if(hdr==NULL || hdr->
keyNr<2) {
534 if(verbose>0) {printf(
"%s()\n", __func__); fflush(stdout);}
545 if(verbose>0) printf(
"data is GEMS but Scanditronics format\n");
553 struct tm start_time;
555 for(ii=0; ii<hdr->
keyNr; ii++) {
558 if(n<10 || n>19)
continue;
576 statusSet(status, __func__, __FILE__, __LINE__, ret);
585 strcpy(tac->
c[0].
name,
"Detector1-Coinc");
586 strcpy(tac->
c[1].
name,
"Detector1-Singl1");
587 strcpy(tac->
c[2].
name,
"Detector1-Singl2");
588 strcpy(tac->
c[3].
name,
"Detector2-Coinc");
589 strcpy(tac->
c[4].
name,
"Detector2-Singl1");
590 strcpy(tac->
c[5].
name,
"Detector2-Singl2");
591 strcpy(tac->
c[6].
name,
"AUX-counts");
595 if(verbose>2) printf(
" reading data lines...\n");
598 double time_of_day, first_tod=0.0, time_since_start, meas_interval;
599 while(ii<hdr->keyNr && i<tac->_sampleNr) {
600 if(stopped) {
iftDelete(hdr, ii);
continue;}
605 n=sscanf(hdr->
item[ii].
value,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
606 &time_of_day, &time_since_start, &meas_interval,
607 &tac->
c[0].
y[i], &tac->
c[1].
y[i], &tac->
c[2].
y[i], &tac->
c[3].
y[i],
608 &tac->
c[4].
y[i], &tac->
c[5].
y[i], &tac->
c[6].
y[i]);
612 if(i==0) {ii++;
continue;}
616 if(time_of_day==0.0 && meas_interval==0.0) {
617 stopped=1;
iftDelete(hdr, ii);
continue;}
618 if(i==0) first_tod=time_of_day;
619 tac->
x1[i]=time_since_start;
620 tac->
x2[i]=time_since_start+meas_interval;
625 if(verbose>2) printf(
" %d data line(s) read.\n", i);
630 if(verbose>4) printf(
" first_tod := %.1lf\n", first_tod);
633 for(i=0; i<tac->
sampleNr; i++) tac->
x[i]=0.5*(tac->
x1[i]+tac->
x2[i]);
637 char scan_start_time[32], sampler_start_time[32];
638 time_t tim=(time_t)first_tod;
646 if(tmtim.tm_year>71 || tmtim.tm_mday>1) {
647 if(verbose>0) printf(
"data is not GEMS but Scanditronics format\n");
649 strftime(scan_start_time, 32,
"%Y-%m-%d %H:%M:%S", &tmtim)!=0) {
650 printf(
"first_sample_time := %s\n", scan_start_time);
655 if(start_time.tm_hour==0 && start_time.tm_min==0 && start_time.tm_sec==0) {
656 start_time.tm_hour=tmtim.tm_hour;
657 start_time.tm_min=tmtim.tm_min;
658 start_time.tm_sec=tmtim.tm_sec;
659 n=strftime(sampler_start_time, 32,
"%Y-%m-%d %H:%M:%S", &start_time);
660 if(n==0) strcpy(sampler_start_time,
"");
661 strcpy(scan_start_time, sampler_start_time);
663 n=strftime(sampler_start_time, 32,
"%Y-%m-%d %H:%M:%S", &start_time);
664 if(n==0) strcpy(sampler_start_time,
"");
665 start_time.tm_hour=tmtim.tm_hour;
666 start_time.tm_min=tmtim.tm_min;
667 start_time.tm_sec=tmtim.tm_sec;
668 n=strftime(scan_start_time, 32,
"%Y-%m-%d %H:%M:%S", &start_time);
669 if(n==0) strcpy(scan_start_time,
"");
671 if(!scan_start_time[0]) {
685 if(sampler_start_time[0])
686 (void)
iftPut(&tac->
h,
"sampler_start_time", sampler_start_time, 1, NULL);