From 846e3757627416b9e90772ffa45201dbd5aea2b4 Mon Sep 17 00:00:00 2001 From: Maria Zurek <zurek@anl.gov> Date: Sun, 8 Aug 2021 19:08:07 +0000 Subject: [PATCH] Resolve "Add energy scan benchmark for energy resolution" --- .gitlab-ci.yml | 1 + benchmarks/clustering/options/full_cal_reco.py | 13 +++++++++++-- benchmarks/ecal/options/barrel.py | 8 +++++++- benchmarks/full/options/full_reconstruction.py | 15 ++++++++++++--- benchmarks/imaging_ecal/options/hybrid_cluster.py | 15 ++++++++++----- .../imaging_ecal/options/imaging_2dcluster.py | 11 +++++++---- .../imaging_ecal/options/imaging_topocluster.py | 12 ++++++++---- benchmarks/imaging_ecal/options/scfi_cluster.py | 9 +++++++-- 8 files changed, 63 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe8bc91e..25014331 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,6 +58,7 @@ common:detector: - ln -s "${LOCAL_DATA_PATH}/sim_output" sim_output - ln -s "${LOCAL_DATA_PATH}/datasets/data" data - ls -lrtha + - curl -sL https://eicweb.phy.anl.gov/EIC/benchmarks/detector_benchmarks/-/jobs/artifacts/master/raw/results/emcal_barrel_calibration.json?job=collect_results:barrel_ecal --output config/emcal_barrel_calibration.json interruptible: true include: diff --git a/benchmarks/clustering/options/full_cal_reco.py b/benchmarks/clustering/options/full_cal_reco.py index 3f23faa1..4d3f9d67 100644 --- a/benchmarks/clustering/options/full_cal_reco.py +++ b/benchmarks/clustering/options/full_cal_reco.py @@ -2,6 +2,7 @@ An example option file to digitize/reconstruct/clustering calorimeter hits ''' from Gaudi.Configuration import * +import json import os import ROOT @@ -12,13 +13,21 @@ detector_name = str(os.environ.get("JUGGLER_DETECTOR", "athena")) detector_path = str(os.environ.get("DETECTOR_PATH", ".")) compact_path = os.path.join(detector_path, detector_name) +# input arguments from calibration file +with open('config/emcal_barrel_calibration.json') as f: + calib_data = json.load(f)['electron'] + +print(calib_data) + +cb_ecal_sf = float(calib_data['sampling_fraction_img']) +scifi_barrel_sf = float(calib_data['sampling_fraction_scfi']) + # get sampling fractions from system environment variable, 1.0 by default ci_ecal_sf = float(os.environ.get("CI_ECAL_SAMP_FRAC", 0.253)) -cb_ecal_sf = float(os.environ.get("CB_ECAL_SAMP_FRAC", 0.01324)) cb_hcal_sf = float(os.environ.get("CB_HCAL_SAMP_FRAC", 0.038)) ci_hcal_sf = float(os.environ.get("CI_HCAL_SAMP_FRAC", 0.025)) ce_hcal_sf = float(os.environ.get("CE_HCAL_SAMP_FRAC", 0.025)) -scifi_barrel_sf = float(os.environ.get("CB_EMCAL_SCFI_SAMP_FRAC",0.0938)) + # input and output input_sims = [f.strip() for f in str.split(os.environ["JUGGLER_SIM_FILE"], ",") if f.strip()] output_rec = str(os.environ["JUGGLER_REC_FILE"]) diff --git a/benchmarks/ecal/options/barrel.py b/benchmarks/ecal/options/barrel.py index 870f6bf0..a7d22cda 100644 --- a/benchmarks/ecal/options/barrel.py +++ b/benchmarks/ecal/options/barrel.py @@ -2,6 +2,7 @@ An example script to digitize/reconstruct/clustering endcap ecal hits ''' from Gaudi.Configuration import * +import json import os import ROOT @@ -16,7 +17,12 @@ compact_path = str(os.environ.get("JUGGLER_COMPACT_PATH", "{}.xml".format(os.pat input_sims = [f.strip() for f in str.split(os.environ["JUGGLER_SIM_FILE"], ",") if f.strip()] output_rec = str(os.environ["JUGGLER_REC_FILE"]) n_events = int(os.environ["JUGGLER_N_EVENTS"]) -cb_ecal_sf = float(os.environ.get("CB_ECAL_SAMP_FRAC", 0.01324)) + +# input arguments from calibration file +with open('config/emcal_barrel_calibration.json') as f: + calib_data = json.load(f)['electron'] + +cb_ecal_sf = float(calib_data['sampling_fraction_img']) # geometry service geo_service = GeoSvc("GeoSvc", detectors=[compact_path], OutputLevel=INFO) diff --git a/benchmarks/full/options/full_reconstruction.py b/benchmarks/full/options/full_reconstruction.py index 7ff92cfd..7f0c9708 100644 --- a/benchmarks/full/options/full_reconstruction.py +++ b/benchmarks/full/options/full_reconstruction.py @@ -4,6 +4,8 @@ from Configurables import ApplicationMgr, EICDataSvc, PodioOutput, GeoSvc from GaudiKernel import SystemOfUnits as units from GaudiKernel.SystemOfUnits import MeV, GeV, mm, cm, mrad +import json + detector_name = "athena" if "JUGGLER_DETECTOR" in os.environ : detector_name = str(os.environ["JUGGLER_DETECTOR"]) @@ -18,13 +20,20 @@ compact_path = os.path.join(detector_path, detector_name) qe_data = [(1.0, 0.25), (7.5, 0.25),] # CAL reconstruction -# get sampling fractions from system environment variable, 1.0 by default +# get sampling fractions from system environment variable ci_ecal_sf = float(os.environ.get("CI_ECAL_SAMP_FRAC", 0.253)) -cb_ecal_sf = float(os.environ.get("CB_ECAL_SAMP_FRAC", 0.01324)) cb_hcal_sf = float(os.environ.get("CB_HCAL_SAMP_FRAC", 0.038)) ci_hcal_sf = float(os.environ.get("CI_HCAL_SAMP_FRAC", 0.025)) ce_hcal_sf = float(os.environ.get("CE_HCAL_SAMP_FRAC", 0.025)) -scifi_barrel_sf = float(os.environ.get("CB_EMCAL_SCFI_SAMP_FRAC",0.0938)) + +# input arguments from calibration file +with open('config/emcal_barrel_calibration.json') as f: + calib_data = json.load(f)['electron'] + +print(calib_data) + +cb_ecal_sf = float(calib_data['sampling_fraction_img']) +scifi_barrel_sf = float(calib_data['sampling_fraction_scfi']) # input and output input_sims = [f.strip() for f in str.split(os.environ["JUGGLER_SIM_FILE"], ",") if f.strip()] diff --git a/benchmarks/imaging_ecal/options/hybrid_cluster.py b/benchmarks/imaging_ecal/options/hybrid_cluster.py index 5b2e1ead..4f91158d 100644 --- a/benchmarks/imaging_ecal/options/hybrid_cluster.py +++ b/benchmarks/imaging_ecal/options/hybrid_cluster.py @@ -1,8 +1,8 @@ +import json import os import ROOT from Gaudi.Configuration import * from GaudiKernel.SystemOfUnits import MeV, mm, cm, mrad, rad, ns - from Configurables import ApplicationMgr, EICDataSvc, PodioOutput, GeoSvc from Configurables import PodioInput @@ -16,12 +16,17 @@ from Configurables import Jug__Reco__ImagingPixelReco as ImagingPixelReco from Configurables import Jug__Reco__ImagingTopoCluster as ImagingTopoCluster from Configurables import Jug__Reco__ImagingClusterReco as ImagingClusterReco +# input arguments from calibration file +with open('config/emcal_barrel_calibration.json') as f: + calib_data = json.load(f)['electron'] + +print(calib_data) -# input arguments through environment variables kwargs = dict() -kwargs['img_sf'] = float(os.environ.get('CB_EMCAL_IMG_SF', '0.01324')) -kwargs['scfi_sf'] = float(os.environ.get('CB_EMCAL_SCFI_SF', '0.0938')) -# raise error if not defined +kwargs['img_sf'] = float(calib_data['sampling_fraction_img']) +kwargs['scfi_sf'] = float(calib_data['sampling_fraction_scfi']) + +# input arguments through environment variables kwargs['input'] = os.environ['CB_EMCAL_SIM_FILE'] kwargs['output'] = os.environ['CB_EMCAL_REC_FILE'] kwargs['compact'] = os.environ['CB_EMCAL_COMPACT_PATH'] diff --git a/benchmarks/imaging_ecal/options/imaging_2dcluster.py b/benchmarks/imaging_ecal/options/imaging_2dcluster.py index 9baee078..45669e17 100644 --- a/benchmarks/imaging_ecal/options/imaging_2dcluster.py +++ b/benchmarks/imaging_ecal/options/imaging_2dcluster.py @@ -1,3 +1,4 @@ +import json import os import ROOT from Gaudi.Configuration import * @@ -11,10 +12,14 @@ from Configurables import Jug__Reco__CalorimeterHitsEtaPhiProjector as CalHitsPr from Configurables import Jug__Reco__CalorimeterIslandCluster as IslandCluster from Configurables import Jug__Reco__ClusterRecoCoG as RecoCoG +# input arguments from calibration file +with open('config/emcal_barrel_calibration.json') as f: + calib_data = json.load(f)['electron'] -# input arguments through environment variables kwargs = dict() -kwargs['sf'] = float(os.environ.get('CB_EMCAL_SCFI, SAMP_FRAC', '0.0134')) +kwargs['sf'] = float(calib_data['sampling_fraction_scfi']) + +# input arguments through environment variables kwargs['input'] = os.environ.get('CB_EMCAL_SIM_FILE', '../topside/barrel_pion0_5GeV.root') kwargs['output'] = os.environ.get('CB_EMCAL_REC_FILE', 'barrel_pion0_5GeV_cluster.root') kwargs['compact'] = os.environ.get('CB_EMCAL_COMPACT_PATH', '../topside/test.xml') @@ -26,8 +31,6 @@ if kwargs['nev'] < 1: print(kwargs) -# get sampling fraction from system environment variable, 1.0 by default -sf = float(os.environ.get('CB_EMCAL_SAMP_FRAC', '1.0')) geo_service = GeoSvc('GeoSvc', detectors=kwargs['compact'].split(','), OutputLevel=INFO) podioevent = EICDataSvc('EventDataSvc', inputs=kwargs['input'].split(','), OutputLevel=DEBUG) diff --git a/benchmarks/imaging_ecal/options/imaging_topocluster.py b/benchmarks/imaging_ecal/options/imaging_topocluster.py index 9c715fcc..94901baa 100644 --- a/benchmarks/imaging_ecal/options/imaging_topocluster.py +++ b/benchmarks/imaging_ecal/options/imaging_topocluster.py @@ -1,3 +1,4 @@ +import json import os import ROOT from Gaudi.Configuration import * @@ -14,9 +15,14 @@ from Configurables import Jug__Reco__ImagingTopoCluster as ImagingTopoCluster from Configurables import Jug__Reco__ImagingClusterReco as ImagingClusterReco -# input arguments through environment variables +# input arguments from calibration file +with open('config/emcal_barrel_calibration.json') as f: + calib_data = json.load(f)['electron'] + kwargs = dict() -kwargs['sf'] = float(os.environ.get('CB_EMCAL_SAMP_FRAC', '1.0')) +kwargs['sf'] = float(calib_data['sampling_fraction_img']) + +# input arguments through environment variables kwargs['input'] = os.environ.get('CB_EMCAL_SIM_FILE', '../topside/barrel_pion0_5GeV.root') kwargs['output'] = os.environ.get('CB_EMCAL_REC_FILE', 'barrel_pion0_5GeV_cluster.root') kwargs['compact'] = os.environ.get('CB_EMCAL_COMPACT_PATH', '../topside/test.xml') @@ -28,8 +34,6 @@ if kwargs['nev'] < 1: print(kwargs) -# get sampling fraction from system environment variable, 1.0 by default -sf = float(os.environ.get('CB_EMCAL_SAMP_FRAC', '1.0')) geo_service = GeoSvc("GeoSvc", detectors=kwargs['compact'].split(','), OutputLevel=INFO) podioevent = EICDataSvc("EventDataSvc", inputs=kwargs['input'].split(','), OutputLevel=DEBUG) out = PodioOutput("out", filename=kwargs['output']) diff --git a/benchmarks/imaging_ecal/options/scfi_cluster.py b/benchmarks/imaging_ecal/options/scfi_cluster.py index 3926326b..1c0def2b 100644 --- a/benchmarks/imaging_ecal/options/scfi_cluster.py +++ b/benchmarks/imaging_ecal/options/scfi_cluster.py @@ -1,3 +1,4 @@ +import json import os import ROOT from Gaudi.Configuration import * @@ -11,10 +12,14 @@ from Configurables import Jug__Reco__CalorimeterHitsMerger as CalHitsMerger from Configurables import Jug__Reco__CalorimeterIslandCluster as IslandCluster from Configurables import Jug__Reco__ClusterRecoCoG as RecoCoG +# input arguments from calibration file +with open('config/emcal_barrel_calibration.json') as f: + calib_data = json.load(f)['electron'] -# input arguments through environment variables kwargs = dict() -kwargs['sf'] = float(os.environ.get('CB_EMCAL_SCFI, SAMP_FRAC', '0.0938')) +kwargs['sf'] = float(calib_data['sampling_fraction_scfi']) + +# input arguments through environment variables kwargs['input'] = os.environ.get('CB_EMCAL_SIM_FILE', '../topside/barrel_pion0_5GeV.root') kwargs['output'] = os.environ.get('CB_EMCAL_REC_FILE', 'barrel_pion0_5GeV_cluster.root') kwargs['compact'] = os.environ.get('CB_EMCAL_COMPACT_PATH', '../topside/test.xml') -- GitLab