#!/bin/tcsh -f
#

# 
# process HDF_Eventpar on selected hdf file
#

if ( `hostname` != 'asellus' ) then
   echo "Error, run this script on host 'asellus' only"
   exit
endif

set cdir=`FDMgetpath`	# get current path, starting from the AC_Bias root

echo ${cdir} | grep 'ACBias_Analysis' > /dev/null
if ( ${status} != 0 ) then
   echo "Error, processing is only allowed in 'analysis' path"
   exit
endif 

if ( ${cdir} == '' ) then
   echo "Error, no proper path for data processing"
   exit
endif

set ddir='/ssd'`echo ${cdir} | sed 's^Analysis^Measurements^'`

if ( ! -d ${ddir} ) then
   echo "Error, data directory does not exist on SSD disc: ${ddir}"
   exit
endif

setenv NO_AT_BRIDGE 1    # prevent unneccesary error messages from GTK3

#source /opt/local/TN/env/tesfdmtools.csh       # standard scripts
#========================================== # edited scripts ( temporarely )
#setenv PYTHONPATH  /home/devries/Athena/git/tesfdmtools
#set path = ( /home/devries/Athena/git/tesfdmtools/scripts /home/devries/Athena/git/bin $path )
#===========================================

if ( $# > 0 ) then

   foreach file ( `ls -1 ${ddir}/*.h5` )

      basename ${file} | grep noise > /dev/null

      if ( ${status} != 0 ) then

         echo "process: ${file}"

         mHDF_Eventpar $* ${file}

      endif

   end

   exit

endif

foreach file ( `ls -1 ${ddir}/*.h5` )

   basename ${file} | grep noise > /dev/null

   if ( ${status} != 0 ) then

      echo "process: ${file}"

      mHDF_Eventpar -f all --pdf -sum -ss ${file}  
#      mHDF_NEP -f all --pdf -sum -lf -ip ${file}

   endif

end

chgrp tesfdm *
chmod g+w *


