1 |
#!/bin/bash
|
2 |
|
3 |
#check if scramv1 is executed
|
4 |
if [ -z $CMSSW_BASE ]; then
|
5 |
echo "Please run cmsenv first"
|
6 |
exit
|
7 |
fi
|
8 |
|
9 |
#variables definition
|
10 |
CUR_DIR=$PWD
|
11 |
CMSSW_DIR=$CMSSW_BASE'/src/Visualisation/Frog/'
|
12 |
FROG_DIR=$CMSSW_DIR'./soft/'
|
13 |
REPLACE='Visualisation.Frog'
|
14 |
Cosmics_Raw_cfg='Frog_Analyzer_CosmicsFrowRaw_cfg.py'
|
15 |
Cosmics_Reco_cfg='Frog_Analyzer_CosmicsFrowReco_cfg.py'
|
16 |
frog_config='Frog_config.txt'
|
17 |
script_name="frogRun.ch"
|
18 |
run=0
|
19 |
data_set="/Cosmics/Commissioning08-PromptReco-v2/RECO"
|
20 |
|
21 |
#check if frog is compiled
|
22 |
if ! [ -f $FROG_DIR/Lib/libfrog.so ]; then
|
23 |
echo "compiling Frog"
|
24 |
cd $FROG_DIR
|
25 |
/bin/bash -l -c make
|
26 |
echo ""
|
27 |
cd $CUR_DIR
|
28 |
if ! [ -f $FROG_DIR/Lib/libfrog.so ]; then
|
29 |
echo "file $FROG_DIR/Lib/libfrog.so didn't found,"
|
30 |
echo "compilation failed, please go to "
|
31 |
echo "$FROG_DIR"
|
32 |
echo "and compile manually"
|
33 |
echo "Stop"
|
34 |
exit
|
35 |
fi
|
36 |
fi
|
37 |
|
38 |
#getting parameters
|
39 |
if [ $# -eq 1 ]; then
|
40 |
cat help/help_short
|
41 |
exit
|
42 |
fi
|
43 |
|
44 |
|
45 |
while [ $# -ge 2 ]; do
|
46 |
case $1 in
|
47 |
--help )
|
48 |
cat help/help_short
|
49 |
exit;;
|
50 |
-r )
|
51 |
shift 1
|
52 |
run=$1
|
53 |
|
54 |
shift 1;;
|
55 |
-d )
|
56 |
shift 1
|
57 |
data_set=$1
|
58 |
shift 1;;
|
59 |
-D)
|
60 |
shift 1
|
61 |
dataset=$1
|
62 |
run=-1
|
63 |
sample_name="$data_set""_AllRuns"
|
64 |
shift 1
|
65 |
break;;
|
66 |
* )
|
67 |
shift 1;;
|
68 |
esac
|
69 |
done
|
70 |
|
71 |
#define all filenames
|
72 |
if ! [ $sample_name ]; then
|
73 |
sample_name="$data_set""_Run_""$run"
|
74 |
fi
|
75 |
sample_name=$(echo "$sample_name" | sed -e 's:/:_:g')
|
76 |
sample_name=$(echo "$sample_name" | sed -e 's:-:_:g')
|
77 |
sample_name=$(echo "$sample_name" | sed -e 's:__:_:g')
|
78 |
config_file=$sample_name"_cfg.py"
|
79 |
cff_file=$sample_name"_cff"
|
80 |
cff_file_py=$sample_name"_cff.py"
|
81 |
cff_present=0
|
82 |
|
83 |
#define working directory
|
84 |
if [ $run -eq 0 ]; then
|
85 |
working_dir="$CUR_DIR/Last/"$data_set"/"
|
86 |
if [ -d $working_dir ]; then
|
87 |
rm -rf $working_dir/*
|
88 |
fi
|
89 |
elif [ $run -lt 0 ]; then
|
90 |
working_dir="$CUR_DIR/All"$data_set/
|
91 |
else
|
92 |
working_dir=$CUR_DIR"/Run_"$run$data_set
|
93 |
fi
|
94 |
|
95 |
#choosing the cfg.py file to run
|
96 |
if [ $(echo $data_set | grep "RAW") ]; then
|
97 |
cfg="Frog_Analyzer_CosmicsFrowRaw_cfg.py"
|
98 |
elif [ $(echo $data_set | grep "RECO") ]; then
|
99 |
cfg="Frog_Analyzer_CosmicsFrowReco_cfg.py"
|
100 |
else
|
101 |
echo "Don't know which cfg file to run. Will use default one:"
|
102 |
cfg="Frog_Analyzer_CosmicsFrowRaw_cfg.py"
|
103 |
fi
|
104 |
|
105 |
#getting cff file if needed
|
106 |
if [ -f $cff_file_py ]; then
|
107 |
rm $cff_file_py
|
108 |
fi
|
109 |
|
110 |
if [ $run -eq 0 ]; then
|
111 |
./get_files.py -d $data_set -f $cff_file_py
|
112 |
if ! [ -f _tmp_last_run_ ]; then
|
113 |
echo "File _tmp_last_run_ doesn't exist "
|
114 |
echo "Can't found the last run for dataset $data_set"
|
115 |
echo "Please choose one with -r option, or retry later"
|
116 |
echo "stop"
|
117 |
exit
|
118 |
else
|
119 |
run=$(head -n 1 _tmp_last_run_)
|
120 |
rm _tmp_last_run_
|
121 |
sample_name=$(echo $sample_name | sed -e 's:Run_0:Run_'$run':g')
|
122 |
mv $cff_file_py $sample_name"_cff.py"
|
123 |
config_file=$sample_name"_cfg.py"
|
124 |
cff_file=$sample_name"_cff"
|
125 |
cff_file_py=$sample_name"_cff.py"
|
126 |
if [ -d $working_dir ]; then
|
127 |
rm -rf $working_dir/*
|
128 |
fi
|
129 |
fi
|
130 |
fi
|
131 |
|
132 |
if ! [ -f $working_dir/$cff_file_py ]; then
|
133 |
if [ $run -lt 0 ]; then
|
134 |
./get_files.py -D $data_set -f $cff_file_py
|
135 |
elif [ $run -gt 0 ]; then
|
136 |
./get_files.py -r $run -d $data_set -f $cff_file_py
|
137 |
fi
|
138 |
|
139 |
if ! [ -f $cff_file_py ]; then
|
140 |
echo "$cff_file_py' : No such file"
|
141 |
echo "Stop"
|
142 |
exit
|
143 |
fi
|
144 |
fi
|
145 |
|
146 |
mkdir -p $working_dir
|
147 |
|
148 |
if [ -f $cff_file_py ]; then
|
149 |
mv $cff_file_py $working_dir/.
|
150 |
fi
|
151 |
|
152 |
if [ $run -ge 0 ]; then
|
153 |
echo " Run: $run"
|
154 |
else
|
155 |
echo " Run: ALL"
|
156 |
fi
|
157 |
echo " Dataset: $data_set"
|
158 |
echo " List of root files: $cff_file_py"
|
159 |
|
160 |
echo " base cfg file : $cfg"
|
161 |
echo " cfg file to run : $config_file"
|
162 |
echo " working dir : $working_dir"
|
163 |
|
164 |
if ! [ -f ./cfg/$cfg ]; then
|
165 |
echo "./cfg/$cfg : No such file"
|
166 |
echo "Stop"
|
167 |
exit
|
168 |
fi
|
169 |
|
170 |
cd $working_dir
|
171 |
if [ "$( ps -eo command | grep $working_dir | grep -v grep )" ]; then
|
172 |
echo "Several processus found working in directory "
|
173 |
echo "$working_dir"
|
174 |
echo " PID User START TIME COMM"
|
175 |
ps -eo pid,user,start,time,command | grep $working_dir | grep -v grep | awk '{print $1,$2,$3,$4,$5}'
|
176 |
echo "Running cmssw or frog may interfere.Please wait than the processus finished"
|
177 |
echo "Stop"
|
178 |
exit
|
179 |
fi
|
180 |
|
181 |
cp $cff_file_py $CMSSW_DIR/python/.
|
182 |
sed -e 's:'$REPLACE'.files_list_cfi:'$REPLACE'.'$cff_file':g' $CUR_DIR/cfg/$cfg | sed -e 's:output.vis:'$sample_name'.vis:g' > $working_dir/$config_file
|
183 |
cp $working_dir/$config_file $CMSSW_DIR/python/_tmp_cfg.py
|
184 |
|
185 |
cd $CMSSW_DIR
|
186 |
echo "Compiling CMSSW"
|
187 |
scramv1 b
|
188 |
|
189 |
cd $working_dir
|
190 |
|
191 |
if [ "$(ls -1 | grep $sample_name | grep vis | grep -v vis.gz)" ]; then
|
192 |
rm $sample_name*.vis
|
193 |
fi
|
194 |
|
195 |
if [ "$(ls -1 | grep $sample_name | grep vis.gz)" ]; then
|
196 |
num_vis=$(ls -1 | grep $sample_name | grep vis.gz | wc -l)
|
197 |
echo "$num_vis .vis.gz files found:"
|
198 |
echo "Will run frog on:"
|
199 |
vis_file=$(ls -1 | grep $sample_name | grep vis.gz | head -n 1)
|
200 |
echo $vis_file
|
201 |
if ! [ -f $frog_config ]; then
|
202 |
cp $CUR_DIR/cfg/$frog_config .
|
203 |
fi
|
204 |
xterm -T "Frog $data_set Run: $run" -e "$FROG_DIR/frog $working_dir/$vis_file -c $working_dir/$frog_config 2>&1 | $CUR_DIR/src/log_filter.py | tee $working_dir/frog_out.log"&
|
205 |
exit
|
206 |
fi
|
207 |
|
208 |
if [ -f $working_dir/cmssw_out.log ]; then
|
209 |
rm $working_dir/cmssw_out.log
|
210 |
fi
|
211 |
#xterm -T "cmsRun $data_set Run: $run" -e "cmsRun $CMSSW_DIR/python/_tmp_cfg.py 2>&1 | tee $working_dir/cmssw_out.log"&
|
212 |
xterm -T "cmsRun $data_set Run: $run" -e "cmsRun $CMSSW_DIR/python/_tmp_cfg.py 2>&1 | $CUR_DIR/src/log_filter.py | tee $working_dir/cmssw_out.log"&
|
213 |
|
214 |
if ! [ -f $frog_config ]; then
|
215 |
sed -e 's:InputGeom = { CMS.geom.gz };:InputGeom = { '$CUR_DIR/cfg/'CMS.geom.gz };:g' $CUR_DIR/cfg/$frog_config > $working_dir/$frog_config
|
216 |
fi
|
217 |
|
218 |
#xterm -T "Frog $data_set Run: $run" -e "$FROG_DIR/frog $working_dir/_tmp_.vis -c $working_dir/$frog_config 2>&1 | tee $working_dir/frog_out.log"&
|
219 |
xterm -T "Frog $data_set Run: $run" -e "$FROG_DIR/frog $working_dir/_tmp_.vis -c $working_dir/$frog_config 2>&1 | $CUR_DIR/src/log_filter.py | tee $working_dir/frog_out.log"&
|
220 |
|
221 |
#exporting needed variables for controlling cmssw
|
222 |
export CMSSW_DIR=$CMSSW_DIR
|
223 |
export working_dir=$working_dir
|
224 |
export CUR_DIR=$CUR_DIR
|
225 |
export sample_name=$sample_name
|
226 |
|
227 |
$CUR_DIR/src/cmssw_control.sh&
|
228 |
|
229 |
|
230 |
exit
|
231 |
|
232 |
|