From 22db118d04b57e4bd257a8c554d66115a8cbf8bb Mon Sep 17 00:00:00 2001 From: Andreas Loeschcke Centeno Date: Wed, 17 Sep 2025 23:44:05 +0200 Subject: [PATCH] Made steering file part of hands-on 2.2 --- .../options/runMoliereRadius.py | 12 +--- .../options/runMoliereRadiusSolution.py | 63 +++++++++++++++++++ test/CMakeLists.txt | 2 +- 3 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadiusSolution.py diff --git a/GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadius.py b/GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadius.py index f4b6586..12935f8 100644 --- a/GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadius.py +++ b/GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadius.py @@ -38,8 +38,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", @@ -48,14 +48,8 @@ OutputLevel=INFO ) -from Configurables import MoliereRadiusSolution -moliere_radius = MoliereRadiusSolution ("MoliereRadius", - InputCaloHitCollection=random_noise_digitizer.OutputCaloDigiHitCollection, - InputBarycenter=eventStats_functional.OutputEnergyBarycentre, - InputTotalEnergy=eventStats_functional.OutputTotalEnergy) - app_mgr = ApplicationMgr( - TopAlg=[eventStats_functional, random_noise_digitizer, moliere_radius], + TopAlg=[eventStats_functional, random_noise_digitizer], EvtSel='NONE', EvtMax=-1, ExtSvc=[EventDataSvc("EventDataSvc"), UniqueIDGenSvc("uidSvc"), audsvc], diff --git a/GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadiusSolution.py b/GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadiusSolution.py new file mode 100644 index 0000000..f4b6586 --- /dev/null +++ b/GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadiusSolution.py @@ -0,0 +1,63 @@ +# +# 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_eventStats.root" +io_svc.Output = "../../data/simpleCalo_moliereRadius.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-6, + NoiseWidth=1e-7, + OutputLevel=INFO + ) + +from Configurables import MoliereRadiusSolution +moliere_radius = MoliereRadiusSolution ("MoliereRadius", + InputCaloHitCollection=random_noise_digitizer.OutputCaloDigiHitCollection, + InputBarycenter=eventStats_functional.OutputEnergyBarycentre, + InputTotalEnergy=eventStats_functional.OutputTotalEnergy) + +app_mgr = ApplicationMgr( + TopAlg=[eventStats_functional, random_noise_digitizer, moliere_radius], + EvtSel='NONE', + EvtMax=-1, + ExtSvc=[EventDataSvc("EventDataSvc"), UniqueIDGenSvc("uidSvc"), audsvc], + StopOnSignal=True, +) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1fc60ed..67482b0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -43,7 +43,7 @@ set_test_env(test_EventStats) add_test(NAME test_MoliereRadius WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND k4run GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadius.py --IOSvc.Input ${PROJECT_SOURCE_DIR}/GaudiTutorial/data/simpleCalo_simulation.root --IOSvc.Output ${PROJECT_SOURCE_DIR}/GaudiTutorial/data/simpleCalo_moliereRadius.root) + COMMAND k4run GaudiTutorial/MoliereRadiusFunctional/options/runMoliereRadiusSolution.py --IOSvc.Input ${PROJECT_SOURCE_DIR}/GaudiTutorial/data/simpleCalo_simulation.root --IOSvc.Output ${PROJECT_SOURCE_DIR}/GaudiTutorial/data/simpleCalo_moliereRadius.root) set_test_env(test_MoliereRadius) add_test(NAME test_RandomNoiseDigitizer