Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:02

0001 #!/bin/bash
0002 
0003 usage='Usage: -r <run number> -d <crab_subdirectory> -o <output_dir> -w <work_dir> -m <merge_dir>'
0004 
0005 args=`getopt rdowm: -- "$@"`
0006 if test $? != 0
0007      then
0008          echo $usage
0009          exit 1
0010 fi
0011 
0012 eval set -- "$args"
0013 for i 
0014   do
0015   case "$i" in
0016       -r) shift; run_num=$2;shift;;
0017       -d) shift; crab_dir=$2;shift;;
0018       -o) shift; output_dir=$2;shift;;
0019       -w) shift; work_dir=$2;shift;;
0020       -m) shift; merge_dir=$2;shift;;
0021   esac      
0022 done
0023 
0024 #this_dir=`pwd`;
0025 #echo "this is your working dir"
0026 #echo `pwd`
0027 
0028 
0029 echo "HELLO! " ${merge_dir}
0030 
0031 if [ "X"${run_num} == "X" ]
0032     then
0033     echo "INVALID RUN NUMBER! Please give a valid run number!"
0034     echo $usage
0035     exit 
0036 fi
0037 
0038 if [ "X"${work_dir} == "X" ]
0039     then
0040 #    work_dir=``;
0041     work_dir=`pwd`;
0042     echo " using default work dir" ${work_dir}
0043 else
0044     echo " using work dir "${work_dir}
0045 fi
0046 
0047 if [ "X"${merge_dir} == "X" ]
0048     then
0049     merge_dir=${run_num}
0050     echo " using default merge dir" ${merge_dir}
0051 else
0052     echo " using merge dir "${merge_dir}
0053 fi
0054 
0055 if [ "X"${crab_dir} == "X" ]
0056     then
0057     crab_dir=`\ls -rt1 ${work_dir}/${merge_dir} | grep "crab_" | tail -1 | awk '{print $NF}'`;
0058     echo " using default output dir" ${crab_dir}
0059 else
0060     echo " using output dir "${crab_dir}
0061 fi
0062 
0063 
0064 
0065 echo 'Merging CRAB output ' ${run_num} 'crab_dir' ${crab_dir}
0066 
0067 cd ${work_dir}/${merge_dir}/${crab_dir}/res;
0068 #pwd;
0069 
0070 # check root files
0071 nroot=`\ls DQM_V0001_EcalPreshower_R*root | grep -vc ${run_num}`;
0072 nmergeroot=`\ls DQM_V0001_EcalPreshower_R*root | grep -c ${run_num}`;
0073 #echo $nmergeroot
0074 
0075 if [ "${nroot}" == "0" ] && [ "${nmergeroot}" == "0" ]
0076 then
0077     echo " NO root files" $nroot ".. exiting"
0078     exit
0079 else
0080     echo " $nroot root files, $nmergeroot merged files"
0081 fi
0082 
0083 #rm -f EcalCosmicsHists_${run_num}.root
0084 # now to hadd
0085 hadd -f DQM_V0001_EcalPreshower_${run_num}.root DQM_V0001_EcalPreshower_R*root
0086 
0087 # check log files
0088 nstdout=`\ls -l CMSSW*stdout | wc | awk '{print $1}'`;
0089 nmergeout=`\ls DQM_V0001_EcalPreshower_*log | grep -c ${run_num}`;
0090 if [ "${nstdout}" == "0" ] #&& [ "${nmergeout}" == "0" ]
0091 then
0092     echo " NO stdout files" $nstdout 
0093     #exit
0094 else
0095     echo " $nstdout stdout files, $nmergeout merged files"
0096     cat CMSSW*stdout > DQM_V0001_EcalPreshower_${run_num}.log
0097 fi
0098 
0099 gzip -f DQM_V0001_EcalPreshower_${run_num}.log
0100 
0101 if [ "X"${output_dir} == "X" ]
0102     then
0103     output_dir=/castor/cern.ch/user/c/ccecal/ES
0104     echo " use default output dir" $output_dir
0105     rfmkdir ${output_dir}
0106     rfchmod 775 ${output_dir}
0107     rfcp DQM_V0001_EcalPreshower_${run_num}.log.gz ${output_dir}
0108     rfcp DQM_V0001_EcalPreshower_${run_num}.root ${output_dir}
0109     rfchmod 775 ${output_dir}/DQM_V0001_EcalPreshower_${run_num}.log.gz
0110     rfchmod 775 ${output_dir}/DQM_V0001_EcalPreshower_${run_num}.root
0111 else
0112     echo " using output dir "${output_dir}
0113     rfmkdir ${output_dir}
0114     rfchmod 775 ${output_dir}
0115     rfcp DQM_V0001_EcalPreshower_${run_num}.log.gz ${output_dir}
0116     rfcp DQM_V0001_EcalPreshower_${run_num}.root ${output_dir}
0117     rfchmod 775 ${output_dir}/DQM_V0001_EcalPreshower_${run_num}.log.gz
0118     rfchmod 775 ${output_dir}/DQM_V0001_EcalPreshower_${run_num}.root
0119 #    rm -f EcalCosmicsHists_${run_num}.log
0120 fi
0121 
0122 size=`\ls -l DQM_V0001_EcalPreshower_${run_num}.root | grep -c ${run_num}`;
0123 echo $size
0124 
0125 if [ "${size}" == "0" ]
0126 then
0127     echo " Warning: your merged file has size ZERO.. will not delete root files."
0128 else
0129     echo
0130 #    echo " Warning: deleting root files"
0131 #    \ls EcalCosmicsHists_*root | grep -v ${run_num} | awk '{print "rm -f "$NF}' |sh
0132 fi
0133 
0134 #rm -rf CMSSW*stdout
0135 #rm -rf CMSSW*stderr
0136 #rm -rf crab*xml
0137 
0138 #\ls -l;
0139