- Added support for EMBL PSD detectors for TRIS and AMOR.
This commit is contained in:
@@ -84,6 +84,10 @@
|
||||
** performing data acquisition in
|
||||
** SQHM__TOF mode, i.e. for data from
|
||||
** time-of-flight detectors.
|
||||
** SinqHM_filler_daq_psd - routine called by SinqHM_filler_daq for
|
||||
** performing data acquisition in
|
||||
** SQHM__HM_PSD mode, i.e. for data from
|
||||
** EMBL detectors.
|
||||
**
|
||||
** SinqHM_filler_daq - routine called by SinqHM_filler for
|
||||
** performing data acquisition.
|
||||
@@ -511,7 +515,7 @@
|
||||
** .. a message waiting for us. Return to process it.
|
||||
*/
|
||||
}
|
||||
/*
|
||||
/*
|
||||
**-----------------------------------------------------------------------------
|
||||
*/
|
||||
void SinqHM_filler_daq_tof () {
|
||||
@@ -692,6 +696,207 @@
|
||||
if ((Tsi_flags & STATUS_FLAGS__UD) != 0) printf (" UD");
|
||||
if ((Tsi_flags & STATUS_FLAGS__GU) != 0) printf (" GU");
|
||||
|
||||
is = timer_settime (FillTimerId, ~TIMER_ABSTIME, &FillerTime, NULL);
|
||||
if (is != 0) {
|
||||
printf ("%s -- failed to set timer\n", Filler_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Our flag has been set. There should be ..
|
||||
** .. a message waiting for us. Return to process it.
|
||||
*/
|
||||
}
|
||||
/*
|
||||
**-----------------------------------------------------------------------------
|
||||
*/
|
||||
void SinqHM_filler_daq_psd () {
|
||||
/* =====================
|
||||
** Routine to handle Time-of-flight Mode
|
||||
** Note:
|
||||
** Lwl_fifo could, in principle, be accessed via a register for better
|
||||
** efficiency. However, this can cause trouble with the GDB debugger
|
||||
** when single stepping. I think this is probably connected with
|
||||
** instruction pipe-lining.
|
||||
** For the time being, the register copy of Lwl_fifo will NOT be used.
|
||||
*/
|
||||
register uint *my_lwl_fifo;
|
||||
register union {
|
||||
uint ui4;
|
||||
usint ui2[2];
|
||||
uchar ui1[4];
|
||||
} lwl_hdr, xData, yData;
|
||||
|
||||
int xPos, yPos, iTime, dataPos;
|
||||
int i, j, is, ts, left, right, middl, not_finished;
|
||||
uint *edge_pntr;
|
||||
char er_eol[] = {ESC, '[', '0', 'J'}; /* Erase to End-of-Line */
|
||||
uchar my_buff[32];
|
||||
uint *histlPtr = (uint *)Hist_base_addr;
|
||||
usint *histsPtr = (usint *)Hist_base_addr;
|
||||
uchar *histcPtr = (uchar *)Hist_base_addr;
|
||||
|
||||
/*-----------------------------------------------
|
||||
** Make register copies of some items for speed.
|
||||
*/
|
||||
my_lwl_fifo = Lwl_fifo;
|
||||
/*-----------------------------------------------*/
|
||||
while (Filler_flag == 0) { /* Loop till flag gets set */
|
||||
|
||||
lwl_hdr.ui4 = *Lwl_fifo; /* Read a header from the FIFO */
|
||||
|
||||
if (lwl_hdr.ui4 == LWL_FIFO_EMPTY) {
|
||||
taskDelay (0); /* If FIFO is empty, we can take a breather! */
|
||||
|
||||
}else if ( (lwl_hdr.ui4 & LWL_HDR_TYPE_MASK) == LWL_PSD_DATA) {
|
||||
/*
|
||||
we have located a PSD data packet. Let us read the xPos and
|
||||
yPos packes.
|
||||
*/
|
||||
VmioBase[VMIO_PORT_A] = 0xff; /* Set timer level (if present) */
|
||||
|
||||
for (i=0; i<1000; i++) {
|
||||
xData.ui4 = *Lwl_fifo; /* Get the x Position */
|
||||
if (xData.ui4 != LWL_FIFO_EMPTY) break;
|
||||
taskDelay (0); /* But wait if FIFO is slow! */
|
||||
}
|
||||
if (xData.ui4 == LWL_FIFO_EMPTY) {
|
||||
printf ("Time-out getting X position !\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i=0; i<1000; i++) {
|
||||
yData.ui4 = *Lwl_fifo; /* Get the y Position */
|
||||
if (yData.ui4 != LWL_FIFO_EMPTY) break;
|
||||
taskDelay (0); /* But wait if FIFO is slow! */
|
||||
}
|
||||
if (yData.ui4 == LWL_FIFO_EMPTY) {
|
||||
printf ("Time-out getting Y position!\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
check if data aquisition is active
|
||||
*/
|
||||
if ((lwl_hdr.ui4 & Lwl_hdr_daq_mask) != Lwl_hdr_daq_soll) {
|
||||
/* Some header bits are not what they should be (e.g. NRL
|
||||
** ow PWF may be set) so skip the event.
|
||||
*/
|
||||
N_skipped++;
|
||||
if (Dbg_lev1) {
|
||||
printf("Skipped header: 0x%08x\n"
|
||||
" Mask: 0x%08x\n"
|
||||
" Soll: 0x%08x\n",
|
||||
lwl_hdr.ui4, Lwl_hdr_daq_mask, Lwl_hdr_daq_soll);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
We have a valid PSD packet. Find and check positions.
|
||||
*/
|
||||
xPos = (xData.ui2[1] - psdXOffset)/psdXFactor;
|
||||
yPos = (yData.ui2[1] - psdYOffset)/psdYFactor;
|
||||
if(xPos < 0 || xPos > psdXSize)
|
||||
{
|
||||
printf("X position out of range: %d, alllowed 0 - %d\n",
|
||||
xPos, psdXSize);
|
||||
continue;
|
||||
}
|
||||
if(yPos < 0 || yPos > psdYSize)
|
||||
{
|
||||
printf("Y position out of range: %d, alllowed 0 - %d\n",
|
||||
yPos, psdYSize);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
Extract time stamp and match to the appropriate time bin.
|
||||
*/
|
||||
iTime = lwl_hdr.ui4 & LWL_PSD_TIME;
|
||||
if(Dbg_lev1){
|
||||
printf("Received detector hit at x,y, time: %d, %d, %d\n",
|
||||
xPos, yPos, iTime);
|
||||
}
|
||||
|
||||
edge_pntr = Tof_edges[0]->edges;
|
||||
left = 0;
|
||||
right = Tof_edges[0]->n_bins;
|
||||
middl = (left + right)/2;
|
||||
not_finished = True;
|
||||
iTime -= Tof_dts_soll;
|
||||
while (not_finished) {
|
||||
switch (right - left) {
|
||||
case 0:
|
||||
not_finished = False;
|
||||
break;
|
||||
case 1:
|
||||
middl = (iTime >= edge_pntr[right]) ? right : left;
|
||||
not_finished = False;
|
||||
break;
|
||||
default:
|
||||
middl = (left + right)/2;
|
||||
if (iTime == edge_pntr[middl]) {
|
||||
not_finished = False;
|
||||
}else if (iTime > edge_pntr[middl]) {
|
||||
left = middl;
|
||||
}else {
|
||||
right = middl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Dbg_lev1){
|
||||
printf("Matched time stamp %d into bin %d\n", iTime,middl);
|
||||
}
|
||||
|
||||
/*
|
||||
calculate histogram position to update
|
||||
*/
|
||||
dataPos = yPos*psdXSize*Tof_edges[0]->n_bins +
|
||||
xPos*Tof_edges[0]->n_bins + middl;
|
||||
switch(Bytes_per_bin)
|
||||
{
|
||||
case 1:
|
||||
histcPtr[dataPos]++;
|
||||
break;
|
||||
case 2:
|
||||
histsPtr[dataPos]++;
|
||||
break;
|
||||
case 4:
|
||||
histlPtr[dataPos]++;
|
||||
break;
|
||||
}
|
||||
|
||||
VmioBase[VMIO_PORT_A] = 0x00; /* Reset timer level (if present) */
|
||||
N_events++;
|
||||
}else if ((lwl_hdr.ui4 & LWL_HDR_TYPE_MASK) == LWL_PSD_TSI) {
|
||||
/*
|
||||
we have located a PSD style TSI telegram
|
||||
*/
|
||||
process_psd_tsi(lwl_hdr.ui4);
|
||||
}else {
|
||||
/* Anything else gets flushed */
|
||||
lwl_Packet_Read (lwl_hdr.ui4, my_buff);
|
||||
}
|
||||
|
||||
if (FillTimer_expired) {
|
||||
if (Print_hdr) printf ("\nTaking data in PSD Mode\n"
|
||||
" #-Events #-Skip #-TSI #-Hits %s",
|
||||
"#-Flash Delay-Time Sync-Status\n");
|
||||
Print_hdr = False;
|
||||
FillTimer_expired = False;
|
||||
printf ("\r%10u %10u %10u %10u %10u %10u %s", N_events, N_skipped,
|
||||
(N_no_coin_tsi + N_coin_tsi), psdHitCount,
|
||||
psdFlashCount, Dt_or_dts.dts, er_eol);
|
||||
if (Daq_active) printf (" DAQ");
|
||||
if ((Tsi_flags & STATUS_FLAGS__PF) != 0) printf (" PF");
|
||||
if ((Tsi_flags & STATUS_FLAGS__SWC) != 0) printf (" SWC");
|
||||
if (Nrl_active) printf (" NRL");
|
||||
if ((Tsi_flags & STATUS_FLAGS__SYNC3) != 0) printf (" SYNC3");
|
||||
if ((Tsi_flags & STATUS_FLAGS__SYNC2) != 0) printf (" SYNC2");
|
||||
if ((Tsi_flags & STATUS_FLAGS__SYNC1) != 0) printf (" SYNC1");
|
||||
if ((Tsi_flags & STATUS_FLAGS__SYNC0) != 0) printf (" SYNC0");
|
||||
if ((Tsi_flags & STATUS_FLAGS__UD) != 0) printf (" UD");
|
||||
if ((Tsi_flags & STATUS_FLAGS__GU) != 0) printf (" GU");
|
||||
|
||||
is = timer_settime (FillTimerId, ~TIMER_ABSTIME, &FillerTime, NULL);
|
||||
if (is != 0) {
|
||||
printf ("%s -- failed to set timer\n", Filler_name);
|
||||
@@ -774,6 +979,7 @@
|
||||
SinqHM_filler_daq_hrpt (); /* Do HRPT (CERCA) type detectors */
|
||||
break;
|
||||
case SQHM__HM_PSD:
|
||||
SinqHM_filler_daq_psd (); /* Do PSD readout */
|
||||
break;
|
||||
case SQHM__TOF:
|
||||
SinqHM_filler_daq_tof (); /* Do time-of-flight read-out */
|
||||
|
||||
Reference in New Issue
Block a user