Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-06 08:09:41

0001 #! /bin/bash
0002 verbose_mode=false 
0003 allsegments=false
0004 nfiles=100
0005 dosubmit=false 
0006 user=`id -u -n`
0007 triggertype="MB"
0008 prodtype="26"
0009 condor_testfile="condor_blank.job"
0010 
0011 #build the condor jobs
0012 make_condor_jobs()
0013 {
0014         if [ ! -d $(pwd)"/../"${triggertype}"_output" ]; then 
0015                 if [ "$verbose_mode" = true ]; then 
0016                         echo "data directory doesn't exist for ${triggertype}, fixing now"
0017                 fi 
0018                 
0019                 mkdir $(pwd)"/../"${triggertype}"_output"
0020         fi 
0021         if [[ $nfiles -eq 0 ]]; then 
0022                 nfiles=`wc -l < ${triggertype}_data/herwig_files.list`
0023         fi      
0024         for i in $(seq 0 ${nfiles}); do 
0025                 j=$(( i+1 ))
0026                 condor_file="$(pwd)/condor_file_dir/condor_"$triggertype"_seg_"$i".job"
0027                 condor_out_file=$(pwd)"/condor_file_dir/condor_"$triggertype"_seg_"$i".out"
0028                 condor_err_file=$(pwd)"/condor_file_dir/condor_"$triggertype"_seg_"$i".err"
0029                 condor_log_file=$(pwd)"/condor_file_dir/condor_"$triggertype"_seg_"$i".log"
0030                 herwig_hepmc=`sed "${j}q;d" ${triggertype}_data/herwig_files.list`
0031                 pythia_truth=`sed "${j}q;d" ${triggertype}_data/pythia_truth.list`
0032                 pythia_jet=`sed "${j}q;d" ${triggertype}_data/pythia_jet.list`
0033 
0034                 if [ "$vebose_mode" = true ]; then
0035                         echo "Producing condor job file " $condor_file
0036                 fi
0037                 IFS=$'\n' read -d '' -r -a blanklines < $condor_testfile
0038                 echo "${blanklines[0]}" > $condor_file 
0039                 echo "${blanklines[1]}"$(pwd)"/RunHerwigProductionQA.sh" >> $condor_file
0040                 echo "${blanklines[2]}"$i $triggertype $herwig_hepmc $pythia_truth $pythia_jet >> $condor_file
0041                 echo "${blanklines[3]}"$condor_out_file >> $condor_file
0042                 echo "${blanklines[4]}"$condor_err_file >> $condor_file
0043                 echo "${blanklines[5]}"$condor_log_file >> $condor_file
0044                 echo "${blanklines[6]} $(pwd)/../${triggertype}_output" >>$condor_file
0045                 echo "${blanklines[7]}" >> $condor_file
0046                 echo "${blanklines[8]}" >> $condor_file 
0047                 echo "${blanklines[9]}" "   "  $user >> $condor_file 
0048                 echo "${blanklines[10]}" >> $condor_file
0049                 echo "${blanklines[11]}" >> $condor_file
0050                 echo "${blanklines[12]}" >> $condor_file
0051                 echo "${blanklines[13]}" >> $condor_file
0052         done            
0053 }
0054 
0055 submit_condor_jobs(){
0056         #if submit just get all files in expected job type
0057         for n in $(seq 0 ${nfiles}); do 
0058                 i=$(pwd)"/condor_file_dir/condor_"$triggertype"_seg_"$n".job"
0059                 condor_submit $i
0060         done
0061 }
0062 
0063 has_argument(){
0064         [[ ("$1" == *=* && -n ${1#*=}) || ( ! -z "$2" && "$2" != -*) ]]
0065 }
0066 
0067 extract_argument() {
0068         echo "${2:-${1#*=}}"
0069 }
0070 
0071 handle_options()
0072 {
0073         while [ $# -gt 0 ]; do 
0074                 case $1 in 
0075                         -h | --help)
0076                                 echo "Options for Herwig/Pythia Comparisons at the HepMC level"
0077                                 echo "$0 [OPTIONS]"
0078                                 echo "This script runs a comparison QA between produced Herwig HepMC files and existant Pythia productions"
0079                                 echo " "
0080                                 echo " -h, --help       Display this message"
0081                                 echo " -v, --verbose    Enable verbose job creation (Default false) "
0082                                 echo " -s, --submit     Submit condor jobs (default false)"
0083                                 echo " -g,  --get       Makes the filelist for Herwig & Pythia before running (default false)"
0084                                 echo " -t, --type       Which production "
0085                                 echo "                  MB (default)"
0086                                 echo "                  Jets:Jet5, Jet15, Jet20, Jet30, Jet40, Jet50"
0087                                 echo "                  PhotonJets: PhotonJet5, PhotonJet10"
0088                                 echo " "
0089                                 echo " -n, --number     How many files to test against (default 100, 0 is all) "
0090                                 exit 0 
0091                                 ;;
0092                         -v | --verbose)
0093                                 verbose_mode=true
0094                                 shift
0095                                 ;;
0096                         -s | --submit)
0097                                 dosubmit=true
0098                                 shift
0099                                 ;;
0100                         -g | --get)
0101                                 makedatalist=true
0102                                 shift
0103                                 ;;
0104                         -t | --type) 
0105                                 triggertype=$(extract_argument $@)
0106                                 shift
0107                                 shift
0108                                 ;;
0109                         -n | --number) 
0110                                 nfiles=$(extract_argument $@)
0111                                 shift 
0112                                 shift 
0113                                 ;;
0114                         *)
0115                                 echo "Invalid option: $1 "
0116                                 exit 1
0117                                 ::
0118                 esac
0119         done
0120 }
0121 converttriggertype()
0122 {
0123         if [ "${triggertype}" = "MB" ]; then
0124                 prodtype=26
0125         elif [ "${triggertype}" = "Jet5" ]; then
0126                 prodtype=36
0127         elif [ "${triggertype}" = "Jet10" ]; then
0128                 prodtype=12
0129         elif [ "${triggertype}" = "Jet12" ]; then
0130                 prodtype=39
0131         elif [ "${triggertype}" = "Jet15" ]; then
0132                 prodtype=33
0133         elif [ "${triggertype}" = "Jet20" ]; then
0134                 prodtype=21
0135         elif [ "${triggertype}" = "Jet30" ]; then
0136                 prodtype=11
0137         elif [ "${triggertype}" = "Jet40" ]; then
0138                 prodtype=19
0139         elif [ "${triggertype}" = "Jet50" ]; then
0140                 prodtype=34
0141         elif [ "${triggertype}" = "PhotonJet5" ]; then
0142                 prodtype=27
0143         elif [ "${triggertype}" = "PhotonJet10" ]; then
0144                 prodtype=28
0145         elif [ "${triggertype}" = "PhotonJet10" ]; then
0146                 prodtype=29
0147         fi
0148 }
0149 handle_options "$@"
0150 if [ "$verbose_mode" = true ]; then 
0151         echo "Running over ${nfiles} segement(s)"
0152 fi 
0153 if [ "$makedatalist" = true ]; then
0154         base_dir=$(pwd)
0155         if [ "$verbose_mode" = true ]; then 
0156                 echo "Checking if data directory exists for ${triggertype}"
0157         fi 
0158         if [ ! -d ${triggertype}"_data" ]; then 
0159                 if [ "$verbose_mode" = true ]; then 
0160                         echo "data directory doesn't exist for ${triggertype}, fixing now"
0161                 fi 
0162                 
0163                 mkdir -p ${triggertype}"_data"
0164         fi 
0165         if [ "$verbose_mode" = true ]; then 
0166                 echo "Create Herwig Datalist for ${triggertype}"
0167         fi
0168         if [ "$triggertype" = "MB" ]; then 
0169                  ls /sphenix/tg/tg01/jets/sgross/HerwigHepMC/Herwig_${triggertype}/*.hepmc > ${triggertype}_data/herwig_files.list
0170         else
0171                 ls /sphenix/tg/tg01/jets/sgross/HerwigHepMC/Herwig_${triggertype}/*filtered*.hepmc > ${triggertype}_data/herwig_files.list
0172         fi
0173         if [ "$verbose_mode" = true ]; then 
0174                 echo "Create Pythia Datalist for ${triggertype}"
0175         fi 
0176         cd ${triggertype}_data
0177         converttriggertype 
0178         CreateFileList.pl -nopileup -type ${prodtype} -run 28 G4Hits DST_TRUTH_JET
0179         mv g4hits.list pythia_truth.list
0180         mv dst_truth_jet.list pythia_jet.list
0181         cd ${base_dir}
0182 fi
0183 make_condor_jobs
0184 if [ "$dosubmit" = true ]; then
0185         submit_condor_jobs
0186 fi
0187 
0188