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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
#!/bin/bash
#
function printhelp ()
{
echo " "
echo "Usage:"
echo " EdmInventory.sh [-h | -t | -b<treename>] filename"
echo " where:"
echo " -h Print this text."
echo " -t Print a list of TTree objects in the given file."
echo " -b<treename> Print details of all branches in the given tree "
echo " of the specified file. If treename is 'all'"
echo " do this for all trees found."
echo " filename is the name of the Root file of interest."
echo " "
}
#
function branchlist ()
{
root -l -b -n << EOF
.x ${branchMacro}
$1
$2
quit
.q
EOF
return
}
#
function allbranches ()
{
root -l -b -n << EOF
.x ${allbranchMacro}
$1
quit
.q
EOF
return
}
#
function treelist ()
{
root -l -b -n << EOF
.x ${treeMacro}
$1
quit
.q
EOF
return
}
#
# Initialize treename and branchname
#
b_option="false"
t_option="false"
treename="none"
branchname="none"
#
# Establish getopt
#
TEMP=`getopt -n EdmInventory -o htb: -- "$@"`
rc=$?
if [ $rc -ne 0 ]
then
echo "$getopt failure with error $rc"
exit 1
fi
eval set -- "$TEMP"
#
# Make sure nothing bad happened
#
if [ $? != 0 ]
then
echo "Incorrect getopt usage. Quitting."
exit 2
fi
#
#echo "`basename $0` $@"
#echo "Input arguments appear to be:"
#
while true ; do
case "$1" in
-h) printhelp ;
exit ;;
-t) t_option="true" ;
shift ;;
-b) b_option="true" ;
treename=$2 ;
shift 2 ;;
-x) x_option="true" ;
# x has an optional argument. As we are in quoted mode,
# an empty parameter will be generated if its optional
# argument is not found.
case "$2" in
"") echo "Option x, no argument" ;
treename="Events" ;
shift 2 ;;
*) echo "Option x, argument \`$2'" ;
treename=$2 ;
shift 2 ;;
esac ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
#
if [ $# -lt 1 ]
then
echo " "
echo "Please supply a file name as an argument."
exit
fi
#
if [ -z "$ROOTSYS" ]
then
echo " "
echo "No version of Root is set up. Aborting."
exit
fi
releaseBin=$CMSSW_RELEASE_BASE/bin/`scramv1 arch`
here=`dirname $0`
if [ -f ${here}/branchlist.C ]
then
branchMacro=${here}/branchlist.C
else
branchMacro=${releaseBin}/branchlist.C
fi
#
if [ -f ${here}/allbranches.C ]
then
allbranchMacro=${here}/allbranches.C
else
allbranchMacro=${releaseBin}/allbranches.C
fi
#
if [ -f ${here}/treelist.C ]
then
treeMacro=${here}/treelist.C
else
treeMacro=${releaseBin}/treelist.C
fi
#
filename=$1
if [ ! -f $filename ]
then
echo " "
echo "There is no file named $filename. Aborting."
exit 1
fi
#
if [ $t_option = "true" ]
then
treelist $filename
fi
#
if [ $b_option = "true" ]
then
if [ $treename = "all" ]
then
allbranches $filename
else
branchlist $filename $treename
fi
fi
#
exit
|