3 # Shell script to compare content of the OCDB entries.
6 # Usage: bash $inputFile $flag $outputFile
8 # Usage: bash $inputFile $object_name $dump_type [XML/MI] $outfile
10 # Usage: bash $inputFile1 $inputFile2 $object_name $dump_type [XML/MI] $outfile
11 # Example usage: see example functions below
15 # create a text file with the OCDB setupt descriptors#
19 # $2 flag type of the input file
22 # AliESDs.root = "ESD"
26 if [ $# -lt 3 ] ; then
27 echo "Usage: $0 \$inputFile \$flag \$outputFile"
34 if [ ! -f ${inFile} ] ; then
35 echo ${inFile} not found!
38 if [ -f ${outFile} ] ; then
43 cat > ${tmpscript} <<HEREDOC
45 AliOCDBtoolkit::DumpOCDBAsTxt("${inFile}","${inFlag}","${outFile}");
49 aliroot -l -q -b ${tmpscript}
50 sleep 60 && rm ${tmpscript} &
61 # $3 type of the dump (XML or MI recursive dump )
64 if [ $# -lt 4 ] ; then
65 echo "Usage: $0 \$inputFile \$object_name \$dump_type [XML/MI] \$outfile"
73 if [ ! -f ${inFile} ] ; then
74 echo ${inFile} not found!
77 if [ -f ${outFile} ] ; then
80 if [ ${ftype} = "XML" ] ; then
82 elif [ ${ftype} = "MI" ] ; then
85 echo "option ${ftype} not recognized! Use \"XML\" or \"MI\"!"
89 cat > ${tmpscript} <<HEREDOC
91 AliOCDBtoolkit::DumpOCDBFile("${inFile}","${outFile}",1,${isXML});
95 aliroot -l -q -b ${tmpscript}
96 sleep 60 && rm ${tmpscript} &
107 # $4 type of the dump (xml or MI recursive dump )
109 # $5 output diff file name
110 if [ $# -lt 5 ] ; then
111 echo "Usage: $0 \$inputFile1 \$inputFile2 \$object_name \$dump_type [XML/MI] \$outfile"
122 if [ ${ftype} = "XML" ] ; then
126 elif [ ${ftype} = "MI" ] ; then
129 echo "option ${ftype} not recognized! Use \"XML\" or \"MI\"!"
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
142 # Dump differences between the OCDB tables -comparison based on the hash values of OCDB entries
147 # difference is stdout
152 cdbName=$(cut -f1 $list1)
153 for i in $cdbName ; do
154 line1="$(grep $i $list1)"
155 line2="$(grep $i $list2)"
156 if [ -z "${line2}" ] ; then
157 echo $i not found in $list2!
160 match1=$(echo $line1 | cut -d' ' -f 5)
161 match2=$(echo $line2 | cut -d' ' -f 5)
162 if [ "$match1" -ne "$match2" ] ; then
163 echo $i doesnt match:
164 echo $(echo $line1| awk '{print $2 "/" $3}') \#hash: $match1
165 echo $(echo $line2| awk '{print $2 "/" $3}') \#hash: $match2
176 # Example usage+ developer test routines.
180 ocdbMakeTable "/hera/alice/jwagner/simulations/benchmark/aliroot_tests/ppbench/rec.log" "log" "testout"
183 dumpObject "/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root" "object" "XML" "testout2XML"
184 dumpObject "/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root" "object" "MI" "testout2MI"
187 file1="/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root"
188 file2="$ALICE_ROOT/OCDB/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root"
189 diffObject ${file1} ${file2} "object" "MI" "testdiffMI"
190 diffObject ${file1} ${file2} "object" "XML" "testdiffXML"
194 source /hera/alice/jwagner/software/aliroot/loadMyAliroot.sh TPCdev