File indexing completed on 2024-04-06 12:12:48
0001
0002
0003 function printhelp ()
0004 {
0005 echo " "
0006 echo "Usage:"
0007 echo " EdmInventory.sh [-h | -t | -b<treename>] filename"
0008 echo " where:"
0009 echo " -h Print this text."
0010 echo " -t Print a list of TTree objects in the given file."
0011 echo " -b<treename> Print details of all branches in the given tree "
0012 echo " of the specified file. If treename is 'all'"
0013 echo " do this for all trees found."
0014 echo " filename is the name of the Root file of interest."
0015 echo " "
0016 }
0017
0018 function branchlist ()
0019 {
0020 root -l -b -n << EOF
0021 .x ${branchMacro}
0022 $1
0023 $2
0024 quit
0025 .q
0026 EOF
0027 return
0028 }
0029
0030 function allbranches ()
0031 {
0032 root -l -b -n << EOF
0033 .x ${allbranchMacro}
0034 $1
0035 quit
0036 .q
0037 EOF
0038 return
0039 }
0040
0041 function treelist ()
0042 {
0043 root -l -b -n << EOF
0044 .x ${treeMacro}
0045 $1
0046 quit
0047 .q
0048 EOF
0049 return
0050 }
0051
0052
0053
0054 b_option="false"
0055 t_option="false"
0056 treename="none"
0057 branchname="none"
0058
0059
0060
0061 TEMP=`getopt -n EdmInventory -o htb: -- "$@"`
0062 rc=$?
0063 if [ $rc -ne 0 ]
0064 then
0065 echo "$getopt failure with error $rc"
0066 exit 1
0067 fi
0068 eval set -- "$TEMP"
0069
0070
0071
0072 if [ $? != 0 ]
0073 then
0074 echo "Incorrect getopt usage. Quitting."
0075 exit 2
0076 fi
0077
0078
0079
0080
0081 while true ; do
0082 case "$1" in
0083 -h) printhelp ;
0084 exit ;;
0085 -t) t_option="true" ;
0086 shift ;;
0087 -b) b_option="true" ;
0088 treename=$2 ;
0089 shift 2 ;;
0090 -x) x_option="true" ;
0091
0092
0093
0094 case "$2" in
0095 "") echo "Option x, no argument" ;
0096 treename="Events" ;
0097 shift 2 ;;
0098 *) echo "Option x, argument \`$2'" ;
0099 treename=$2 ;
0100 shift 2 ;;
0101 esac ;;
0102 --) shift ; break ;;
0103 *) echo "Internal error!" ; exit 1 ;;
0104 esac
0105 done
0106
0107 if [ $
0108 then
0109 echo " "
0110 echo "Please supply a file name as an argument."
0111 exit
0112 fi
0113
0114 if [ -z "$ROOTSYS" ]
0115 then
0116 echo " "
0117 echo "No version of Root is set up. Aborting."
0118 exit
0119 fi
0120 releaseBin=$CMSSW_RELEASE_BASE/bin/`scramv1 arch`
0121 here=`dirname $0`
0122 if [ -f ${here}/branchlist.C ]
0123 then
0124 branchMacro=${here}/branchlist.C
0125 else
0126 branchMacro=${releaseBin}/branchlist.C
0127 fi
0128
0129 if [ -f ${here}/allbranches.C ]
0130 then
0131 allbranchMacro=${here}/allbranches.C
0132 else
0133 allbranchMacro=${releaseBin}/allbranches.C
0134 fi
0135
0136 if [ -f ${here}/treelist.C ]
0137 then
0138 treeMacro=${here}/treelist.C
0139 else
0140 treeMacro=${releaseBin}/treelist.C
0141 fi
0142
0143 filename=$1
0144 if [ ! -f $filename ]
0145 then
0146 echo " "
0147 echo "There is no file named $filename. Aborting."
0148 exit 1
0149 fi
0150
0151 if [ $t_option = "true" ]
0152 then
0153 treelist $filename
0154 fi
0155
0156 if [ $b_option = "true" ]
0157 then
0158 if [ $treename = "all" ]
0159 then
0160 allbranches $filename
0161 else
0162 branchlist $filename $treename
0163 fi
0164 fi
0165
0166 exit