Changeset 8762 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
10/17/07 13:52:00 (17 years ago)
Author:
hoehne
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8761 r8762  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2007/10/17 Daniel Hoehne
     22
     23   * datacenter/scripts/mcsequences:
     24     - included sql query and update/insert sequence information in MCDB
     25     - small bugfixes: corrected grep for epoch and mode
     26
     27
    2028
    2129 2007/10/16 Daniel Hoehne
  • trunk/MagicSoft/Mars/datacenter/scripts/mcsequences

    r8761 r8762  
    4949# find montecarlo directories, build one sequence per directory and write sequence file
    5050printprocesslog "INFO building one sequence per mcdirectory and epoch"
     51
     52user="test"
     53db="TestMonteCarlo"
     54pw="Ics+eaTD"
     55
    5156dirs=`find $mcrawpath -type d`
    5257for dir in ${dirs[@]}
    5358do
    54    cont=`echo $dir | cut -d/ -f6`
    55 #   cont=`echo $dir | cut -d/ -f10`
     59#   cont=`echo $dir | cut -d/ -f6`
     60   cont=`echo $dir | cut -d/ -f10`
    5661   if [ "$cont" == "" ]
    5762   then
     
    6469   do
    6570      echo $epoch >> $scriptlog 2>&1
    66       calfile=`find $dir -lname *$epoch*.root | grep "_C_"`
    67       pedfile=`find $dir -lname *$epoch*.root | grep "_P_"`
    68 #      datfiles=`find $dir -lname '*$epoch*.root' | grep "_D_"`
     71      calfile=`find $dir -lname *${epoch}/*.root | grep "_C_"`
     72      pedfile=`find $dir -lname *${epoch}/*.root | grep "_P_"`
    6973     
    7074      calrun=`echo $calfile | cut -d_ -f2`
     
    7478      for mode in ${modes[@]}
    7579      do
    76          datruns=`find $dir -lname *$epoch*.root | grep $mode | grep "_D_" | cut -d_ -f2 | tr "\n" " "`
     80         datruns=`find $dir -lname *${epoch}/*.root | grep ${mode}_ | grep "_D_" | cut -d_ -f2 | tr "\n" " "`
    7781         if [ "$datruns" != "" ]
    7882         then
    79             # workaround due to 5digit runnumber for data with runnumber < 35487
    8083            firstrun=`echo $datruns | cut -c 0-8`
    81             #   firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
    82             date=`echo $dir | cut -c 28-37 | sed -e 's/\//-/g'`
    83 #           date=`echo $dir | cut -c 57-66 | sed -e 's/\//-/g'`
    84             # for tests
    85             #      date=`echo $dir | cut -c 57-66 | sed -e 's/\//-/g'`
    86      
    87             # workaround due to 5digit runnumber for data with runnumber < 35487
    88             no=`echo $firstrun | cut -c 0-4`
    89             #   no=`printf %08d $firstrun | cut -c 0-4`
    90             #   no2=`printf %08d $firstrun`
    91             sequpath=$mcsequpath/$no
    92             makedir $sequpath >> $scriptlog 2>&1
    93             sequfile=$sequpath/sequence$firstrun.txt
    94             #   sequfile=$sequpath/sequence$no2.txt
    95             echo "writing sequfile "$sequfile >> $scriptlog 2>&1
    96             printprocesslog "INFO writing sequencefile $sequfile"
    97      
    98             echo "Sequence:        $firstrun" >| $sequfile
    99             echo "Night:           $date" >> $sequfile
    100             echo "Epoch:           $epoch" >> $sequfile
    101             echo "Mode:            $mode" >> $sequfile
    102             echo "" >> $sequfile
    103             echo "CalRuns:         $calrun" >> $sequfile
    104             echo "PedRuns:         $pedrun" >> $sequfile
    105             echo "DatRuns:         $datruns" >> $sequfile
    106             echo "" >> $sequfile
    107             echo "MonteCarlo: Yes" >> $sequfile
    108             echo "" >> $sequfile
     84            #date=`echo $dir | cut -c 28-37 | sed -e 's/\//-/g'`
     85            date=`echo $dir | cut -c 57-66 | sed -e 's/\//-/g'`
     86            zbin=`echo $date | cut -c 3,4`
     87           
     88            for datrun in ${datruns[@]}
     89            do
     90               update=" update MCRunData set fSequenceFirst=\"$firstrun\" where fRunNumber=\"$datrun\" "
     91               mysql -ss -u $user --password=$pw --host=vela $db -e " $update "
     92            done   
     93
     94            query=" select fSpectrumKEY, fPSFKEY, fAmplFadcKEY, fAtmosphericModelKEY, fObservationModeKEY, fMCParticleKEY, fReflectorVersionKEY, fCorsikaVersionKEY, fCameraVersionKEY, fViewConeAngleOKEY from MCRunData where fRunNumber=\"$firstrun\" "
     95            values=`mysql -ss -u $user --password=$pw --host=vela $db -e " $query "`
     96            spec=`echo $values | cut -d" " -f1`
     97            psf=`echo $values | cut -d" " -f2`
     98            amplfadc=`echo $values | cut -d" " -f3`
     99            atmo=`echo $values | cut -d" " -f4`
     100            obs=`echo $values | cut -d" " -f5`
     101            part=`echo $values | cut -d" " -f6`
     102            refl=`echo $values | cut -d" " -f7`
     103            cors=`echo $values | cut -d" " -f8`
     104            cam=`echo $values | cut -d" " -f9`
     105            view=`echo $values | cut -d" " -f10`
     106            query1=" select fSequenceFirst from MCSequenceProcessStatus where fSequenceFirst=\"$firstrun\" "
     107            query2=" select fSequenceFirst from MCSequences where fSequenceFirst=\"$firstrun\" "
     108            check1=`mysql -ss -u $user --password=$pw --host=vela $db -e " $query1 "`
     109            check2=`mysql -ss -u $user --password=$pw --host=vela $db -e " $query2 "`
     110            insert1=" insert MCSequenceProcessStatus set fSequenceFirst=\"$firstrun\", fSequenceFileWritten=Now() "
     111            insert2=" insert MCSequences set fSequenceFirst=\"$firstrun\", fRunStart=\"$date\", fZBin=\"$zbin\", fSpectrumKEY=\"$spec\", fPSFKEY=\"$psf\", fAmplFadcKEY=\"$amplfadc\", fAtmosphericModelKEY=\"$atmo\", fObservationModeKEY=\"$obs\", fMCParticleKEY=\"$part\", fReflectorVersionKEY=\"$refl\", fCorsikaVersionKEY=\"$cors\", fCameraVersionKEY=\"$cam\", fViewConeAngleOKEY=\"$view\" "
     112            update2=" update MCSequences set fRunStart=\"$date\", fZBin=\"$zbin\", fSpectrumKEY=\"$spec\", fPSFKEY=\"$psf\", fAmplFadcKEY=\"$amplfadc\", fAtmosphericModelKEY=\"$atmo\", fObservationModeKEY=\"$obs\", fMCParticleKEY=\"$part\", fReflectorVersionKEY=\"$refl\", fCorsikaVersionKEY=\"$cors\", fCameraVersionKEY=\"$cam\", fViewConeAngleOKEY=\"$view\" where fSequenceFirst=\"$firstrun\" "
     113            if [ "$check1" == "" ]
     114            then
     115               mysql -ss -u $user --password=$pw --host=vela $db -e " $insert1 "
     116            fi
     117            if [ "$check2" == "" ]
     118            then
     119               mysql -ss -u $user --password=$pw --host=vela $db -e " $insert2 "
     120            else
     121               mysql -ss -u $user --password=$pw --host=vela $db -e " $update2 "
     122            fi
     123           
     124            no=`echo $firstrun | cut -c 0-4`
     125            sequpath=$mcsequpath/$no
     126            makedir $sequpath >> $scriptlog 2>&1
     127            sequfile=$sequpath/sequence$firstrun.txt
     128            echo "writing sequfile "$sequfile >> $scriptlog 2>&1
     129            printprocesslog "INFO writing sequencefile $sequfile"
     130   
     131            echo "Sequence:        $firstrun" >| $sequfile
     132            echo "Night:           $date" >> $sequfile
     133            echo "Epoch:           $epoch" >> $sequfile
     134            echo "Mode:            $mode" >> $sequfile
     135            echo "" >> $sequfile
     136            echo "CalRuns:         $calrun" >> $sequfile
     137            echo "PedRuns:         $pedrun" >> $sequfile
     138            echo "DatRuns:         $datruns" >> $sequfile
     139            echo "" >> $sequfile
     140            echo "MonteCarlo: Yes" >> $sequfile
     141            echo "" >> $sequfile
    109142         fi
    110143      done
Note: See TracChangeset for help on using the changeset viewer.