- Enhanced and debugged histogram memory for AMOR

* added PROJECT both in HM and driver code
  * added single detector support.
- Removed several bugs in the AMOR data bit.
- Updated documentation
This commit is contained in:
cvs
2001-08-17 14:33:05 +00:00
parent a538361516
commit db6c355f44
56 changed files with 4060 additions and 426 deletions

View File

@@ -731,9 +731,9 @@
uint ui4;
usint ui2[2];
uchar ui1[4];
} lwl_hdr, xData, yData;
} lwl_hdr, xData, yData, edData;
int xPos, yPos, iTime, dataPos;
int xPos, yPos, iTime, dataPos, edNum;
signed int sPosx, sPosy;
int i, j, is, ts, left, right, middl, not_finished;
uint *edge_pntr;
@@ -868,6 +868,122 @@
*/
dataPos = yPos*psdXSize*Tof_edges[0]->n_bins +
xPos*Tof_edges[0]->n_bins + middl;
/* UD must come but the bit is not yet defined
if ((Hm_mode_UD != 0) &&
((lwl_hdr.ui4 & LWL_HDR_UD_MASK) != 0)) {
dataPos +=
(psdXSize*psdYSize+MAX_PSD_ED)*Tof_edges[0]->n_bins ;
}
*/
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_ED_MASK) == 0) {
/*
we have located a single detector packet from AMOR. We need to
read the detector number
*/
VmioBase[VMIO_PORT_A] = 0xff; /* Set timer level (if present) */
for (i=0; i<1000; i++) {
edData.ui4 = *Lwl_fifo; /* Get the detector number */
if (edData.ui4 != LWL_FIFO_EMPTY) break;
taskDelay (0); /* But wait if FIFO is slow! */
}
if (xData.ui4 == LWL_FIFO_EMPTY) {
printf ("Time-out getting detector number !\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 single detector packet.
*/
edNum = edData.ui2[1];
if(edNum < 0 || edNum >= MAX_PSD_ED){
printf("Got invalid detector number %d\n",edNum);
continue;
}
/*
Extract time stamp and match to the appropriate time bin.
*/
iTime = lwl_hdr.ui4 & LWL_PSD_TIME;
if(Dbg_lev1){
printf("Received single detector hit at no, time: %d, %d\n",
edNum, 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 = (psdYSize*psdXSize + edNum)*Tof_edges[0]->n_bins + middl;
/* UD must come but the UD bit is not defined......
if ((Hm_mode_UD != 0) &&
((lwl_hdr.ui4 & LWL_HDR_UD_MASK) != 0)) {
dataPos +=
(psdXSize*psdYSize+MAX_PSD_ED)*Tof_edges[0]->n_bins ;
}
*/
switch(Bytes_per_bin)
{
case 1: