Last active
July 19, 2022 12:55
-
-
Save delannoy/9bb5717807a3b88181de951a0bcac536 to your computer and use it in GitHub Desktop.
vbfhn gen-production
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # [vbfhn - Notes of gen-production](https://docs.google.com/document/d/1_QVUkCEOtk3ZRdC1dl6DSHnPOGmct64vPnZTc0CuqEs/) | |
| WORKDIR="${WORK:-${PWD}}" | |
| MADGRAPHDIR="${WORKDIR}/GenProductions/bin/MadGraph5_aMCatNLO" | |
| CARDPROCESS='SingleVectorLQ_M500' | |
| CARDDIR="cards/production/2017/13TeV/SingleVectorLQ/PdfLo/${CARDPROCESS}" | |
| GRIDPACK="${MADGRAPHDIR}/${CARDPROCESS}_slc7_amd64_gcc700_CMSSW_10_6_19_tarball.tar.xz" | |
| # [https://cms-pdmv.cern.ch/mcm/requests?dataset_name=SingleVectorLQ_InclusiveDecay_M-500_TuneCP2_13TeV-madgraph-pythia8] | |
| CAMPAIGN='EXO-RunIIFall17' | |
| LHEGENSIM="${CAMPAIGN}wmLHEGS-02236" | |
| DIGIRECO="${CAMPAIGN}DRPremix-03025" | |
| MINIAOD="${CAMPAIGN}MiniAODv2-02974" | |
| NANOAOD="${CAMPAIGN}NanoAODv5-02844" | |
| cardSetup(){ | |
| # [https://twiki.cern.ch/twiki/bin/viewauth/CMS/QuickGuideMadGraph5aMCatNLO] | |
| cd "${WORKDIR}/" | |
| git clone '[email protected]:cms-sw/genproductions.git' 'GenProductions/' || git clone 'https://github.com/cms-sw/genproductions.git' 'GenProductions/' | |
| cd "${MADGRAPHDIR}" | |
| ls -l "${CARDDIR}" | |
| # SingleVectorLQ_M500_run_card.dat parameters corresponding to the LHC/CMS conditions | |
| # SingleVectorLQ_M500_proc_card.dat processes of interest | |
| # SingleVectorLQ_M500_extramodels.dat name of the UFO model uploaded on the database | |
| # SingleVectorLQ_M500_customizecards.dat exact parameters of the customized model configuration considered | |
| cat "${CARDDIR}/${CARDPROCESS}_customizecards.dat" | |
| # mass mass of the LQ | |
| # decay width of the LQ | |
| # npcoup 1 k (Yang-Mill=1 or Minimal=0) | |
| # npcoup 2 Lambda_topnu | |
| # npcoup 3 lambda_btau | |
| } | |
| customizeCard(){ | |
| local process="$1" | |
| local mn3="$2" | |
| local filename="${process}_MuE_M${mn3}_customizecards.dat" | |
| local vtan3='0.01' | |
| mkdir -p "${cardPath}" | |
| rm -vf "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card mn1 1000000' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card mn2 1000000' >> "${cardPath}/${filename}" | |
| printf '%s\n' "set param_card mn3 ${mn3}" >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card ven1 0.000000e+00' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card ven2 0.000000e+00' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card ven3 0.000000e+00' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card vmun1 0.000000e+00' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card vmun2 0.000000e+00' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card vmun3 0.000000e+00' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card vtan1 0.000000e+00' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set param_card vtan2 0.000000e+00' >> "${cardPath}/${filename}" | |
| printf '%s\n' "set param_card vtan3 ${vtan3}" >> "${cardPath}/${filename}" | |
| printf '%s\n' 'compute_widths 9900012' >> "${cardPath}/${filename}" | |
| # printf '%s\n' 'compute_widths 9900014' >> "${cardPath}/${filename}" | |
| } | |
| procCard(){ | |
| local process="$1" | |
| local mn3="$2" | |
| local filename="${process}_MuE_M${mn3}_proc_card.dat" | |
| mkdir -p "${cardPath}" | |
| rm -vf "${cardPath}/${filename}" | |
| printf '%s\n' 'import model SM_HeavyN_NLO' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'define l = l+ l-' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'define w = w- w+' >> "${cardPath}/${filename}" | |
| # printf '%s\n' 'define e = e+ e-' >> "${cardPath}/${filename}" | |
| # printf '%s\n' 'define mu = mu+ mu-' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'define ta = ta+ ta-' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'generate p p > l n1 [QCD]' >> "${cardPath}/${filename}" | |
| printf '%s\n' "output ${process}_MuE_M${mn3}" >> "${cardPath}/${filename}" # --nojpeg | |
| } | |
| runCard(){ | |
| local process="$1" | |
| local mn3="$2" | |
| local filename="${process}_MuE_M${mn3}_run_card.dat" | |
| wget 'https://github.com/Hooooon12/genproductions/raw/newproduction/bin/MadGraph5_aMCatNLO/cards/HeavyNeutrino_Dilepton_NLO/VBFTypeI_NLO/VBFTypeI_NLO_DF_M1000/VBFTypeI_NLO_DF_M1000_run_card.dat' --output-document "${cardPath}/${filename}" | |
| } | |
| extraModelsCard(){ | |
| local process="$1" | |
| local mn3="$2" | |
| local filename="${process}_MuE_M${mn3}_extramodels.dat" | |
| printf '%s\n' 'SM_HeavyN_Gen3Mass_NLO.tgz' > "${cardPath}/${filename}" | |
| } | |
| metaDataCard(){ | |
| local filepath="${WORKDIR}/GenProductions/MetaData/pdflist_5f_2017.dat" | |
| wget 'https://github.com/Hooooon12/genproductions/raw/newproduction/MetaData/pdflist_5f_2017.dat' --output-document "${filepath}" | |
| sed -i 's|#325100 \(.*\)|325100 \1|g' "${filepath}" | |
| } | |
| madspinCard(){ | |
| local process="$1" | |
| local mn3="$2" | |
| local decay='n1 > ta j j' # 'n1 > w ta, w > j j' | |
| local filename="${process}_MuE_M${mn3}_madspin_card.dat" | |
| rm -vf "${cardPath}/${filename}" | |
| printf '%s\n\n' 'set ms_dir ./madspingrid' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set Nevents_for_max_weigth 250 # number of events for the estimate of the max. weight' >> "${cardPath}/${filename}" | |
| printf '%s\n\n' 'set max_weight_ps_point 400 # number of PS to estimate the maximum for each event' >> "${cardPath}/${filename}" | |
| printf '%s\n' 'set max_running_process 1' >> "${cardPath}/${filename}" | |
| printf '%s\n\n' 'set spinmode none' >> "${cardPath}/${filename}" | |
| printf '%s\n' "decay ${decay}" >> "${cardPath}/${filename}" | |
| printf '%s\n' 'launch' >> "${cardPath}/${filename}" | |
| } | |
| modifyCards(){ | |
| local process="$1" | |
| local mn3="$2" | |
| cd "${WORKDIR}" | |
| cardPath="${MADGRAPHDIR}/cards/production/13TeV/HeavyNeutrino_Dilepton_NLO/${process}/${process}_MuE_M${mn3}" | |
| mkdir -p "${cardPath}" | |
| cd "${MADGRAPHDIR}" | |
| customizeCard "${process}" "${mn3}" | |
| procCard "${process}" "${mn3}" | |
| runCard "${process}" "${mn3}" | |
| extraModelsCard "${process}" "${mn3}" | |
| madspinCard "${process}" "${mn3}" | |
| metaDataCard | |
| } | |
| # cardSetup | |
| # modifyCards 'DYTypeI_NLO' '300' | |
| # git diff "${MADGRAPHDIR}" | |
| gridpack(){ | |
| # [https://twiki.cern.ch/twiki/bin/viewauth/CMS/QuickGuideMadGraph5aMCatNLO#Quick_tutorial_on_how_to_produce] | |
| cardSetup | |
| cd "${MADGRAPHDIR}" | |
| ./gridpack_generation.sh "${CARDPROCESS}" "${CARDDIR}" && ls -l "${GRIDPACK}" | |
| } | |
| setupCMSSW(){ | |
| # [https://cms-pdmv.cern.ch/mcm/public/restapi/requests/get_setup/EXO-RunIIFall17wmLHEGS-02236] | |
| local cmsswversion="$1" | |
| source '/cvmfs/cms.cern.ch/cmsset_default.sh' | |
| # export SCRAM_ARCH='slc6_amd64_gcc630' | |
| cd "${WORKDIR}/GenProductions" | |
| [[ -d "${cmsswversion}/src" ]] || scram project 'CMSSW' "${cmsswversion}" | |
| cd "${cmsswversion}/src/" | |
| eval `scramv1 runtime -sh` # cmsenv | |
| scram build # --ignore-arch | |
| } | |
| downloadFragment(){ | |
| local url="https://cms-pdmv.cern.ch/mcm/public/restapi/requests/get_fragment/${LHEGENSIM}" | |
| local fragmentpy="Configuration/GenProduction/python/${LHEGENSIM}-fragment.py" | |
| cd "${WORKDIR}/GenProductions" | |
| curl --progress-bar --insecure "${url}" --retry 3 --create-dirs --output "${fragmentpy}" && ls -l "$_" | |
| sed --in-place "s|args = cms.vstring.*|args = cms.vstring(\'"${GRIDPACK}"\'),|g" "${fragmentpy}" | |
| scram build # --ignore-arch | |
| } | |
| cmsDriverLHE(){ | |
| cd "${WORKDIR}/GenProductions" | |
| local EVENTS="${1:-488}" | |
| local SEED=$(($(date +%s) % 100 + 1)) | |
| # Note: `cmsDriver.py` cannot handle absolute paths | |
| cmsDriver.py "Configuration/GenProduction/python/${LHEGENSIM}-fragment.py" \ | |
| --fileout "file:${LHEGENSIM}.root" \ | |
| --mc \ | |
| --eventcontent RAWSIM,LHE \ | |
| --datatier GEN-SIM,LHE \ | |
| --conditions 93X_mc2017_realistic_v3 \ | |
| --beamspot Realistic25ns13TeVEarly2017Collision \ | |
| --step LHE,GEN,SIM \ | |
| --nThreads 8 \ | |
| --geometry DB:Extended \ | |
| --era Run2_2017 \ | |
| --python_filename "${LHEGENSIM}_1_cfg.py" \ | |
| --no_exec \ | |
| --customise Configuration/DataProcessing/Utils.addMonitoring \ | |
| --customise_commands process.RandomNumberGeneratorService.externalLHEProducer.initialSeed="int(${SEED})" \ | |
| -n "${EVENTS}" | |
| } | |
| cmsDriverRECO1(){ | |
| cd "${WORKDIR}/GenProductions" | |
| cmsDriver.py 'step1' \ | |
| --filein "file:${LHEGENSIM}.root" \ | |
| --fileout "file:${DIGIRECO}_step1.root" \ | |
| --pileup_input "dbs:/Neutrino_E-10_gun/RunIISummer17PrePremix-MCv2_correctPU_94X_mc2017_realistic_v9-v1/GEN-SIM-DIGI-RAW" \ | |
| --mc \ | |
| --eventcontent 'PREMIXRAW' \ | |
| --datatier 'GEN-SIM-RAW' \ | |
| --conditions '94X_mc2017_realistic_v11' \ | |
| --step 'DIGIPREMIX_S2,DATAMIX,L1,DIGI2RAW,HLT:2e34v40' \ | |
| --nThreads 8 \ | |
| --datamix 'PreMix' \ | |
| --era 'Run2_2017' \ | |
| --python_filename "${DIGIRECO}_1_cfg.py" \ | |
| --no_exec \ | |
| --customise 'Configuration/DataProcessing/Utils.addMonitoring' \ | |
| -n 10 | |
| } | |
| cmsDriverRECO2(){ | |
| cd "${WORKDIR}/GenProductions" | |
| cmsDriver.py 'step2' \ | |
| --filein "file:${DIGIRECO}_step1.root" \ | |
| --fileout "file:${DIGIRECO}.root" \ | |
| --mc \ | |
| --eventcontent 'AODSIM' \ | |
| --runUnscheduled \ | |
| --datatier 'AODSIM' \ | |
| --conditions '94X_mc2017_realistic_v11' \ | |
| --step 'RAW2DIGI,RECO,RECOSIM,EI' \ | |
| --nThreads 8 \ | |
| --era 'Run2_2017' \ | |
| --python_filename "${DIGIRECO}_2_cfg.py" \ | |
| --no_exec \ | |
| --customise 'Configuration/DataProcessing/Utils.addMonitoring' \ | |
| -n 1089 | |
| } | |
| cmsDriverMiniAOD(){ | |
| cd "${WORKDIR}/GenProductions" | |
| cmsDriver.py 'step1' \ | |
| --filein "file:${DIGIRECO}.root" \ | |
| --fileout "file:${MINIAOD}.root" \ | |
| --mc \ | |
| --eventcontent 'MINIAODSIM' \ | |
| --runUnscheduled \ | |
| --datatier 'MINIAODSIM' \ | |
| --conditions '94X_mc2017_realistic_v14' \ | |
| --step 'PAT' \ | |
| --nThreads 4 \ | |
| --scenario 'pp' \ | |
| --era 'Run2_2017,run2_miniAOD_94XFall17' \ | |
| --python_filename "${MINIAOD}_1_cfg.py" \ | |
| --no_exec \ | |
| --customise 'Configuration/DataProcessing/Utils.addMonitoring' \ | |
| -n 10 | |
| } | |
| cmsDriverNanoAOD(){ | |
| cd "${WORKDIR}/GenProductions" | |
| cmsDriver.py 'step1' \ | |
| --filein "file:${MINIAOD}.root" \ | |
| --fileout "file:${NANOAOD}.root" \ | |
| --mc \ | |
| --eventcontent 'NANOAODSIM' \ | |
| --datatier 'NANOAODSIM' \ | |
| --conditions '102X_mc2017_realistic_v7' \ | |
| --step 'NANO' \ | |
| --nThreads 2 \ | |
| --era 'Run2_2017,run2_nanoAOD_94XMiniAODv2' \ | |
| --python_filename "${NANOAOD}_1_cfg.py" \ | |
| --no_exec \ | |
| --customise 'Configuration/DataProcessing/Utils.addMonitoring' \ | |
| -n 10 \ | |
| --customise_commands="process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)))" | |
| } | |
| lhe(){ | |
| # [https://twiki.cern.ch/twiki/bin/viewauth/CMS/QuickGuideMadGraph5aMCatNLO#Standalone_production_running_th] | |
| setupCMSSW 'CMSSW_9_3_15' | |
| downloadFragment | |
| cmsDriverLHE | |
| cmsRun -e -j "${LHEGENSIM}_rt.xml" "${LHEGENSIM}_1_cfg.py" | |
| } | |
| digiReco(){ | |
| voms-proxy-init --voms cms --valid 168:00 | |
| setupCMSSW 'CMSSW_9_4_7' | |
| cmsDriverRECO1 | |
| cmsRun -e -j "${DIGIRECO}_rt.xml" "${DIGIRECO}_1_cfg.py" | |
| cmsDriverRECO2 | |
| cmsRun -e -j "${DIGIRECO}_2_rt.xml" "${DIGIRECO}_2_cfg.py" | |
| } | |
| miniAOD(){ | |
| setupCMSSW 'CMSSW_9_4_7' | |
| cmsDriverMiniAOD | |
| cmsRun "${MINIAOD}_1_cfg.py" | |
| } | |
| nanoAOD(){ | |
| setupCMSSW 'CMSSW_10_2_15' | |
| cmsDriverNanoAOD | |
| cmsRun "${NANOAOD}_1_cfg.py" | |
| } | |
| main(){ | |
| gridpack | |
| lhe | |
| digiReco | |
| miniAOD | |
| nanoAOD | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment