README -- file_output 2/16/2004 D. Lawrence The files in this directory implement the DAQ's file output naming scheme. This is a pretty convoluted system so I'll try and describe it here: In order to have CODA automatically split the run into files of a specific size, several things must be done: 1. The CODA configuration in the msql database must have {@split_file} {CODA} for the "code" field of the coda_0 line in the main table for the configuration. Note that this means EVERY configuration that wishes to split files must have this. 2. There must exist an entry in the "*_option" table for the configuration with name equal to "dataFile and value equal to "@split_file". Again, this must be done for EVERY configuration. 3. There must exist an entry in the "*_option" table for the configuration with name equal to "SPLITMB and value equal to the number of megabytes to split on. Typically, this is just set to 2000. 4. The file "split_file.tcl" must be passed to the event recorder when it is started. Use the -f option for this. An example is given in split_file.tcl. The output_disk.pl script is run from split_file.tcl to check that there is room on the raid disk before we create a new file there. If not, then the link /home/primex/raid is switched to point to an empty disk. (This feature is currently disabled in the testlab setup since we don't have multiple raid disks and /home/primex/raid is a real directory.) DATABASE INSERTS/UPDATES An entry for each file is inserted into the Run_Files table of the primex_online MySQL database from split_file.tcl. New inserts are done using NULL for the "Number_of_Events". A special program, "count_events" was written to quickly find the number of events in a file by looking only at the front and back. (Source code is in /home/primex/DAQ/src/count_events.) There are two places where the number of events are updated for entries in the Run_Files datbase. The first is in split_file.tcl itself. This is so the entries will be updated as the files are closed and the Time field will be at least semi-accurate. It also will help make sure at least some files for a given run will have this information in the DB should the DAQ crash. The second place where "Number_of_Events" is updated is in the end.pl script. This is needed because split_file.tcl is not called when the run is ended and the last file is closed. WARNING As stated at the top of this document, this system is rather convoluted with scripts calling scripts and executed shell commands, any one of which could fail. In particular, Tcl is really bad about choking and dying if every little thing is not perfectly in place. That will make this a hard system to debug when an error occurs (which is why I wrote this).