Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:18

0001 #!/bin/bash
0002 
0003 dataset="/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/RunIISummer15GS-MCRUN2_71_V1-v1/GEN-SIM"
0004 query="file dataset=${dataset} site=T2_CH_CERN"
0005 queue="cmscaf1nh"
0006 
0007 ################################################################################
0008 if [ x${CMSSW_BASE} = 'x' ]
0009 then
0010     echo "Please source a CMSSW environment."
0011     exit 1
0012 fi
0013 
0014 ################################################################################
0015 eos=/afs/cern.ch/project/eos/installation/cms/bin/eos.select
0016 
0017 out_name=$(echo ${dataset} | sed 's|^/||;s|/GEN-SIM||;s|/|_|g;')
0018 
0019 submit_dir="submit_${out_name}"
0020 current_dir=$(pwd -P)
0021 eos_dir=/eos/cms/store/caf/user/${USER}/ZMuMuMassConstraintParameterFinder/${out_name}/
0022 
0023 rm -rf ${submit_dir}
0024 mkdir ${submit_dir}
0025 ${eos} mkdir -p ${eos_dir}
0026 
0027 input_files=$(das_client --limit=0 --query="${query}")
0028 
0029 
0030 # create skim jobs for each input file
0031 cd ${submit_dir}
0032 count=1
0033 for input in ${input_files}
0034 do
0035     formatted_count=$(printf %04d ${count})
0036     output=dimuon_mass_${formatted_count}.root
0037     script_name=dimuon_mass_${formatted_count}.sh
0038     cat > ${script_name} <<EOF
0039 #!/bin/bash
0040 CWD=\$(pwd -P)
0041 cd ${CMSSW_BASE}/src
0042 eval \`scramv1 ru -sh\`
0043 cd \${CWD}
0044 echo \${CWD}
0045 cp $(readlink -e ../zmumudistribution_cfg.py) .
0046 cmsRun zmumudistribution_cfg.py inputFiles=${input} outputFile=${output}
0047 ${eos} cp ${output} ${eos_dir}
0048 EOF
0049     chmod +x ${script_name}
0050     bsub_output=$(bsub -q ${queue} ${script_name})
0051     echo ${bsub_output}
0052     job_id=$(echo ${bsub_output} | sed 's|^Job <\([0-9]\{9\}\)>.*|\1|')
0053     if [[ ${count} -eq 1 ]]
0054     then
0055         conditions="ended(${job_id})"
0056     else
0057         conditions="${conditions} && ended(${job_id})"
0058     fi
0059     count=$((count + 1))
0060 done
0061 
0062 
0063 # merge the output of the skim jobs
0064 output=dimuon_mass.root
0065 script_name=dimuon_mass_merge.sh
0066 cat > ${script_name} <<EOF
0067 #!/bin/bash
0068 CWD=\$(pwd -P)
0069 cd ${CMSSW_BASE}/src
0070 eval \`scramv1 ru -sh\`
0071 cd \${CWD}
0072 echo \${CWD}
0073 ${eos} cp -r ${eos_dir} ROOT_FILES/
0074 cd ROOT_FILES
0075 rm ${output}
0076 hadd ${output} *.root
0077 ${eos} cp ${output} ${eos_dir}
0078 root -l -b -q "${current_dir}/printParameters.C(\"${output}\")" > ${current_dir}/${submit_dir}/zMuMuMassConstraintParameters.txt
0079 EOF
0080 chmod +x ${script_name}
0081 bsub -q ${queue} -w "${conditions}" ${script_name}
0082 cd ${current_dir}