ROOTPWA
convertEvtFilesInMassBins.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 .evt 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 .evt 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 .evt files. please source the setup script for the data environment first."
50  exit 1
51 fi
52 
53 
54 #internal parameters
55 #REGENERATE_EVT_FILES="true"
56 REGENERATE_EVT_FILES="false"
57 PDG_TABLE="${ROOTPWA}/amplitude/particleDataTable.txt"
58 
59 
60 # find mass bin directories
61 MASS_BINS=$(find ${ROOTPWA_DATA_DIR} -type d -regex '.*/[0-9]+.[0-9]+' -printf '%f\n' | sort -n)
62 if [[ -z "${MASS_BINS}" ]]
63 then
64  echo "!!! error: cannot find any mass bins in ${ROOTPWA_DATA_DIR}"
65  exit 1
66 fi
67 
68 # convert real data files
69 for MASS_BIN in ${MASS_BINS}
70 do
71  DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}
72  EVT_FILE=${DIR}/${MASS_BIN}.evt
73  ROOT_FILE=${DIR}/${MASS_BIN}.root
74  echo ">>> info: converting '${EVT_FILE}' to '${ROOT_FILE}'"
75  CMD="root -b -q rootlogon.C convertEvtToTree.C+\(\\\"${EVT_FILE}\\\",\\\"${ROOT_FILE}\\\"\)"
76  echo ${CMD}
77  time eval ${CMD}
78  echo
79 done
80 
81 # convert MC data files
82 for MASS_BIN in ${MASS_BINS}
83 do
84  #DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}/MC
85  DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}
86  EVT_FILE=${DIR}/${MASS_BIN}.ps.evt
87  ROOT_FILE=${DIR}/${MASS_BIN}.ps.root
88  echo ">>> info: converting '${EVT_FILE}' to '${ROOT_FILE}'"
89  CMD="root -b -q rootlogon.C convertEvtToTree.C+\(\\\"${EVT_FILE}\\\",\\\"${ROOT_FILE}\\\"\)"
90  echo ${CMD}
91  time eval ${CMD}
92  echo
93 done
94 
95 # PWA2000 uses the four-vectors as they are given in the .evt files.
96 # this may lead to inconsistencies in the mass values used in the .evt
97 # files and those used for the isobars. it also causes troubles when
98 # comparing PWA2000 amplitudes with those generated with the new
99 # framework. enabling the regeneration of the .evt files rewrites them
100 # with energies according to the mass in the particle data table and
101 # leaving the three-momenta essentially untouched
102 if [[ "${REGENERATE_EVT_FILES}" == "true" ]]
103 then
104 
105  # rewrite real data files
106  for MASS_BIN in ${MASS_BINS}
107  do
108  DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}
109  EVT_FILE=${DIR}/${MASS_BIN}.evt
110  ROOT_FILE=${DIR}/${MASS_BIN}.root
111  echo ">>> info: rewriting '${EVT_FILE}' based on '${ROOT_FILE}'"
112  CMD="root -b -q rootlogon.C convertTreeToEvt.C+\(\\\"${ROOT_FILE}\\\",\\\"${EVT_FILE}\\\",\\\"${PDG_TABLE}\\\"\)"
113  echo ${CMD}
114  time eval ${CMD}
115  echo
116  done
117 
118  # rewrite MC data files
119  for MASS_BIN in ${MASS_BINS}
120  do
121  DIR=${ROOTPWA_DATA_DIR}/${MASS_BIN}/MC
122  EVT_FILE=${DIR}/${MASS_BIN}.ps.evt
123  ROOT_FILE=${DIR}/${MASS_BIN}.ps.root
124  echo ">>> info: rewriting '${EVT_FILE}' based on '${ROOT_FILE}'"
125  CMD="root -b -q rootlogon.C convertTreeToEvt.C+\(\\\"${ROOT_FILE}\\\",\\\"${EVT_FILE}\\\",\\\"${PDG_TABLE}\\\"\)"
126  echo ${CMD}
127  time eval ${CMD}
128  echo
129  done
130 
131 fi
132 
133 echo ">>> info: ${0} finished on $(date)"
134 exit 0