Index: trunk/DataCheck/FillAuxData.sh
===================================================================
--- trunk/DataCheck/FillAuxData.sh	(revision 12676)
+++ trunk/DataCheck/FillAuxData.sh	(revision 12679)
@@ -34,5 +34,5 @@
 # get last 2 nights
 dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` )
-dates=( "2011/11/15" )
+dates=( "2011/11/23" )
 
 # do rsync for rawfiles of these dates
@@ -68,8 +68,13 @@
       echo $thresholdfile" not found"
    fi
-   biascontrolfile=$auxdir/$runnumber.BIAS_CONTROL_VOLTAGE.fits
-   if ! [ -e $biascontrolfile ]
+   biasvoltagefile=$auxdir/$runnumber.BIAS_CONTROL_VOLTAGE.fits
+   if ! [ -e $biasvoltagefile ]
    then 
-      echo $biascontrolfile" not found"
+      echo $biasvoltagefile" not found"
+   fi
+   biascurrentsfile=$auxdir/$runnumber.BIAS_CONTROL_CURRENTS.fits
+   if ! [ -e $biascurrentsfile ]
+   then 
+      echo $biascurrentsfile" not found"
    fi
 
@@ -79,18 +84,53 @@
    for filenum in ${filenumbers[@]}
    do
+      filenum=42
       echo $filenum
-      query2="SELECT fRunStart from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
-      starttime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query2" 2>> $logfile`
-      query3="SELECT fRunStop from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
-      stoptime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query3" 2>> $logfile`
-      echo "start: "$starttime 
-      echo "stop: "$stoptime 
+      #query2="SELECT fRunStart from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
+      #starttime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query2" 2>> $logfile`
+      #query3="SELECT fRunStop from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
+      #stoptime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query3" 2>> $logfile`
+      #echo "start: "$starttime 
+      #echo "stop: "$stoptime 
+      rawfile=/loc_data/raw/$date/$runnumber"_"`printf %03d $filenum`.fits
+      #/home/fact/FACT++/fitsdump -h -t Events $rawfile 
+      mjdref=`/home/fact/FACT++/fitsdump -h -t Events $rawfile  2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
+      tstarti=`/home/fact/FACT++/fitsdump -h -t Events $rawfile  2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
+      tstartf=`/home/fact/FACT++/fitsdump -h -t Events $rawfile  2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
+      tstart=`echo " $tstarti + $mjdref + $tstartf " | bc -l`
+      tstopi=`/home/fact/FACT++/fitsdump -h -t Events $rawfile  2>/dev/null | grep 'TSTOPI' | grep -E -o '[0-9]{5}'`
+      tstopf=`/home/fact/FACT++/fitsdump -h -t Events $rawfile  2>/dev/null | grep 'TSTOPF' | grep -E -o '0[.][0-9]+'`
+      tstop=`echo " $tstopi + $mjdref + $tstopf " | bc -l`
+      echo "tstart in mjd: "$tstart
+      echo "tstop in mjd: "$tstop
+      
+      # get information from tracking
       echo $trackingfile
-      ftcopy $trackingfile'[Time>55889.1][col Ra]' - | ftstat - 
+      ramin=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'min' | grep -E -o '[0-9][.][0-9]+'`
+      ramax=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'max' | grep -E -o '[0-9][.][0-9]+'`
+      ramean=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'mean' | grep -E -o '[0-9][.][0-9]+'`
+      decmin=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'min' | grep -E -o '[0-9][.][0-9]+'`
+      decmax=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'max' | grep -E -o '[0-9][.][0-9]+'`
+      decmean=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'mean' | grep -E -o '[0-9][.][0-9]+'`
+      echo "ra: "$ramin" - "$ramean" - "$ramax
+      echo "dec: "$decmin" - "$decmean" - "$decmax
+
+      # get information from trigger
+      echo $triggerratefile
+      #ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat -
+      ratemin=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]+'`
+      ratemax=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]+'`
+      ratemean=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]+'`
+      echo "rate: "$ratemin" - "$ratemean" - "$ratemax
+
+      # get information from trigger
+      echo $thresholdfile
+      echo "ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat -"
+      threshmin=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]+'`
+      threshmax=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]+'`
+      threshmean=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]+'`
+      echo "rate: "$threshmin" - "$threshmean" - "$threshmax
+
 
       exit
-# notes: 
-# ftcopy /loc_data/aux/2011/11/23/20111123.BIAS_CONTROL_NOMINAL.fits'[Time>55889.1][col Time]' - | ftstat - 
-# ftcopy /loc_data/aux/2011/11/15/20111115.DRIVE_CONTROL_TRACKING_POSITION.fits'[Time>55880.8 && Time< 55880.9][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat -
    done
    
