/[PAMELA software]/chewbacca/extractcalibs.sh
ViewVC logotype

Annotation of /chewbacca/extractcalibs.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Tue Nov 4 09:44:26 2008 UTC (16 years ago) by mocchiut
Branch: MAIN
File MIME type: application/x-sh
chewbacca upgrade, YP upgrade

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     echo "TTree *ccp = 0;" >> ${TEMPL};
65     echo "TTree *ccp1 = 0;" >> ${TEMPL};
66     echo "TTree *ccp2 = 0;" >> ${TEMPL};
67     echo "TTree *ctcb = 0;" >> ${TEMPL};
68     echo "TTree *ctc1 = 0;" >> ${TEMPL};
69     echo "TTree *ctc2 = 0;" >> ${TEMPL};
70     echo "TTree *cs4c = 0;" >> ${TEMPL};
71     echo "TFile *calib = new TFile(\"${OUTDIR}/${FNAME}/nome\",\"RECREATE\");" >> ${TEMPL};
72     echo "calib->SetCompressionLevel(9);" >> ${TEMPL};
73     echo "calib->cd();" >> ${TEMPL};
74     echo "ccp=cp->CloneTree(-1,\"fast\");" >> ${TEMPL};
75     echo "ccp1=cp1->CloneTree(-1,\"fast\");" >> ${TEMPL};
76     echo "ccp2=cp2->CloneTree(-1,\"fast\");" >> ${TEMPL};
77     echo "ctcb=tcb->CloneTree(-1,\"fast\");" >> ${TEMPL};
78     echo "ctc1=tc1->CloneTree(-1,\"fast\");" >> ${TEMPL};
79     echo "ctc2=tc2->CloneTree(-1,\"fast\");" >> ${TEMPL};
80     echo "cs4c=s4c->CloneTree(-1,\"fast\");" >> ${TEMPL};
81     echo "calib->Write();" >> ${TEMPL};
82     echo "calib->Close();" >> ${TEMPL};
83     echo ".q" >> ${TEMPL};
84     #
85     rm -rf ${OUTDIR}/go.exe ;
86     GO=${OUTDIR}/go.exe ;
87     #
88     for file in `ls ${INDIR}`; do
89     FN=`basename $file`;
90     echo ${FN} >> ${LOG};
91     CH=`echo $FN |grep .root`;
92     if [ "$CH" != "" ]; then
93     cat ${TEMPL} | sed s/nome/${FN}/ > ${GO};
94     root -b -l < ${GO} &> ${LOG};
95     fi;
96     done
97     rm -f ${GO};
98     rm -f ${TEMPL};
99     cd ${OUTDIR} && tar zcvf ${OUTDIR}/${FNAME}.tar.gz ${FNAME} ;
100     rm -rf ${OUTDIR}/${FNAME} ;
101     cd ${THISDIR} ;

  ViewVC Help
Powered by ViewVC 1.1.23