Changeset 9491 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
08/14/09 17:01:45 (15 years ago)
Author:
hoehne
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9490 r9491  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2009/08/14 Daniel Hoehne-Moench
     22
     23   * datacenter/scripts/mcsequences:
     24     - included display of azimuth range in sequence file
     25     - changed sequencing to one sequence per mc run
     26
     27
    2028
    2129 2009/08/13 Thomas Bretz
  • trunk/MagicSoft/Mars/datacenter/scripts/mcsequences

    r9408 r9491  
    1919#
    2020#   Author(s): Daniela Dorner  12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
    21 #   Author(s): Daniel Hoehne-Moench  01/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
     21#   Author(s): Daniel Hoehne-Moench  08/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
    2222#
    2323#   Copyright: MAGIC Software Development, 2000-2009
     
    2626# ========================================================================
    2727#
    28 # The script is building two sequences per directory and epoch. One for
    29 # training and one for testing. The relevant parameters are taken from
    30 # the MC database.
     28# The script is building one sequence per mc run. The relevant parameters
     29# are taken from the MC database.
    3130#
    3231
     
    4140checklock
    4241                                             
    43 # find montecarlo directories, build two sequences per directory and write sequence files
    44 printprocesslog "INFO building two sequences per mcdirectory and epoch, one for training and one for testing"
     42# find montecarlo directories, build one sequence per run
     43printprocesslog "INFO building one sequence per run"
    4544
    4645getdbsetup
     
    5756   printprocesslog "INFO dir: "$dir
    5857   
    59    epochs=`ls -l $mcpath/camera | cut -c 52-80`
     58   epochs=`ls -l $mcpath/camera | cut -d' ' -f8`
    6059   for epoch in ${epochs[@]}
    6160   do
    6261      printprocesslog "INFO epoch: "$epoch
     62
    6363      calfile=`find $dir -lname *${epoch}/*.root | grep "_C_"`
    6464      pedfile=`find $dir -lname *${epoch}/*.root | grep "_P_"`
    65      
    6665      calrun=`echo $calfile | cut -d_ -f2`
    6766      pedrun=`echo $pedfile | cut -d_ -f2`
     
    7170      do
    7271         datruns=`find $dir -lname *${epoch}/*.root | grep ${mode}_ | grep "_D_" | cut -d_ -f2 | tr "\n" " "`
    73         if [ "$datruns" != "" ]
     72        if [ "$datruns" != "" ]
    7473         then
    75             num=`echo $datruns | wc -w`
    76             train=`expr $num / 5`
    77             test=`expr $num - $train`
    78             last=`expr $num \* 9`
    79             train2=`expr $train \* 9`
    80             firstrun=`echo $datruns | cut -c 0-8`
    81             trainruns=`echo $datruns | cut -c 0-$train2`
    82             trainruns2=`echo $trainruns | sed -e 's/ /,/g'`
    83             testruns=`echo $datruns | cut -c $train2-$last`
    84             testruns2=`echo $testruns | sed -e 's/ /,/g'`
    85             firstruntrain=`echo $trainruns | cut -c 0-8`
    86             firstruntest=`echo $testruns | cut -c 0-8`
    87 
    8874            date=`echo $dir | cut -c 28-37 | sed -e 's/\//-/g'`
    8975            #date=`echo $dir | cut -c 57-66 | sed -e 's/\//-/g'`
    9076            zbin=`echo $date | cut -c 3,4`
     77         
     78            for datrun in ${datruns[@]}
     79            do
     80               query1=" select fSpectrumKEY, fPSFKEY, fAmplFadcKEY, fAtmosphericModelKEY, fObservationModeKEY, fMCParticleKEY, fReflectorVersionKEY, fCorsikaVersionKEY, fCameraVersionKEY, fViewConeAngleOKEY, fAddSpotSizeKEY, fTriggerFlagKEY, fPhiMax, fPhiMin from MCRunData where fRunNumber=\"$datrun\" "
     81               query2=" select sum(fNumEvents), sum(fNumTriggers), sum(fNumSumTriggers) from MCRunData where fRunNumber=\"$datrun\" "
     82               values=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $query1 "`
     83               values2=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $query2 "`
     84               spec=`echo $values | cut -d" " -f1`
     85               psf=`echo $values | cut -d" " -f2`
     86               amplfadc=`echo $values | cut -d" " -f3`
     87               atmo=`echo $values | cut -d" " -f4`
     88               obs=`echo $values | cut -d" " -f5`
     89               part=`echo $values | cut -d" " -f6`
     90               refl=`echo $values | cut -d" " -f7`
     91               cors=`echo $values | cut -d" " -f8`
     92               cam=`echo $values | cut -d" " -f9`
     93               view=`echo $values | cut -d" " -f10`
     94               ass=`echo $values | cut -d" " -f11`
     95               trig=`echo $values | cut -d" " -f12`
     96               azmax=`echo $values | cut -d" " -f13`
     97               azmin=`echo $values | cut -d" " -f14`
     98               events=`echo $values2 | cut -d" " -f1`
     99               triggers=`echo $values2 | cut -d" " -f2`
     100               sumtriggers=`echo $values2 | cut -d" " -f3`
     101               query3=" select fSequenceFirst from MCSequenceProcessStatus where fSequenceFirst=\"$datrun\" "
     102               query4=" select fSequenceFirst from MCSequences where fSequenceFirst=\"$datrun\" "
     103               insert1=" insert MCSequenceProcessStatus set fSequenceFirst=\"$datrun\", fPriority=\"$datrun\", fSequenceFileWritten=Now() "
     104               insert2=" insert MCSequences set fSequenceFirst=\"$datrun\", fRunStart=\"$date\", fNumEvents=\"$trainevents\", fNumTriggers=\"$triggers\", fNumSumTriggers=\"$sumtriggers\", fZBin=\"$zbin\", fSpectrumKEY=\"$spec\", fPSFKEY=\"$psf\", fAddSpotSizeKEY=\"$ass\", fAmplFadcKEY=\"$amplfadc\", fAtmosphericModelKEY=\"$atmo\", fObservationModeKEY=\"$obs\", fMCParticleKEY=\"$part\", fReflectorVersionKEY=\"$refl\", fCorsikaVersionKEY=\"$cors\", fCameraVersionKEY=\"$cam\", fViewConeAngleOKEY=\"$view\", fTriggerFlagKEY=\"$trig\", fPhiMax=\"$azmax\", fPhiMin=\"$azmin\", fTestTrainKEY=2 "
     105               update1=" update MCRunData set fSequenceFirst=\"$datrun\" where fRunNumber=\"$datrun\" "
     106               update2=" update MCSequences set fRunStart=\"$date\", fNumEvents=\"$events\", fNumTriggers=\"$triggers\", fNumSumTriggers=\"$sumtriggers\", fZBin=\"$zbin\", fSpectrumKEY=\"$spec\", fPSFKEY=\"$psf\", fAddSpotSizeKEY=\"$ass\", fAmplFadcKEY=\"$amplfadc\", fAtmosphericModelKEY=\"$atmo\", fObservationModeKEY=\"$obs\", fMCParticleKEY=\"$part\", fReflectorVersionKEY=\"$refl\", fCorsikaVersionKEY=\"$cors\", fCameraVersionKEY=\"$cam\", fViewConeAngleOKEY=\"$view\", fTriggerFlagKEY=\"$trig\", fPhiMax=\"$azmax\", fPhiMin=\"$azmin\", fTestTrainKEY=2 where fSequenceFirst=\"$datrun\" "
    91107
    92 
    93             #training runs
    94             for trainrun in ${trainruns[@]}
    95             do
    96                trainupdate=" update MCRunData set fSequenceFirst=\"$firstruntrain\" where fRunNumber=\"$trainrun\" "
    97                mysql -ss -u $us --password=$pw --host=$ho $db -e " $trainupdate "
    98             done   
    99 
    100             trainquery1=" select fSpectrumKEY, fPSFKEY, fAmplFadcKEY, fAtmosphericModelKEY, fObservationModeKEY, fMCParticleKEY, fReflectorVersionKEY, fCorsikaVersionKEY, fCameraVersionKEY, fViewConeAngleOKEY, fAddSpotSizeKEY, fTriggerFlagKEY from MCRunData where fRunNumber=\"$firstruntrain\" "
    101             trainquery2=" select sum(fNumEvents), sum(fNumTriggers), sum(fNumSumTriggers) from MCRunData where fRunNumber in ($trainruns2) "
    102             trainvalues=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $trainquery1 "`
    103             trainvalues2=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $trainquery2 "`
    104             trainspec=`echo $trainvalues | cut -d" " -f1`
    105             trainpsf=`echo $trainvalues | cut -d" " -f2`
    106             trainamplfadc=`echo $trainvalues | cut -d" " -f3`
    107             traintrainatmo=`echo $trainvalues | cut -d" " -f4`
    108             trainobs=`echo $trainvalues | cut -d" " -f5`
    109             trainpart=`echo $trainvalues | cut -d" " -f6`
    110             trainrefl=`echo $trainvalues | cut -d" " -f7`
    111             traincors=`echo $trainvalues | cut -d" " -f8`
    112             traincam=`echo $trainvalues | cut -d" " -f9`
    113             trainview=`echo $trainvalues | cut -d" " -f10`
    114             trainass=`echo $trainvalues | cut -d" " -f11`
    115             traintrig=`echo $trainvalues | cut -d" " -f12`
    116             trainevents=`echo $trainvalues2 | cut -d" " -f1`
    117             traintriggers=`echo $trainvalues2 | cut -d" " -f2`
    118             trainsumtriggers=`echo $trainvalues2 | cut -d" " -f3`
    119             trainquery3=" select fSequenceFirst from MCSequenceProcessStatus where fSequenceFirst=\"$firstruntrain\" "
    120             trainquery4=" select fSequenceFirst from MCSequences where fSequenceFirst=\"$firstruntrain\" "
    121             traincheck3=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $trainquery3 "`
    122             traincheck4=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $trainquery4 "`
    123             traininsert1=" insert MCSequenceProcessStatus set fSequenceFirst=\"$firstruntrain\", fPriority=\"$firstruntrain\", fSequenceFileWritten=Now() "
    124             traininsert2=" insert MCSequences set fSequenceFirst=\"$firstruntrain\", fRunStart=\"$date\", fNumEvents=\"$trainevents\", fNumTriggers=\"$traintriggers\", fNumSumTriggers=\"$trainsumtriggers\", fZBin=\"$zbin\", fSpectrumKEY=\"$trainspec\", fPSFKEY=\"$trainpsf\", fAddSpotSizeKEY=\"$trainass\", fAmplFadcKEY=\"$trainamplfadc\", fAtmosphericModelKEY=\"$trainatmo\", fObservationModeKEY=\"$trainobs\", fMCParticleKEY=\"$trainpart\", fReflectorVersionKEY=\"$trainrefl\", fCorsikaVersionKEY=\"$traincors\", fCameraVersionKEY=\"$traincam\", fViewConeAngleOKEY=\"$trainview\", fTriggerFlagKEY=\"$traintrig\", fTestTrainKEY=2 "
    125             trainupdate2=" update MCSequences set fRunStart=\"$date\", fNumEvents=\"$trainevents\", fNumTriggers=\"$traintriggers\", fNumSumTriggers=\"$trainsumtriggers\", fZBin=\"$zbin\", fSpectrumKEY=\"$trainspec\", fPSFKEY=\"$trainpsf\", fAddSpotSizeKEY=\"$trainass\", fAmplFadcKEY=\"$trainamplfadc\", fAtmosphericModelKEY=\"$trainatmo\", fObservationModeKEY=\"$trainobs\", fMCParticleKEY=\"$trainpart\", fReflectorVersionKEY=\"$trainrefl\", fCorsikaVersionKEY=\"$traincors\", fCameraVersionKEY=\"$traincam\", fViewConeAngleOKEY=\"$trainview\", fTriggerFlagKEY=\"$traintrig\", fTestTrainKEY=2 where fSequenceFirst=\"$firstruntrain\" "
    126             if [ "$traincheck3" == "" ]
    127             then
    128                mysql -ss -u $us --password=$pw --host=$ho $db -e " $traininsert1 "
    129             fi
    130             if [ "$traincheck4" == "" ]
    131             then
    132                mysql -ss -u $us --password=$pw --host=$ho $db -e " $traininsert2 "
    133             else
    134                mysql -ss -u $us --password=$pw --host=$ho $db -e " $trainupdate2 "
    135             fi
    136            
    137             trainno=`echo $firstruntrain | cut -c 0-4`
    138             trainsequpath=$mcsequpath/$trainno
    139             makedir $trainsequpath
    140             trainsequfile=$trainsequpath/sequence$firstruntrain.txt
    141             printprocesslog "INFO writing train sequencefile $trainsequfile"
    142    
    143             echo "Sequence:        $firstruntrain" >| $trainsequfile
    144             echo "Night:           $date" >> $trainsequfile
    145             echo "Epoch:           $epoch" >> $trainsequfile
    146             echo "Mode:            $mode" >> $trainsequfile
    147             echo "" >> $trainsequfile
    148             echo "CalRuns:         $calrun" >> $trainsequfile
    149             echo "PedRuns:         $pedrun" >> $trainsequfile
    150             echo "DatRuns:         $trainruns" >> $trainsequfile
    151             echo "" >> $trainsequfile
    152             echo "MonteCarlo: Yes" >> $trainsequfile
    153             echo "Training sequence" >> $trainsequfile
    154             echo "" >> $trainsequfile
    155 
    156 
    157             #test runs
    158             for testrun in ${testruns[@]}
    159             do
    160                testupdate=" update MCRunData set fSequenceFirst=\"$firstruntest\" where fRunNumber=\"$testrun\" "
    161                mysql -ss -u $us --password=$pw --host=$ho $db -e " $testupdate "
    162             done   
    163 
    164             testquery1=" select fSpectrumKEY, fPSFKEY, fAmplFadcKEY, fAtmosphericModelKEY, fObservationModeKEY, fMCParticleKEY, fReflectorVersionKEY, fCorsikaVersionKEY, fCameraVersionKEY, fViewConeAngleOKEY, fAddSpotSizeKEY, fTriggerFlagKEY from MCRunData where fRunNumber=\"$firstruntest\" "
    165             testquery2=" select sum(fNumEvents), sum(fNumTriggers), sum(fNumSumTriggers) from MCRunData where fRunNumber in ($testruns2) "
    166             testvalues=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $testquery1 "`
    167             testvalues2=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $testquery2 "`
    168             testspec=`echo $testvalues | cut -d" " -f1`
    169             testpsf=`echo $testvalues | cut -d" " -f2`
    170             testamplfadc=`echo $testvalues | cut -d" " -f3`
    171             testatmo=`echo $testvalues | cut -d" " -f4`
    172             testobs=`echo $testvalues | cut -d" " -f5`
    173             testpart=`echo $testvalues | cut -d" " -f6`
    174             testrefl=`echo $testvalues | cut -d" " -f7`
    175             testcors=`echo $testvalues | cut -d" " -f8`
    176             testcam=`echo $testvalues | cut -d" " -f9`
    177             testview=`echo $testvalues | cut -d" " -f10`
    178             testass=`echo $testvalues | cut -d" " -f11`
    179             testtrig=`echo $testvalues | cut -d" " -f12`
    180             testevents=`echo $testvalues2 | cut -d" " -f1`
    181             testtriggers=`echo $testvalues2 | cut -d" " -f2`
    182             testsumtriggers=`echo $testvalues2 | cut -d" " -f3`
    183             testquery3=" select fSequenceFirst from MCSequenceProcessStatus where fSequenceFirst=\"$firstruntest\" "
    184             testquery4=" select fSequenceFirst from MCSequences where fSequenceFirst=\"$firstruntest\" "
    185             testcheck3=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $testquery3 "`
    186             testcheck4=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $testquery4 "`
    187             testinsert1=" insert MCSequenceProcessStatus set fSequenceFirst=\"$firstruntest\", fPriority=\"$firstruntest\", fSequenceFileWritten=Now() "
    188             testinsert2=" insert MCSequences set fSequenceFirst=\"$firstruntest\", fRunStart=\"$date\", fNumEvents=\"$testevents\", fNumTriggers=\"$testtriggers\", fNumSumTriggers=\"$testsumtriggers\", fZBin=\"$zbin\", fSpectrumKEY=\"$testspec\", fPSFKEY=\"$testpsf\", fAddSpotSizeKEY=\"$testass\", fAmplFadcKEY=\"$testamplfadc\", fAtmosphericModelKEY=\"$testatmo\", fObservationModeKEY=\"$testobs\", fMCParticleKEY=\"$testpart\", fReflectorVersionKEY=\"$testrefl\", fCorsikaVersionKEY=\"$testcors\", fCameraVersionKEY=\"$testcam\", fViewConeAngleOKEY=\"$testview\", fTriggerFlagKEY=\"$testtrig\", fTestTrainKEY=3 "
    189             testupdate2=" update MCSequences set fRunStart=\"$date\", fNumEvents=\"$testevents\", fNumTriggers=\"$testtriggers\", fNumSumTriggers=\"$testsumtriggers\", fZBin=\"$zbin\", fSpectrumKEY=\"$testspec\", fPSFKEY=\"$testpsf\", fAddSpotSizeKEY=\"$testass\", fAmplFadcKEY=\"$testamplfadc\", fAtmosphericModelKEY=\"$testatmo\", fObservationModeKEY=\"$testobs\", fMCParticleKEY=\"$testpart\", fReflectorVersionKEY=\"$testrefl\", fCorsikaVersionKEY=\"$testcors\", fCameraVersionKEY=\"$testcam\", fViewConeAngleOKEY=\"$testview\", fTriggerFlagKEY=\"$testtrig\", fTestTrainKEY=3 where fSequenceFirst=\"$firstruntest\" "
    190             if [ "$testcheck3" == "" ]
    191             then
    192                mysql -ss -u $us --password=$pw --host=$ho $db -e " $testinsert1 "
    193             fi
    194             if [ "$testcheck4" == "" ]
    195             then
    196                mysql -ss -u $us --password=$pw --host=$ho $db -e " $testinsert2 "
    197             else
    198                mysql -ss -u $us --password=$pw --host=$ho $db -e " $testupdate2 "
    199             fi
    200            
    201             testno=`echo $firstruntest | cut -c 0-4`
    202             testsequpath=$mcsequpath/$testno
    203             makedir $testsequpath
    204             testsequfile=$testsequpath/sequence$firstruntest.txt
    205             printprocesslog "INFO writing test sequencefile $testsequfile"
    206    
    207             echo "Sequence:        $firstruntest" >| $testsequfile
    208             echo "Night:           $date" >> $testsequfile
    209             echo "Epoch:           $epoch" >> $testsequfile
    210             echo "Mode:            $mode" >> $testsequfile
    211             echo "" >> $testsequfile
    212             echo "CalRuns:         $calrun" >> $testsequfile
    213             echo "PedRuns:         $pedrun" >> $testsequfile
    214             echo "DatRuns:         $testruns" >> $testsequfile
    215             echo "" >> $testsequfile
    216             echo "MonteCarlo: Yes" >> $testsequfile
    217             echo "Test sequence" >> $testsequfile
    218             echo "" >> $testsequfile
     108               mysql -ss -u $us --password=$pw --host=$ho $db -e " $update1 "
     109               check3=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $query3 "`
     110               check4=`mysql -ss -u $us --password=$pw --host=$ho $db -e " $query4 "`
     111               if [ "$check3" == "" ]
     112               then
     113                  mysql -ss -u $us --password=$pw --host=$ho $db -e " $insert1 "
     114               fi
     115               if [ "$check4" == "" ]
     116               then
     117                  mysql -ss -u $us --password=$pw --host=$ho $db -e " $insert2 "
     118               else
     119                  mysql -ss -u $us --password=$pw --host=$ho $db -e " $update2 "
     120               fi
     121               
     122               no=`echo $datrun | cut -c 1-4`
     123               sequpath=$mcsequpath/$no
     124               makedir $sequpath
     125               sequfile=$sequpath/sequence$datrun.txt
     126               printprocesslog "INFO writing sequencefile $sequfile"
     127               
     128               echo "Sequence:        $datrun" >| $sequfile
     129               echo "Night:           $date" >> $sequfile
     130               echo "Epoch:           $epoch" >> $sequfile
     131               echo "Mode:            $mode" >> $sequfile
     132               echo "Azimuth:         $azmin - $azmax" >> $sequfile
     133               echo "" >> $sequfile
     134               echo "CalRuns:         $calrun" >> $sequfile
     135               echo "PedRuns:         $pedrun" >> $sequfile
     136               echo "DatRuns:         $datrun" >> $sequfile
     137               echo "" >> $sequfile
     138               echo "MonteCarlo: Yes" >> $sequfile
     139               echo "" >> $sequfile
     140               
     141            done
    219142         fi
    220143      done
Note: See TracChangeset for help on using the changeset viewer.