Technical Documentation of the Auto-Combine Function
Code located at /star/u/starqa/QA/
The name of the code is newFilesCheck.c
The makefile is makeFilesCheck.
Synopsis:
This new program executes every 30 minutes. It requests a list of all new files in DAQInfo that are available to be QA’d. When it finds multiple files from the same run number it will automatically combine them together. A log of previously combined files is also kept so that additional files that become available later can be added to a previously combined run number.
Outline of Code:
- The code reads in the timestamp of the last time newFilesCheck.c was executed. This timestamp is in the file “markerAutoCombine.txt”.
- It queries DAQInfo for any new files available after this timestamp.
- If there are new files it begins a for loop of the possible trigger types. Steps 4-6 are run for each trigger type.
- It checks to see if files with the same trigger and run number have been auto-combined before by looking in the log file “listofFiles.txt”. If there is a match it will move to step 5. If there isn’t a match it will query DAQInfo again but with no requirement on when the files become available (i.e. checking for single files coming available in ~30 minute increments). If the number of files returned is less than two then the code cycles to the next trigger type (back to the beginning of step 4).
- The files are now ready to be combined. The list of files (new and previously combined, if any) are inserted into Offline QA where the daemon can check for new requests. Also, the id of the output files is designed to start with zz and end with a random number up to 5 digits.
- The program then waits for the daemon to return the status of ‘Y’ meaning the combining is done. The output combined file is stored in /star/data10/qa/. The program then writes the run number, number of files now in the combined file, trigger type and the id to a file called “listofFilesNew.txt”.
Example:
12038114 05 st_ph zz4539
- Next we want to delete redundant files (i.e. previously combined files that were just updated with new files). This is done by checking the contents of “listofFilesNew.txt” with “listofFiles.txt”. If the same run number appears in both files then the older file (i.e. that in listofFiles.txt) is deleted. Once this is done a new “listofFiles.txt” is written in order to start this process over again in the next execution (30 minutes later). Also, if more than 300 files are in the log file the oldest files at the bottom are deleted.
- A new timestamp is recorded in “markerAutoCombine.txt”.
The crontab command is:
0 * * * * /star/u/starqa/QA/newFilesCheck
30 * * * * /star/u/starqa/QA/newFilesCheck