|
The anti-sorter performs two important tasks:
First we give an overview of the parts of the anti-detector data acquisition and describe the block data format which the anti-sorter uses as input, as well as the event data format used as output in subsection 2. We then give an overview of the coding structure of the anti-sorter process in section 3, which is then followed by a more detailed description of the individual components of the anti-sorter code in sections 4 through 6. A summary of how data integrity is enforced is given in section 7.
The data from each crate is collected by the "anti-collector" (written, developed, and tested by Jeff George) in block form which is subsequently passed to the anti-sorter. The Fastbus crate data structure is shown in the figure below. Each module header contains two pieces of useful information: the number of words in the module event, the event buffer number (8 total for the Lecroy 1877 TDC). The number of words in the module event is essential for finding the next module header, and the event buffer number is used for checking the integrity of the data. All 5 TDC modules are required to have the same event buffer number for a particular event. The use of the event buffer number to check data integrity is described in subsection 4.2 and section 5.
|
module 1 header ith channel number + time edge word jth channel number + time edge word ... module 2 header ith channel number + time edge word jth channel number + time edge word ... |
|---|
Fastbus crate data structure (see also example)
| word 1 | data_size | size of event in bytes |
|---|---|---|
| word 2 | data_type | data type flag (50 for anti-detector data) |
| word 3 | run_number | run number |
| word 4 | nodename | name of online workstation; 8-byte char array containing the string "sukant" including null at end |
| word 5 | ||
| word 6 | server_number | (10 for sukant) |
| word 7 | ltcgps | LTC timestamp at last GPS update (uncorrected) |
| word 8 | event_number | event number |
| word 9 | gps_sec/NSGPS | UTC at last update to seconds (in seconds since 1/1/70) |
| word 10 | gps_usec/NUSGPS | higher precision UTC (in microseconds) |
| word 11 | ltctrg | LTC timestamp at TRG |
| word 12 | ltcbip | LTC timestamp at end of BIP |
| word 13 | T0(1),T0(2) | trigger times for huts 1 and 2 (16 bits each) |
| word 14 | T0(3),T0(4) | trigger times for huts 3 and 4 (16 bits each) |
| word 15 | status_flag | Busy bits and other event status bits (repacked in offline data) |
Anti-detector event header (see also
example);
all data is filled in by the anti-collector,
except for words 13 and 14 which are filled in by the anti-sorter
The next figure gives an overview of how all the input block data is converted to the output anti-detector event format. The block data header consists of 7 words. The first word is the number of words in the buffer. The next 6 words are memory pointers indicating the beginning of 6 blocks of data. The first block is the VME data, the next four blocks are the Fastbus data, and the last block is currently unused.
The Fastbus data has to be digested carefully before it can be merged correctly with the VME data, and several data integrity checks are performed during this procedure. In the next few sections, we now turn to a detailed discussion of the anti-sorter code to see how this is done.
|
block data header (7 words) VME data Fastbus crate 1 data Fastbus crate 2 data Fastbus crate 3 data Fastbus crate 4 data (empty block) |
|---|
|
Event 1 header (15 words) ith channel number, leading edge, trailing edge jth channel number, leading edge, trailing edge ... Event 2 header (15 words) ith channel number, leading edge, trailing edge jth channel number, leading edge, trailing edge ... |
|---|
Input to and output from the "anti-sorter" online process.
Data is received in block form from the anti-collector in "NOVA" buffers of roughly 256 events. This number cannot be much larger because of memory limitations in the SUN workstation which serves as the anti-detector online computer. This number can be made smaller, but was originally chosen to be as large as possible due to lack of buffering, and consequent loss of events, during the dual port memory swiching in the VME crate. Two parameters in the anti-sorter code are relevant to the buffer size: NEVT_MAX_COLLECTOR (currently set to be 300) and NEVT_MAX_SAVE (currently set to be 40). NEVT_MAX_COLLECTOR sets the size of the internal arrays which buffer the crate data as it is sorted, and NEVT_MAX_SAVE sets the size of the internal arrays which buffer the crate data which are unmatched after finishing a particular buffer of data. This unmatched crate data at the end of a buffer is saved until the next buffer of data is received, when it is put at the front of the crate data to be matched. In this way, the 5 blocks of crate data do not need to be perfectly synchronized. In practice, zero to a few events in a buffer of 256 events must be saved across buffers to form complete events for data taking at 10 Hz. This number increases with the data taking rate.
Overview of anti-sorter code (see also flow chart)
|
Overview of Fastbus scanning code in anti-sorter
Note that a current hardware problem in the FSCC occurs on occasion so that the FSCC word counter is incorrect for all events after a certain point in a run. To remedy this, we consider a second criteria for valid beginning of event in case the DC2 byte count and FSCC word count do not match. By chance, the last two words in an event are zero at present. This is because the last module read out is the Struck STR137 latch, which produces 3 words of data. The first word is the 16 bit event number, and the last two words are unused at present. Thus, in case the DC2 byte count and FSCC word count do not match, we look at the last two words of the previous event. If they are both zero, then we assume a valid beginning of event.
Note that in the FSCC header and counter word there is a "bad event bit" (18th bit). We count the number of times this is set true for each crate, and the result is written to the log file. However, no further action is taken at the present time. The setting of the bad event bit seems to be correlated with the above mentioned FSCC word counter hardware problem.
4.2. Loop Through TDC Data
After a valid beginning of an event has been identified, we then
proceed to loop through all of the TDC modules. The first word is the
module header for the first TDC. This header contains two useful
pieces of information:
As we loop through the TDC data words we extract several pieces of information: the module number, the time edge sign, the 16 bit time, and the TDC channel number. The TDC channel number is converted into a global anti-detector PMT number (*3), defined as follows:
crate*480 + module*96 + channelwhere
crate=0,1,2,3 module=0,1,2,3,4 channel=0,1,2,3,...,95The module number is used as a simple check on data integrity, ie if the module number from the TDC data word does not match the TDC module number, we skip the event. The time edge sign, 16 bit time, and channel number are all saved for repacking into the final anti-detector event format (see section 6).
We also check a certain TDC channel in the crate for the trigger time Currently, this is in the 5th TDC module (out of 5 modules), 92nd channel (out of 96 channels). This is saved to calibrate the time of the event. Also, we check the 93rd through 96th channels in 50ns (parameter EVTNUM_DELTA) time window around the trigger time for edges which give us the lowest 4 bits of the event number from the TRG module. These 4 bits are used to obtain the event number, as well as check the integrity of the event number, described in the next subsection.
4.3. Fastbus Crate Event Numbers
The final step in processing the Fastbus crate event is to determine
the event numbers for the data. Note that more than one trigger can
occur during the several microsecond time window of the TDC. The
Struck STR137 latch obtains the event number for the first trigger in
the time window, which also serves as the STOP for the
TDCs [After a 6 microsecond delay.]. Subsequent triggers which
follow within a few microseconds will have new event numbers, which
may or may not increase by units of 1, depending upon the triggering
configuration. The lowest 4 bits of the event number are fed into TDC
channels, and the event number is reconstructed using this
information. The difference between the 4 bit TDC event number for
subsequent triggers in the window and the 4 bit TDC event number for
the trigger associated with the 16 bit Struck latch event number
modulo 16 is used as an offset to be added to the Struck latch event
number.
The event number is uniquely determined, as long as there are less than 16 triggers within a TDC time window (as is the case in current data taking at Super-Kamiokande).
The last three words of the event contain the information latched by the Struck 137 module in the Fastbus crate. The first word contains the 16 bit event number from the TRG module, and the last two words are currently unused. The 16 bit event number is checked for "rollover" by comparing the event number with the previous event number. If the difference is 65536 (variable MAX_EVTNUM_TDC) to within a margin of 1024 (variable EVTNUM_DELTA), then we increase all subsequent event numbers by 65536.
This completes the description of how Fastbus crate data is converted into crate events with event numbers. In the next section we turn to a discussion of how the 4 Fastbus crate and VME crate events are merged into a complete anti-detector event.
The first task of this section is to determine the last event number to look at for this buffer. This is defined to be the lowest event number with all 5 crates of data. The events with event numbers higher than this are saved for matching with data from the next buffer. The reason why we need this is because the block data from the various crates are not perfectly synchronized. It is possible for events to have data spread across two input buffers from the anti-collector.
Next, we check for Fastbus crate event numbers which have no corresponding VME crate event numbers. This is recorded and put into the log file; no further action is initiated at the present time.
Now we loop through all VME crate events. First we check to make sure that the event number is higher than the previous event number, and that the event number has not incremented more than 10000 over the previous event number. If the event violates either of these conditions, we skip the event.
Next, we loop through each Fastbus crate to see if all 4 Fastbus crates have matching event data. Also, we check to see if all 4 Fastbus crates have matching TDC module event buffer numbers (*4) If either condition is violated, then we skip the event.
Finally, we are now ready to prepare the event for output to the "anti-sender" (written, developed, and tested by Andy Stachyra) which buffers, checks, and sends the final data to the event builder. First we write the trigger times for each crate into the 13th and 14th long words (32 bit words) in the header. The 16 bit times are packed sequentially by crate number. Next, we repack the Fastbus TDC data in short word (16 bit) format, described in section 6.
|
Overview of Fastbus and VME crate event merging code in anti-sorter
6.1. Short Word Data Format
The TDC data format comes in long word (32 bit) format. The most
significant 16 bits of the word contain information pertaining to the
channel, module number, and time edge sign. The least significant 16
bits contain the time in TDC counts (0.5 nanosecond per count). Each
logic pulse input represents a single PMT pulse, the width of the
logic pulse being proportional to the integrated charge of the PMT
pulse, and the leading edge of the logic pulse giving the time of the
leading edge of the PMT pulse. Since the channel number information
is repeated twice for each logic pulse, we can repack the two long
words into 3 short words (16 bit), thus reducing the overall data size
by roughly 30%.
The figure below summarizes the final PMT hit format of 3 short words. The first short word contains 4 noise filter bits and a 12 bit channel number (see formula in subsection 4.2). The second short word contains the 16 bit leading edge time, and the third short word contains the 16 bit trailing edge time.
|
Short word format of repacked PMT hit
Since the passthrough filter bit is currently set to be always true, there is no filtering of the PMT hits at the present time.
6.3. Treatment of TDC Time Edge Anomalies
Examples of TDC data anomalies include multiple leading or trailing
edges, and single leading or trailing edges. Multiple same sign edges
can occur if the logic pulse input into the TDC is noisy or has
reflections. Single leading or trailing edges can occur if the logic
pulse input happens to fall across the end of the TDC window.
If a leading time edge for a channel in the data stream is not followed by a trailing edge, we write a short word of zero for the trailing edge time. Similarly, if a trailing edge is not preceded by a leading edge, we write a short word of zero for the leading edge time.
Note that size of the final output buffer passed to the anti-sender must be an integral number of long words. If the number of short words resulting from the repacking of the event is odd, then we write a "dummy" PMT hit at the end of the event, with channel number 0xffff followed by two times of zero.
After processing each buffer of data, the anti-sorter code also performs online data quality monitoring. Three quantities are monitored for each input data buffer received from the anti-collector:
The following figure summarizes the quantities used for enforcing the integrity of the data.
checks performed during the scanning of Fastbus data
(section 4):
(to determine whether to issue Fastbus controller reset signal):
|
Summary of data integrity checks performed by anti-sorter