-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun_HistoMaker.sh
executable file
·108 lines (107 loc) · 5.1 KB
/
run_HistoMaker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
LOWSTAT=1
PHM=1
RAND=`uuid | sed "s;-;_;g"`
CWD=`pwd -P`
echo " ---------------------------------------------------"
for arg in "$@"; do
if [[ ! $arg == *".py" ]]; then
echo "$arg is not a crab script"
else
CRAB_CFG=$arg
echo
echo "Using crab config file: $CRAB_CFG"
echo
# read infos from crab config file
LFN=`grep "config.Data.outLFNDirBase" $CRAB_CFG | sed "s;';;g" | awk '{ print $3 }' | sed 's;/$;;'`
TASKNAME=`grep "config.Data.outputDatasetTag" $CRAB_CFG | sed "s;';;g" | awk '{ print $3 }'`
PRIMARY=`grep "config.Data.inputDataset" $CRAB_CFG | sed "s;';;g;s;/; ;g" | awk '{ print $3 }'`
AUTONAME=`echo $CRAB_CFG | sed "s;crab3_;;;s;.py;;"`
# Read info from the crab status
#crab status -d crab_$AUTONAME > crab_status_$RAND.txt
#NJOB=`cat crab_status_$RAND.txt | grep -v Warning | grep -E "%.*\(.*\)" | tail -1 | sed "s;(; ;;s;); ;;s;/; ;" | awk '{ print $NF }'`
#rm crab_status_$RAND.txt
# Read njobs from crab.log which is faster and more reliable
NJOB=`grep "Jobs status" crab_$AUTONAME/crab.log | head -1 | sed "s;(; ;;s;); ;;s;/; ;" | awk '{ print $NF }'`
# Set input directory
TIME=`/data/jkarancs/scripts/se_util.csh ls T2_HU_Budapest:$LFN/$PRIMARY/$TASKNAME | tail -1`
DL_DIR=`echo $LFN/$PRIMARY/$TASKNAME/$TIME | sed "s;/store/user;/data/gridout;"`
NCOMP=`ls $DL_DIR/*/*.root | wc -l`
PERCENT=`echo $(( $NCOMP*100/$NJOB ))`
# Decide if it is needed to create an SEU list first (BADROC list)
cd /data/jkarancs/CMSSW/TimingStudy/Latest/src > /dev/null
cmsenv > /dev/null 2>&1 > /dev/null
cd /data/jkarancs/CMSSW/PixelHistoMaker_git > /dev/null
if [ -f PHM_PHASE1_out/BADROC_"$AUTONAME".root ]; then BADROC=0; else BADROC=1; fi
# Wait until at least 50% of the files download for quick restults on low statistics
if (( $LOWSTAT )); then
while (( $PERCENT < 75 )); do
sleep 5m
NCOMP=`ls $DL_DIR/*/*.root | wc -l`
PERCENT=`echo $(( $NCOMP*100/$NJOB ))`
done
echo " ---------------------------------------------------"
echo
echo "75% of jobs finished, running first a low statistics analysis (on 10% statistics)"
echo
if (( $BADROC )); then
echo "- Start creating BADROC list first"
echo " Input files: $DL_DIR/*/*5.root ($NCOMP/$NJOB)"
echo " Output file: PHM_PHASE1_out/BADROC_"$AUTONAME"_lowstat.root"
echo " Log file: PHM_PHASE1_out/BADROC_"$AUTONAME"_lowstat.log"
if (( $PHM )); then
# Wait for BADROC list to finish, before running plotting
./Phase1PixelHistoMaker -b -o PHM_PHASE1_out/BADROC_"$AUTONAME"_lowstat.root $DL_DIR/*/*5.root > PHM_PHASE1_out/BADROC_"$AUTONAME"_lowstat.log 2>&1
else
# Otherwise run in background
nohup ./Phase1PixelHistoMaker -b -o PHM_PHASE1_out/BADROC_"$AUTONAME"_lowstat.root $DL_DIR/*/*5.root > PHM_PHASE1_out/BADROC_"$AUTONAME"_lowstat.log 2>&1 &
fi
fi
if (( $PHM )); then
echo
echo "- Start running PixelHistoMaker (in background)"
echo " Input files: $DL_DIR/*/*5.root ($NCOMP/$NJOB)"
echo " Output file: PHM_PHASE1_out/HitEffMonitoring_"$AUTONAME"_lowstat.root"
echo " Log file: PHM_PHASE1_out/HitEffMonitoring_"$AUTONAME"_lowstat.log"
nohup python run_phm.py --outdir="PHM_PHASE1_out/HitEffMonitoring_"$AUTONAME"_lowstat" --nfile=$(($NCOMP/10/7)) --nproc=4 "$DL_DIR/*/*5.root" --run > "PHM_PHASE1_out/HitEffMonitoring_"$AUTONAME"_lowstat.log" 2>&1 &
fi
echo
fi
# Run the full statistics analysis
while (( $PERCENT < 95 )); do
sleep 5m
NCOMP=`ls $DL_DIR/*/*.root | wc -l`
PERCENT=`echo $(( $NCOMP*100/$NJOB ))`
done
echo " ---------------------------------------------------"
echo
echo "95% of jobs finished, running full statistics analysis"
echo
if (( $BADROC )); then
echo "- Start creating BADROC list first"
echo " Input files: $DL_DIR/*/*.root ($NCOMP/$NJOB)"
echo " Output file: PHM_PHASE1_out/BADROC_"$AUTONAME".root"
echo " Log file: PHM_PHASE1_out/BADROC_"$AUTONAME".log"
if (( $PHM )); then
# Wait for BADROC list to finish, before running plotting
./Phase1PixelHistoMaker -b -o PHM_PHASE1_out/BADROC_"$AUTONAME".root $DL_DIR/*/*.root > PHM_PHASE1_out/BADROC_"$AUTONAME".log 2>&1
else
# Otherwise run in background
nohup ./Phase1PixelHistoMaker -b -o PHM_PHASE1_out/BADROC_"$AUTONAME".root $DL_DIR/*/*.root > PHM_PHASE1_out/BADROC_"$AUTONAME".log 2>&1 &
fi
fi
if (( $PHM )); then
echo
echo "- Start running PixelHistoMaker (in background)"
echo " Input files: $DL_DIR/*/*.root ($NCOMP/$NJOB)"
echo " Output file: PHM_PHASE1_out/HitEffMonitoring_"$AUTONAME".root"
echo " Log file: PHM_PHASE1_out/HitEffMonitoring_"$AUTONAME".log"
nohup python run_phm.py --outdir="PHM_PHASE1_out/HitEffMonitoring_"$AUTONAME --nfile=$(($NCOMP/20)) --nproc=4 "$DL_DIR/*/*.root" --run > "PHM_PHASE1_out/HitEffMonitoring_"$AUTONAME".log" 2>&1 &
fi
echo
echo " --------------- "$AUTONAME" Done. -----------------"
echo
cd $CWD > /dev/null
cmsenv > /dev/null 2>&1 > /dev/null
fi
done