]>
Commit | Line | Data |
---|---|---|
983b8aef | 1 | #!/bin/bash |
2 | main() | |
3 | { | |
4 | #create the event list for one run: the run number if guessed from the path | |
5 | #the input file can either be a root file with the trees or a zipfile with | |
6 | #file FilterEvents_Trees.root inside | |
7 | [[ $# -eq 0 ]] && echo "Usage: $0 file" && exit | |
8 | file=$1 | |
9 | outputFile=$2 | |
10 | ||
11 | runNumber=$(guessRunNumber $file) | |
12 | period=$(guessPeriod $file) | |
13 | ptMinHighPt="8.0"; | |
14 | ptMinV0s="3.0"; | |
15 | if [[ ${period%_*} =~ (LHC10h|LHC11h|LHC12h) ]]; then | |
16 | ptMinHighPt="14.0"; | |
17 | ptMinV0s="6.0"; | |
18 | fi | |
19 | ||
20 | [[ -z $outputFile ]] && outputFile=${runNumber}.list | |
21 | ||
22 | [[ ! -f $file ]] && echo "cannot access file $file" && exit | |
23 | ||
24 | [[ "${file##*\.}" == *zip ]] && file+="#FilterEvents_Trees.root" | |
25 | ||
26 | this=$0 | |
27 | [[ ${OSTYPE} =~ inux ]] && this=$(readlink -f $0) | |
28 | scriptPath=${this%/*} | |
29 | ||
30 | echo outputFile=$outputFile | |
31 | echo runNumber=$runNumber | |
32 | echo period=$period | |
33 | echo PWD=$PWD | |
34 | echo scriptPath=$scriptPath | |
35 | echo aliroot -b -q "${scriptPath}/makeEventList.C(\"${file}\",${ptMinHighPt},${ptMinV0s})" | |
36 | ||
37 | aliroot -b -q "${scriptPath}/makeEventList.C(\"${file}\",${ptMinHighPt},${ptMinV0s})" 2>/dev/null\ | |
38 | | awk -v period=${period} '/^offlineTrigger/ {triggerType=$2;} $8 !~ "*" && $0 ~ "^*.*/\\w*/\\w*/" { n=split($10,a,"/"); rawfile="/"a[4]"/"a[5]"/"a[6]"/"period"/"a[8]"/raw/"a[n-1]".root"; print rawfile" "$8" "triggerType; }' \ | |
39 | | sort -V | uniq > $outputFile | |
40 | } | |
41 | ||
42 | guessRunNumber() | |
43 | { | |
44 | ( | |
45 | #guess run number from the path, pick the rightmost one | |
46 | IFS="/" | |
47 | declare -a path=( $1 ) | |
48 | dirDepth=${#path[*]} | |
49 | for ((x=${dirDepth}-1;x>=0;x--)); do | |
50 | field=${path[${x}]} | |
51 | [[ ${field} =~ ^000[0-9]*[0-9]$ ]] && runNumber=${field#000} && break | |
52 | done | |
53 | echo $runNumber | |
54 | ) | |
55 | } | |
56 | ||
57 | guessPeriod() | |
58 | { | |
59 | ( | |
60 | #guess the year from the path, pick the rightmost one | |
61 | IFS="/" | |
62 | declare -a path=( $1 ) | |
63 | dirDepth=${#path[*]} | |
64 | for ((x=${dirDepth}-1;x>=0;x--)); do | |
65 | field=${path[${x}]} | |
66 | [[ ${field} =~ ^LHC[0-9][0-9][a-z]_*.*$ ]] && period=${field%%_*} && break | |
67 | done | |
68 | echo $period | |
69 | ) | |
70 | } | |
71 | ||
72 | main "$@" |