#!/bin/bash
source /pbs/throng/virgo/userDev/frobinet/virgo/env-virgo.sh
. /usr/local/shared/bin/xrootd_env.sh
export PATH=/usr/local/bin/:$PATH

for file in ./segments_week/segments_*.txt; do
    
    week_s=`echo $file | cut -f 3 -d '_'`
    week_e=`echo $file | cut -f 4 -d '_'`
    week_e=`echo $week_e | cut -f 1 -d '.'`
    
    echo ${week_s}-${week_e}
    outdir=./perf/${week_s}-${week_e}
    mkdir -p $outdir
    rm -fr ${outdir}/*

    gps_start=`head -n 1 $file | awk '{print $1}'`
    gps_end=`tail -n 1 $file | awk '{print $2}'`
    vetoperf.exe "channel=V1:Hrec_hoft_16384Hz" "segments=$file" vetoes="./V1:*.txt" "outdir=${outdir}" "gps-start=${gps_start}" "gps-end=${gps_end}"

done
