Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:15:17

0001 #!/bin/bash
0002 
0003 # Usage check
0004 if [ $# -ne 2 ]; then
0005     echo "Usage: $0 MIN_RUN MAX_RUN"
0006     exit 1
0007 fi
0008 
0009 min_run=$1
0010 max_run=$2
0011 
0012 # Validate that both are integers
0013 if ! [[ "$min_run" =~ ^[0-9]+$ && "$max_run" =~ ^[0-9]+$ ]]; then
0014     echo "Error: MIN_RUN and MAX_RUN must be integers."
0015     exit 1
0016 fi
0017 
0018 query="SELECT runnumber
0019        FROM run 
0020        WHERE runtype = 'cosmics'
0021        AND runnumber BETWEEN $min_run AND $max_run
0022        AND brtimestamp IS NOT NULL
0023        AND ertimestamp  IS NOT NULL
0024        AND ertimestamp > brtimestamp
0025        AND (ertimestamp - brtimestamp) > INTERVAL '10 minutes'
0026        ORDER BY runnumber;"
0027 
0028 result=$(psql -h sphnxdaqdbreplica -d daq -t -A -F"    " -c "$query")
0029 
0030 echo "$result" > runlist.txt
0031 
0032 echo "Done. Run list has been saved to runlist.txt"