Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:14:30

0001 #!/bin/bash
0002 # This script processes a list of run numbers and retrieves event numbers
0003 
0004 # Define the input file containing the list of run numbers
0005 input_file="GoldenEmcalRunList.txt"
0006 
0007 # Define the output file where the event numbers will be saved
0008 output_file="EventNumberList_GoldenEmcalRuns.txt"
0009 
0010 # Empty the output file before starting (if the file already exists, its contents will be deleted)
0011 > "$output_file"
0012 
0013 # Read each runnumber from the input file and process it one by one
0014 while IFS= read -r runnumber; do
0015     # For each runnumber, execute the psql command to query event numbers from database
0016     # The -h option specifies the host (sphnxdaqdbreplica)
0017     # The -t and -A options format the output to remove extra lines and formatting
0018     # The -F" " option sets the field separator to a space
0019     # The result of the query is appended to the output file
0020     echo "Run # $runnumber"
0021     psql -h sphnxdaqdbreplica daq -t -A -F" " -c "SELECT * FROM event_numbers WHERE runnumber = $runnumber;" >> "$output_file"
0022 done < "$input_file"
0023 
0024 # After all runnumbers have been processed, print a message indicating the task is complete
0025 echo "All runnumbers processed. Results saved in $output_file"
0026