From 2d5ab00b021ea28823dda6b44b5bcf126103e2c5 Mon Sep 17 00:00:00 2001 From: Joshua Falco Beirer <joshua.falco.beirer@cern.ch> Date: Thu, 8 Feb 2024 11:54:14 +0100 Subject: [PATCH] Switch to CA-config for FastCaloSim in Geant4 Switch to CA-config for FastCaloSim in Geant4 --- .../python/BeamEffectsAlgConfig.py | 6 +- .../G4AtlasAlg/python/G4AtlasAlgConfig.py | 12 ++- .../G4AtlasTools/python/G4AtlasToolsConfig.py | 42 ++++++++-- .../python/G4GeometryToolConfig.py | 6 +- .../python/G4PhysicsRegionConfig.py | 9 ++- .../python/G4FastSimulationConfig.py | 17 +++- .../python/CollectionMergerConfig.py | 3 +- .../ISF_FastCaloSimParametrizationConfig.py | 11 +++ .../python/CommonSimulationSteering.py | 8 ++ .../python/G4AtlasAlg_Skeleton.py | 2 +- .../python/SimulationHelpers.py | 13 ++- .../SimuJobTransforms/python/__init__.py | 5 +- .../SimulationConfig/python/SimConfigFlags.py | 6 +- .../test/test_AtlasG4_FastCaloSim_MT.sh | 54 +++++++++++-- .../test/test_AtlasG4_FastCaloSim_MTvsST.sh | 81 +++++++++++-------- .../python/TileSamplingFractionConfig.py | 3 +- 16 files changed, 216 insertions(+), 62 deletions(-) diff --git a/Simulation/BeamEffects/python/BeamEffectsAlgConfig.py b/Simulation/BeamEffects/python/BeamEffectsAlgConfig.py index 7875e91fdcf..422ddeda6da 100755 --- a/Simulation/BeamEffects/python/BeamEffectsAlgConfig.py +++ b/Simulation/BeamEffects/python/BeamEffectsAlgConfig.py @@ -102,7 +102,11 @@ def BeamEffectsAlgCfg(flags, name="BeamEffectsAlg", **kwargs): """Return an accumulator and algorithm for beam effects, wihout output""" acc = ComponentAccumulator() - kwargs.setdefault("ISFRun", flags.Sim.ISFRun) + from SimulationConfig.SimEnums import LArParameterization + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + kwargs.setdefault("ISFRun", True) + else: + kwargs.setdefault("ISFRun", flags.Sim.ISFRun) # Set default properties if flags.Sim.DoFullChain and flags.Digitization.PileUp: diff --git a/Simulation/G4Atlas/G4AtlasAlg/python/G4AtlasAlgConfig.py b/Simulation/G4Atlas/G4AtlasAlg/python/G4AtlasAlgConfig.py index a2e02fc7fdc..a8724f74482 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/python/G4AtlasAlgConfig.py +++ b/Simulation/G4Atlas/G4AtlasAlg/python/G4AtlasAlgConfig.py @@ -13,6 +13,11 @@ def G4AtlasAlgCfg(flags, name="G4AtlasAlg", **kwargs): """Return ComponentAccumulator configured for Atlas G4 simulation, without output""" # wihout output result = ComponentAccumulator() + from SimulationConfig.SimEnums import LArParameterization + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + # Add a dummy version of the SimKernel to the CA before adding the properly configured version + # Presently necessary for FastCaloSim to ensure the proper order of ISF_CollectionMerger + result.addEventAlgo(CompFactory.G4AtlasAlg(name, **kwargs)) kwargs.setdefault("UseShadowEvent", flags.Sim.UseShadowEvent) if flags.Sim.UseShadowEvent and "TruthPreselectionTool" not in kwargs: from ISF_HepMC_Tools.ISF_HepMC_ToolsConfig import TruthPreselectionToolCfg @@ -26,8 +31,13 @@ def G4AtlasAlgCfg(flags, name="G4AtlasAlg", **kwargs): ## Don"t drop the GeoModel kwargs.setdefault("ReleaseGeoModel", flags.Sim.ReleaseGeoModel) + from SimulationConfig.SimEnums import LArParameterization + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + kwargs.setdefault("ExtraInputs", + {('CaloDetDescrManager', 'ConditionStore+CaloDetDescrManager'), + ('LArfSamplSym', 'ConditionStore+LArfSamplSym'), + ('TileSamplingFraction', 'ConditionStore+TileSamplingFraction')}) kwargs.setdefault("ExtraOutputs", SimHitContainerListCfg(flags)) - ## Record the particle flux during the simulation kwargs.setdefault("RecordFlux", flags.Sim.RecordFlux) diff --git a/Simulation/G4Atlas/G4AtlasTools/python/G4AtlasToolsConfig.py b/Simulation/G4Atlas/G4AtlasTools/python/G4AtlasToolsConfig.py index 3995663f14d..216974b34c4 100644 --- a/Simulation/G4Atlas/G4AtlasTools/python/G4AtlasToolsConfig.py +++ b/Simulation/G4Atlas/G4AtlasTools/python/G4AtlasToolsConfig.py @@ -10,6 +10,10 @@ from AthenaConfiguration.AccumulatorCache import AccumulatorCache def FastSimulationToolListCfg(flags): result = ComponentAccumulator() tools = [] + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + from G4FastSimulation.G4FastSimulationConfig import FastCaloSimCfg + tools += [ result.popToolsAndMerge(FastCaloSimCfg(flags)) ] + if flags.Detector.GeometryBpipe: if not flags.Detector.GeometryFwdRegion and (flags.Detector.GeometryAFP or flags.Detector.GeometryALFA or flags.Detector.GeometryZDC): # equivalent of simFlags.ForwardDetectors() == 2: @@ -31,9 +35,13 @@ def FastSimulationToolListCfg(flags): tools += [ result.popToolsAndMerge(EMECFastShowerCfg(flags)) ] tools += [ result.popToolsAndMerge(FCALFastShowerCfg(flags)) ] tools += [ result.popToolsAndMerge(FCAL2FastShowerCfg(flags)) ] - if flags.Sim.LArParameterization in [LArParameterization.DeadMaterialFrozenShowers, LArParameterization.FrozenShowersFCalOnly]: + if flags.Sim.LArParameterization in [LArParameterization.DeadMaterialFrozenShowers, LArParameterization.FrozenShowersFCalOnly, LArParameterization.FastCaloSim]: # TODO Check this makes sense. from G4FastSimulation.G4FastSimulationConfig import DeadMaterialShowerCfg tools += [ result.popToolsAndMerge(DeadMaterialShowerCfg(flags)) ] + # Enable fast simulation of the calorimeter with FastCaloSim + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + from G4FastSimulation.G4FastSimulationConfig import FastCaloSimCfg + tools += [ result.popToolsAndMerge(FastCaloSimCfg(flags)) ] if flags.Detector.GeometryMuon: if flags.Sim.CavernBackground not in [CavernBackground.Off, CavernBackground.Read] and not flags.Sim.RecordFlux: from TrackWriteFastSim.TrackWriteFastSimConfig import NeutronFastSimCfg @@ -95,6 +103,14 @@ def TrackFastSimSensitiveDetectorListCfg(flags): result.setPrivateTools(tools) return result +def CaloCellContainerSensitiveDetectorListCfg(flags): + result = ComponentAccumulator() + tools = [] + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + from ISF_FastCaloSimParametrization.ISF_FastCaloSimParametrizationConfig import CaloCellContainerSDCfg + tools += [ result.popToolsAndMerge(CaloCellContainerSDCfg(flags)) ] + result.setPrivateTools(tools) + return result def ITkSensitiveDetectorListCfg(flags): result = ComponentAccumulator() @@ -208,6 +224,7 @@ def EnvelopeSensitiveDetectorListCfg(flags): def SimHitContainerListCfg(flags): + from SimulationConfig.SimEnums import LArParameterization writtenContainers =[] if flags.Detector.GeometryMuon: if flags.Muon.setupGeoModelXML: @@ -217,13 +234,23 @@ def SimHitContainerListCfg(flags): from MuonG4SD.MuonG4SDConfig import SimHitContainerListCfg writtenContainers += SimHitContainerListCfg(flags) if flags.Detector.GeometryLAr: - writtenContainers += [("LArHitContainer", "LArHitEMB")] - writtenContainers += [("LArHitContainer", "LArHitEMEC")] - writtenContainers += [("LArHitContainer", "LArHitFCAL")] - writtenContainers += [("LArHitContainer", "LArHitHEC")] + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + writtenContainers += [("LArHitContainer", "LArHitEMB_G4")] + writtenContainers += [("LArHitContainer", "LArHitEMEC_G4")] + writtenContainers += [("LArHitContainer", "LArHitFCAL_G4")] + writtenContainers += [("LArHitContainer", "LArHitHEC_G4")] + else: + writtenContainers += [("LArHitContainer", "LArHitEMB")] + writtenContainers += [("LArHitContainer", "LArHitEMEC")] + writtenContainers += [("LArHitContainer", "LArHitFCAL")] + writtenContainers += [("LArHitContainer", "LArHitHEC")] if flags.Detector.GeometryTile: - writtenContainers += [("TileHitVector", "MBTSHits")] - writtenContainers += [("TileHitVector", "TileHitVec")] + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + writtenContainers += [("TileHitVector", "MBTSHits_G4")] + writtenContainers += [("TileHitVector", "TileHitVec_G4")] + else: + writtenContainers += [("TileHitVector", "MBTSHits")] + writtenContainers += [("TileHitVector", "TileHitVec")] if flags.Detector.GeometryTRT: writtenContainers += [("TRTUncompressedHitCollection", "TRTUncompressedHits")] if flags.Detector.EnableBCM: @@ -256,6 +283,7 @@ def SensitiveDetectorListCfg(flags): tools += result.popToolsAndMerge(MuonSensitiveDetectorListCfg(flags)) tools += result.popToolsAndMerge(TrackFastSimSensitiveDetectorListCfg(flags)) tools += result.popToolsAndMerge(FwdSensitiveDetectorListCfg(flags)) + tools += result.popToolsAndMerge(CaloCellContainerSensitiveDetectorListCfg(flags)) result.setPrivateTools(tools) return result diff --git a/Simulation/G4Atlas/G4AtlasTools/python/G4GeometryToolConfig.py b/Simulation/G4Atlas/G4AtlasTools/python/G4GeometryToolConfig.py index c092dccbb6b..6b3fc106fc7 100644 --- a/Simulation/G4Atlas/G4AtlasTools/python/G4GeometryToolConfig.py +++ b/Simulation/G4Atlas/G4AtlasTools/python/G4GeometryToolConfig.py @@ -9,7 +9,7 @@ from AthenaCommon import Logging from SimulationConfig.SimEnums import BeamPipeSimMode, CalibrationRun, CavernBackground, LArParameterization #the physics region tools -from G4AtlasTools.G4PhysicsRegionConfig import SX1PhysicsRegionToolCfg, BedrockPhysicsRegionToolCfg, CavernShaftsConcretePhysicsRegionToolCfg, PixelPhysicsRegionToolCfg, SCTPhysicsRegionToolCfg, TRTPhysicsRegionToolCfg, TRT_ArPhysicsRegionToolCfg,ITkPixelPhysicsRegionToolCfg,ITkStripPhysicsRegionToolCfg,HGTDPhysicsRegionToolCfg,BeampipeFwdCutPhysicsRegionToolCfg, FWDBeamLinePhysicsRegionToolCfg, EMBPhysicsRegionToolCfg, EMECPhysicsRegionToolCfg, HECPhysicsRegionToolCfg, FCALPhysicsRegionToolCfg, FCAL2ParaPhysicsRegionToolCfg, EMECParaPhysicsRegionToolCfg, FCALParaPhysicsRegionToolCfg, PreSampLArPhysicsRegionToolCfg, DeadMaterialPhysicsRegionToolCfg +from G4AtlasTools.G4PhysicsRegionConfig import SX1PhysicsRegionToolCfg, BedrockPhysicsRegionToolCfg, CavernShaftsConcretePhysicsRegionToolCfg, PixelPhysicsRegionToolCfg, SCTPhysicsRegionToolCfg, TRTPhysicsRegionToolCfg, TRT_ArPhysicsRegionToolCfg,ITkPixelPhysicsRegionToolCfg,ITkStripPhysicsRegionToolCfg,HGTDPhysicsRegionToolCfg,BeampipeFwdCutPhysicsRegionToolCfg, FWDBeamLinePhysicsRegionToolCfg, CALOPhysicsRegionToolCfg, EMBPhysicsRegionToolCfg, EMECPhysicsRegionToolCfg, HECPhysicsRegionToolCfg, FCALPhysicsRegionToolCfg, FCAL2ParaPhysicsRegionToolCfg, EMECParaPhysicsRegionToolCfg, FCALParaPhysicsRegionToolCfg, PreSampLArPhysicsRegionToolCfg, DeadMaterialPhysicsRegionToolCfg from G4AtlasTools.G4PhysicsRegionConfig import DriftWallPhysicsRegionToolCfg, DriftWall1PhysicsRegionToolCfg, DriftWall2PhysicsRegionToolCfg, MuonSystemFastPhysicsRegionToolCfg #the field config tools @@ -566,12 +566,14 @@ def ATLAS_RegionCreatorListCfg(flags): if flags.Sim.LArParameterization is not LArParameterization.NoFrozenShowers: regionCreatorList += [result.popToolsAndMerge(FCALParaPhysicsRegionToolCfg(flags)), result.popToolsAndMerge(FCAL2ParaPhysicsRegionToolCfg(flags))] - if flags.Sim.LArParameterization in [LArParameterization.DeadMaterialFrozenShowers, LArParameterization.FrozenShowersFCalOnly]: + if flags.Sim.LArParameterization in [LArParameterization.DeadMaterialFrozenShowers, LArParameterization.FrozenShowersFCalOnly, LArParameterization.FastCaloSim]: # TODO Check this makes sense pass #todo - add the line below regionCreatorList += [ result.popToolsAndMerge(PreSampLArPhysicsRegionToolCfg(flags)), result.popToolsAndMerge(DeadMaterialPhysicsRegionToolCfg(flags))] + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + regionCreatorList += [result.popToolsAndMerge(CALOPhysicsRegionToolCfg(flags))] ## FIXME _initPR never called for FwdRegion?? #if simFlags.ForwardDetectors.statusOn: # if DetFlags.geometry.FwdRegion_on(): diff --git a/Simulation/G4Atlas/G4AtlasTools/python/G4PhysicsRegionConfig.py b/Simulation/G4Atlas/G4AtlasTools/python/G4PhysicsRegionConfig.py index 8bf5d98d219..885facd1ebc 100644 --- a/Simulation/G4Atlas/G4AtlasTools/python/G4PhysicsRegionConfig.py +++ b/Simulation/G4Atlas/G4AtlasTools/python/G4PhysicsRegionConfig.py @@ -196,8 +196,15 @@ def TRT_KrPhysicsRegionToolCfg(flags, name='TRT_KrPhysicsRegionTool', **kwargs): result.setPrivateTools(RegionCreator(name, **kwargs)) return result +def CALOPhysicsRegionToolCfg(flags, name='CALOPhysicsRegionTool', **kwargs): + result = ComponentAccumulator() + kwargs.setdefault("RegionName", 'CALO') + volumeList = ['CALO::CALO', 'LArMgr::LAr::Endcap::Cryostat::Cylinder::Mixed','LArMgr::LAr::Barrel::Cryostat::MotherVolume','LArMgr::ModeratorTube'] + kwargs.setdefault("VolumeList", volumeList) + result.setPrivateTools(RegionCreator(name, **kwargs)) + return result + -# Calo Regions def EMBPhysicsRegionToolCfg(flags, name='EMBPhysicsRegionTool', **kwargs): result = ComponentAccumulator() kwargs.setdefault("RegionName", 'EMB') diff --git a/Simulation/G4Utilities/G4FastSimulation/python/G4FastSimulationConfig.py b/Simulation/G4Utilities/G4FastSimulation/python/G4FastSimulationConfig.py index 815867133d3..8816dd31100 100644 --- a/Simulation/G4Utilities/G4FastSimulation/python/G4FastSimulationConfig.py +++ b/Simulation/G4Utilities/G4FastSimulation/python/G4FastSimulationConfig.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory @@ -16,3 +16,18 @@ def DeadMaterialShowerCfg(flags, **kwargs): kwargs.setdefault("RegionNames", ["DeadMaterial"]) result.setPrivateTools(CompFactory.DeadMaterialShowerTool(name="DeadMaterialShower", **kwargs)) return result + + +def FastCaloSimCfg(flags, **kwargs): + result = ComponentAccumulator() + # Set the parametrization service + from ISF_FastCaloSimServices.ISF_FastCaloSimServicesConfig import FastCaloSimV2ParamSvcCfg + kwargs.setdefault("ISF_FastCaloSimV2ParamSvc", result.getPrimaryAndMerge(FastCaloSimV2ParamSvcCfg(flags)).name) + # Set the FastCaloSim extrapolation tool + from ISF_FastCaloSimParametrization.ISF_FastCaloSimParametrizationConfig import FastCaloSimCaloExtrapolationCfg + kwargs.setdefault("FastCaloSimCaloExtrapolation", result.addPublicTool(result.popToolsAndMerge(FastCaloSimCaloExtrapolationCfg(flags)))) + # Name of region where FastCaloSim will be triggered + kwargs.setdefault("RegionNames", ["CALO"]) + kwargs.setdefault('CaloCellContainerSDName', "ToolSvc.SensitiveDetectorMasterTool.CaloCellContainerSD") + result.setPrivateTools(CompFactory.FastCaloSimTool(name="FastCaloSim", **kwargs)) + return result diff --git a/Simulation/ISF/ISF_Core/ISF_Algorithms/python/CollectionMergerConfig.py b/Simulation/ISF/ISF_Core/ISF_Algorithms/python/CollectionMergerConfig.py index 2a7a13b6c4a..9c38eb460cd 100644 --- a/Simulation/ISF/ISF_Core/ISF_Algorithms/python/CollectionMergerConfig.py +++ b/Simulation/ISF/ISF_Core/ISF_Algorithms/python/CollectionMergerConfig.py @@ -105,7 +105,8 @@ def CollectionMergerCfg(flags, mergeable collection to.""" result = ComponentAccumulator() - if flags.Sim.ISFRun and flags.Sim.ISF.HITSMergingRequired.get(region, True): + from SimulationConfig.SimEnums import LArParameterization + if (flags.Sim.ISFRun or flags.Sim.LArParameterization is LArParameterization.FastCaloSim) and flags.Sim.ISF.HITSMergingRequired.get(region, True): mergeable_collection = f'{bare_collection_name}{mergeable_collection_suffix}' from ISF_Algorithms.CollectionMergerConfig import ISFCollectionMergerCfg diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/ISF_FastCaloSimParametrizationConfig.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/ISF_FastCaloSimParametrizationConfig.py index 98a12dc2bf7..43aedcd16b2 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/ISF_FastCaloSimParametrizationConfig.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/ISF_FastCaloSimParametrizationConfig.py @@ -75,6 +75,17 @@ def FastCaloSimGeometryHelperCfg(flags, name="FastCaloSimGeometryHelper", **kwar acc.setPrivateTools(CompFactory.FastCaloSimGeometryHelper(name, **kwargs)) return acc +def CaloCellContainerSDCfg(flags, name='CaloCellContainerSD', **kwargs): + acc = ComponentAccumulator() + kwargs.setdefault ('NoVolumes', True) + kwargs.setdefault("OutputCollectionNames", ["DefaultCaloCellContainer"]) + # Add ISF_FastHitConvertTool, which will also take care + # of creating mergable FastCaloSim HIT collections + from ISF_FastCaloSimServices.ISF_FastCaloSimServicesConfig import FastHitConvertToolCfg + kwargs.setdefault("FastHitConvertTool", acc.addPublicTool(acc.popToolsAndMerge(FastHitConvertToolCfg(flags)))) + acc.setPrivateTools(CompFactory.CaloCellContainerSDTool(name, **kwargs)) + return acc + def ISF_FastCaloSimParametrization_SimPreInclude(flags): flags.Sim.RecordStepInfo=True from SimulationConfig.SimEnums import VertexSource,LArParameterization,CalibrationRun diff --git a/Simulation/SimuJobTransforms/python/CommonSimulationSteering.py b/Simulation/SimuJobTransforms/python/CommonSimulationSteering.py index 1729a565f10..8ecbd9e54cc 100644 --- a/Simulation/SimuJobTransforms/python/CommonSimulationSteering.py +++ b/Simulation/SimuJobTransforms/python/CommonSimulationSteering.py @@ -119,6 +119,14 @@ def CommonSimulationCfg(flags, log): #add the G4AtlasAlg from G4AtlasAlg.G4AtlasAlgConfig import G4AtlasAlgCfg cfg.merge(G4AtlasAlgCfg(flags)) + from SimulationConfig.SimEnums import LArParameterization + if flags.Sim.LArParameterization is LArParameterization.FastCaloSim: + cfg.getEventAlgo("ISF_CollectionMerger").InputLArEMBHits.data.sort() # temporary workaround + cfg.getEventAlgo("ISF_CollectionMerger").InputLArEMECHits.data.sort() # temporary workaround + cfg.getEventAlgo("ISF_CollectionMerger").InputLArFCALHits.data.sort() # temporary workaround + cfg.getEventAlgo("ISF_CollectionMerger").InputLArHECHits.data.sort() # temporary workaround + cfg.getEventAlgo("ISF_CollectionMerger").InputTileHits.data.sort() # temporary workaround + cfg.getEventAlgo("ISF_CollectionMerger").InputMBTSHits.data.sort() # temporary workaround from SimulationConfig.SimEnums import CalibrationRun if flags.Sim.CalibrationRun in [CalibrationRun.LAr, CalibrationRun.LArTile, CalibrationRun.LArTileZDC]: diff --git a/Simulation/SimuJobTransforms/python/G4AtlasAlg_Skeleton.py b/Simulation/SimuJobTransforms/python/G4AtlasAlg_Skeleton.py index dfe92e7ab17..c95f941b6d7 100644 --- a/Simulation/SimuJobTransforms/python/G4AtlasAlg_Skeleton.py +++ b/Simulation/SimuJobTransforms/python/G4AtlasAlg_Skeleton.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration import sys from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags diff --git a/Simulation/SimuJobTransforms/python/SimulationHelpers.py b/Simulation/SimuJobTransforms/python/SimulationHelpers.py index e744b4a5f35..32646e60593 100644 --- a/Simulation/SimuJobTransforms/python/SimulationHelpers.py +++ b/Simulation/SimuJobTransforms/python/SimulationHelpers.py @@ -1,5 +1,5 @@ -# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration -from SimulationConfig.SimEnums import BeamPipeSimMode, CalibrationRun, CavernBackground, LArParameterization +# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration +from SimulationConfig.SimEnums import BeamPipeSimMode, CalibrationRun, CavernBackground, LArParameterization, SimulationFlavour def getDetectorsFromRunArgs(flags, runArgs): @@ -76,7 +76,6 @@ def enableCalHitsZDC(flags): flags.Sim.PRRThreshold = False flags.Sim.PRRWeight = False - def enableCalHitsAll(flags): """Turns on calibration hits for LAr, Tile and ZDC""" flags.Sim.CalibrationRun = CalibrationRun.LArTileZDC @@ -96,3 +95,11 @@ def enableParticleID(flags): def enableVerboseSelector(flags): """ """ flags.Sim.OptionalUserActionList += ['G4DebuggingTools.G4DebuggingToolsConfig.VerboseSelectorToolCfg'] + +def enableFastCaloSim(flags): + # Set LArParametrization to FastCaloSim + flags.Sim.LArParameterization = LArParameterization.FastCaloSim + # Deacticate dead material hits for calibration run + flags.Sim.CalibrationRun = CalibrationRun.Off + # Set simulator name as metadata + flags.Sim.ISF.Simulator = SimulationFlavour.ATLFAST3MT \ No newline at end of file diff --git a/Simulation/SimuJobTransforms/python/__init__.py b/Simulation/SimuJobTransforms/python/__init__.py index a52e158aa6f..231fd495ff9 100644 --- a/Simulation/SimuJobTransforms/python/__init__.py +++ b/Simulation/SimuJobTransforms/python/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration from .SimulationHelpers import enableFrozenShowersFCalOnly as FrozenShowersFCalOnly from .SimulationHelpers import enableBeamPipeKill as BeamPipeKill @@ -6,5 +6,6 @@ from .SimulationHelpers import enableTightMuonStepping as TightMuonStepping from .SimulationHelpers import enableG4SignalCavern as G4SignalCavern from .SimulationHelpers import enableCalHits as CalHits from .SimulationHelpers import enableParticleID as ParticleID +from .SimulationHelpers import enableFastCaloSim as FastCaloSim -__all__ = ['FrozenShowersFCalOnly', 'BeamPipeKill', 'TightMuonStepping', 'G4SignalCavern', 'CalHits', 'ParticleID'] +__all__ = ['FrozenShowersFCalOnly', 'BeamPipeKill', 'TightMuonStepping', 'G4SignalCavern', 'CalHits', 'ParticleID', 'FastCaloSim'] diff --git a/Simulation/SimulationConfig/python/SimConfigFlags.py b/Simulation/SimulationConfig/python/SimConfigFlags.py index da2576284c5..9bd717fcb04 100644 --- a/Simulation/SimulationConfig/python/SimConfigFlags.py +++ b/Simulation/SimulationConfig/python/SimConfigFlags.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration from AthenaConfiguration.AthConfigFlags import AthConfigFlags, isGaudiEnv from AthenaConfiguration.AutoConfigFlags import GetFileMD @@ -205,7 +205,7 @@ def createSimConfigFlags(): def _decideHITSMerging(prevFlags): # Further specialization possible in future - if prevFlags.Sim.ISF.Simulator.isFullSim(): + if prevFlags.Sim.ISF.Simulator.isFullSim() and prevFlags.Sim.LArParameterization!=LArParameterization.FastCaloSim: doID = False doITk = False doCALO = False @@ -215,7 +215,7 @@ def createSimConfigFlags(): doITk = True doCALO = True doMUON = True - elif prevFlags.Sim.ISF.Simulator.usesFastCaloSim(): + elif prevFlags.Sim.ISF.Simulator.usesFastCaloSim() or prevFlags.Sim.LArParameterization is LArParameterization.FastCaloSim: doID = False doITk = False doCALO = True diff --git a/Simulation/Tests/SimCoreTestsMT/test/test_AtlasG4_FastCaloSim_MT.sh b/Simulation/Tests/SimCoreTestsMT/test/test_AtlasG4_FastCaloSim_MT.sh index a6200f8a18f..5a002043149 100755 --- a/Simulation/Tests/SimCoreTestsMT/test/test_AtlasG4_FastCaloSim_MT.sh +++ b/Simulation/Tests/SimCoreTestsMT/test/test_AtlasG4_FastCaloSim_MT.sh @@ -17,23 +17,67 @@ AtlasG4_tf.py \ --skipEvents '0' \ --preInclude 'SimulationJobOptions/preInclude.FastCaloSim.py,Campaigns/MC21Simulation.py' \ --postInclude 'default:PyJobTransforms/UseFrontier.py' \ - --postExec 'sim:topSeq.BeamEffectsAlg.ISFRun=True' \ + --postExec 'sim:topSeq.BeamEffectsAlg.ISFRun=True;topSeq+=CfgMgr.JobOptsDumperAlg(FileName="LegacyConfig.txt")' \ --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ --outputHITSFile="test.HITS.pool.root" \ - --physicsList="FTFP_BERT_ATL" \ - --conditionsTag "default:OFLCOND-MC21-SDR-RUN3-07" \ - --geometryVersion="default:ATLAS-R3S-2021-03-00-00" \ + --physicsList="FTFP_BERT_ATL" \ + --conditionsTag "default:OFLCOND-MC21-SDR-RUN3-07" \ + --geometryVersion="default:ATLAS-R3S-2021-03-00-00" \ --imf False; rc=$? +status=$rc +echo "art-result: $rc simOLD" +cp log.AtlasG4Tf log.AtlasG4Tf_OLD + +AtlasG4_tf.py \ + --CA \ + --multithreaded \ + --randomSeed '10' \ + --maxEvents '20' \ + --skipEvents '0' \ + --preInclude 'sim:Campaigns.MC21Simulation,SimuJobTransforms.FastCaloSim' \ + --postInclude 'default:PyJobTransforms.UseFrontier' \ + --postExec 'sim:cfg.addEventAlgo(CompFactory.JobOptsDumperAlg(FileName="CAConfig.txt"))' \ + --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ + --outputHITSFile="test.HITS.CA.pool.root" \ + --physicsList="FTFP_BERT_ATL" \ + --conditionsTag "default:OFLCOND-MC21-SDR-RUN3-07" \ + --geometryVersion="default:ATLAS-R3S-2021-03-00-00" \ + --imf False; + +rc1=$? +if [ $status -eq 0 ] +then + status=$rc1 +fi +echo "art-result: $rc1 simCA" +cp log.AtlasG4Tf log.AtlasG4Tf_CA + +rc4=-9999 +if [ $rc -eq 0 ] && [ $rc1 -eq 0 ] +then + acmd.py diff-root test.HITS.pool.root test.HITS.CA.pool.root --error-mode resilient --mode=semi-detailed --order-trees + rc4=$? + status=$rc4 +fi +echo "art-result: $rc4 HITS_OLDvsCA" + + + rc2=-9999 -echo "art-result: $rc simulation" if [ $rc -eq 0 ] then ArtPackage=$1 ArtJobName=$2 art.py compare grid --entries 20 ${ArtPackage} ${ArtJobName} --mode=semi-detailed --order-trees rc2=$? + if [ $status -eq 0 ] + then + status=$rc2 + fi fi echo "art-result: $rc2 regression" + +exit $status diff --git a/Simulation/Tests/SimCoreTestsMT/test/test_AtlasG4_FastCaloSim_MTvsST.sh b/Simulation/Tests/SimCoreTestsMT/test/test_AtlasG4_FastCaloSim_MTvsST.sh index da9def9a788..8035d10fa58 100755 --- a/Simulation/Tests/SimCoreTestsMT/test/test_AtlasG4_FastCaloSim_MTvsST.sh +++ b/Simulation/Tests/SimCoreTestsMT/test/test_AtlasG4_FastCaloSim_MTvsST.sh @@ -14,53 +14,68 @@ export ATHENA_CORE_NUMBER=8 AtlasG4_tf.py \ ---multithreaded \ ---randomSeed '10' \ ---maxEvents '20' \ ---skipEvents '0' \ ---preInclude 'SimulationJobOptions/preInclude.FastCaloSim.py,Campaigns/MC21Simulation.py' \ ---postInclude 'default:PyJobTransforms/UseFrontier.py' \ ---postExec 'sim:topSeq.BeamEffectsAlg.ISFRun=True' \ ---inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ ---outputHITSFile="test.MT.HITS.pool.root" \ ---physicsList="FTFP_BERT_ATL" \ ---conditionsTag "default:OFLCOND-MC21-SDR-RUN3-07" \ ---geometryVersion="default:ATLAS-R3S-2021-03-00-00" \ ---preExec 'AtlasG4Tf:simFlags.ReleaseGeoModel=False;' \ ---imf False; - + --CA \ + --multithreaded \ + --randomSeed '10' \ + --maxEvents '20' \ + --skipEvents '0' \ + --preInclude 'sim:Campaigns.MC21Simulation,SimuJobTransforms.FastCaloSim' \ + --postInclude 'default:PyJobTransforms.UseFrontier' \ + --postExec 'sim:cfg.addEventAlgo(CompFactory.JobOptsDumperAlg(FileName="CAConfig.txt"))' \ + --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ + --outputHITSFile="test.HITS.MT.pool.root" \ + --physicsList="FTFP_BERT_ATL" \ + --conditionsTag "default:OFLCOND-MC21-SDR-RUN3-07" \ + --geometryVersion="default:ATLAS-R3S-2021-03-00-00" \ + --imf False; rc=$? +status=$rc echo "art-result: $rc MTsim" -rc2=-9999 -if [ $rc -eq 0 ] -then - ArtPackage=$1 - ArtJobName=$2 - unset ATHENA_CORE_NUMBER - AtlasG4_tf.py \ + +unset ATHENA_CORE_NUMBER +AtlasG4_tf.py \ + --CA \ --randomSeed '10' \ --maxEvents '20' \ --skipEvents '0' \ - --preInclude 'SimulationJobOptions/preInclude.FastCaloSim.py,Campaigns/MC21Simulation.py' \ - --postInclude 'default:PyJobTransforms/UseFrontier.py' \ - --postExec 'sim:topSeq.BeamEffectsAlg.ISFRun=True' \ + --preInclude 'sim:Campaigns.MC21Simulation,SimuJobTransforms.FastCaloSim' \ + --postInclude 'default:PyJobTransforms.UseFrontier' \ + --postExec 'sim:cfg.addEventAlgo(CompFactory.JobOptsDumperAlg(FileName="CAConfig.txt"))' \ --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ - --outputHITSFile="test.ST.HITS.pool.root" \ - --physicsList="FTFP_BERT_ATL" \ - --conditionsTag "default:OFLCOND-MC21-SDR-RUN3-07" \ - --geometryVersion="default:ATLAS-R3S-2021-03-00-00" \ - --preExec 'AtlasG4Tf:simFlags.ReleaseGeoModel=False;' \ + --outputHITSFile="test.HITS.ST.pool.root" \ + --physicsList="FTFP_BERT_ATL" \ + --conditionsTag "default:OFLCOND-MC21-SDR-RUN3-07" \ + --geometryVersion="default:ATLAS-R3S-2021-03-00-00" \ --imf False; - rc2=$? +rc2=$? +if [ $status -eq 0 ] +then + status=$rc2 fi echo "art-result: $rc2 STsim" + rc3=-9999 -if [ $rc2 -eq 0 ] +if [ $status -eq 0 ] then - acmd.py diff-root test.MT.HITS.pool.root test.ST.HITS.pool.root --error-mode resilient --mode=semi-detailed --order-trees --ignore-leaves RecoTimingObj_p1_EVNTtoHITS_timings index_ref + acmd.py diff-root test.MT.HITS.pool.root test.ST.HITS.pool.root --error-mode resilient --mode=semi-detailed --order-trees rc3=$? + status=$rc3 fi echo "art-result: $rc3 comparision" +rc4=-9999 +if [ $rc -eq 0 ] +then + ArtPackage=$1 + ArtJobName=$2 + art.py compare grid --entries 20 ${ArtPackage} ${ArtJobName} --mode=semi-detailed --order-trees --file=test.MT.HITS.pool.root + rc4=$? + if [ $status -eq 0 ] + then + status=$rc4 + fi +fi +echo "art-result: $rc4 regression" +exit $status diff --git a/TileCalorimeter/TileConditions/python/TileSamplingFractionConfig.py b/TileCalorimeter/TileConditions/python/TileSamplingFractionConfig.py index 2b42b400e54..819fb540f5d 100644 --- a/TileCalorimeter/TileConditions/python/TileSamplingFractionConfig.py +++ b/TileCalorimeter/TileConditions/python/TileSamplingFractionConfig.py @@ -32,7 +32,8 @@ def TileSamplingFractionCondAlgCfg(flags, **kwargs): samplingFractionProxy = TileCondProxyCoolFlt('TileCondProxyCool_SamplingFraction', Source = samplingFractionFolder) samplingFractionTag = None # Tag connected to global conditions tag is used by default - if flags.GeoModel.Run >= LHCPeriod.Run4 or flags.Overlay.DataOverlay or flags.Sim.ISF.Simulator.usesFastCaloSim(): + from SimulationConfig.SimEnums import LArParameterization + if flags.GeoModel.Run >= LHCPeriod.Run4 or flags.Overlay.DataOverlay or flags.Sim.ISF.Simulator.usesFastCaloSim() or flags.Sim.LArParameterization is LArParameterization.FastCaloSim: samplingFractionTag = 'TileOfl02CalibSfr-SIM-07' from IOVDbSvc.IOVDbSvcConfig import addFolders -- GitLab