#!/bin/sh
# @Author: Elena Graverini
# @Date:   2016-01-13 10:52:22
# @Last Modified by:   Elena Graverini
# @Last Modified time: 2016-01-15 10:35:16

# Locations
swsource=$HOME/STAging/macros/CCEScan
runCondSw=$HOME/STAging/macros/runCond
scripts=$swsource/batch
logs=/disk/data1/hep/elena/logs/ST/CCEScan

# Backup old data
echo "Backup file!"
echo "cp /disk/data1/hep/elena/data/ST/Aging/Hamburg.root /disk/data1/hep/elena/data/ST/Aging/Hamburg_backup_Jan16_2.root"
cp /disk/data1/hep/elena/data/ST/Aging/Hamburg.root /disk/data1/hep/elena/data/ST/Aging/Hamburg_backup_Jan16_2.root

# Prepare script
scriptname="hamburg_allIT"
cp $scripts/base.sh $scripts/temp_scripts/${scriptname}.sh


# IT Hamburg model predictions
# ============================
echo "Preparing IT:"
for sector in `cat $swsource/ITsectors.dat`
do
    echo "${swsource}/Hamburg -d IT -l T3X2 -s ${sector} -b" >> $scripts/temp_scripts/${scriptname}.sh
done
for sector in `cat $swsource/ITinner.dat`
do
    echo "${swsource}/Hamburg -d IT -l T3X2 -s ${sector} -r 175 -b" >> $scripts/temp_scripts/${scriptname}.sh
done

# Submit job
# ==========
# 66 TT sectors
# 27 IT sectors
# 5 TT inner sectors * 3 radii
# 7 IT inner sectors
# --> total of 115 sectors to run.
# Hamburg alone = 100 s per sector --> 11500 s
# Full TT issue of fluenceExtract = ~20 min (1210 s)
# --> total ~6*1210 s = 7260 s
qsub -l cput=99000 $scripts/temp_scripts/${scriptname}.sh -o ${logs}/${scriptname}.log -e ${logs}/${scriptname}.log -j oe
