Ignore:
Timestamp:
06/25/07 14:06:05 (18 years ago)
Author:
hoehne
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/scripts/linkmc

    r8482 r8602  
    1919#
    2020#   Author(s): Daniela Dorner  12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
     21#   Author(s): Daniel Hoehne   06/2007 <mailto:hoehne@astro.uni-wuerzburg.de>
    2122#
    2223#   Copyright: MAGIC Software Development, 2000-2007
     
    2829# to a structure from which the files can be processed more easily with the
    2930# automatic analysis.
     31# Furthermore the content of the files is filled in the database running
     32# fillcamera.C.
    3033# This script is not yet running automatically.
    3134#
     
    3841# /magic/montecarlo/rawfiles/README.txt
    3942#
    40 # First the data files are linked and then in each new directory also the
    41 # pedestal and calibration file is linked.
    42 #
     43# First a file is linked and then fillcamera.C is executed. In case of an
     44# error in fillcamera.C the link is removed.
     45# In each new directory also the pedestal and calibration file is linked.
     46#
     47# ========================================================================
     48
    4349
    4450source `dirname $0`/sourcefile
     
    4854set -C
    4955
    50 scriptlog=$runlogpath/$progam-`date +%F`.log
     56scriptlog=$runlogpath/$program-`date +%F`.log
    5157date >> $scriptlog 2>&1
    5258
     
    7076
    7177# observation modes
    72 modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Gammadiffuse0" "Protonnowobble0" )
    73 #be carful:
     78modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Gammadiffuse0" "Protonnowobble0" "ProtonnowobbleHE0")
     79# be careful:
    7480# w- not yet foreseen in this script
    7581
     
    107113
    108114
    109 #get runnumber
     115
    110116runno=`cat $next`
    111117
    112118#get files, which have to be linked
    113 camfiles=`find $mccampath -type f | grep -v Cal_and_Ped`
     119camfiles=`find $mccampath -type f | grep -v Cal_and_Ped | sort`
    114120
    115121printprocesslog "INFO linking new camerafiles starting with runno $runno"
    116122for camfile in ${camfiles[@]}
    117123do
     124
     125
    118126   #continue, if file is already linked
    119    if grep $camfile $processed >> $scriptlog 2>&1
     127   if find $mcpath/* -lname '$mccampath*.root' -printf %l'\n' | grep $camfile >> $scriptlog 2>&1
     128#   if grep $camfile $processed >> $scriptlog 2>&1
    120129   then
    121130      continue
    122131   fi
     132
     133
    123134   printprocesslog "INFO linking $file"
    124135   file=`basename $camfile` #filename
     
    129140   wobble=`echo $file | cut -d_ -f6 | cut -c 2` #mode from filename
    130141   particle=`echo $file | cut -d_ -f1` #particle type from filename
    131    psf=`echo $camfile | cut -d/ -f5 | cut -c 6,8` #psf from path
    132    
    133    particledir=`echo $camfile | cut -d/ -f4` #particletype from path
    134    wobbledir=`echo $camfile | cut -d/ -f6` #mode from path
     142   psf=`echo $camfile | cut -d/ -f6 | cut -c 6,8` #psf from path
     143   
     144   particledir=`echo $camfile | cut -d/ -f5` #particletype from path
     145   wobbledir=`echo $camfile | cut -d/ -f7` #mode from path
    135146   
    136147   #build mode name
     
    167178   echo $runno >| $next
    168179
     180   linkmclogpath=$logpath/$program/$no2
     181   makedir $linkmclogpath >> $scriptlog 2>&1
     182   linkmclog=$linkmclogpath/$program-$no2.log
     183
    169184   #link file
     185   echo "linking file $camfile"
    170186   ln -sv $camfile $newfile >> $scriptlog 2>&1
    171    #add filename to processed file
    172    echo $camfile >> $processed
     187
     188   # run fillcamera.C. In case of success the camfile is written to .processed. In case of an error the link is removed
     189   echo "run fillcamera for mc run $no2" >> $scriptlog 2>&1
     190   check2=`root -q -b $macrospath/fillcamera.C+\("\"$newfile\""\,kTRUE\) | tee $linkmclog | intgrep`
     191   case $check2 in
     192      1)   echo " check2=$check2 -> everything ok " >> $scriptlog 2>&1
     193           printprocesslog "INFO done fillcamera successfully for mc run $no2"
     194           # add filename to .processed
     195           echo $camfile >> $processed
     196           ;;
     197      0)   echo " check2=$check2 -> no connection to db -> continue..." >> $scriptlog 2>&1
     198           printprocesslog "WARN connection to DB failed, removing link"
     199           check="no"
     200           # remove link
     201           rm $newfile >> $scriptlog 2>&1
     202           ;;
     203      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
     204           printprocesslog "ERROR fillcamera failed for mc run $no2, removing link"
     205           check=$check2
     206           # remove link
     207           rm $newfile >> $scriptlog 2>&1
     208           ;;
     209   esac
    173210
    174211done
     
    178215#get files
    179216pedfile=`find $mccampath/Cal_and_Ped -name *_P_*.root`
     217
     218
    180219calfile=`find $mccampath/Cal_and_Ped -name *_C_*.root`
     220
     221
    181222echo "calfile"$calfile >> $scriptlog 2>&1
    182223echo "pedfile"$pedfile >> $scriptlog 2>&1
     
    186227then
    187228   "too many files in the directory $mccampath/Cal_and_Ped -> exit" >> $scriptlog 2>&1
     229
     230
     231   rm -v $lockfile >> $scriptlog 2>&1
     232   exit
    188233   printprocesslog "ERROR too many ped and cal files found in $mccampath/Cal_and_Ped"
    189234   finish >> $scriptlog 2>&1
     
    196241do
    197242   #continue, if directory has already linked C and P run
    198    cont=`ls $dir/*_0000[12]_[CP]_MonteCarlo_E.root 2>/dev/null | wc -w`
     243   cont=`ls $dir/*_0000000[12]_[CP]_MonteCarlo_E.root 2>/dev/null | wc -w`
    199244   if [ "$cont" == "2" ] >> $scriptlog 2>&1
    200245   then
Note: See TracChangeset for help on using the changeset viewer.