Ignore:
Timestamp:
10/06/06 13:29:44 (18 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/scripts/processsequence

    r7732 r8006  
    1818#
    1919#
    20 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
    21 #
    22 #   Copyright: MAGIC Software Development, 2000-2004
     20#   Author(s): Daniela Dorner  10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
     21#
     22#   Copyright: MAGIC Software Development, 2000-2006
    2323#
    2424#
     
    4040##############################################################################
    4141
    42 #function to create directory
    43 function makedir()
     42#to be set by the user (if you don't use the command-line options)
     43#path of your output directory
     44#outpath=/home/dorner/ToO
     45outpath=
     46#give either sequence number or sequence file (including path)
     47sequence=
     48sequfile=""
     49
     50function usage()
    4451{
    45    if [ ! -d $@ ]
     52   echo "Usage: $0 [options]"
     53   echo "options:"
     54   echo -n "  --sequ sequence#       "
     55   echo " giving number of sequence which shall be processed "
     56   echo -n "  --sequ-file sequfile   "
     57   echo " giving sequencfile (including path) of sequence which shall be processed "
     58   echo -n "  --out outpath          "
     59   echo " giving the path where all outputfiles are stored "
     60   echo -n "  -cal                   "
     61   echo " running only calibration"
     62   echo -n "  -b                     "
     63   echo " running in non-interactive mode (i.e. you are not asked if the paths are ok)"
     64#   echo -n "  -merppu                "
     65#   echo " running only merppupdate"
     66   echo -n "  -star                  "
     67   echo " running only star"
     68   echo ""
     69   echo "Remarks: "
     70   echo    " - you can set the variables (or part of it) also in the script "
     71   echo    " - you have to set the outpath and either the sequence number or the sequence file"
     72   echo    "    (if both is set, the sequence given by the sequencefile is processed)"
     73   echo ""
     74   exit
     75}
     76
     77interactive="yes"
     78
     79while [ "$1" ]
     80do
     81   case $1 in
     82           --sequ)  shift
     83                    sequence=$1
     84                    ;;
     85           --mars)  shift
     86                    mars=$1
     87                    ;;
     88            --out)  shift
     89                    outpath=$1
     90                    ;;
     91               -b)  interactive='no'
     92                    ;;
     93             -cal)  cal='yes'
     94                    ;;
     95#          -merppu)  merppu='yes'
     96#                    ;;
     97            -star)  star='yes'
     98                    ;;
     99      --sequ-file)  shift
     100                    sequfile=$1
     101                    ;;
     102               -h)  usage
     103                    ;;
     104      *)      echo "unknown option $1 "
     105              usage
     106              exit
     107              ;;
     108   esac
     109   shift
     110done
     111
     112##getting settings for root
     113#if [ "$mars" = "" ]
     114#then
     115#   echo "WARNING Mars-Version has not been set"
     116#   echo ""
     117#   usage
     118#fi
     119#source $mars/datacenter/scripts/setup
     120
     121if [ "$outpath" = "" ]
     122then
     123   echo "WARNING outpath has not been set"
     124   echo ""
     125   usage
     126fi
     127
     128if [ "$sequence" = "" ] && [ "$sequfile" = "" ]
     129then
     130   echo "WARNING neither sequ nor sequfile has been set"
     131   echo ""
     132   usage
     133fi
     134
     135echo ""
     136echo "You have set the variables to: "
     137#echo "mars:     "$mars
     138echo " outpath:  "$outpath
     139
     140if [ "$sequfile" = "" ]
     141then
     142   if ! n8=`printf %08d $sequence`
    46143   then
    47      mkdir -pv $@
    48      if [ ! -d $@ ]
    49      then
    50         echo "could not make dir "$@
    51         exit
    52      fi
    53    fi
    54 }
    55 
    56 
    57 #to be set by the user
    58 mars=/home/user/Mars
    59 outpath=/home/user/outpath
    60 sequence=55221
    61 
    62 
    63 #needed if not set in .bashrc or when script is e.g. executed in cronjob
    64 export ROOTSYS=/opt/root_v4.04.02g
    65 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
    66 export PATH=$PATH:$ROOTSYS/bin
    67 
    68 
    69 no=`printf %08d $sequence | cut -c 1-4`
    70 sequfile="/magic/sequences/"$no"/sequence"`printf %08d $sequence`".txt"
    71 calpath=$outpath"/callisto/"`printf %08d $sequence`
    72 starpath=$outpath"/star/"`printf %08d $sequence`
    73 
    74 echo "mars:     "$mars
    75 echo "outpath:  "$outpath
    76 echo "sequence: "$sequence
    77 echo "sequfile: "$sequfile
    78 echo "path where calibration files are stored : "$calpath
    79 echo "path where star files are stored        : "$starpath
    80 
    81 makedir $calpath
    82 makedir $starpath
    83 
    84 cd $mars
    85 
    86 echo "run callisto..."
    87 echo "./callisto -b -q -f --log=$calpath/callisto$sequence.log --out=$calpath $sequfile "
    88 ./callisto -b -q -f --log=$calpath/callisto$sequence.log --out=$calpath $sequfile
    89 echo "callisto is finished "
    90 echo ""
    91 
    92 
    93 
    94 calfiles=`find $calpath -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*_Y_*.root`
    95 
    96 echo "run merpp update for calibrated files..."
    97 echo "calibrated data files: "$calfiles
    98 
    99 for calfile in ${calfiles[@]}
    100 do
    101    echo "calfile: "$calfile
    102    outpath=`dirname $calfile`
    103    echo "outpath: "$outpath
    104    
    105    merpplogpath=$outpath"/merpplogs"
    106    makedir $merpplogpath
    107    
    108    runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
    109    ccfile=`find /magic/subsystemdata/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
    110    cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
    111    echo "runno: "$runno
    112    echo "ccfile: "$ccfile
    113    if [ "$ccfile" = "" ]
    114    then
    115       echo "no ccfile found for run "$runno
    116       break
    117    fi
    118    echo "cacofile: "$cacofile
    119    if [ "$cacofile" = "" ]
    120    then
    121       echo "no cacofile found for run "$runno
    122       echo "finding cacofile..."
    123       for (( i = 0; i <= 10; i++ ))
    124       do
    125          newrun=`echo $runno - $i | bc`
    126   #      echo "$missingcacorun + $i = $newrun"
    127          path=`dirname $ccfile`
    128          path=`echo $path | sed -e 's/cc/caco/'`
    129          echo "path: "$path
    130          cacofile=`find $path -name *$newrun*`
    131          if [ "$cacofile" = "" ]
    132          then
    133             continue
    134          else
    135             break
    136             echo "cacofile: "$cacofile
    137          fi
    138       done
    139    fi
    140    echo "./merpp -u --log=$merpplogpath/merppccupdate$runno.log --runfile=$runno $ccfile $calfile "
    141    ./merpp -u --log=$merpplogpath/merppccupdate$runno.log --runfile=$runno $ccfile $calfile
    142 
    143    echo "./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --auto-time $cacofile $calfile "
    144    ./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --auto-time $cacofile $calfile
    145 done
    146 echo "merppupdate is finished"
    147 echo ""
    148 
    149 
    150 
    151 echo "run star..."
    152 echo "./star -b -q -f --log=$starpath/star$sequence.log --ind=$callistopath --out=$starpath $sequfile "
    153 ./star -b -q -f --log=$starpath/star$sequence.log --ind=$callistopath --out=$starpath $sequfile
    154 echo "star is finished "
    155 
    156 
     144      echo "your sequence number is not valid"
     145      usage
     146      exit
     147   fi
     148   no=`echo $n8 | cut -c 1-4`
     149   sequfile="/magic/sequences/"$no"/sequence$n8.txt"
     150   echo " sequence: "$sequence
     151   echo " sequfile: "$sequfile
     152   if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
     153   then
     154      calpath=$outpath"/callisto/$n8"
     155      echo " path where calibration files are stored : "$calpath
     156   fi
     157   if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
     158   then
     159      starpath=$outpath"/star/$n8"
     160      echo " path where star files are stored        : "$starpath
     161   fi
     162else
     163   echo " sequfile: "$sequfile
     164   if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
     165   then
     166      calpath=$outpath"/callisto"
     167      echo " path where calibration files are stored : "$calpath
     168   fi
     169   if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
     170   then
     171      starpath=$outpath"/star"
     172      echo " path where star files are stored        : "$starpath
     173   fi
     174fi
     175
     176
     177if [ "$interactive" = "yes" ]
     178then
     179   echo ""
     180   echo "paths ok? continue?"
     181   echo "please insert y, if you want continue"
     182   echo "              n, if you want quit"
     183
     184   answer=`head -n 1`
     185#   echo "answer: "$answer
     186   case $answer in
     187      y) echo "continue processing sequence"
     188         ;;
     189      n) exit
     190         ;;
     191      *) echo "your answer is not clear -> exit"
     192         exit
     193         ;;
     194   esac
     195fi
     196
     197exit
     198
     199
     200#cd $mars
     201
     202if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
     203then
     204   mkdir -pv $calpath
     205
     206   echo "run callisto..."
     207   echo "./callisto -b -q -f --log=$calpath/callisto$sequence.log --out=$calpath $sequfile "
     208   ./callisto -b -q -f --log=$calpath/callisto$sequence.log --out=$calpath $sequfile
     209   check=$?
     210   case $check in
     211      0)  echo "callisto finished sucessfully"
     212          echo "";;
     213      *)  echo -n "ERROR: callisto returned $check - please check "
     214          echo -n "http://www.astro.uni-wuerzburg.de/datacenter/instructions/intern/errorcoding.txt"
     215          echo " for more details"
     216          exit;;
     217   esac
     218
     219
     220   calfiles=`find $calpath -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*_Y_*.root`
     221
     222   echo "run merpp update for calibrated files..."
     223   echo "calibrated data files: "$calfiles
     224
     225   for calfile in ${calfiles[@]}
     226   do
     227      echo "calfile: "$calfile
     228      outpath=`dirname $calfile`
     229      echo "outpath: "$outpath
     230
     231      merpplogpath=$outpath"/merpplogs"
     232      makedir $merpplogpath
     233
     234      runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
     235      ccfile=`find /magic/subsystemdata/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
     236      cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
     237      echo "runno: "$runno
     238      echo "ccfile: "$ccfile
     239      if [ "$ccfile" = "" ]
     240      then
     241         echo "no ccfile found for run "$runno
     242         break
     243      fi
     244      echo "cacofile: "$cacofile
     245      if [ "$cacofile" = "" ]
     246      then
     247         echo "no cacofile found for run "$runno
     248         echo "finding cacofile..."
     249         for (( i = 0; i <= 10; i++ ))
     250         do
     251            newrun=`echo $runno - $i | bc`
     252     #      echo "$missingcacorun + $i = $newrun"
     253            path=`dirname $ccfile`
     254            path=`echo $path | sed -e 's/cc/caco/'`
     255            echo "path: "$path
     256            cacofile=`find $path -name *$newrun*`
     257            if [ "$cacofile" = "" ]
     258            then
     259               continue
     260            else
     261               break
     262               echo "cacofile: "$cacofile
     263            fi
     264         done
     265      fi
     266     
     267      logfile=$merpplogpath/merppccupdate$runno.log
     268      echo "./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile "
     269      ./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile
     270      check=$?
     271      case $check in
     272         0)  ;;
     273         *)  echo "ERROR: merppccupdate returned $check "
     274             echo "please check the logfile $logfile "
     275             exit;;
     276      esac
     277
     278      logfile=$merpplogpath/merppcacoupdate$runno.log
     279      echo "./merpp -u --log=$logfile --auto-time $cacofile $calfile "
     280      ./merpp -u --log=$logfile --auto-time $cacofile $calfile
     281      check=$?
     282      case $check in
     283         0)  ;;
     284         *)  echo "ERROR: merppcacoupdate returned $check "
     285             echo "please check the logfile $logfile "
     286             exit;;
     287      esac
     288   done
     289   echo "merppupdate is finished"
     290   echo ""
     291fi
     292
     293if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
     294then
     295   mkdir -pv $starpath
     296
     297   echo "run star..."
     298   logfile=$starpath/star$sequence.log
     299   if ! ls $calpath
     300   then
     301      echo "couldn't find $calpath => taking standard inpath for star"
     302      echo "./star -b -q -f --log=$logfile --out=$starpath $sequfile "
     303      ./star -b -q -f --log=$logfile --out=$starpath $sequfile
     304   else
     305      echo "./star -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile "
     306      ./star -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile
     307   fi
     308   check=$?
     309   case $check in
     310      0)  echo "star finished sucessfully"
     311          echo "";;
     312      *)  echo "ERROR: star returned $check - please check "
     313          echo "please check the logfile $logfile "
     314          exit;;
     315   esac
     316
     317   echo "star is finished "
     318fi
     319
     320
Note: See TracChangeset for help on using the changeset viewer.