Privacy and Security Notice

Calling all Indices! A new utility for the RECSIS programmer. next up previous
Next: SCAT/EventStore/ced/swish Interface: interprocess communication Up: Example of getting access Previous: The Hardcore FORTRAN way

Calling all Indices! A new utility for the RECSIS programmer.

The previous example was not all that difficult, however keeping track of which index in which bank quickly becomes a headache. A utility has been written that will make this easier. The utility consists of a perl script that reads in clasbanks.ddl and creates two include files, include/clas_index.inc and include/clas_offsets.inc. The include file clas_offsets.inc contains a list of parameter statements which will give you the variable offset within the bank. The parameters are name with the following syntax, bankname_variablename , where variablename is taken from the ddl file. Below is the section for the CC bank:

[] C    Offsets for the CC bank follow

 

          integer CC_ID           !  the address of the  hit detector element

          parameter ( CC_ID = 1 )

          integer CC_TDC          !  tdc information

          parameter ( CC_TDC = 2 )

          integer CC_ADC          !  adc information

          parameter ( CC_ADC = 3 )

Note that even the comments get included in the file so that this file readable. Now instead of remembering if the TDC's come second or third in the CC bank, you can index via IW(ind+cc_tdc). Also the use of such a script and include files makes it much easier to insert new columns into a BOS bank definition. If the offsets are used throughout the code, the changes to the BOS bank offsets become transparent. That is if for some reason CC_TDC became 3, none of the existing code would have to be changed, as long as clas_offsets.inc is updated. Unfortunately all the existing FORTRAN code has hardwired variable offsets throughout, making future changes next to impossible.

With an easy way to get the variable offsets, is there an easy way to get the bank offsets? Unfortunately the bank offsets are not as clear cut as the variable offsets, since the bank offsets change on an event by event basis. What is available is a routine recutl/get_all_index.F which when called will fill the common block contained in, include/clas_index.inc, with all the bank indices available. Below is a section of code that demonstrates how to use these features.

[] 1.  #include "bcs.inc"

2.  #include "clas_offsets.inc"

3.  #include "clas_index.inc"

4.   

5.              call get_all_index

6.   

7.              write(*,*)"event number=",iw(head_ind+head_nevent)

8.   

9.              do 201 while (cc_ind16 .ne. 0)

10.             do 199 ic = 1, IWROW(cc_ind)

11.               call hfill(99, iw16(cc_ind16 + cc_adc + (ic-1)*IWCOL(cc_ind)),

12.        1                           iw16(cc_ind16 + cc_tdc + (ic-1)*IWCOL(cc_ind)),

13.        2                          1.0)

14.  199     continue

15.             cc_ind = IWNXT(cc_ind)

16.             cc_ind16 = 2*cc_ind

17.  201    continue

In lines 14#43 we include the appropriate include files. On line 5 get_all_index is called which get all the indices for all the available banks. On line 7 the event number is pulled out of the HEAD bank, where head_ind is the index of the HEAD bank and head_nevent is the offset for the event number in the HEAD bank. Notice this was all done on one line of code. In lines 94#416 the Cerenkov TDC and ADC values are extracted. First on line 9 a check is made to make sure the CC bank exists. On line 10 a loop is performed from the first row to the last row of the CC bank where each row represents a hit[*]. On lines 11,12 and 13 hfill is called and the values for the TDC and ADC information is set to HBOOK. After a loop over all the hits in one sector (bank) a check is made to see if there is another CC bank at line 15 and if so it overwrites the index for the next CC bank in cc_ind[*]. Note that we had to multiply the index by 2 since CC is a 16 bit bank. A word of warning, this example is dangerous since it overwrites the value of cc_ind. In order to get the index for the CC bank after this piece of code, the user would need to call get_all_index again. Generally code for 32 bit banks will be much simpler and easier to read and understand.

The routine get_all_index.F first looks in the IW array for the bank index and then searches the JW array. If you don't know which array contains the bank, there is a variable, BankName_array (ie. cc_array), that is set to 1 if the bank was found in the IW array and 2 if the bank was found in the JW array. Indexing within the BOS IW or JW array with this system is convenient as listing the BankName+Column+Row where BankName = BankName_ind, Column = BankName_Variable and Row (or Hit) = (counter-1)*IWCOL(BankName_ind).


next up previous
Next: SCAT/EventStore/ced/swish Interface: interprocess communication Up: Example of getting access Previous: The Hardcore FORTRAN way
Arne Freyberger
11/3/1997