1 |
mocchiut |
1.1 |
#!/bin/bash --norc |
2 |
|
|
THISDIR=`pwd` ; |
3 |
|
|
INDIR=`pwd` ; |
4 |
|
|
OUTDIR=`pwd` ; |
5 |
|
|
FNAME=extcalibs ; |
6 |
|
|
# |
7 |
|
|
if [ $# -gt 0 ]; then |
8 |
|
|
for INPUT in $*; do |
9 |
|
|
if [ $INPUT == "--help" ] || [ $INPUT == "-h" ]; then |
10 |
|
|
echo "" |
11 |
|
|
echo " Usage: ./extractcalibs.sh [options] " |
12 |
|
|
echo "" |
13 |
|
|
echo " Options: " |
14 |
|
|
echo "" |
15 |
|
|
echo " --input-dir=/path/to/level0/files/ : Path to level0 files " |
16 |
|
|
echo "" |
17 |
|
|
echo " --output-dir=/path/to/output/tar/file/ : Path were to put the output file with calibrations and temporary folder." |
18 |
|
|
echo "" |
19 |
|
|
echo " --filename=name: Name of the output file (no extension) " |
20 |
|
|
echo "" |
21 |
|
|
exit 0 |
22 |
|
|
fi |
23 |
|
|
TEST=`echo $INPUT | sed 's/--input-dir=//g'` |
24 |
|
|
if [ $TEST != $INPUT ]; then |
25 |
|
|
INDIR=`echo $TEST`; |
26 |
|
|
fi |
27 |
|
|
TEST=`echo $INPUT | sed 's/--output-dir=//g'` |
28 |
|
|
if [ $TEST != $INPUT ]; then |
29 |
|
|
OUTDIR=`echo $TEST`; |
30 |
|
|
fi |
31 |
|
|
TEST=`echo $INPUT | sed 's/--filename=//g'` |
32 |
|
|
if [ $TEST != $INPUT ]; then |
33 |
|
|
FNAME=`echo $TEST`; |
34 |
|
|
fi |
35 |
|
|
done |
36 |
|
|
fi; |
37 |
|
|
echo "" |
38 |
|
|
echo " Extracting calibrations from files in the directory $INDIR " |
39 |
|
|
echo "" |
40 |
|
|
# |
41 |
|
|
if [ -d ${OUTDIR}/${FNAME} ]; then |
42 |
|
|
echo ""; |
43 |
|
|
echo " Directory ${OUTDIR}/${FNAME} already exists, DELETING IT in 30 seconds (use CTRL-C to stop me NOW) "; |
44 |
|
|
echo ""; |
45 |
|
|
sleep 30; |
46 |
|
|
rm -rf ${OUTDIR}/${FNAME} ; |
47 |
|
|
fi; |
48 |
|
|
rm -rf ${OUTDIR}/${FNAME}.log ; |
49 |
|
|
touch ${OUTDIR}/${FNAME}.log ; |
50 |
|
|
LOG=${OUTDIR}/${FNAME}.log ; |
51 |
|
|
mkdir ${OUTDIR}/${FNAME} ; |
52 |
|
|
# |
53 |
|
|
rm -rf ${OUTDIR}/extcal.template; |
54 |
|
|
TEMPL=${OUTDIR}/extcal.template; |
55 |
|
|
touch ${TEMPL}; |
56 |
|
|
echo "TFile *_file0 = TFile::Open(\"${INDIR}/nome\");" >> ${TEMPL}; |
57 |
|
|
echo "TTree *cp = (TTree*)_file0->Get(\"CalibCalPed\")" >> ${TEMPL}; |
58 |
|
|
echo "TTree *cp1 = (TTree*)_file0->Get(\"CalibCalPulse1\")" >> ${TEMPL}; |
59 |
|
|
echo "TTree *cp2 = (TTree*)_file0->Get(\"CalibCalPulse2\")" >> ${TEMPL}; |
60 |
|
|
echo "TTree *tcb = (TTree*)_file0->Get(\"CalibTrkBoth\")" >> ${TEMPL}; |
61 |
|
|
echo "TTree *tc1 = (TTree*)_file0->Get(\"CalibTrk1\")" >> ${TEMPL}; |
62 |
|
|
echo "TTree *tc2 = (TTree*)_file0->Get(\"CalibTrk2\")" >> ${TEMPL}; |
63 |
|
|
echo "TTree *s4c = (TTree*)_file0->Get(\"CalibS4\")" >> ${TEMPL}; |
64 |
mocchiut |
1.2 |
echo "TTree *mcmd = (TTree*)_file0->Get(\"Mcmd\")" >> ${TEMPL}; |
65 |
mocchiut |
1.1 |
echo "TTree *ccp = 0;" >> ${TEMPL}; |
66 |
|
|
echo "TTree *ccp1 = 0;" >> ${TEMPL}; |
67 |
|
|
echo "TTree *ccp2 = 0;" >> ${TEMPL}; |
68 |
|
|
echo "TTree *ctcb = 0;" >> ${TEMPL}; |
69 |
|
|
echo "TTree *ctc1 = 0;" >> ${TEMPL}; |
70 |
|
|
echo "TTree *ctc2 = 0;" >> ${TEMPL}; |
71 |
|
|
echo "TTree *cs4c = 0;" >> ${TEMPL}; |
72 |
mocchiut |
1.2 |
echo "TTree *cmcmd = 0;" >> ${TEMPL}; |
73 |
mocchiut |
1.1 |
echo "TFile *calib = new TFile(\"${OUTDIR}/${FNAME}/nome\",\"RECREATE\");" >> ${TEMPL}; |
74 |
|
|
echo "calib->SetCompressionLevel(9);" >> ${TEMPL}; |
75 |
|
|
echo "calib->cd();" >> ${TEMPL}; |
76 |
|
|
echo "ccp=cp->CloneTree(-1,\"fast\");" >> ${TEMPL}; |
77 |
|
|
echo "ccp1=cp1->CloneTree(-1,\"fast\");" >> ${TEMPL}; |
78 |
|
|
echo "ccp2=cp2->CloneTree(-1,\"fast\");" >> ${TEMPL}; |
79 |
|
|
echo "ctcb=tcb->CloneTree(-1,\"fast\");" >> ${TEMPL}; |
80 |
|
|
echo "ctc1=tc1->CloneTree(-1,\"fast\");" >> ${TEMPL}; |
81 |
|
|
echo "ctc2=tc2->CloneTree(-1,\"fast\");" >> ${TEMPL}; |
82 |
|
|
echo "cs4c=s4c->CloneTree(-1,\"fast\");" >> ${TEMPL}; |
83 |
mocchiut |
1.2 |
echo "cmcmd=mcmd->CloneTree(-1,\"fast\");" >> ${TEMPL}; |
84 |
mocchiut |
1.1 |
echo "calib->Write();" >> ${TEMPL}; |
85 |
|
|
echo "calib->Close();" >> ${TEMPL}; |
86 |
|
|
echo ".q" >> ${TEMPL}; |
87 |
|
|
# |
88 |
|
|
rm -rf ${OUTDIR}/go.exe ; |
89 |
|
|
GO=${OUTDIR}/go.exe ; |
90 |
|
|
# |
91 |
|
|
for file in `ls ${INDIR}`; do |
92 |
|
|
FN=`basename $file`; |
93 |
|
|
echo ${FN} >> ${LOG}; |
94 |
|
|
CH=`echo $FN |grep .root`; |
95 |
|
|
if [ "$CH" != "" ]; then |
96 |
|
|
cat ${TEMPL} | sed s/nome/${FN}/ > ${GO}; |
97 |
|
|
root -b -l < ${GO} &> ${LOG}; |
98 |
|
|
fi; |
99 |
|
|
done |
100 |
|
|
rm -f ${GO}; |
101 |
|
|
rm -f ${TEMPL}; |
102 |
|
|
cd ${OUTDIR} && tar zcvf ${OUTDIR}/${FNAME}.tar.gz ${FNAME} ; |
103 |
|
|
rm -rf ${OUTDIR}/${FNAME} ; |
104 |
|
|
cd ${THISDIR} ; |