ROOTPWA
convertTreeFilesInMassBins.sh
Go to the documentation of this file.
1 #!/bin/bash
2 ##########################################################################
3 #
4 # Copyright 2012
5 #
6 # This file is part of rootpwa
7 #
8 # rootpwa is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # rootpwa is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
20 #
21 ##########################################################################
22 #-------------------------------------------------------------------------
23 # File and Version Information:
24 # $Rev:: 799 $: revision of last commit
25 # $Author:: bgrube $: author of last commit
26 # $Date:: 2011-11-04 16:58:53 +0100 #$: date of last commit
27 #
28 # Description:
29 # converts all .root files in the given mass bin directories into .evt files
30 #
31 # uses PWA environment variable(s)
32 # ROOTPWA_ENV_SET
33 # ROOTPWA
34 # ROOTPWA_DATA_DIR
35 #
36 #
37 # Author List:
38 # Boris Grube TUM (original author)
39 # Karl Bicker TUM
40 #
41 #
42 #-------------------------------------------------------------------------
43 
44 
45 echo ">>> info: ${0} started on $(date)"
46 echo ">>> info: converting .evt files in ${ROOTPWA_DATA_DIR}"
47 echo
48 if [[ "${ROOTPWA_DATA_ENV_SET}" != "true" ]]
49 then
50  echo "!!! error: ROOTPWA data environment is not setup. cannot convert .evt files. please source the setup script for the data environment first."
51  exit 1
52 fi
53 
54 
55 
56 # find mass bin directories
57 MASS_BINS=$(find ${ROOTPWA_DATA_DIR} -type d -regex '.*/[0-9]+.[0-9]+' -printf '%f\n' | sort -n)
58 if [[ -z "${MASS_BINS}" ]]
59 then
60  echo "!!! error: cannot find any mass bins in ${ROOTPWA_DATA_DIR}"
61  exit 1
62 fi
63 
64 # convert real data files
65 for MASS_BIN in ${MASS_BINS}
66 do
67  DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}
68  EVT_FILE=${DIR}/${MASS_BIN}.evt
69  ROOT_FILE=${DIR}/${MASS_BIN}.root
70  echo ">>> info: converting '${ROOT_FILE}' to '${EVT_FILE}'"
71  CMD="root -b -q rootlogon.C convertTreeToEvt.C+\(\\\"${ROOT_FILE}\\\",\\\"${EVT_FILE}\\\"\)"
72  echo ${CMD}
73  time eval ${CMD}
74  echo
75 done
76 
77 # convert MC data files
78 for MASS_BIN in ${MASS_BINS}
79 do
80  #DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}/MC
81  DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}
82  EVT_FILE=${DIR}/${MASS_BIN}.ps.evt
83  ROOT_FILE=${DIR}/${MASS_BIN}.ps.root
84  echo ">>> info: converting '${ROOT_FILE}' to '${EVT_FILE}'"
85  CMD="root -b -q rootlogon.C convertTreeToEvt.C+\(\\\"${ROOT_FILE}\\\",\\\"${EVT_FILE}\\\"\)"
86  echo ${CMD}
87  time eval ${CMD}
88  echo
89 done
90 
91 
92 echo ">>> info: ${0} finished on $(date)"
93 exit 0