#!/bin/sh # Set up LIGOtools (at either site), in case it's not already set up #\ # (following lines executed by sh but not by tclshexe) #\ if /usr/bin/test -x /opt/CDS/c/ligotools/bin/use_ligotools; then #\ eval `/opt/CDS/c/ligotools/bin/use_ligotools` #\ elif /usr/bin/test -x /opt/LLO/c/controls/ligotools/bin/use_ligotools; then #\ eval `/opt/LLO/c/controls/ligotools/bin/use_ligotools` #\ fi #\ ## The next line tells sh to execute the script using tclshexe \ exec tclshexe "$0" ${1+"$@"} #-- Load Tcl libraries package require segments package require tconvert #-- Figure out the name of this script set script [file tail [info script]] #-- Figure out what site we're at set basedir "" foreach site [list llo lho] { set dir /cvs/cds/$site/web/scirun/S3/LockStatistics/S3segments if [file exists $dir] { set basedir $dir break } } if { $basedir == "" } { puts "Cannot determine the site" exit 1 } #-- Figure out site-dependent things switch $site { "lho" { set ifolist {H1 H2} } "llo" { set ifolist {L1} } } set conlogdir /cvs/cds/$site/conlog #-- Look up the range of the S3 run (with some extra at the ends) set s3start [tconvert Oct 31 2003 0:00 UTC] set s3stop [tconvert Jan 31 2004 0:00 UTC] #-- Loop over ifos foreach ifo $ifolist { #-- Initialize some things set seglist {} set lastseginfo "" set segfile $basedir/S3${ifo}v00_segs.txt #-- If the segment file already exists, read it. This allows us to do an #-- incremental conlog query rather than querying the whole run. set qstart $s3start if [file exists $segfile] { set seglist [SegRead $segfile] if { [llength $seglist] > 0 } { #-- Query should start after last known segment set qstart [lindex [lindex $seglist end] 1 ] } } #-- If query interval is empty, just bail out if { $qstart >= $s3stop } continue #-- Execute a conlog query set data [ exec $conlogdir/bin/conlog_science $ifo 10 $qstart $s3stop gps ] #-- Pick out the end time of the query regexp {Between +\d+- *(\d+)} $data - queryend #-- Parse the segment list foreach {- segnum duration start stop} [regexp -all -inline -line \ {^..-(\d+)\s+(\d+).+(\d{9,10})- *(\d{9,10})} $data] { if { $stop < $queryend } { lappend seglist [list $start $stop $segnum $duration] } else { set lastseginfo "# Segment $segnum started at $start, still going at $stop after $duration sec" } } #-- Write out the segment list to a temporary file set tempfile temp.$script.[info hostname].[pid] set fid [open $tempfile w] puts $fid "# S3 $ifo segment list from $script at\ [clock format [clock seconds]]" puts $fid "# num start stop duration" foreach seg $seglist { foreach {start stop segnum duration} $seg break puts $fid [format "%4d %10d %10d %6d" $segnum $start $stop $duration ] } if { $lastseginfo != "" } { puts $fid $lastseginfo } close $fid #-- Now rename the temp file file rename -force $tempfile $segfile }