]>
Commit | Line | Data |
---|---|---|
eaef9ce4 | 1 | #!/bin/bash |
ff4820ec | 2 | # |
3 | # Shell script to compare content of the OCDB entries. | |
4 | # | |
5 | # ocdbMakeTable() | |
6 | # Usage: bash $inputFile $flag $outputFile | |
7 | # dumpObject() | |
8 | # Usage: bash $inputFile $object_name $dump_type [XML/MI] $outfile | |
9 | # diffObject | |
10 | # Usage: bash $inputFile1 $inputFile2 $object_name $dump_type [XML/MI] $outfile | |
11 | # Example usage: see example functions below | |
12 | ||
91d14a8c | 13 | ocdbMakeTable(){ |
14 | # | |
15 | # create a text file with the OCDB setupt descriptors# | |
16 | # | |
17 | # Input: | |
18 | # $1 inputFile name | |
19 | # $2 flag type of the input file | |
eaef9ce4 | 20 | # flags: |
21 | # log file = "log" | |
22 | # AliESDs.root = "ESD" | |
23 | # galice.root = "MC" | |
91d14a8c | 24 | # Output: |
25 | # $3 output file name | |
eaef9ce4 | 26 | if [ $# -lt 3 ] ; then |
27 | echo "Usage: $0 \$inputFile \$flag \$outputFile" | |
28 | return 1 | |
29 | fi | |
30 | local inFile=${1} | |
31 | local inFlag=${2} | |
32 | local outFile=${3} | |
33 | shift 3 | |
34 | if [ ! -f ${inFile} ] ; then | |
35 | echo ${inFile} not found! | |
36 | return 1 | |
37 | fi | |
38 | if [ -f ${outFile} ] ; then | |
39 | >${outFile} | |
40 | fi | |
41 | ||
42 | tmpscript=$(mktemp) | |
43 | cat > ${tmpscript} <<HEREDOC | |
44 | { | |
45 | AliOCDBtoolkit::DumpOCDBAsTxt("${inFile}","${inFlag}","${outFile}"); | |
46 | } | |
47 | HEREDOC | |
48 | ||
49 | aliroot -l -q -b ${tmpscript} | |
50 | sleep 60 && rm ${tmpscript} & | |
51 | return 1 | |
91d14a8c | 52 | } |
53 | ||
54 | ||
55 | dumpObject(){ | |
56 | # | |
57 | # | |
58 | # Input: | |
59 | # $1 path | |
60 | # $2 obj name | |
eaef9ce4 | 61 | # $3 type of the dump (XML or MI recursive dump ) |
91d14a8c | 62 | # Output: |
eaef9ce4 | 63 | # $4 output file name |
64 | if [ $# -lt 4 ] ; then | |
65 | echo "Usage: $0 \$inputFile \$object_name \$dump_type [XML/MI] \$outfile" | |
66 | return 1 | |
67 | fi | |
68 | local inFile=${1} | |
69 | local fobject=${2} | |
70 | local ftype=${3} | |
71 | local outFile=${4} | |
72 | shift 4 | |
73 | if [ ! -f ${inFile} ] ; then | |
74 | echo ${inFile} not found! | |
75 | return 1 | |
76 | fi | |
77 | if [ -f ${outFile} ] ; then | |
78 | >${outFile} | |
79 | fi | |
80 | if [ ${ftype} = "XML" ] ; then | |
81 | isXML=kTRUE | |
82 | elif [ ${ftype} = "MI" ] ; then | |
83 | isXML=kFALSE | |
84 | else | |
85 | echo "option ${ftype} not recognized! Use \"XML\" or \"MI\"!" | |
86 | return 1 | |
87 | fi | |
88 | tmpscript=$(mktemp) | |
89 | cat > ${tmpscript} <<HEREDOC | |
90 | { | |
91 | AliOCDBtoolkit::DumpOCDBFile("${inFile}","${outFile}",1,${isXML}); | |
92 | } | |
93 | HEREDOC | |
94 | ||
95 | aliroot -l -q -b ${tmpscript} | |
96 | sleep 60 && rm ${tmpscript} & | |
97 | return 1 | |
91d14a8c | 98 | } |
99 | ||
100 | diffObject(){ | |
101 | # | |
102 | # | |
103 | # Input: | |
104 | # $1 path0 | |
105 | # $2 path1 | |
eaef9ce4 | 106 | # $3 obj name |
107 | # $4 type of the dump (xml or MI recursive dump ) | |
91d14a8c | 108 | # Output: |
eaef9ce4 | 109 | # $5 output diff file name |
110 | if [ $# -lt 5 ] ; then | |
111 | echo "Usage: $0 \$inputFile1 \$inputFile2 \$object_name \$dump_type [XML/MI] \$outfile" | |
112 | return 1 | |
113 | fi | |
114 | local inFile1=${1} | |
115 | local inFile2=${2} | |
116 | local fobject=${3} | |
117 | local ftype=${4} | |
118 | local outFile=${5} | |
119 | shift 5 | |
120 | local tmp1=$(mktemp) | |
121 | local tmp2=$(mktemp) | |
122 | if [ ${ftype} = "XML" ] ; then | |
123 | isXML=kTRUE | |
124 | tmp1="${tmp1}.xml" | |
125 | tmp2="${tmp2}.xml" | |
126 | elif [ ${ftype} = "MI" ] ; then | |
127 | isXML=kFALSE | |
128 | else | |
129 | echo "option ${ftype} not recognized! Use \"XML\" or \"MI\"!" | |
130 | return 1 | |
131 | fi | |
132 | dumpObject ${inFile1} ${fobject} ${ftype} ${tmp1%.xml} | |
133 | dumpObject ${inFile2} ${fobject} ${ftype} ${tmp2%.xml} | |
134 | diff ${tmp1} ${tmp2} >${outFile} | |
135 | rm ${tmp1} ${tmp2} 2>/dev/null | |
136 | rm "${tmp1}.xml" "${tmp2}.xml" 2>/dev/null | |
137 | return 1 | |
138 | } | |
139 | ||
ff4820ec | 140 | # |
141 | # Example usage+ developer test routines. | |
142 | # | |
143 | ||
eaef9ce4 | 144 | example1(){ |
145 | ocdbMakeTable "/hera/alice/jwagner/simulations/benchmark/aliroot_tests/ppbench/rec.log" "log" "testout" | |
146 | } | |
147 | example2(){ | |
148 | dumpObject "/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root" "object" "XML" "testout2XML" | |
149 | dumpObject "/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root" "object" "MI" "testout2MI" | |
150 | } | |
151 | example3(){ | |
152 | file1="/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root" | |
153 | file2="$ALICE_ROOT/OCDB/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root" | |
154 | diffObject ${file1} ${file2} "object" "MI" "testdiffMI" | |
155 | diffObject ${file1} ${file2} "object" "XML" "testdiffXML" | |
156 | } | |
ff4820ec | 157 | |
158 | developerTest(){ | |
159 | source /hera/alice/jwagner/software/aliroot/loadMyAliroot.sh TPCdev | |
160 | example1 | |
161 | example2 | |
162 | example3 | |
163 | } |