-
Notifications
You must be signed in to change notification settings - Fork 3
/
filelist
executable file
·51 lines (43 loc) · 2.11 KB
/
filelist
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
#!/bin/bash
dataset=$1
site=${2:-T2_CH_CERN}
runrange=$3
nEventsMax=${5:-3000000000}
ISLOCAL=y
usage(){
echo "basename $0 datasetpath site nEventsMax"
}
if [ -z "$dataset" ]; then
echo "[ERROR `basename $0`] No datasetpath in input"
usage
exit 1
fi
case $site in
any)
localsite=`grep "site name" /cvmfs/cms.cern.ch/SITECONF/local/JobConfig/site-local-config.xml | cut -d '=' -f 2 | tr '>' ' ' | sed 's|"||g'`
dasgoclient --query="site dataset=$dataset" | grep $localsite -q || unset ISLOCAL
;;
*)
dasgoclient --query="site dataset=$dataset" | grep $site -q || {
echo "[ERROR `basename $0`] dataset $dataset not at $site" >> /dev/stderr
dasgoclient --query="site dataset=$dataset" >> /dev/stderr
# exit 1
}
;;
esac
if [ -n "$runrange" ];then
runmin=`echo $runrange | cut -d '-' -f 1`
runmax=`echo $runrange | cut -d '-' -f 2`
else
runmin=0
runmax=999999
fi
query="file dataset=$dataset status=valid | grep file.name, file.size"
#echo $query
if [ -n "${ISLOCAL}" ];then
dasgoclient --query="$query" --limit=0 | tr '[' ' ' | tr "'" ' ' | tr "]" " " | sed 's|,.*"||;s|,.*||;/^$/ d;' | awk '(NF!=0){print $0}' | sort | uniq | awk -v nEventsMAX=${nEventsMax} 'BEGIN{i=0};(NF!=0){nEvents+=$2; print i,$1,$2,nEvents/nEventsMAX,nEvents,nEventsMAX; if(nEvents>nEventsMAX){i++;nEvents=0}}' | sed 's|/store/|"/store/|' | sed 's|.root|.root"|'
else
dasgoclient --query="$query" --limit=0 | tr '[' ' ' | tr "'" ' ' | tr "]" " " | sed 's|,.*"||;s|,.*||;/^$/ d;' | awk '(NF!=0){print $0}' | sort | uniq | awk -v nEventsMAX=${nEventsMax} 'BEGIN{i=0};(NF!=0){nEvents+=$2; print i,$1,$2,nEvents/nEventsMAX,nEvents,nEventsMAX; if(nEvents>nEventsMAX){i++;nEvents=0}}' | sed 's|.root|.root"|' | sed 's|/store/|"root://cms-xrd-global.cern.ch//store/|'
fi
#dasgoclient --query="$query" --limit=0 | tr '[' ' ' | tr "'" ' ' | tr "]" " " | sed 's|,.*"||;s|,.*||;/^$/ d;' | awk '(NF!=0){print $0}' | sort | uniq | awk -v nEventsMAX=${nEventsMax} 'BEGIN{i=0};(NF!=0){nEvents+=$2; print i,$1,$2,nEvents/nEventsMAX,nEvents,nEventsMAX; if(nEvents>nEventsMAX){i++;nEvents=0}}'
# tr -d '[' | tr -d "'" | tr ']' ',' | cut -d ',' -f 1,3 |