ROOTPWA
convertAmpFilesInMassBins.sh
Go to the documentation of this file.
1 #!/bin/bash
2 ##########################################################################
3 #
4 # Copyright 2010
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:: $: revision of last commit
25 # $Author:: $: author of last commit
26 # $Date:: $: date of last commit
27 #
28 # Description:
29 # converts all .amp files in the given mass bin directories into ROOT 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 #
40 #
41 #-------------------------------------------------------------------------
42 
43 
44 echo ">>> info: ${0} started on $(date)"
45 echo ">>> info: converting .amp files in ${ROOTPWA_DATA_DIR}"
46 echo
47 if [[ "${ROOTPWA_DATA_ENV_SET}" != "true" ]]
48 then
49  echo "!!! error: ROOTPWA data environment is not setup. cannot convert .amp files. please source the setup script for the data environment first."
50  exit 1
51 fi
52 
53 
54 # internal paramters
55 RECREATE_LINKS="false"
56 
57 
58 # find mass bin directories
59 MASS_BINS=$(find ${ROOTPWA_DATA_DIR} -type d -regex '.*/[0-9]+.[0-9]+' -printf '%f\n' | sort -n)
60 if [[ -z "${MASS_BINS}" ]]
61 then
62  echo "!!! error: cannot find any mass bins in ${ROOTPWA_DATA_DIR}"
63  exit 1
64 fi
65 
66 
67 for MASS_BIN in ${MASS_BINS}
68 do
69  DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}
70  for AMP_FILE in ${DIR}/{,PSP}AMPS/*.amp
71  do
72  ROOT_FILE=${AMP_FILE%.amp}.root
73  echo ">>> info: converting '${AMP_FILE}' to '${ROOT_FILE}'"
74  CMD="root -b -q rootlogon.C convertAmpToTree.C+\(\\\"${AMP_FILE}\\\",\\\"${ROOT_FILE}\\\"\)"
75  echo ${CMD}
76  time eval ${CMD}
77  echo
78  if [[ "${RECREATE_LINKS}" == "true" ]]
79  then
80  ln --symbolic --force --verbose ../$(basename ${ROOT_FILE}) $(dirname ${ROOT_FILE})/SYM
81  fi
82  done
83 
84 done
85 
86 
87 echo ">>> info: ${0} finished on $(date)"
88 exit 0