From 751ac1098a9148f24c99676a390102c4f0e40b38 Mon Sep 17 00:00:00 2001 From: Andreas Loeschcke Centeno Date: Thu, 18 Sep 2025 11:48:39 +0200 Subject: [PATCH] Added noise digitizer solution and updated test --- .../options/runRandomNoiseDigitizer.py | 4 +- .../runRandomNoiseDigitizerSolution.py | 58 +++++++++++++++++++ test/CMakeLists.txt | 2 +- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizerSolution.py diff --git a/GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizer.py b/GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizer.py index bc09985..bbef440 100644 --- a/GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizer.py +++ b/GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizer.py @@ -39,8 +39,8 @@ OutputLevel=INFO ) -from Configurables import RandomNoiseDigitizerSolution -random_noise_digitizer = RandomNoiseDigitizerSolution("RandomNoiseDigitizer", +from Configurables import RandomNoiseDigitizer +random_noise_digitizer = RandomNoiseDigitizer("RandomNoiseDigitizer", InputCaloSimHitCollection=["simplecaloRO"], OutputCaloDigiHitCollection=["CaloDigiHits"], uidSvcName="uidSvc", diff --git a/GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizerSolution.py b/GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizerSolution.py new file mode 100644 index 0000000..bc09985 --- /dev/null +++ b/GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizerSolution.py @@ -0,0 +1,58 @@ +# +# Copyright (c) 2020-2024 Key4hep-Project. +# +# This file is part of Key4hep. +# See https://key4hep.github.io/key4hep-doc/ for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from Gaudi.Configuration import INFO +from k4FWCore import IOSvc, ApplicationMgr +from Configurables import EventDataSvc, UniqueIDGenSvc, ChronoAuditor, AuditorSvc + +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] + +io_svc = IOSvc("IOSvc") +io_svc.Input = "../../data/simpleCalo_simulation.root" +io_svc.Output = "../../data/simpleCalo_noiseDigitizer.root" + +from Configurables import EventStats + +eventStats_functional = EventStats("EventStats", + + InputCaloHitCollection=["simplecaloRO"], + OutputEnergyBarycentre=["EnergyBarycentreX", "EnergyBarycentreY", "EnergyBarycentreZ"], + OutputTotalEnergy=["TotalEnergy"], + SaveHistograms=True, + OutputLevel=INFO +) + +from Configurables import RandomNoiseDigitizerSolution +random_noise_digitizer = RandomNoiseDigitizerSolution("RandomNoiseDigitizer", + InputCaloSimHitCollection=["simplecaloRO"], + OutputCaloDigiHitCollection=["CaloDigiHits"], + uidSvcName="uidSvc", + NoiseMean=1e-3, + NoiseWidth=1e-4, + OutputLevel=INFO + ) + +app_mgr = ApplicationMgr( + TopAlg=[eventStats_functional, random_noise_digitizer], + EvtSel='NONE', + EvtMax=-1, + ExtSvc=[EventDataSvc("EventDataSvc"), UniqueIDGenSvc("uidSvc"), audsvc], + StopOnSignal=True, +) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 67482b0..37b910f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -48,7 +48,7 @@ set_test_env(test_MoliereRadius) add_test(NAME test_RandomNoiseDigitizer WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND k4run GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizer.py --IOSvc.Input ${PROJECT_SOURCE_DIR}/GaudiTutorial/data/simpleCalo_simulation.root --IOSvc.Output ${PROJECT_SOURCE_DIR}/GaudiTutorial/data/simpleCalo_noiseDigitizer.root) + COMMAND k4run GaudiTutorial/RandomNoiseDigitizer/options/runRandomNoiseDigitizerSolution.py --IOSvc.Input ${PROJECT_SOURCE_DIR}/GaudiTutorial/data/simpleCalo_simulation.root --IOSvc.Output ${PROJECT_SOURCE_DIR}/GaudiTutorial/data/simpleCalo_noiseDigitizer.root) set_test_env(test_MoliereRadius) # For LD_LIBRARY_PATH