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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
#!/bin/bash
WebDir='/eos/cms/store/group/dpg_hcal/comm_hcal/www/HcalRemoteMonitoring'
WebSite='https://cms-conddb.cern.ch/eosweb/hcal/HcalRemoteMonitoring'
HistoDir='/store/group/dpg_hcal/comm_hcal/www/HcalRemoteMonitoring/ALCARECOPSM/histos'
eos='/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select'
# print usage info
if [[ "$1" == "" ]]; then
echo "Usage:"
echo " $0 file [comment] [-ignore-file] [-das-cache]"
echo " file -- a file with run numbers"
echo " comment -- add a comment line (instead of spaces use '_')"
echo " -ignore-file -- skips production of run html pages. Produces"
echo " only the ALCARECO page. File name is not needed."
echo " -das-cache -- whether to save DAS information locally for a reuse"
echo
echo "example: ./ALCARECO.sh Run_List.txt"
exit 1
fi
cmsenv 2>/dev/null
if [ $? == 0 ] ; then
eval `scramv1 runtime -sh`
fi
temp_var=`ls ${eos}`
status="$?"
echo "using eos command <${temp_var}>"
if [ ! ${status} -eq 0 ] ; then
echo "failed to find eos command"
# exit 1
fi
# create log directory
LOG_DIR="dir-Logs"
if [ ! -d ${LOG_DIR} ] ; then mkdir ${LOG_DIR}; fi
rm -f ${LOG_DIR}/*
# Process arguments and set the flags
fileName=$1
comment=$2
if [ ${#comment} -gt 0 ] && [ "${comment:0:1}" == "-" ] ; then comment=""; fi
ignoreFile=0
debug=0
dasCache=0
DAS_DIR="d-DAS-info"
for a in $@ ; do
if [ "$a" == "-ignore-file" ] ; then
echo " ** file will be ignored"
fileName=""
ignoreFile=1
elif [ "$a" == "-das-cache" ] ; then
echo " ** DAS cache ${DAS_DIR} enabled"
dasCache=1
if [ ! -d ${DAS_DIR} ] ; then mkdir ${DAS_DIR}; fi
else
temp_var=${a/-debug/}
if [ ${#a} -gt ${#temp_var} ] ; then
debug=${temp_var}
echo " ** debug detected (debug=${debug})"
fi
fi
done
# Obtain the runList from a file, if needed
runList=""
if [ ${#fileName} -gt 0 ] ; then
if [ -s ${fileName} ] ; then
runList=`cat ${fileName}`
else
echo "<${fileName}> does not seem to be a valid file"
exit 2
fi
else
if [ ${ignoreFile} -eq 0 ] ; then
echo " ! no file provided"
fi
echo " ! will produce only html page"
fi
# Check the runList and correct the correctables
# Replace ',' and ';' by empty spaces
runList=`echo "${runList}" | sed 'sk,k\ kg' | sed 'sk;k\ kg'`
ok=1
for r in ${runList} ; do
if [ ! ${#r} -eq 6 ] ; then
echo "run numbers are expected to be of length 6. Check <$r>"
ok=0
fi
debug_loc=0
if [ "$r" -eq "$r" ] 2>/dev/null ; then
if [ ${debug_loc} -eq 1 ] ; then echo "run variable <$r> is a number (ok)"; fi
else
echo "error: run variable <$r> is not an integer number"
ok=0
fi
done
echo "Tested `wc -w <<< "${runList}"` runs from file ${fileName}"
if [ ${ok} -eq 0 ] ; then
echo "errors in the file ${fileName} with run numbers"
exit 3
else
if [ ${#fileName} -gt 0 ] ; then
echo "run numbers in ${fileName} verified ok"
fi
fi
comment=`echo ${comment} | sed sk\_k\ kg`
if [ ${#comment} -gt 0 ] ; then
echo "comment \"${comment}\" will be added to the pages"
fi
if [ ${debug} -eq 3 ] ; then exit; fi
echo
echo
echo
echo 'Run numbers for processing'
echo "${runList}"
echo -e "list complete\n"
#processing
for i in ${runList} ; do
runnumber=$i
logFile="${LOG_DIR}/log_${runnumber}.out"
rm -f ${logFile}
# if [[ "$runnumber" > 233890 ]] ; then
echo
echo
echo
echo "Run for processing $runnumber"
echo "always copy root file from /eos !!!"
echo "file=root://eoscms//cms/$HistoDir/Global_$runnumber.root"
# always copy root file from /eos !!!
## if [ ! -s Global_${runnumber}.root ] ; then
## xrdcp root://eoscms//eos/cms/$HistoDir/Global_$runnumber.root Global_$runnumber.root
xrdcp -f root://eoscms//eos/cms/$HistoDir/Global_$runnumber.root Global_$runnumber.root
status="$?"
if [ ! ${status} -eq 0 ] ; then
echo "failed to get file Global_${runnumber}.root"
exit 2
fi
## fi
#ALCARECOPSM processing
echo -e "\nRemoteMonitoringPSM\n" >> ${logFile}
# ./../../macros/psm/RemoteMonitoringPSM.cc.exe Global_$runnumber.root 2>&1 | tee -a ${logFile}
# ./../../macros/psm/RemoteMonitoringALCARECOPSM.cc.exe Global_$runnumber.root Global_$runnumber.root Global 2>&1 | tee -a ${logFile}
./../../macros/psm/RemoteMonitoringALCARECOPSM.cc.exe Global_$runnumber.root Global_$runnumber.root 2>&1 | tee -a ${logFile}
if [ ! $? -eq 0 ] ; then
echo "ALCARECOPSM processing failed"
exit 2
fi
## if [ ! -s HELP.html ] ; then
## echo "GLOBAL failure was not detected. HELP.html is missing"
## exit 2
## fi
local_WebDir=dir-ALCARECOPSM-GLOBAL_${runnumber}
rm -rf ${local_WebDir}
if [ ! -d ${local_WebDir} ] ; then mkdir ${local_WebDir}; fi
for j in $(ls -r *.html); do
cat $j | sed 's#cms-cpt-software.web.cern.ch\/cms-cpt-software\/General\/Validation\/SVSuite#cms-conddb.cern.ch\/eosweb\/hcal#g' \
> ${local_WebDir}/$j
done
cp *.png ${local_WebDir}
## cp HELP.html ${local_WebDir}
#-----------------------------------------------------------------------------------------copying:
#---------------111
# first variant:
mkdir $WebDir/ALCARECOPSM/GLOBAL_$runnumber
cp *.png $WebDir/ALCARECOPSM/GLOBAL_$runnumber/.
cp *.html $WebDir/ALCARECOPSM/GLOBAL_$runnumber/.
echo "cp png and html file done"
#---------------222 wrong, create dir GLOBAL_$runnumber and inside, the dir local_WebDir
# more simple second variant:
#scp -r ${local_WebDir} $WebDir/ALCARECOPSM/GLOBAL_$runnumber
#echo "cp -r for dir with png and html file done"
#---------------old
# instead old variant:
# files=`cd ${local_WebDir}; ls`
###echo "ALCARECOPSM files=${files}"
# if [ ${debug} -eq 0 ] ; then
# eos mkdir -p $WebDir/ALCARECOPSM/GLOBAL_$runnumber
# if [ ! $? -eq 0 ] ; then
# echo "ALCARECOPSM eos mkdir failed"
# exit 2
# fi
# for f in ${files} ; do
# echo "eoscp ${local_WebDir}/${f} $WebDir/ALCARECOPSM/GLOBAL_$runnumber/${f}"
# eos cp ${local_WebDir}/${f} $WebDir/ALCARECOPSM/GLOBAL_$runnumber/${f}
# if [ ! $? -eq 0 ] ; then
# echo "ALCARECOPSM eoscp failed for ${f}"
#### exit 2
# fi
# done
# else
## debuging
# echo "debugging: files are not copied to EOS"
# fi
#
#---------------
#
# removing:
#
#
#
rm *.html
rm *.png
# rm -rf dir-ALCARECOPSM-GLOBAL_*
# rm *.root
#
#---------------
#fi
done
if [ ${debug} -eq 2 ] ; then
echo "debug=2 skipping web page creation"
exit 2
fi
#---------------
echo "ALCARECOPSM script done"
#---------------
|