1 |
#!/bin/sh
|
2 |
|
3 |
usage ()
|
4 |
{
|
5 |
echo ""
|
6 |
echo "Usage: $0 -d directory -t TTreeName "
|
7 |
echo "where: directory is the location of the *.root files to be analyzed"
|
8 |
echo "Example: $0 -d /home/data/santanas/output -t treeName/tree"
|
9 |
echo ""
|
10 |
echo " Note: the option \"-d directory\" can be replaced by \"-f filename\" in case of a single root file to be analyzed"
|
11 |
echo " Example: $0 -f data/input/testTree.root -t promptanaTree/tree"
|
12 |
echo ""
|
13 |
exit 1;
|
14 |
}
|
15 |
|
16 |
if [ $# -le 3 ]; then usage; fi;
|
17 |
while [ $# -gt 0 ]; # till there are parameters
|
18 |
do
|
19 |
case "$1" in
|
20 |
-f) FILENAME="$2"; shift ;;
|
21 |
-d) DIRNAME="$2"; shift ;;
|
22 |
-t) TTREENAME="$2"; shift ;;
|
23 |
*) usage ;;
|
24 |
esac
|
25 |
shift # get following parameters
|
26 |
done
|
27 |
|
28 |
if [ ! -z "${FILENAME}" ] && [ ! -z "${DIRNAME}" ] ; then
|
29 |
usage;
|
30 |
exit;
|
31 |
fi
|
32 |
|
33 |
cd `dirname $0`/../ ; # go to the directory rootNtupleAnalyzer/
|
34 |
|
35 |
if [ ! -z "${FILENAME}" ] ; then
|
36 |
FILES=${FILENAME}
|
37 |
elif [ ! -z "${DIRNAME}" ] ; then
|
38 |
FILES=`ls ${DIRNAME}/*.root`
|
39 |
fi
|
40 |
|
41 |
cat > temporaryMacro.C <<EOF
|
42 |
{
|
43 |
TChain c("$TTREENAME");
|
44 |
EOF
|
45 |
|
46 |
for FILE in $FILES
|
47 |
do
|
48 |
echo " c.Add(\"${FILE}\"); " >> temporaryMacro.C
|
49 |
done
|
50 |
|
51 |
cat >> temporaryMacro.C <<EOF
|
52 |
c.MakeClass("rootNtupleClass");
|
53 |
}
|
54 |
EOF
|
55 |
|
56 |
root -l -q temporaryMacro.C
|
57 |
|
58 |
rm temporaryMacro.C
|
59 |
if [ -f "rootNtupleClass.h" ] && [ -f "rootNtupleClass.C" ]; then
|
60 |
echo "Moving rootNtupleClass.h/C to ./include/ and ./src/ directories ..."
|
61 |
mv -i rootNtupleClass.h include/
|
62 |
mv -i rootNtupleClass.C src/
|
63 |
#if [ -f "include/rootNtupleClass.h" ] && [ -f "src/rootNtupleClass.C" ]; then echo "... done."; fi;
|
64 |
|
65 |
#echo "Creating src/analysisClass.C ..."
|
66 |
#cp -i src/analysisClass_template.C src/analysisClass.C
|
67 |
|
68 |
echo "done";
|
69 |
else
|
70 |
echo "Error: files rootNtupleClass.h/C have not been created."
|
71 |
fi
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|