Changeset 7453 for trunk/MagicSoft


Ignore:
Timestamp:
12/12/05 16:30:50 (19 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7452 r7453  
    2323     - fixed condition for removing lock-file
    2424
     25   * datacenter/scripts/dowebplots:
     26     - improved new procedure
     27     - added removing of old files
     28     - added documentation
     29
    2530   * datacenter/scripts/linkmc:
    2631     - improved handling of directories
     32     - added new mode
     33     - added documentation
     34     - simplyfied check for C and P link
    2735
    2836
  • trunk/MagicSoft/Mars/datacenter/scripts/dowebplots

    r7426 r7453  
    3535
    3636datetime=`date +%F-%H-%M-%S`
     37webdir=/www/htdocs/datacenter
    3738
    3839scriptlogpath=$logpath/run/dowebplots/`date +%Y/%m/%d`
     
    5657
    5758
     59#finding all rootfiles in the webdirectory
     60#this are all statusdisplays
     61rootfiles=`find $webdir/{sinope,callisto,star,ganymed}/ -name '*.root' -maxdepth 10 | grep -v '_I_' | grep -v '_Y_' | grep -v 'subsystemdata' | grep -v 'star_lapalma'`
    5862
    59 rootfiles=`find /www/htdocs/datacenter/ -name '*.root' -maxdepth 10 | grep -v '_I_' | grep -v '_Y_' | grep -v 'subsystemdata' | grep -v 'star_lapalma'`
    60 
     63#exit if no rootfiles are found
    6164if [ "$rootfiles" = "" ]
    6265then
     
    6770fi
    6871
    69 echo "rootfiles: "${rootfiles[@]} >> $scriptlog 2>&1
    7072
     73#produce plots for each rootfile
    7174for rootfile in ${rootfiles[@]}
    7275do
    7376   date >> $scriptlog 2>&1
    74    psfile=`echo $file | sed -e 's/.root$/.ps/g'`
     77   #get names of the psfile and the
     78   #pngfiles (1 per tab in the statusdiplay)
     79   psfile=`echo $rootfile | sed -e 's/.root$/.ps/g'`
     80   tabfile=`echo $rootfile | sed -e 's/.root$/-tab/g'`
    7581   echo "rootfile: $rootfile" >> $scriptlog 2>&1
    76    echo "psfile:   $psfile" >> $scriptlog 2>&1
     82   echo "psfile:   $psfile"   >> $scriptlog 2>&1
     83   echo "tabfile:  $tabfile"  >> $scriptlog 2>&1
    7784   
     85   #get date of root- and psfile
    7886   daterootfile=`date +%Y%m%d -r $rootfile` >> $scriptlog 2>&1
    7987   datepsfile=`date +%Y%m%d -r $psfile` >> $scriptlog 2>&1
     
    8997   echo "date of psfile:   $datepsfile"   >> $scriptlog 2>&1
    9098
     99   #if the psfile is newer than the rootfile
     100   #no plots have to be done -> continue
    91101   if [ "$datepsfile" -gt "$daterootfile" ] >> $scriptlog 2>&1
    92102   then
     
    99109
    100110   echo "converting plots to png..." >> $scriptlog 2>&1
    101    pstoimg -antialias -flip r270 -density 100 -type png -multipage $psfile >> $scriptlog 2>&1
     111   pstoimg -antialias -flip r270 -density 100 -type png -multipage -out=$tabfile$psfile >> $scriptlog 2>&1
     112done
     113
     114echo "removing old files" >> $scriptlog 2>&1
     115#make sure, that old plots of files, that are already removed from disk,
     116#  are deleted also in the webdirectory
     117#this has to be done, as ps and png files are excluded from rsync,
     118#as rsync is done with --delete option (script /home/operator/condor/webupdate
     119
     120#find all directories with plots
     121dirs=`find $webdir/{star,callisto,ganymed,sinope}/* -type d | grep -v merpplogs`
     122
     123for dir in ${dir[@]}
     124do
     125   #find psfiles in directory
     126   psfiles=`ls $dir/*.ps`
     127   #continue, if there are no psfiles
     128   if [ "$psfiles" == "" ]
     129   then
     130      continue
     131   fi
     132   
     133   for psfile in ${psfiles[@]}
     134   do
     135      #create name of corresponding rootfile
     136      rootfile=`echo $psfile | sed -e 's/.ps$/.root/g'`
     137      #delete ps and pngfiles if rootfile is not existing
     138      if ! ls $rootfile >> $scriptlog 2>&1
     139      then
     140         echo "deleting old plots for $rootfile..." >> $scriptlog 2>&1
     141         path=`dirname $psfile`
     142         rm -v $psfile >> $scriptlog 2>&1
     143         rm -v $path/*.png >> $scriptlog 2>&1
     144      fi
     145   done
    102146done
    103147
  • trunk/MagicSoft/Mars/datacenter/scripts/linkmc

    r7452 r7453  
    5353mccampath=/montecarlo/camera
    5454mcpath=/montecarlo/rawfiles
    55 next=$mcpath/.next
    56 processed=$mcpath/.processed
    57 processeddir=$mcpath/.processed.dir
    58 readme=$mcpath/README.txt
     55next=$mcpath/.next #in .next the next runno is stored
     56processed=$mcpath/.processed #in .processed the linked files are stored
     57readme=$mcpath/README.txt #file in which the information about the modes is redirected to have always an updated explanation
    5958
    6059if ! ls $next >> $scriptlog 2>&1
     
    6867
    6968
    70 modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Proton" "DiffuseGamma" )
     69modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Gammadiffuse0" "Protonnowobble0" )
     70
     71#be carful:
     72# w- not yet foreseen in this script
    7173
    7274echo "" >> $readme 2>&1
     
    101103
    102104
     105#get runnumber
    103106runno=`cat $next`
    104107
     108#get files, which have to be linked
    105109camfiles=`find $mccampath -type f | grep -v Cal_and_Ped`
    106110
    107111for camfile in ${camfiles[@]}
    108112do
     113   #continue, if file is already linked
    109114   if grep $camfile $processed >> $scriptlog 2>&1
    110115   then
    111116      continue
    112117   fi
    113    file=`basename $camfile`
    114    no=`printf %08d $runno | cut -c 0-5`
    115 #   no2=`printf %08d $runno`
     118   file=`basename $camfile` #filename
     119   no=`printf %08d $runno | cut -c 0-5` #first 5 digits of a 8digit runno -> for path
     120#   no2=`printf %08d $runno` #runno with 8 digits
    116121# workaround due to 5digit runnumber for data with runnumber < 35487
    117122   no2=`printf %05d $runno`
    118    zbin=`echo $file | cut -d_ -f2 | cut -c 5-6`
    119    zbin=`printf %02d $zbin`
    120    wobble=`echo $file | cut -d_ -f6 | cut -c 2`
    121    particle=`echo $file | cut -d_ -f1`
    122    psf=`echo $camfile | cut -d/ -f5 | cut -c 6,8`
    123    
    124    particledir=`echo $camfile | cut -d/ -f4`
    125    wobbledir=`echo $camfile | cut -d/ -f6`
    126    
     123   zbin=`echo $file | cut -d_ -f2 | cut -c 5-6` #zbin from filename
     124   zbin=`printf %02d $zbin` #2digit
     125   wobble=`echo $file | cut -d_ -f6 | cut -c 2` #mode from filename
     126   particle=`echo $file | cut -d_ -f1` #particle type from filename
     127   psf=`echo $camfile | cut -d/ -f5 | cut -c 6,8` #psf from path
     128   
     129   particledir=`echo $camfile | cut -d/ -f4` #particletype from path
     130   wobbledir=`echo $camfile | cut -d/ -f6` #mode from path
     131   
     132   #build mode name
    127133   testmode=$particle$wobbledir$wobble
    128 #   echo "testmode:"$testmode >> $scriptlog 2>&1
    129 
     134
     135   #get mode extension for filename
    130136   case $wobble in
    131137       0)   wobblemode="";;
     
    136142   esac
    137143   
     144   #get no of mode from array $modes
    138145   for (( i=1 ; i <= 12 ; i++ ))
    139146   do
    140147       if [ "${modes[$i]}" == "$testmode" ]
    141148       then
    142 #          echo "modes[$i]=${modes[$i]}" >> $scriptlog 2>&1
    143149          totalmode=$i
    144150          break
     
    146152   done
    147153
    148    totalmode=`printf %02d $totalmode`
    149 #   echo "totalmode: "$totalmode >> $scriptlog 2>&1
    150 
    151    project=${particle}${zbin}${wobblemode}
     154   totalmode=`printf %02d $totalmode` #2 digits
     155
     156   project=${particle}${zbin}${wobblemode} #build project name
     157   #create new filename
    152158   newfile="$mcpath/19$zbin/$totalmode/$psf/19${zbin}${totalmode}${psf}_${no2}_D_${project}_E.root"
    153159   newdir=`dirname $newfile`
    154160   makedir $newdir >> $scriptlog 2>&1
    155161
    156    runno=`expr $runno + 1`
     162   runno=`expr $runno + 1` #next runnumber
    157163   echo $runno >| $next
    158164
    159    ln -sv $camfile $newfile >> $scriptlog 2>&1
     165   #link file
     166   ln -sv $camfile $newfile >> $scriptlog 2>&1
     167   #add filename to processed file
    160168   echo $camfile >> $processed
    161169
     
    163171
    164172echo "linking cal and ped file" >> $scriptlog 2>&1
     173#get files
    165174pedfile=`find $mccampath/Cal_and_Ped -name *_P_*.root`
    166175calfile=`find $mccampath/Cal_and_Ped -name *_C_*.root`
    167176echo "calfile"$calfile >> $scriptlog 2>&1
    168177echo "pedfile"$pedfile >> $scriptlog 2>&1
     178#check number of files
    169179numfiles=`echo $pedfile $calfile | wc -w`
    170180if [ "$numfiles" != "2" ]
     
    175185fi
    176186
     187#get all directories in the linked structure
    177188dirs=`find $mcpath -type d`
    178189
    179190for dir in ${dirs[@]}
    180191do
    181    if grep $dir $processeddir >> $scriptlog 2>&1
     192   #continue, if directory has already linked C and P run
     193   $cont=`ls $dir/*_0000[12]_[CP]_MonteCarlo_E.root | wc -w`
     194   if [ "$cont" == "2" ] >> $scriptlog 2>&1
    182195   then
    183196      continue
    184197   fi
    185198
     199   #continue, if directory is not at the lowest level of the structure
    186200   cont=`echo $dir | cut -d/ -f6`
    187201   if [ "$cont" == "" ]
     
    190204   fi
    191205
     206   #get date for filename from directory name
    192207   date=`echo $dir | cut -c 22-25,27,28,30,31`
     208   
     209   #create new filenames and link files
    193210# workaround due to 5digit runnumber for data with runnumber < 35487
    194211#   newcalfile="${dir}/${date}_00000001_C_MonteCarlo_E.root"
     
    199216   newpedfile="${dir}/${date}_00002_P_MonteCarlo_E.root"
    200217   ln -sv $pedfile $newpedfile >> $scriptlog 2>&1
    201    echo $dir >> $processeddir
    202218done
    203219
Note: See TracChangeset for help on using the changeset viewer.