ROOTPWA
test_workspace.sh
Go to the documentation of this file.
1 # this script tests the status of the Kpipi PWA workflow chain
2 # the variables in set_workspace_var.sh must be set correctly
3 # author: Promme@web.de ; jasinski@kph.uni-mainz.de
4 # worked with SVN version 290
5 
6 #!/bin/bash
7 
8 # test if ${ROOTPWA} is set (set it in .bashrc for example)
9 if [ -d ${ROOTPWA} ];
10 then
11  echo -e "\n ROOTPWA variable is set to ${ROOTPWA} \n"
12 else
13  echo -e "\E[37;31m \n ROOTPWA variable is not set correctly! "; tput sgr0
14  echo -e "\E[37;31m Please set it first! "; tput sgr0
15  echo -e "\n Aborting this script"; tput sgr0
16  return 0;
17 fi
18 
19 # load the variables (even if already done)
20 source ${ROOTPWA}/scripts/pwa_Kpipi_example/set_workspace_var.sh
21 
22 # array with variables 1/0 for each step to hold
23 export STEP_NAME=(\
24  " getting files "\
25  " setting up workspace "\
26  " Filling flat phasespace events "\
27  " MC acceptance of flat phasespace "\
28  " Filtering RAW and MC data into bins "\
29  " Generation of partial wave key files "\
30  " Calculation of Amplitudes and Integrals"\
31  " Specifying amplitudes for fit "\
32  " Fitting the partial waves "\
33  " Visualization of fit results "\
34  )
35 export STEP_DONE=( 0 0 0 0 0 0 0 0 0 0 );
36 
37 # perform some test giving hints for the current PWA analysis status
38 
39 # step 1: is the raw file in place?
40 if [ -f ${KPIPI_RAW_FILE_DIR}/${KPIPI_RAW_FILE} ]
41 then
42  if [ -f ${KPIPI_MC_FILE_DIR}/${KPIPI_MC_FILE} ]
43  then
44  STEP_DONE[0]=1
45  fi
46 fi
47 
48 # step 6: search for at least one .key file
49 # we need the number of keyfiles for further tests first
50 let KEYFILE_COUNTER=0
51 if [ -d ${KPIPI_KEYFILE_DIR} ]
52 then
53  for KEYFILE in ${KPIPI_KEYFILE_DIR}/*
54  do
55  EXT=${KEYFILE#*.}
56  if [ ${EXT} == "key" ]
57  then
58  ((KEYFILE_COUNTER++))
59  STEP_DONE[5]=1
60  fi
61  done
62 fi
63 
64 # step 2: Is the workspace directory set correctly? Are there some bins?
65 # step 3: Searching for .genbod.evt files
66 STEP_DONE[2]=1
67 FILTERED_MC_EXACT_EVENTS_EXIST=1
68 # step 4: MC data checks
69 STEP_DONE[3]=1
70 # step 5: Searching for .evt files and .acc.evt files
71 STEP_DONE[4]=1
72 FILTERED_RAW_EVENTS_EXIST=1
73 FILTERED_MC_ACC_EVENTS_EXIST=1
74 # step 7: count the .amp files in the AMPS folder
75 STEP_DONE[6]=1
76 if [ -d ${KPIPI_WORK_DIR} ]
77 then
78  # count valid directories
79  let COUNTBINS=0;
80  for BIN in ${KPIPI_WORK_DIR}/*
81  do
82  _BIN=$(basename ${BIN}) # get the directory name
83  BINHIGH=${_BIN#*.} # the number behind the "." is the hight bound
84  BINLOW=${_BIN%.*} # the number in front of the "." is the low bound
85  # not everything in ./* is always a valid folder. Check the name to have numbers
86  if echo ${BINLOW} | grep "^[0-9]*$">/tmp/aux
87  then
88  ((COUNTBINS++));
89  if [ ! -f ${BIN}/${BINLOW}.${BINHIGH}.genbod.evt ]
90  then
91  STEP_DONE[2]=0 # only one genbod file must be missing to turn the result false
92  FILTERED_MC_EXACT_EVENTS_EXIST=0
93  fi
94  if [ ! -f ${KPIPI_MC_FILE_DIR}/${KPIPI_MC_FILE} ]
95  then
96  STEP_DONE[3]=0 # this check is sensless here since the file is obtained by the web. To be changed.
97  fi
98  if [ ! -f ${BIN}/${BINLOW}.${BINHIGH}.evt ]
99  then
100  STEP_DONE[4]=0 # only one event file must be missing to turn the result false
101  FILTERED_RAW_EVENTS_EXIST=0
102  fi
103  if [ ! -f ${BIN}/${BINLOW}.${BINHIGH}.acc.evt ]
104  then
105  STEP_DONE[4]=0 # only one acceptance file must be missing to turn the result false
106  FILTERED_MC_ACC_EVENTS_EXIST=0
107  fi
108  # check for .amp and .int files in AMPS folder
109  let AMPFILE_COUNTER=0
110  for AMPFILE in cat $(ls ${BIN}/AMPS/)
111  do
112  EXT=${AMPFILE#*.}
113  if [ ${EXT} == "amp" ]
114  then
115  ((AMPFILE_COUNTER++))
116  fi
117  done
118  if [ ! ${AMPFILE_COUNTER} == ${KEYFILE_COUNTER} ]
119  then
120  STEP_DONE[6]=0
121  fi
122  if [ ! -f ${BIN}/AMPS/norm.int ]
123  then
124  STEP_DONE[6]=0
125  fi
126  # check for .amp and .int files in PSPAMPS folder
127  let AMPFILE_COUNTER=0
128  for AMPFILE in cat $(ls ${BIN}/PSPAMPS/)
129  do
130  EXT=${AMPFILE#*.}
131  if [ ${EXT} == "amp" ]
132  then
133  ((AMPFILE_COUNTER++))
134  fi
135  done
136  if [ ! ${AMPFILE_COUNTER} == ${KEYFILE_COUNTER} ]
137  then
138  STEP_DONE[6]=0
139  fi
140  if [ ! -f ${BIN}/PSPAMPS/norm.int ]
141  then
142  STEP_DONE[6]=0
143  fi
144  # check for .amp and .int files in ACCAMPS folder
145  let AMPFILE_COUNTER=0
146  for AMPFILE in cat $(ls ${BIN}/ACCAMPS/)
147  do
148  EXT=${AMPFILE#*.}
149  if [ ${EXT} == "amp" ]
150  then
151  ((AMPFILE_COUNTER++))
152  fi
153  done
154  if [ ! ${AMPFILE_COUNTER} == ${KEYFILE_COUNTER} ]
155  then
156  STEP_DONE[6]=0
157  fi
158  if [ ! -f ${BIN}/ACCAMPS/norm.int ]
159  then
160  STEP_DONE[6]=0
161  fi
162  fi
163  done
164  if [ ${COUNTBINS} == ${KPIPI_NBINS} ]
165  then
166  STEP_DONE[1]=1
167  else
168  # negate also some other steps in this case
169  STEP_DONE[2]=0
170  STEP_DONE[3]=0
171  STEP_DONE[4]=0
172  STEP_DONE[6]=0
173  fi
174 else
175  # negate also some other steps in this case
176  STEP_DONE[2]=0
177  STEP_DONE[3]=0
178  STEP_DONE[4]=0
179  STEP_DONE[6]=0
180  FILTERED_MC_EXACT_EVENTS_EXIST=0
181  FILTERED_RAW_EVENTS_EXIST=0
182  FILTERED_MC_ACC_EVENTS_EXIST=0
183 fi
184 
185 # step 8: search for wavelist
186 if [ -f ${KPIPI_WAVE_LIST} ]
187 then
188  STEP_DONE[7]=1
189 fi
190 
191 # step 9: number of fit files should be equal to number of bins
192 let RESULTFILE_COUNTER=0
193 for RESULTFILE in ${KPIPI_FIT_DIR}/*.result.root
194 do
195  ((RESULTFILE_COUNTER++))
196 done
197 if [ ${RESULTFILE_COUNTER} == ${KPIPI_NBINS} ]
198 then
199  STEP_DONE[8]=1
200 fi
201 
202 # step 10: Is there already a file available showing the Intensities?
203 if [ -f ${KPIPI_FIT_DIR}/waveintensities.ps ]
204 then
205  STEP_DONE[9]=1
206 fi
207 
208 # show the results of the performed tests
209 echo -e "\n The current status of the PWA analysis chain is: \n"
210 for (( I=0; I<10; I++ )) # in
211 do
212  if [ ${STEP_DONE[$I]} == "1" ]
213  then
214  echo -e " ${STEP_NAME[$I]}\E[37;32m completed"; tput sgr0
215  else
216  echo -e " ${STEP_NAME[$I]}\E[37;31m not complete "; tput sgr0
217  fi
218 done
219 echo -e "\n Warning: the consistency of data is not beeing checked! \n"