Index: trunk/MagicSoft/Mars/datacenter/scripts/mcsequences
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/mcsequences	(revision 8482)
+++ trunk/MagicSoft/Mars/datacenter/scripts/mcsequences	(revision 8758)
@@ -40,5 +40,5 @@
 set -C
 
-scriptlog=$runlogpath/$program`date +%F`.log
+scriptlog=$runlogpath/$program-$datetime.log
 date >> $scriptlog 2>&1
 
@@ -48,9 +48,10 @@
 
 # find montecarlo directories, build one sequence per directory and write sequence file
-printprocesslog "INFO building one sequence per mcdirectory"
+printprocesslog "INFO building one sequence per mcdirectory and epoch"
 dirs=`find $mcrawpath -type d`
 for dir in ${dirs[@]}
 do 
-   cont=`echo $dir | cut -d/ -f6`
+#   cont=`echo $dir | cut -d/ -f6`
+   cont=`echo $dir | cut -d/ -f10`
    if [ "$cont" == "" ]
    then
@@ -58,35 +59,45 @@
    fi
    echo $dir >> $scriptlog 2>&1
-   files=`ls $dir`
-   calfile=`find $dir -name *_C_*`
-   pedfile=`find $dir -name *_P_*`
-   calrun=`echo $calfile | cut -d_ -f2`
-   pedrun=`echo $pedfile | cut -d_ -f2`
-   datruns=`find $dir -name *_D_* | cut -d_ -f2 | tr "\n" " "`
-# workaround due to 5digit runnumber for data with runnumber < 35487
-#   firstrun=`echo $datruns | cut -c 0-8`
-   firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
-   date=`echo $dir | cut -c 22-31 | sed -e 's/\//-/g'`
    
-# workaround due to 5digit runnumber for data with runnumber < 35487
-#   no=`echo $firstrun | cut -c 0-4`
-   no=`printf %08d $firstrun | cut -c 0-4`
-   no2=`printf %08d $firstrun`
-   sequpath=$mcsequpath/$no
-   makedir $sequpath >> $scriptlog 2>&1
-#   sequfile=$sequpath/sequence$firstrun.txt
-   sequfile=$sequpath/sequence$no2.txt
-   echo "writing sequfile "$sequfile >> $scriptlog 2>&1
-   printprocesslog "INFO writing sequencefile $sequfile"
-   
-   echo "Sequence:        $firstrun" >| $sequfile
-   echo "Night:           $date" >> $sequfile
-   echo "" >> $sequfile
-   echo "CalRuns:         $calrun" >> $sequfile
-   echo "PedRuns:         $pedrun" >> $sequfile
-   echo "DatRuns:         $datruns" >> $sequfile
-   echo "" >> $sequfile
-   echo "MonteCarlo: Yes" >> $sequfile
-   echo "" >> $sequfile
+   epochs=`ls -l $mcpath/camera | cut -c 52-70`
+   for epoch in ${epochs[@]}
+   do
+      echo $epoch >> $scriptlog 2>&1
+      calfile=`find $dir -lname *$epoch*.root | grep "_C_"`
+      pedfile=`find $dir -lname *$epoch*.root | grep "_P_"`
+#      datfiles=`find $dir -lname '*$epoch*.root' | grep "_D_"`
+      
+      calrun=`echo $calfile | cut -d_ -f2`
+      pedrun=`echo $pedfile | cut -d_ -f2`
+      datruns=`find $dir -lname *$epoch*.root | grep "_D_" | cut -d_ -f2 | tr "\n" " "`
+      # workaround due to 5digit runnumber for data with runnumber < 35487
+      firstrun=`echo $datruns | cut -c 0-8`
+      #   firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
+#      date=`echo $dir | cut -c 28-37 | sed -e 's/\//-/g'`
+      # for tests
+      date=`echo $dir | cut -c 57-66 | sed -e 's/\//-/g'`
+      
+      # workaround due to 5digit runnumber for data with runnumber < 35487
+      no=`echo $firstrun | cut -c 0-4`
+      #   no=`printf %08d $firstrun | cut -c 0-4`
+      #   no2=`printf %08d $firstrun`
+      sequpath=$mcsequpath/$no
+      makedir $sequpath >> $scriptlog 2>&1
+      sequfile=$sequpath/sequence$firstrun.txt
+      #   sequfile=$sequpath/sequence$no2.txt
+      echo "writing sequfile "$sequfile >> $scriptlog 2>&1
+      printprocesslog "INFO writing sequencefile $sequfile"
+      
+      echo "Sequence:        $firstrun" >| $sequfile
+      echo "Night:           $date" >> $sequfile
+      echo "Epoch:           $epoch" >> $sequfile
+      echo "" >> $sequfile
+      echo "CalRuns:         $calrun" >> $sequfile
+      echo "PedRuns:         $pedrun" >> $sequfile
+      echo "DatRuns:         $datruns" >> $sequfile
+      echo "" >> $sequfile
+      echo "MonteCarlo: Yes" >> $sequfile
+      echo "" >> $sequfile
+   done
 done
 
