From f84d9b0a01d685c5cdad16962d9c83a7a1c34930 Mon Sep 17 00:00:00 2001 From: rsadek Date: Fri, 4 Feb 2022 11:35:54 +0100 Subject: [PATCH 1/3] Enable option for saving parameters at plane for matching training with machine learning --- MC/bin/o2dpg_sim_workflow.py | 10 ++++++++++ MC/run/PWGDQ/runBeautyToJpsi_fwdy_PbPb.sh | 2 +- MC/run/PWGDQ/runPromptCharmonia_fwdy_PbPb.sh | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index f2a804094..e5ec5b4e1 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -99,6 +99,8 @@ # Global Forward reconstruction configuration parser.add_argument('--fwdmatching-assessment-full', action='store_true', help='enables complete assessment of global forward reco') +# Matching training for machine learning +parser.add_argument('--fwdmatching-save-trainingdata', action='store_true', help='enables saving parameters at plane for matching training with machine learning') args = parser.parse_args() print (args) @@ -711,6 +713,12 @@ def createRestDigiTask(name, det='ALLSMALLER'): MFTMCHMATCHtask['cmd']+= getDPL_global_options() workflow['stages'].append(MFTMCHMATCHtask) + if args.fwdmatching_save_trainingdata == True: + MFTMCHMATCHTraintask = createTask(name='mftmchMatchTrain_'+str(tf), needs=[MCHMIDMATCHtask['name'], MFTRECOtask['name']], tf=tf, cwd=timeframeworkdir, lab=["RECO"], mem='1500') + MFTMCHMATCHTraintask['cmd'] = '${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.saveMode" : 2, "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) + MFTMCHMATCHTraintask['cmd']+= getDPL_global_options() + workflow['stages'].append(MFTMCHMATCHTraintask) + ## Vertexing PVConfig = {**AlpideConfig} # start with Alpide config which is relevant here if COLTYPEIR == 'pp': @@ -837,6 +845,8 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''): if usebkgcache: aodneeds += [ BKG_KINEDOWNLOADER_TASK['name'] ] + if args.fwdmatching_save_trainingdata == True: # Hack + aodneeds += [ MFTMCHMATCHTraintask['name'] ] aod_df_id = '{0:03}'.format(tf) AODtask = createTask(name='aod_'+str(tf), needs=aodneeds, tf=tf, cwd=timeframeworkdir, lab=["AOD"], mem='4000', cpu='1') diff --git a/MC/run/PWGDQ/runBeautyToJpsi_fwdy_PbPb.sh b/MC/run/PWGDQ/runBeautyToJpsi_fwdy_PbPb.sh index 5263f8ce2..b2b0edde4 100644 --- a/MC/run/PWGDQ/runBeautyToJpsi_fwdy_PbPb.sh +++ b/MC/run/PWGDQ/runBeautyToJpsi_fwdy_PbPb.sh @@ -16,7 +16,7 @@ NTIMEFRAMES=${NTIMEFRAMES:-1} ${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 5020 -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -e TGeant4 -mod "--skipModules ZDC" \ -trigger "external" -ini $O2DPG_ROOT/MC/config/PWGDQ/ini/GeneratorHF_bbbar_fwdy.ini \ - -genBkg pythia8 -procBkg "heavy_ion" -colBkg PbPb --embedding -nb ${NBKGEVENTS} --mft-reco-full --mft-assessment-full --fwdmatching-assessment-full + -genBkg pythia8 -procBkg "heavy_ion" -colBkg PbPb --embedding -nb ${NBKGEVENTS} --mft-reco-full --mft-assessment-full --fwdmatching-assessment-full --fwdmatching-save-trainingdata # run workflow ${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json diff --git a/MC/run/PWGDQ/runPromptCharmonia_fwdy_PbPb.sh b/MC/run/PWGDQ/runPromptCharmonia_fwdy_PbPb.sh index 5484a95d5..725cbaa6b 100755 --- a/MC/run/PWGDQ/runPromptCharmonia_fwdy_PbPb.sh +++ b/MC/run/PWGDQ/runPromptCharmonia_fwdy_PbPb.sh @@ -16,7 +16,7 @@ NTIMEFRAMES=${NTIMEFRAMES:-1} ${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 5020 -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -e TGeant4 -mod "--skipModules ZDC" \ -confKey "GeneratorExternal.fileName=${O2DPG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorCocktailPromptCharmoniaToMuonEvtGen_PbPb5TeV.C;GeneratorExternal.funcName=GeneratorCocktailPromptCharmoniaToMuonEvtGen_PbPb5TeV()" \ - -genBkg pythia8 -procBkg "heavy_ion" -colBkg PbPb --embedding -nb ${NBKGEVENTS} --mft-reco-full --mft-assessment-full --fwdmatching-assessment-full + -genBkg pythia8 -procBkg "heavy_ion" -colBkg PbPb --embedding -nb ${NBKGEVENTS} --mft-reco-full --mft-assessment-full --fwdmatching-assessment-full --fwdmatching-save-trainingdata # run workflow ${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json From 837f5c4749badc261bcfe2ab42e2f22f9d7d8b23 Mon Sep 17 00:00:00 2001 From: rsadek Date: Sun, 13 Feb 2022 16:34:50 +0100 Subject: [PATCH 2/3] structure fix --- MC/bin/o2dpg_sim_workflow.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index e5ec5b4e1..a2b74a0e7 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -707,18 +707,16 @@ def createRestDigiTask(name, det='ALLSMALLER'): workflow['stages'].append(MCHMIDMATCHtask) MFTMCHMATCHtask = createTask(name='mftmchMatch_'+str(tf), needs=[MCHMIDMATCHtask['name'], MFTRECOtask['name']], tf=tf, cwd=timeframeworkdir, lab=["RECO"], mem='1500') - MFTMCHMATCHtask['cmd'] = '${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) + + if args.fwdmatching_save_trainingdata == True: + MFTMCHMATCHtask['cmd'] ='${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.saveMode" : 2, "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) + else: + MFTMCHMATCHtask['cmd'] = '${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) if args.fwdmatching_assessment_full == True: MFTMCHMATCHtask['cmd']+= ' | o2-globalfwd-assessment-workflow ' MFTMCHMATCHtask['cmd']+= getDPL_global_options() workflow['stages'].append(MFTMCHMATCHtask) - if args.fwdmatching_save_trainingdata == True: - MFTMCHMATCHTraintask = createTask(name='mftmchMatchTrain_'+str(tf), needs=[MCHMIDMATCHtask['name'], MFTRECOtask['name']], tf=tf, cwd=timeframeworkdir, lab=["RECO"], mem='1500') - MFTMCHMATCHTraintask['cmd'] = '${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.saveMode" : 2, "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) - MFTMCHMATCHTraintask['cmd']+= getDPL_global_options() - workflow['stages'].append(MFTMCHMATCHTraintask) - ## Vertexing PVConfig = {**AlpideConfig} # start with Alpide config which is relevant here if COLTYPEIR == 'pp': @@ -846,7 +844,7 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''): aodneeds += [ BKG_KINEDOWNLOADER_TASK['name'] ] if args.fwdmatching_save_trainingdata == True: # Hack - aodneeds += [ MFTMCHMATCHTraintask['name'] ] + aodneeds += [ MFTMCHMATCHtask['name'] ] aod_df_id = '{0:03}'.format(tf) AODtask = createTask(name='aod_'+str(tf), needs=aodneeds, tf=tf, cwd=timeframeworkdir, lab=["AOD"], mem='4000', cpu='1') From a057a7a67865b989d35f1788c33869bd99e2ce7c Mon Sep 17 00:00:00 2001 From: Rafael Pezzi Date: Mon, 14 Feb 2022 12:00:12 +0100 Subject: [PATCH 3/3] Revert last commit + remove ugly hack (squash this) --- MC/bin/o2dpg_sim_workflow.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index a2b74a0e7..7827c43eb 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -707,16 +707,18 @@ def createRestDigiTask(name, det='ALLSMALLER'): workflow['stages'].append(MCHMIDMATCHtask) MFTMCHMATCHtask = createTask(name='mftmchMatch_'+str(tf), needs=[MCHMIDMATCHtask['name'], MFTRECOtask['name']], tf=tf, cwd=timeframeworkdir, lab=["RECO"], mem='1500') - - if args.fwdmatching_save_trainingdata == True: - MFTMCHMATCHtask['cmd'] ='${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.saveMode" : 2, "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) - else: - MFTMCHMATCHtask['cmd'] = '${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) + MFTMCHMATCHtask['cmd'] = '${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) if args.fwdmatching_assessment_full == True: MFTMCHMATCHtask['cmd']+= ' | o2-globalfwd-assessment-workflow ' MFTMCHMATCHtask['cmd']+= getDPL_global_options() workflow['stages'].append(MFTMCHMATCHtask) + if args.fwdmatching_save_trainingdata == True: + MFTMCHMATCHTraintask = createTask(name='mftmchMatchTrain_'+str(tf), needs=[MCHMIDMATCHtask['name'], MFTRECOtask['name']], tf=tf, cwd=timeframeworkdir, lab=["RECO"], mem='1500') + MFTMCHMATCHTraintask['cmd'] = '${O2_ROOT}/bin/o2-globalfwd-matcher-workflow ' + putConfigValues({**{"MFTClustererParam.dictFilePath" : "../", "FwdMatching.saveMode" : 2, "FwdMatching.useMIDMatch":"true"} , **AlpideConfig}) + MFTMCHMATCHTraintask['cmd']+= getDPL_global_options() + workflow['stages'].append(MFTMCHMATCHTraintask) + ## Vertexing PVConfig = {**AlpideConfig} # start with Alpide config which is relevant here if COLTYPEIR == 'pp': @@ -843,8 +845,6 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''): if usebkgcache: aodneeds += [ BKG_KINEDOWNLOADER_TASK['name'] ] - if args.fwdmatching_save_trainingdata == True: # Hack - aodneeds += [ MFTMCHMATCHtask['name'] ] aod_df_id = '{0:03}'.format(tf) AODtask = createTask(name='aod_'+str(tf), needs=aodneeds, tf=tf, cwd=timeframeworkdir, lab=["AOD"], mem='4000', cpu='1')