-
Notifications
You must be signed in to change notification settings - Fork 12
/
xem_setup.sh
executable file
·416 lines (357 loc) · 15.2 KB
/
xem_setup.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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
#!/bin/bash
echo "================================================="
echo "For help on usage, type: ./xem_setup.sh -help"
echo "================================================="
Help()
{
# Display Help
echo "-------------------------------------------------------"
echo "This shell script automatically sets up the necessary symbolic"
echo "links (or dir.) for the XEM experiment based on which "
echo "machine (ifarm, cdaq) the user is at."
echo ""
echo "Syntax: ./xem_setup.sh [ -h | -f ]"
echo ""
echo "options:"
echo "-help Print this help display"
echo ""
echo "For users on IFARM ONLY: "
echo "-f ONLY use this option if you are running this shell script on ifarm. "
echo " This option selects filesystem in which to read/write data "
echo " from the XEM experiment. "
echo ""
echo " The optional arguments are: volatile, ... THATS IT!"
echo ""
echo " volatile, work, group: "
echo " these options will set symbolic links to the corresponding filesystem "
echo " you would want to set these options depending on which stage of the analysis you are in "
echo " for example, use volatile if you are in the beginning stages of off-line analysis"
echo ""
echo " See https://hallcweb.jlab.org/wiki/index.php/XEM_Disk_Space "
echo " for detailed information on each of these filesystems."
echo " "
echo "examples: ./xem_setup.sh -f group"
echo " ./xem_setup.sh -f volatile"
echo " ./xem_setup.sh -f work"
echo "-------------------------------------------------------"
}
set_hcana_link()
{
if [[ -z $HCANALYZER ]]; then
echo ""
echo "Environment variable: $HCANALYZER does NOT exist. "
echo "Please make sure to do: source setup.sh(csh) in hcana first. "
echo ""
else
echo ""
echo "Creating hcana symbolic link now . . ."
ln -sf $HCANALYZER"/hcana"
ln -sf $HCANALYZER"/libHallC.so"
ln -sf $HCANALYZER"/libHallC.so.0.90.0"
echo ""
fi
}
# initialize machine flags to 0
# (depending on where this script gets called, it will turn ON one of these)
ifarm_flg=0
cdaq_flg=0
# define the optional arguments
while getopts ":h:f:" option; do
case $option in
h) # display Help
Help
exit;;
f) # Enter a filesystem name (only applies for ifarm)
fsys=$OPTARG;;
\?) # Invalid option
echo "Error: Invalid option"
Help
exit;;
esac
done
if echo $HOSTNAME | grep -q "ifarm"; then
ifarm_flg=1
elif echo $HOSTNAME | grep -q "cdaq"; then
cdaq_flg=1
else
echo "Unknown hostname, use ifarm or cdaq"
fi
#if [[ ifarm_flg==0 && cdaq_flg==0 ]]; then
# echo "***************************************"
# echo " Did not recognize remote machine. "
# echo " Please run: ./xem_setup.sh -help "
# echo " for help in running this script."
# echo "***************************************"
#fi
#--- most recent raw data (irrespective of exp.)----
coda_raw="/net/cdaq/cdaql1data/coda/data/raw"
coda_raw_copiedtotape="/net/cdaq/cdaql1data/coda/data/raw.copiedtotape"
#--- define tape allocations ---
# make sure to point to the XEM 2022 tape dir
# since this 1st part will be taken during pionLT running.
# where XEM raw data output to be replayed will be stored (.dat files(
# but these are NOT directly accessible, one would have to look for them in cache.
# tape_raw_dir="/mss/hallc/c-xem-2022/raw"
tape_raw_dir="/mss/hallc/xem2/raw"
# tape volume for analysis output (simulation or replay output you want to keep long-term)
tape_analysis_out="/mss/hallc/xem2/analysis"
#--- define cache allocations ---
# xem
cache_raw_dir_xem="/cache/hallc/xem2/raw/"
cache_raw_dir_sp18="/cache/hallc/spring17/raw/"
cache_raw_dir_sp19="/cache/hallc/jpsi-007/raw/"
cache_raw_dir_cafe="/cache/hallc/c-cafe-2022/raw/"
cache_raw_dir_pionlt="/cache/hallc/c-pionlt/raw"
cache_analysis_out="/cache/hallc/xem2/analysis/"
#=================================
# ifarm
# (off-line experiment analysis
# or testing the replay scripts)
#
# =================================
if [[ ifarm_flg -eq 1 ]]; then
# source hallc_replay_XEM
source setup.csh
if [[ -z $fsys ]]; then
echo ""
echo " No optional argumnets provided "
echo ""
echo "----------------------------------------------------------------------"
echo " For help using additional options, please run: ./xem_setup.sh -help "
echo "----------------------------------------------------------------------"
echo "Exiting NOW . . . "
echo ""
exit 1
fi
echo ""
echo "Checking if necessary directories or symlinks exist in remote machine: " ${USER}"@"${HOSTNAME}". . ."
echo ""
# setup the symbolic links to hcana
source /group/c-xem2/software/XEM_v2.0.0/hcana_firmware_update/hcana/setup.csh /group/c-xem2/software/XEM_v2.0.0/hcana_firmware_update/hcana/
set_hcana_link
if [[ $fsys == "volatile" ]]; then
echo ""
echo 'Setting up symbolic links to volatile filesystem on ifarm . . .'
base_dir_voli="/volatile/hallc/xem2/"
echo "Creating dir $base_dir_voli$USER . . ."
mkdir $base_dir_voli$USER
CACHE_LINKS="./CACHE_LINKS/"
if [ ! -d "$CACHE_LINKS" ]; then
mkdir $CACHE_LINKS
else
rm -rf $CACHE_LINKS
mkdir $CACHE_LINKS
fi
echo "Creating symlink to ${cache_raw_dir_xem}"
ln -sf $cache_raw_dir_xem $CACHE_LINKS/cache_xem2
echo "Creating symlink to ${cache_raw_dir_sp18}"
ln -sf $cache_raw_dir_sp18 $CACHE_LINKS/cache_sp18
echo "Creating symlink to ${cache_raw_dir_sp19}"
ln -sf $cache_raw_dir_sp19 $CACHE_LINKS/cache_sp19
echo "Creating symlink to ${cache_raw_dir_pionlt}"
ln -sf $cache_raw_dir_pionlt $CACHE_LINKS/cache_pionlt
echo "Creating symlink to ${cache_raw_dir_cafe}"
ln -sf $cache_raw_dir_cafe $CACHE_LINKS/cache_cafe
echo "Creating dir and symlink to $base_dir_voli$USER/REPORT_OUTPUT . . ."
mkdir $base_dir_voli$USER"/REPORT_OUTPUT"
ln -sf $base_dir_voli$USER"/REPORT_OUTPUT"
#Creating REPORT_OUTPUT/SPEC Directories
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/HMS"
#Add COIN REPORT_OUTPUT Directories
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/REPLAY_REPORT"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/COMMISSIONING"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/CALIBRATION"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/PRODUCTION"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/SCALARS"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/HeeP"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/TIMING"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/shms50k"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/COIN/hms50k"
#Add SHMS REPORT_OUTPUT Directories
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS/REPLAY_REPORT"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS/COMMISSIONING"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS/COMMISSIONING/HODO_CHECK"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS/CALIBRATION"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS/PRODUCTION"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS/SCALARS"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS/TIMING"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/SHMS/shms50k"
#Add HMS REPORT_OUTPUT Directories
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/HMS/REPLAY_REPORT"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/HMS/COMMISSIONING"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/HMS/CALIBRATION"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/HMS/PRODUCTION"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/HMS/SCALARS"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/HMS/TIMING"
mkdir $base_dir_voli$USER"/REPORT_OUTPUT/HMS/hms50k"
echo "Creating dir and symlink to $base_dir_voli$USER/ROOTfiles . . ."
mkdir $base_dir_voli$USER"/ROOTfiles"
ln -sf $base_dir_voli$USER"/ROOTfiles"
#Creating ROOTfiles/SPEC Directories
mkdir $base_dir_voli$USER"/ROOTfiles/COIN"
mkdir $base_dir_voli$USER"/ROOTfiles/SHMS"
mkdir $base_dir_voli$USER"/ROOTfiles/HMS"
#Add COIN ROOTfiles Directories
mkdir $base_dir_voli$USER"/ROOTfiles/COIN/COMMISSIONING"
mkdir $base_dir_voli$USER"/ROOTfiles/COIN/CALIBRATION"
mkdir $base_dir_voli$USER"/ROOTfiles/COIN/PRODUCTION"
mkdir $base_dir_voli$USER"/ROOTfiles/COIN/SCALARS"
mkdir $base_dir_voli$USER"/ROOTfiles/COIN/TIMING"
mkdir $base_dir_voli$USER"/ROOTfiles/COIN/HeeP"
mkdir $base_dir_voli$USER"/ROOTfiles/COIN/shms50k"
mkdir $base_dir_voli$USER"/ROOTfiles/COIN/hms50k"
#Add SHMS ROOTfiles Directories
mkdir $base_dir_voli$USER"/ROOTfiles/SHMS/COMMISSIONING"
mkdir $base_dir_voli$USER"/ROOTfiles/SHMS/COMMISSIONING/HODO_CHECK"
mkdir $base_dir_voli$USER"/ROOTfiles/SHMS/CALIBRATION"
mkdir $base_dir_voli$USER"/ROOTfiles/SHMS/PRODUCTION"
mkdir $base_dir_voli$USER"/ROOTfiles/SHMS/SCALARS"
mkdir $base_dir_voli$USER"/ROOTfiles/SHMS/TIMING"
mkdir $base_dir_voli$USER"/ROOTfiles/SHMS/shms50k"
#Add HMS ROOTfiles Directories
mkdir $base_dir_voli$USER"/ROOTfiles/HMS/COMMISSIONING"
mkdir $base_dir_voli$USER"/ROOTfiles/HMS/CALIBRATION"
mkdir $base_dir_voli$USER"/ROOTfiles/HMS/PRODUCTION"
mkdir $base_dir_voli$USER"/ROOTfiles/HMS/SCALARS"
mkdir $base_dir_voli$USER"/ROOTfiles/HMS/TIMING"
mkdir $base_dir_voli$USER"/ROOTfiles/HMS/hms50k"
elif [[ $fsys == "work" ]]; then
echo ""
echo 'Setting up symbolic links to work filesystem on ifarm . . .'
echo 'Currently not implemented . . .'
elif [[ $fsys == "group" ]]; then
echo ""
echo 'Setting up symbolic links to group filesystem on ifarm . . .'
base_dir_group="/group/c-xem-2022/"
echo 'Currently not implemented . . .'
fi
fi
#===============================
# cdaq cluster
# (online experiment analysis)
#===============================
if [[ cdaq_flg -eq 1 ]]; then
echo "Enter your CUE Username"
read usr
echo "Checking if necessary directories or symlinks exist in remote machine: " ${usr}"@"${HOSTNAME}". . ."
# source xem_online_replay
source setup.csh
# setup the symbolic links to hcana
set_hcana_link
base_dir_cdaq="/net/cdaq/cdaql1data/cdaq/hallc-online-xem2022/USERS/${usr}"
if [ -d "${base_dir_cdaq}" ]; then
echo "Directory ${base_dir_cdaq} exists."
else
mkdir $base_dir_cdaq
fi
echo "Creating symlink to ${coda_raw}"
ln -sf $coda_raw
echo "Creating symlink to ${coda_raw_copiedtotape}"
ln -sf $coda_raw_copiedtotape
CACHE_LINKS="./CACHE_LINKS/"
if [ ! -d "$CACHE_LINKS" ]; then
mkdir $CACHE_LINKS
else
rm -rf $CACHE_LINKS
mkdir $CACHE_LINKS
fi
echo "Creating symlink to ${cache_raw_dir_xem}"
ln -sf $cache_raw_dir_xem $CACHE_LINKS/cache_xem2
echo "Creating symlink to ${cache_raw_dir_sp18}"
ln -sf $cache_raw_dir_sp18 $CACHE_LINKS/cache_sp18
echo "Creating symlink to ${cache_raw_dir_sp19}"
ln -sf $cache_raw_dir_sp19 $CACHE_LINKS/cache_sp19
echo "Creating symlink to ${cache_raw_dir_pionlt}"
ln -sf $cache_raw_dir_pionlt $CACHE_LINKS/cache_pionlt
echo "Creating symlink to ${cache_raw_dir_cafe}"
ln -sf $cache_raw_dir_cafe $CACHE_LINKS/cache_cafe
echo "Creating dir and symlink to $base_dir_cdaq/REPORT_OUTPUT . . ."
mkdir $base_dir_cdaq"/REPORT_OUTPUT"
ln -sf $base_dir_cdaq"/REPORT_OUTPUT"
#Creating REPORT_OUTPUT/SPEC Directories
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/HMS"
#Add COIN REPORT_OUTPUT Directories
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN/REPLAY_REPORT"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN/COMMISSIONING"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN/CALIBRATION"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN/PRODUCTION"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN/SCALARS"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN/TIMING"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN/shms50k"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/COIN/hms50k"
#Add SHMS REPORT_OUTPUT Directories
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS/REPLAY_REPORT"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS/COMMISSIONING"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS/COMMISSIONING/HODO_CHECK"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS/CALIBRATION"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS/PRODUCTION"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS/SCALARS"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS/TIMING"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/SHMS/shms50k"
#Add HMS REPORT_OUTPUT Directories
mkdir $base_dir_cdaq"/REPORT_OUTPUT/HMS/REPLAY_REPORT"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/HMS/COMMISSIONING"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/HMS/CALIBRATION"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/HMS/PRODUCTION"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/HMS/SCALARS"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/HMS/TIMING"
mkdir $base_dir_cdaq"/REPORT_OUTPUT/HMS/hms50k"
echo "Creating dir and symlink to $base_dir_cdaq/ROOTfiles . . ."
mkdir $base_dir_cdaq"/ROOTfiles"
ln -sf $base_dir_cdaq"/ROOTfiles"
#Creating ROOTfiles/SPEC Directories
mkdir $base_dir_cdaq"/ROOTfiles/COIN"
mkdir $base_dir_cdaq"/ROOTfiles/SHMS"
mkdir $base_dir_cdaq"/ROOTfiles/HMS"
#Add COIN ROOTfiles Directories
mkdir $base_dir_cdaq"/ROOTfiles/COIN/COMMISSIONING"
mkdir $base_dir_cdaq"/ROOTfiles/COIN/CALIBRATION"
mkdir $base_dir_cdaq"/ROOTfiles/COIN/PRODUCTION"
mkdir $base_dir_cdaq"/ROOTfiles/COIN/SCALARS"
mkdir $base_dir_cdaq"/ROOTfiles/COIN/TIMING"
mkdir $base_dir_cdaq"/ROOTfiles/COIN/HeeP"
mkdir $base_dir_cdaq"/ROOTfiles/COIN/shms50k"
mkdir $base_dir_cdaq"/ROOTfiles/COIN/hms50k"
#Add SHMS ROOTfiles Directories
mkdir $base_dir_cdaq"/ROOTfiles/SHMS/COMMISSIONING"
mkdir $base_dir_cdaq"/ROOTfiles/SHMS/COMMISSIONING/HODO_CHECK"
mkdir $base_dir_cdaq"/ROOTfiles/SHMS/CALIBRATION"
mkdir $base_dir_cdaq"/ROOTfiles/SHMS/PRODUCTION"
mkdir $base_dir_cdaq"/ROOTfiles/SHMS/SCALARS"
mkdir $base_dir_cdaq"/ROOTfiles/SHMS/TIMING"
mkdir $base_dir_cdaq"/ROOTfiles/SHMS/shms50k"
#Add HMS ROOTfiles Directories
mkdir $base_dir_cdaq"/ROOTfiles/HMS/COMMISSIONING"
mkdir $base_dir_cdaq"/ROOTfiles/HMS/CALIBRATION"
mkdir $base_dir_cdaq"/ROOTfiles/HMS/PRODUCTION"
mkdir $base_dir_cdaq"/ROOTfiles/HMS/SCALARS"
mkdir $base_dir_cdaq"/ROOTfiles/HMS/TIMING"
mkdir $base_dir_cdaq"/ROOTfiles/HMS/hms50k"
echo "Creating dir and symlink to $base_dir_cdaq/HISTOGRAMS . . ."
mkdir $base_dir_cdaq"/HISTOGRAMS"
ln -sf $base_dir_cdaq"/HISTOGRAMS"
#Creating HISTOGRAMS/SPEC Directories
mkdir $base_dir_cdaq"/HISTOGRAMS/COIN"
mkdir $base_dir_cdaq"/HISTOGRAMS/COIN/ROOT"
mkdir $base_dir_cdaq"/HISTOGRAMS/COIN/PDF"
mkdir $base_dir_cdaq"/HISTOGRAMS/SHMS"
mkdir $base_dir_cdaq"/HISTOGRAMS/SHMS/ROOT"
mkdir $base_dir_cdaq"/HISTOGRAMS/SHMS/PDF"
mkdir $base_dir_cdaq"/HISTOGRAMS/HMS"
mkdir $base_dir_cdaq"/HISTOGRAMS/HMS/ROOT"
mkdir $base_dir_cdaq"/HISTOGRAMS/HMS/PDF"
echo "Creating dir and symlink to $base_dir_cdaq/MON_OUTPUT . . ."
mkdir $base_dir_cdaq"/MON_OUTPUT"
ln -sf $base_dir_cdaq"/MON_OUTPUT"
#Creating MON_OUTPUT/SPEC Directories
mkdir $base_dir_cdaq"/MON_OUTPUT/COIN"
mkdir $base_dir_cdaq"/MON_OUTPUT/SHMS"
mkdir $base_dir_cdaq"/MON_OUTPUT/HMS"
mkdir $base_dir_cdaq"/MON_OUTPUT/COIN/REPORT"
mkdir $base_dir_cdaq"/MON_OUTPUT/SHMS/REPORT"
mkdir $base_dir_cdaq"/MON_OUTPUT/HMS/REPORT"
fi