diff --git a/Simulation/FastShower/FastCaloSim/python/FastCaloSimFactoryNew.py b/Simulation/FastShower/FastCaloSim/python/FastCaloSimFactoryNew.py index dc8a08b6151f37736c022441910a147642c52bec..af641d28783194c9cfbd23b923f8aee535ccf18b 100644 --- a/Simulation/FastShower/FastCaloSim/python/FastCaloSimFactoryNew.py +++ b/Simulation/FastShower/FastCaloSim/python/FastCaloSimFactoryNew.py @@ -1,48 +1,151 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration -from RngComps.RandomServices import RNG -from IOVDbSvc.IOVDbSvcConfig import addFolders +from AthenaCommon.Logging import logging from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator -from TrkDetDescrSvc.TrkDetDescrJobProperties import TrkDetFlags -from ISF_FastCaloSimServices.ISF_FastCaloSimHelpers import AdditionalParticleParametrizationFileNames -# Initialize Athena logging -from AthenaCommon.Logging import logging -mlog = logging.getLogger('FastCaloSimFactory::configure:') +# PROPAGATORS +def RungeKuttaPropagatorCfg(flags, name="AtlasRungeKuttaPropagator", **kwargs): + mlog = logging.getLogger(name) + mlog.debug("Start configuration") + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.Trk.RungeKuttaPropagator(name, **kwargs)) + return result + +def STEP_PropagatorCfg(flags, name="AtlasSTEP_Propagator", **kwargs): + mlog = logging.getLogger(name) + mlog.debug("Start configuration") + result = ComponentAccumulator() + kwargs.setdefault("MaterialEffects", False) + result.setPrivateTools(CompFactory.Trk.STEP_Propagator(name, **kwargs)) + return result -def NIMatEffUpdatorCfg(flags, name="ISF_NIMatEffUpdator", **kwargs): - return CompFactory.Trk.NIMatEffUpdator(name, **kwargs) +# UPDATORS +def MaterialEffectsUpdatorCfg(flags, name="MaterialEffectsUpdator", **kwargs): + mlog = logging.getLogger(name) + mlog.debug("Start configuration") + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.Trk.MaterialEffectsUpdator(name, **kwargs)) + return result -def NIPropagatorCfg(flags, name="ISF_NIPropagator", **kwargs): - mlog.info("Now configure the non-interacting propagator...") - kwargs.setdefault("MaterialEffects", False) - result = CompFactory.Trk.STEP_Propagator(name, **kwargs) - mlog.info("Configure non-interacting propagator finished.") +def NIMatEffUpdatorCfg(flags, name="NIMatEffUpdator", **kwargs): + mlog = logging.getLogger(name) + mlog.debug("Start configuration") + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.Trk.NIMatEffUpdator(name, **kwargs)) return result +# NAVIGATOR +def AtlasNavigatorCfg(flags, name="AtlasNavigator", **kwargs): + from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg + mlog = logging.getLogger(name) + mlog.debug("Start configuration") + + result = TrackingGeometrySvcCfg(flags) + kwargs.setdefault("TrackingGeometrySvc", result.getPrimary()) + + result.setPrivateTools(CompFactory.Trk.Navigator(name, **kwargs)) + return result + + +# EXTRAPOLATOR def NITimedExtrapolatorCfg(flags, name="ISF_NITimedExtrapolator", **kwargs): - mlog.info("Now configure the TimedExtrapolator...") - kwargs.setdefault("MaterialEffectsUpdators", [NIMatEffUpdatorCfg(flags)]) + result = ComponentAccumulator() + mlog = logging.getLogger(name) + mlog.debug("Start configuration") + + # Configure MagneticField (resolve AtlasFieldCacheCondObj dependancy) + from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + result.merge(MagneticFieldSvcCfg(flags)) + # add LAr calibration (resolve LAr dependancies) + from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDbCfg + result.merge(LArElecCalibDbCfg(flags, ["fSampl"])) + + TimedPropagators = [] + TimedUpdators = [] + + # NAVIGATOR + Navigator = result.popToolsAndMerge(AtlasNavigatorCfg(flags)) + result.addPublicTool(Navigator) + kwargs.setdefault("Navigator", Navigator) + + # PROPAGATORS + AtlasRungeKuttaPropagator = result.popToolsAndMerge(RungeKuttaPropagatorCfg(flags)) + result.addPublicTool(AtlasRungeKuttaPropagator) + TimedPropagators += [AtlasRungeKuttaPropagator] + + AtlasSTEP_Propagator = result.popToolsAndMerge(STEP_PropagatorCfg(flags)) + result.addPublicTool(AtlasSTEP_Propagator) + TimedPropagators += [AtlasSTEP_Propagator] + kwargs.setdefault("STEP_Propagator", result.getPublicTool(AtlasSTEP_Propagator.name)) + + # UPDATORS + MaterialEffectsUpdator = result.popToolsAndMerge(MaterialEffectsUpdatorCfg(flags)) + result.addPublicTool(MaterialEffectsUpdator) + + NIMatEffUpdator = result.popToolsAndMerge(NIMatEffUpdatorCfg(flags)) + result.addPublicTool(NIMatEffUpdator) + TimedUpdators += [NIMatEffUpdator] + # kwargs.setdefault("MaterialEffectsUpdators", [result.getPublicTool(NIMatEffUpdator.name)]) kwargs.setdefault("ApplyMaterialEffects", False) - kwargs.setdefault("STEP_Propagator", NIPropagatorCfg(flags)) - result = CompFactory.Trk.TimedExtrapolator(name, **kwargs) - mlog.info("Configure TimedExtrapolator finished.") + + # CONFIGURE PROPAGATORS/UPDATORS ACCORDING TO GEOMETRY SIGNATURE + + TimedSubPropagators = [] + TimedSubUpdators = [] + + # -------------------- set it depending on the geometry ---------------------------------------------------- + # default for Global is (Rk,Mat) + TimedSubPropagators += [ AtlasRungeKuttaPropagator.name ] + TimedSubUpdators += [ MaterialEffectsUpdator.name ] + + # default for ID is (Rk,Mat) + TimedSubPropagators += [ AtlasRungeKuttaPropagator.name ] + TimedSubUpdators += [ MaterialEffectsUpdator.name ] + + # default for BeamPipe is (Rk,Mat) + TimedSubPropagators += [ AtlasRungeKuttaPropagator.name ] + TimedSubUpdators += [ MaterialEffectsUpdator.name ] + + # default for Calo is (STEP,Mat) + TimedSubPropagators += [ AtlasSTEP_Propagator.name ] + TimedSubUpdators += [ NIMatEffUpdator.name ] + + # default for MS is (STEP,Mat) + TimedSubPropagators += [ AtlasSTEP_Propagator.name ] + TimedSubUpdators += [ MaterialEffectsUpdator.name ] + + # default for Cavern is (Rk,Mat) + TimedSubPropagators += [ AtlasRungeKuttaPropagator.name ] + TimedSubUpdators += [ MaterialEffectsUpdator.name ] + # ---------------------------------------------------------------------------------------------------------- + + kwargs.setdefault("MaterialEffectsUpdators", TimedUpdators) + kwargs.setdefault("Propagators", TimedPropagators) + kwargs.setdefault("SubPropagators", TimedSubPropagators) + kwargs.setdefault("SubMEUpdators", TimedSubUpdators) + + result.setPrivateTools(CompFactory.Trk.TimedExtrapolator(name, **kwargs)) return result # FastShowerCellBuilderTool -def FastShowerCellBuilderToolBaseCfg(flags, name, **kwargs): +def FastShowerCellBuilderToolBaseCfg(flags, name="ISF_FastShowerCellBuilderTool", **kwargs): + + from RngComps.RandomServices import RNG + from IOVDbSvc.IOVDbSvcConfig import addFolders + from ISF_FastCaloSimServices.ISF_FastCaloSimHelpers import AdditionalParticleParametrizationFileNames acc = RNG(flags.Random.Engine) acc.merge(addFolders(flags, "/GLOBAL/AtlfastII/FastCaloSimParam", "GLOBAL_OFL", tag="FastCaloSim_v2")) - + localFileNameList = AdditionalParticleParametrizationFileNames() localFileNameList.insert(0, "L1_L2_egamma_corr.config20.root") - kwargs.setdefault("AdditionalParticleParametrizationFileNames", localFileNameList) + kwargs.setdefault("AdditionalParticleParametrizationFileNames", localFileNameList) kwargs.setdefault("RandomService", acc.getService("AthRNGSvc")) kwargs.setdefault("RandomStreamName", "AthRNGSvc") kwargs.setdefault("DoSimulWithInnerDetectorTruthOnly", True) @@ -54,37 +157,19 @@ def FastShowerCellBuilderToolBaseCfg(flags, name, **kwargs): kwargs.setdefault("use_Ekin_for_depositions", True) kwargs.setdefault("McLocation", flags.Sim.FastShower.InputCollection) kwargs.setdefault("ParticleParametrizationFileName", "") - kwargs.setdefault("Extrapolator", NITimedExtrapolatorCfg(flags)) + + if "Extrapolator" not in kwargs: + Extrapolator = acc.popToolsAndMerge(NITimedExtrapolatorCfg(flags)) + acc.addPublicTool(Extrapolator) + kwargs.setdefault("Extrapolator", acc.getPublicTool(Extrapolator.name)) + # New kwarg from old FastCaloSimFactory + from TrkDetDescrSvc.TrkDetDescrJobProperties import TrkDetFlags kwargs.setdefault("CaloEntrance", TrkDetFlags.InDetContainerName()) ####################################################################################################### - #theFastShowerCellBuilderTool.Invisibles=[12, 14, 16, 1000022] + # kwargs.setdefault("Invisibles", [12, 14, 16, 1000022]) ######################################################################################################### - acc.addPublicTool(CompFactory.FastShowerCellBuilderTool(name, **kwargs)) - return acc - - -def FastShowerCellBuilderToolCfg(flags, **kwargs): - - acc = FastShowerCellBuilderToolBaseCfg(flags, name="ISF_FastShowerCellBuilderTool", **kwargs) - tool = acc.getPublicTool("ISF_FastShowerCellBuilderTool") - - try: - ParticleParametrizationFileName = tool.ParticleParametrizationFileName - except Exception: - ParticleParametrizationFileName = "" - - # TODO: Always False since len(Add...) = 636 - if ParticleParametrizationFileName == "" and len(tool.AdditionalParticleParametrizationFileNames) == 0: - ParticleParametrizationFileName = "FastCaloSim/v1/ParticleEnergyParametrization.root" - - tool.ParticleParametrizationFileName = ParticleParametrizationFileName - - # TODO: Do we need this: very long output? - mlog.info("ParticleParametrizationFile: %s", ParticleParametrizationFileName) - mlog.verbose("all values:") - mlog.verbose(tool) - + acc.setPrivateTools(CompFactory.FastShowerCellBuilderTool(name, **kwargs)) return acc diff --git a/Simulation/G4Atlas/G4AtlasServices/python/G4AtlasUserActionConfigNew.py b/Simulation/G4Atlas/G4AtlasServices/python/G4AtlasUserActionConfigNew.py index 9284c1aed35c831b72eb6decd414d748d3c74163..9deb17c5892787a6fad6d63999839745c0f34a52 100644 --- a/Simulation/G4Atlas/G4AtlasServices/python/G4AtlasUserActionConfigNew.py +++ b/Simulation/G4Atlas/G4AtlasServices/python/G4AtlasUserActionConfigNew.py @@ -22,12 +22,11 @@ from ISF_Geant4CommonTools.ISF_Geant4CommonToolsConfigNew import EntryLayerToolC def FullG4TrackProcessorUserActionToolCfg(flags, name="FullG4TrackProcessorUserActionTool", **kwargs): result = ComponentAccumulator() if flags.Sim.ISF.Simulator in ["FullG4MT"]: - result.merge(EntryLayerToolMTCfg(flags)) - tool = result.getPublicTool("ISF_EntryLayerToolMT") + tool = result.popToolsAndMerge(EntryLayerToolMTCfg(flags)) else: - result.merge(EntryLayerToolCfg(flags)) - tool = result.getPublicTool("ISF_EntryLayerTool") - kwargs.setdefault("EntryLayerTool", tool) + tool = result.popToolsAndMerge(EntryLayerToolCfg(flags)) + result.addPublicTool(tool) + kwargs.setdefault("EntryLayerTool", result.getPublicTool(tool.name)) result.merge(GeoIDSvcCfg(flags)) kwargs.setdefault("GeoIDSvc", result.getService("ISF_GeoIDSvc")) if flags.Detector.SimulateCavern: @@ -114,7 +113,7 @@ def getDefaultActions(ConfigFlags): actions += [result.popToolsAndMerge(CalibrationDefaultProcessingToolCfg(ConfigFlags))] actions += [result.popToolsAndMerge(LooperKillerToolCfg(ConfigFlags))] - + result.setPrivateTools(actions) return result @@ -139,7 +138,6 @@ def CTBUserActionSvcCfg(ConfigFlags, name="G4UA::CTBUserActionSvc", **kwargs): result = ComponentAccumulator() # FIXME migrate an alternative to this generalActions = result.popToolsAndMerge(getDefaultActions(ConfigFlags)) - generalActions += [result.popToolsAndMerge(LooperKillerToolCfg(ConfigFlags))] # This comment carried over from old style: # FIXME: ADS these actions are not yet migrated to Hive #if simFlags.SimLayout.get_Value()=="tb_LArH6_2004": @@ -178,7 +176,6 @@ def ISFUserActionSvcCfg(ConfigFlags, name="G4UA::ISFUserActionSvc", **kwargs): generalActions = ( TrackProcessorUserAction + MCTruthUserAction + result.popToolsAndMerge(getDefaultActions(ConfigFlags)) + - [result.popToolsAndMerge(LooperKillerToolCfg(ConfigFlags))] + PhysicsValidationUserAction ) diff --git a/Simulation/ISF/ISF_Config/python/ISF_MainConfigNew.py b/Simulation/ISF/ISF_Config/python/ISF_MainConfigNew.py index 3dca45b903abb6e092721f5e2bd19baeceb4f9bc..8008c444527f88d3154ec525dca0b84c91204932 100644 --- a/Simulation/ISF/ISF_Config/python/ISF_MainConfigNew.py +++ b/Simulation/ISF/ISF_Config/python/ISF_MainConfigNew.py @@ -1,17 +1,17 @@ """Main ISF tools configuration with ComponentAccumulator -Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration """ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory from ISF_Services.ISF_ServicesCoreConfigNew import GeoIDSvcCfg from ISF_Services.ISF_ServicesConfigNew import ( - InputConverterCfg, ParticleBrokerSvcCfg, - TruthServiceCfg, LongLivedInputConverterCfg, + InputConverterCfg, TruthServiceCfg, + LongLivedInputConverterCfg, ) from ISF_Tools.ISF_ToolsConfigNew import ( - MemoryMonitorToolCfg, ParticleKillerToolCfg, - EnergyParticleOrderingToolCfg, + ParticleKillerToolCfg, EnergyParticleOrderingToolCfg, + ParticleOrderingToolCfg ) from ISF_SimulationSelectors.ISF_SimulationSelectorsConfigNew import ( DefaultAFIIGeant4SelectorCfg, @@ -21,6 +21,12 @@ from ISF_SimulationSelectors.ISF_SimulationSelectorsConfigNew import ( FullGeant4SelectorCfg, MuonAFIIGeant4SelectorCfg, PassBackGeant4SelectorCfg, + DefaultFastCaloSimV2SelectorCfg, + PionG4FastCaloGeant4Selector, + ProtonG4FastCaloGeant4Selector, + NeutronG4FastCaloGeant4Selector, + ChargedKaonG4FastCaloGeant4Selector, + KLongG4FastCaloGeant4Selector, ) from ISF_Geant4Tools.ISF_Geant4ToolsConfigNew import ( AFIIGeant4ToolCfg, @@ -31,6 +37,10 @@ from ISF_Geant4Tools.ISF_Geant4ToolsConfigNew import ( from ISF_FastCaloSimServices.ISF_FastCaloSimServicesConfigNew import ( FastCaloToolBaseCfg, LegacyAFIIFastCaloToolCfg, + FastCaloSimV2ToolCfg, +) +from ISF_Geant4CommonTools.ISF_Geant4CommonToolsConfigNew import ( + AFIIEntryLayerToolMTCfg ) from ISF_FatrasServices.ISF_FatrasConfig import fatrasSimToolCfg @@ -38,19 +48,24 @@ from ISF_FatrasServices.ISF_FatrasConfig import fatrasSimToolCfg def Kernel_GenericSimulatorMTCfg(flags, name="ISF_Kernel_GenericSimulatorMT", **kwargs): acc = ComponentAccumulator() - acc.merge(ParticleKillerToolCfg(flags)) - tool = acc.getPublicTool("ISF_ParticleKillerTool") - kwargs.setdefault("ParticleKillerTool", tool) + if "ParticleKillerTool" not in kwargs: + tool = acc.popToolsAndMerge(ParticleKillerToolCfg(flags)) + acc.addPublicTool(tool) + pubTool = acc.getPublicTool(tool.name) + kwargs.setdefault("ParticleKillerTool", pubTool) # public toolHandle - acc.merge(GeoIDSvcCfg(flags)) - kwargs.setdefault("GeoIDSvc", acc.getService("ISF_GeoIDSvc")) + if "GeoIDSvc" not in kwargs: + acc.merge(GeoIDSvcCfg(flags)) + kwargs.setdefault("GeoIDSvc", acc.getService("ISF_GeoIDSvc")) - acc.merge(InputConverterCfg(flags)) - kwargs.setdefault("InputConverter", acc.getService("ISF_InputConverter")) + if "InputConverter" not in kwargs: + acc.merge(InputConverterCfg(flags)) + kwargs.setdefault("InputConverter", acc.getService("ISF_InputConverter")) - truthacc = TruthServiceCfg(flags) - kwargs.setdefault("TruthRecordService", truthacc.getPrimary()) - acc.merge(truthacc) + if "TruthRecordService" not in kwargs: + truthacc = TruthServiceCfg(flags) + kwargs.setdefault("TruthRecordService", truthacc.getPrimary()) + acc.merge(truthacc) kwargs.setdefault("Cardinality", flags.Concurrency.NumThreads) kwargs.setdefault("OutputLevel", 1) @@ -60,7 +75,6 @@ def Kernel_GenericSimulatorMTCfg(flags, name="ISF_Kernel_GenericSimulatorMT", ** #Write MetaData container from G4AtlasApps.G4Atlas_MetadataNew import writeSimulationParametersMetadata acc.merge(writeSimulationParametersMetadata(flags)) - acc.addEventAlgo(CompFactory.ISF.SimKernelMT(name, **kwargs)) return acc @@ -72,16 +86,22 @@ def Kernel_GenericSimulatorNoG4MTCfg(flags, name="ISF_Kernel_GenericSimulatorNoG def Kernel_GenericG4OnlyMTCfg(flags, name="ISF_Kernel_GenericG4OnlyMT", **kwargs): acc = ComponentAccumulator() - acc.merge(FullGeant4SelectorCfg(flags)) - tool = acc.getPublicTool("ISF_FullGeant4Selector") - kwargs.setdefault("BeamPipeSimulationSelectors", [tool]) - kwargs.setdefault("IDSimulationSelectors", [tool]) - kwargs.setdefault("CaloSimulationSelectors", [tool]) - kwargs.setdefault("MSSimulationSelectors", [tool]) - - acc.merge(DefaultParticleKillerSelectorCfg(flags)) - tool = acc.getPublicTool("ISF_DefaultParticleKillerSelector") - kwargs.setdefault("CavernSimulationSelectors", [tool]) + defaultG4SelectorRegions = set(["BeamPipeSimulationSelectors", "IDSimulationSelectors", "CaloSimulationSelectors", "MSSimulationSelectors"]) + if defaultG4SelectorRegions - kwargs.keys(): # i.e. if any of these have not been defined yet + tool = acc.popToolsAndMerge(FullGeant4SelectorCfg(flags)) + acc.addPublicTool(tool) + pubTool = acc.getPublicTool(tool.name) + # SimulationSelectors are still public ToolHandleArrays currently + kwargs.setdefault("BeamPipeSimulationSelectors", [pubTool]) + kwargs.setdefault("IDSimulationSelectors", [pubTool]) + kwargs.setdefault("CaloSimulationSelectors", [pubTool]) + kwargs.setdefault("MSSimulationSelectors", [pubTool]) + + if "CavernSimulationSelectors" not in kwargs: + tool = acc.popToolsAndMerge(DefaultParticleKillerSelectorCfg(flags)) + acc.addPublicTool(tool) + pubTool = acc.getPublicTool(tool.name) + kwargs.setdefault("CavernSimulationSelectors", [pubTool]) acc.merge(Kernel_GenericSimulatorMTCfg(flags, name, **kwargs)) return acc @@ -90,10 +110,11 @@ def Kernel_GenericG4OnlyMTCfg(flags, name="ISF_Kernel_GenericG4OnlyMT", **kwargs def Kernel_FullG4MTCfg(flags, name="ISF_Kernel_FullG4MT", **kwargs): acc = ComponentAccumulator() - acc.merge(ParticleKillerToolCfg(flags)) - Fulltool = acc.popToolsAndMerge(FullGeant4ToolCfg(flags)) - PKtool = acc.getPublicTool("ISF_ParticleKillerTool") - kwargs.setdefault("SimulationTools", [PKtool, Fulltool]) + if "SimulationTools" not in kwargs: + kwargs.setdefault("SimulationTools", [ + acc.popToolsAndMerge(ParticleKillerToolCfg(flags)), + acc.popToolsAndMerge(FullGeant4ToolCfg(flags)) + ]) #private ToolHandleArray acc.merge(Kernel_GenericG4OnlyMTCfg(flags, name, **kwargs)) return acc @@ -102,15 +123,13 @@ def Kernel_FullG4MTCfg(flags, name="ISF_Kernel_FullG4MT", **kwargs): def Kernel_FullG4MT_LongLivedCfg(flags, name="ISF_Kernel_FullG4MT_LongLived", **kwargs): acc = ComponentAccumulator() - acc.merge(ParticleKillerToolCfg(flags)) - acc.merge(LongLivedGeant4ToolCfg(flags)) - PKtool = acc.getPublicTool("ISF_ParticleKillerTool") - LLtool = acc.getPublicTool("ISF_LongLivedGeant4Tool") - kwargs.setdefault("SimulationTools", [PKtool, LLtool]) + kwargs.setdefault("SimulationTools", [ + acc.popToolsAndMerge(ParticleKillerToolCfg(flags)), + acc.merge(LongLivedGeant4ToolCfg(flags)) + ]) acc.merge(LongLivedInputConverterCfg(flags)) - kwargs.setdefault("InputConverter", - acc.getService("ISF_LongLivedInputConverter")) + kwargs.setdefault("InputConverter", acc.getService("ISF_LongLivedInputConverter")) acc.merge(Kernel_GenericG4OnlyMTCfg(flags, name, **kwargs)) return acc @@ -119,26 +138,30 @@ def Kernel_FullG4MT_LongLivedCfg(flags, name="ISF_Kernel_FullG4MT_LongLived", ** def Kernel_PassBackG4MTCfg(flags, name="ISF_Kernel_PassBackG4MT", **kwargs): acc = ComponentAccumulator() - acc.merge(PassBackGeant4SelectorCfg(flags)) - tool = acc.getPublicTool("ISF_PassBackGeant4Selector") - kwargs.setdefault("BeamPipeSimulationSelectors", [tool]) - kwargs.setdefault("IDSimulationSelectors", [tool]) - kwargs.setdefault("CaloSimulationSelectors", [tool]) - kwargs.setdefault("MSSimulationSelectors", [tool]) - - acc.merge(DefaultParticleKillerSelectorCfg(flags)) - tool = acc.getPublicTool("ISF_DefaultParticleKillerSelector") - kwargs.setdefault("CavernSimulationSelectors", [tool]) - - acc.merge(ParticleKillerToolCfg(flags)) - acc.merge(PassBackGeant4ToolCfg(flags)) - PKtool = acc.getPublicTool("ISF_ParticleKillerTool") - PBtool = acc.getPublicTool("ISF_PassBackGeant4Tool") - kwargs.setdefault("SimulationTools", [PKtool, PBtool]) - - acc.merge(EnergyParticleOrderingToolCfg(flags)) - tool = acc.getPublicTool("ISF_EnergyParticleOrderingTool") - kwargs.setdefault("ParticleOrderingTool", tool) + defaultG4SelectorRegions = set(["BeamPipeSimulationSelectors", "IDSimulationSelectors", "CaloSimulationSelectors", "MSSimulationSelectors"]) + if defaultG4SelectorRegions - kwargs.keys(): # i.e. if any of these have not been defined yet + tool = acc.popToolsAndMerge(PassBackGeant4SelectorCfg(flags)) + acc.addPublicTool(tool) + pubTool = acc.getPublicTool(tool.name) + kwargs.setdefault("BeamPipeSimulationSelectors", [pubTool]) + kwargs.setdefault("IDSimulationSelectors", [pubTool]) + kwargs.setdefault("CaloSimulationSelectors", [pubTool]) + kwargs.setdefault("MSSimulationSelectors", [pubTool]) + + if "CavernSimulationSelectors" not in kwargs: + tool = acc.popToolsAndMerge(DefaultParticleKillerSelectorCfg(flags)) + acc.addPublicTool(tool) + pubTool = acc.getPublicTool(tool.name) + kwargs.setdefault("CavernSimulationSelectors", [pubTool]) + + if "SimulationTools" not in kwargs: + kwargs.setdefault("SimulationTools", [ + acc.popToolsAndMerge(ParticleKillerToolCfg(flags)), + acc.popToolsAndMerge(PassBackGeant4ToolCfg(flags)) + ]) + + if "ParticleOrderingTool" not in kwargs: + kwargs.setdefault("ParticleOrderingTool", acc.popToolsAndMerge(EnergyParticleOrderingToolCfg(flags))) acc.merge(Kernel_GenericSimulatorMTCfg(flags, name, **kwargs)) return acc @@ -147,35 +170,37 @@ def Kernel_PassBackG4MTCfg(flags, name="ISF_Kernel_PassBackG4MT", **kwargs): def Kernel_ATLFASTIIMTCfg(flags, name="ISF_Kernel_ATLFASTIIMT", **kwargs): acc = ComponentAccumulator() - acc.merge(DefaultAFIIGeant4SelectorCfg(flags)) - tool = acc.getPublicTool("ISF_DefaultAFIIGeant4Selector") - kwargs.setdefault("BeamPipeSimulationSelectors", [tool]) - kwargs.setdefault("IDSimulationSelectors", [tool]) - kwargs.setdefault("MSSimulationSelectors", [tool]) - - acc.merge(MuonAFIIGeant4SelectorCfg(flags)) - acc.merge(EtaGreater5ParticleKillerSimSelectorCfg(flags)) - acc.merge(DefaultLegacyAFIIFastCaloSimSelectorCfg(flags)) - Mutool = acc.getPublicTool("ISF_MuonAFIIGeant4Selector") - EtaGtool = acc.getPublicTool("ISF_EtaGreater5ParticleKillerSimSelector") - DefLegtool = acc.getPublicTool("ISF_DefaultLegacyAFIIFastCaloSimSelector") - kwargs.setdefault("CaloSimulationSelectors", [Mutool, EtaGtool, DefLegtool]) - - acc.merge(DefaultParticleKillerSelectorCfg(flags)) - tool = acc.getPublicTool("ISF_DefaultParticleKillerSelector") - kwargs.setdefault("CavernSimulationSelectors", [tool]) - - acc.merge(ParticleKillerToolCfg(flags)) - acc.merge(LegacyAFIIFastCaloToolCfg(flags)) - acc.merge(AFIIGeant4ToolCfg(flags)) - PKtool = acc.getPublicTool("ISF_ParticleKillerTool") - Legtool = acc.getPublicTool("ISF_LegacyAFIIFastCaloTool") - AFIItool = acc.getPublicTool("ISF_AFIIGeant4Tool") - kwargs.setdefault("SimulationTools", [PKtool, Legtool, AFIItool]) - - acc.merge(EnergyParticleOrderingToolCfg(flags)) - tool = acc.getPublicTool("ISF_EnergyParticleOrderingTool") - kwargs.setdefault("ParticleOrderingTool", tool) + tool = acc.popToolsAndMerge(DefaultAFIIGeant4SelectorCfg(flags)) + acc.addPublicTool(tool) + pubTool = acc.getPublicTool(tool.name) + kwargs.setdefault("BeamPipeSimulationSelectors", [pubTool]) + kwargs.setdefault("IDSimulationSelectors", [pubTool]) + kwargs.setdefault("MSSimulationSelectors", [pubTool]) + + caloSimSelectors = [] + tool = acc.popToolsAndMerge(MuonAFIIGeant4SelectorCfg(flags)) + acc.addPublicTool(tool) + caloSimSelectors += [acc.getPublicTool(tool.name)] + tool = acc.popToolsAndMerge(EtaGreater5ParticleKillerSimSelectorCfg(flags)) + acc.addPublicTool(tool) + caloSimSelectors += [acc.getPublicTool(tool.name)] + tool = acc.popToolsAndMerge(DefaultLegacyAFIIFastCaloSimSelectorCfg(flags)) + acc.addPublicTool(tool) + caloSimSelectors += [acc.getPublicTool(tool.name)] + kwargs.setdefault("CaloSimulationSelectors", caloSimSelectors) + + tool = acc.popToolsAndMerge(DefaultParticleKillerSelectorCfg(flags)) + acc.addPublicTool(tool) + pubTool = acc.getPublicTool(tool.name) + kwargs.setdefault("CavernSimulationSelectors", [pubTool]) + + kwargs.setdefault("SimulationTools", [ + acc.popToolsAndMerge(ParticleKillerToolCfg(flags)), + acc.popToolsAndMerge(LegacyAFIIFastCaloToolCfg(flags)), + acc.popToolsAndMerge(AFIIGeant4ToolCfg(flags)) + ]) + + kwargs.setdefault("ParticleOrderingTool", acc.popToolsAndMerge(EnergyParticleOrderingToolCfg(flags))) # not migrated simFlags.SimulationFlavour = "ATLFASTII" acc.merge(Kernel_GenericSimulatorMTCfg(flags, name, **kwargs)) @@ -185,45 +210,56 @@ def Kernel_ATLFASTIIMTCfg(flags, name="ISF_Kernel_ATLFASTIIMT", **kwargs): def Kernel_ATLFASTIIFMTCfg(flags, name="ISF_Kernel_ATLFASTIIFMT", **kwargs): acc = ComponentAccumulator() - acc.merge(ParticleKillerToolCfg(flags)) - acc.merge(FastCaloToolBaseCfg(flags)) - acc.merge(fatrasSimToolCfg(flags)) - PKtool = acc.getPublicTool("ISF_ParticleKillerTool") - FastCalotool = acc.getPublicTool("ISF_FastCaloTool") - Fatrastool = acc.getPublicTool("ISF_FatrasSimTool") - kwargs.setdefault("SimulationTools", [PKtool, FastCalotool, Fatrastool]) + kwargs.setdefault("SimulationTools", [ + acc.popToolsAndMerge(ParticleKillerToolCfg(flags)), + acc.popToolsAndMerge(FastCaloToolBaseCfg(flags)), + acc.popToolsAndMerge(fatrasSimToolCfg(flags)) + ]) # not migrated 'simFlags.SimulationFlavour = "ATLFASTIIF"' acc.merge(Kernel_GenericSimulatorNoG4MTCfg(flags, name, **kwargs)) return acc -# non-MT -# Note: mostly not migrated -def Kernel_GenericSimulatorCfg(flags, name="ISF_Kernel_GenericSimulator", **kwargs): +def Kernel_G4FastCaloMT(flags, name="ISF_Kernel_G4FastCaloMT", **kwargs): acc = ComponentAccumulator() - acc.merge(InputConverterCfg(flags)) - kwargs.setdefault("InputConverter", acc.getService("ISF_InputConverter")) - - acc.merge(ParticleBrokerSvcCfg(flags)) - kwargs.setdefault("ParticleBroker", acc.getService("ISF_ParticleBrokerSvc")) - - truthacc = TruthServiceCfg(flags) - kwargs.setdefault("TruthRecordService", truthacc.getPrimary()) - acc.merge(truthacc) - - tool = acc.popToolsAndMerge(MemoryMonitorToolCfg(flags)) - kwargs.setdefault("MemoryMonitoringTool", tool) - - kwargs.setdefault("DoCPUMonitoring", flags.Sim.ISF.DoTimeMonitoring) - kwargs.setdefault("DoMemoryMonitoring", flags.Sim.ISF.DoMemoryMonitoring) - kwargs.setdefault("InputHardScatterCollection", "BeamTruthEvent") - kwargs.setdefault("OutputHardScatterTruthCollection", "TruthEvent") - - acc.addEventAlgo(CompFactory.ISF.SimKernelCfg(name, **kwargs)) + # BeamPipe, ID, MS Simulation Selectors + tool = acc.popToolsAndMerge(DefaultAFIIGeant4SelectorCfg(flags)) + acc.addPublicTool(tool) + pubTool = acc.getPublicTool(tool.name) + kwargs.setdefault("BeamPipeSimulationSelectors", [pubTool]) + kwargs.setdefault("IDSimulationSelectors" , [pubTool]) + kwargs.setdefault("MSSimulationSelectors" , [pubTool]) + + # CaloSimulationSelectors + acc.addPublicTool(acc.popToolsAndMerge(MuonAFIIGeant4SelectorCfg(flags))) + acc.addPublicTool(acc.popToolsAndMerge(EtaGreater5ParticleKillerSimSelectorCfg(flags))) + acc.addPublicTool(acc.popToolsAndMerge(PionG4FastCaloGeant4Selector(flags))) + acc.addPublicTool(acc.popToolsAndMerge(ProtonG4FastCaloGeant4Selector(flags))) + acc.addPublicTool(acc.popToolsAndMerge(NeutronG4FastCaloGeant4Selector(flags))) + acc.addPublicTool(acc.popToolsAndMerge(ChargedKaonG4FastCaloGeant4Selector(flags))) + acc.addPublicTool(acc.popToolsAndMerge(KLongG4FastCaloGeant4Selector(flags))) + acc.addPublicTool(acc.popToolsAndMerge(DefaultFastCaloSimV2SelectorCfg(flags))) + kwargs.setdefault("CaloSimulationSelectors" , [ acc.getPublicTool("ISF_MuonAFIIGeant4Selector"), + acc.getPublicTool("ISF_EtaGreater5ParticleKillerSimSelector"), + acc.getPublicTool("ISF_PionG4FastCaloGeant4Selector"), + acc.getPublicTool("ISF_ProtonG4FastCaloGeant4Selector"), + acc.getPublicTool("ISF_NeutronG4FastCaloGeant4Selector"), + acc.getPublicTool("ISF_ChargedKaonG4FastCaloGeant4Selector"), + acc.getPublicTool("ISF_KLongG4FastCaloGeant4Selector"), + acc.getPublicTool("ISF_DefaultFastCaloSimV2Selector") ]) + # CavernSimulationSelectors + acc.addPublicTool(acc.popToolsAndMerge(DefaultParticleKillerSelectorCfg(flags))) + kwargs.setdefault("CavernSimulationSelectors" , [ acc.getPublicTool("ISF_DefaultParticleKillerSelector") ]) + + kwargs.setdefault("SimulationTools" , [ acc.popToolsAndMerge(ParticleKillerToolCfg(flags)), + acc.popToolsAndMerge(FastCaloSimV2ToolCfg(flags)), + acc.popToolsAndMerge(AFIIGeant4ToolCfg(flags)) ]) + kwargs.setdefault("ParticleOrderingTool" , acc.popToolsAndMerge(ParticleOrderingToolCfg(flags))) + + tool = acc.popToolsAndMerge(AFIIEntryLayerToolMTCfg(flags)) + acc.addPublicTool(tool) + kwargs.setdefault("EntryLayerTool" , acc.getPublicTool(tool.name)) # public ToolHandle + acc.merge(Kernel_GenericSimulatorMTCfg(flags, name, **kwargs)) return acc - - -def Kernel_GenericSimulatorNoG4Cfg(flags, name="ISF_Kernel_GenericSimulatorNoG4", **kwargs): - return Kernel_GenericSimulatorCfg(flags, name, **kwargs) diff --git a/Simulation/ISF/ISF_Core/ISF_Algorithms/python/collection_merger_helpersNew.py b/Simulation/ISF/ISF_Core/ISF_Algorithms/python/collection_merger_helpersNew.py index c9934f5f5621b168a6230130e6a2181de908bf80..46a5f8166bcaae839bfd3b3d5cdac40caabfb290 100644 --- a/Simulation/ISF/ISF_Core/ISF_Algorithms/python/collection_merger_helpersNew.py +++ b/Simulation/ISF/ISF_Core/ISF_Algorithms/python/collection_merger_helpersNew.py @@ -37,6 +37,4 @@ def CollectionMergerCfg(ConfigFlags, else: mergeable_collection = bare_collection_name - print (result) - print ("#################################") return result, mergeable_collection diff --git a/Simulation/ISF/ISF_Core/ISF_Services/python/ISF_ServicesConfigNew.py b/Simulation/ISF/ISF_Core/ISF_Services/python/ISF_ServicesConfigNew.py index 8904278b810a94f59bd3f512790392ea95ad54e4..bf37c833007c33f4a08a7c3a1928d2a457c83674 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/python/ISF_ServicesConfigNew.py +++ b/Simulation/ISF/ISF_Core/ISF_Services/python/ISF_ServicesConfigNew.py @@ -78,9 +78,9 @@ def LongLivedInputConverterCfg(ConfigFlags, name="ISF_LongLivedInputConverter", def ParticleBrokerSvcNoOrderingCfg(ConfigFlags, name="ISF_ParticleBrokerSvcNoOrdering", **kwargs): result = ComponentAccumulator() if "EntryLayerTool" not in kwargs: - result.merge(EntryLayerToolCfg(ConfigFlags)) - tool = result.getPublicTool("ISF_EntryLayerTool") - kwargs.setdefault("EntryLayerTool", tool) + tool = result.popToolsAndMerge(EntryLayerToolCfg(ConfigFlags)) + result.addPublicTool(tool) + kwargs.setdefault("EntryLayerTool", result.getPublicTool(tool.name)) kwargs.setdefault("GeoIDSvc", result.getService("ISF_GeoIDSvc")) # assume "GeoIDSvc" has been set alongside "EntryLayerTool" kwargs.setdefault("AlwaysUseGeoIDSvc", False) @@ -106,9 +106,11 @@ def ParticleBrokerSvcCfg(ConfigFlags, name="ISF_ParticleBrokerSvc", **kwargs): def AFIIParticleBrokerSvcCfg(ConfigFlags, name="ISF_AFIIParticleBrokerSvc", **kwargs): - result = AFIIEntryLayerToolCfg(ConfigFlags) - tool = result.getPublicTool("ISF_AFIIEntryLayerTool") - kwargs.setdefault("EntryLayerTool", tool) + result = ComponentAccumulator() + tool = result.popToolsAndMerge(AFIIEntryLayerToolCfg(ConfigFlags)) + result.addPublicTool(tool) + + kwargs.setdefault("EntryLayerTool", result.getPublicTool(tool.name)) kwargs.setdefault("GeoIDSvc", result.getService("ISF_AFIIGeoIDSvc")) result.merge(ParticleBrokerSvcCfg(ConfigFlags, name, **kwargs)) return result diff --git a/Simulation/ISF/ISF_Core/ISF_Tools/python/ISF_ToolsConfigNew.py b/Simulation/ISF/ISF_Core/ISF_Tools/python/ISF_ToolsConfigNew.py index ffe8e8cbc4d0abd92aaf1751592cc1f4f129f819..befd9dd94adeabe1823375c5472d06015463bfe7 100644 --- a/Simulation/ISF/ISF_Core/ISF_Tools/python/ISF_ToolsConfigNew.py +++ b/Simulation/ISF/ISF_Core/ISF_Tools/python/ISF_ToolsConfigNew.py @@ -162,5 +162,5 @@ def EnergyParticleOrderingToolCfg(flags, name="ISF_EnergyParticleOrderingTool", def ParticleKillerToolCfg(flags, name="ISF_ParticleKillerTool", **kwargs): acc = ComponentAccumulator() - acc.addPublicTool(CompFactory.ISF.ParticleKillerSimTool(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.ParticleKillerSimTool(name, **kwargs)) return acc diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/ISF_FastCaloSimParametrizationConfigNew.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/ISF_FastCaloSimParametrizationConfigNew.py index d68568a75c9d09f15a72190e4ed1175c15e709fd..83cc2ec21027f451a48db6a393e4361deca2dd39 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/ISF_FastCaloSimParametrizationConfigNew.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/ISF_FastCaloSimParametrizationConfigNew.py @@ -3,18 +3,30 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration """ from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from FastCaloSim.FastCaloSimFactoryNew import NITimedExtrapolatorCfg def FastCaloSimCaloExtrapolationCfg(flags, name="FastCaloSimCaloExtrapolation", **kwargs): + acc = ComponentAccumulator() + + Extrapolator = acc.popToolsAndMerge(NITimedExtrapolatorCfg(flags)) + acc.addPublicTool(Extrapolator) + GeometryHelper = acc.popToolsAndMerge(FastCaloSimGeometryHelperCfg(flags)) + acc.addPublicTool(GeometryHelper) + kwargs.setdefault("CaloBoundaryR", [1148.0, 120.0, 41.0]) kwargs.setdefault("CaloBoundaryZ", [3550.0, 4587.0, 4587.0]) kwargs.setdefault("CaloMargin", 100) - kwargs.setdefault("Extrapolator", NITimedExtrapolatorCfg(flags)) - kwargs.setdefault("CaloGeometryHelper", FastCaloSimGeometryHelperCfg(flags)) - kwargs.setdefault("CaloEntrance", "InDet::Containers::InnerDetector") + kwargs.setdefault("Extrapolator", acc.getPublicTool(Extrapolator.name)) + kwargs.setdefault("CaloGeometryHelper", acc.getPublicTool(GeometryHelper.name)) + from TrkDetDescrSvc.TrkDetDescrJobProperties import TrkDetFlags + kwargs.setdefault("CaloEntrance", TrkDetFlags.InDetContainerName()) - return CompFactory.FastCaloSimCaloExtrapolation(name, **kwargs) + acc.setPrivateTools(CompFactory.FastCaloSimCaloExtrapolation(name, **kwargs)) + return acc def FastCaloSimGeometryHelperCfg(flags, name="FastCaloSimGeometryHelper", **kwargs): - return CompFactory.FastCaloSimGeometryHelper(name, **kwargs) + acc = ComponentAccumulator() + acc.setPrivateTools(CompFactory.FastCaloSimGeometryHelper(name, **kwargs)) + return acc diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/CMakeLists.txt b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/CMakeLists.txt index f0e196d732163a517514e30aba88b3021caa42fd..707085f4eff235364f868f69907a826f10b58538 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/CMakeLists.txt +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/CMakeLists.txt @@ -20,4 +20,5 @@ atlas_add_component( ISF_FastCaloSimServices atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_add_test( ISF_FastCaloSimServices_Config_test - SCRIPT test/FastCaloSimServices_test.py) \ No newline at end of file + SCRIPT test/FastCaloSimServicesTest.py -n 3 + PROPERTIES TIMEOUT 600) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimHelpers.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimHelpers.py index e3b6c6a5307ed015aee7b9c6aa5623811c2a77ea..74c4c4c4c3d15b4607936c2bea7d6a07714fc15e 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimHelpers.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimHelpers.py @@ -3,7 +3,6 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration """ -#TODO: Do we need this to be function or can it just be an array? def AdditionalParticleParametrizationFileNames(): return [ "DB=/GLOBAL/AtlfastII/FastCaloSimParam:2:EnergyResults/pdgid_211/EN_1000/eta_central", diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfigNew.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfigNew.py index 3e8a1a442c4dfe77a354252f36f61b6d80c904f4..1fc512a9aab7f10ac6141c72f6b1b9f8c348d9de 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfigNew.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfigNew.py @@ -1,18 +1,17 @@ """ComponentAccumulator service configuration for ISF_FastCaloSimServices -Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration """ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory from RngComps.RandomServices import RNG ################################################################################################### -# Moved from AdditionalConfigNew +# Moved from AdditionalConfig from ISF_FastCaloSimParametrization.ISF_FastCaloSimParametrizationConfigNew import FastCaloSimCaloExtrapolationCfg from FastCaloSim.FastCaloSimFactoryNew import (NITimedExtrapolatorCfg, - FastShowerCellBuilderToolCfg) -from FastCaloSim.AddNoiseCellBuilderToolConfig import AddNoiseCellBuilderToolCfg + FastShowerCellBuilderToolBaseCfg) def PunchThroughToolCfg(flags, name="ISF_PunchThroughTool", **kwargs): @@ -38,75 +37,77 @@ def PunchThroughToolCfg(flags, name="ISF_PunchThroughTool", **kwargs): acc.merge(EnvelopeDefSvcCfg(flags)) kwargs.setdefault("EnvelopeDefSvc", acc.getService("AtlasGeometry_EnvelopeDefSvc")) kwargs.setdefault("BeamPipeRadius", 500.) - acc.addPublicTool(CompFactory.ISF.PunchThroughTool(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.PunchThroughTool(name, **kwargs)) return acc def EmptyCellBuilderToolCfg(flags, name="ISF_EmptyCellBuilderTool", **kwargs): acc = ComponentAccumulator() - acc.addPublicTool(CompFactory.EmptyCellBuilderTool(name, **kwargs)) + acc.setPrivateTools(CompFactory.EmptyCellBuilderTool(name, **kwargs)) return acc def LegacyFastShowerCellBuilderToolCfg(flags, name="ISF_LegacyFastShowerCellBuilderTool", **kwargs): - acc = FastShowerCellBuilderToolCfg(flags, name, **kwargs) - FastShowerCellBuilderTool = acc.getPublicTool("ISF_FastShowerCellBuilderTool") + acc = FastShowerCellBuilderToolBaseCfg(flags, name, **kwargs) + FastShowerCellBuilderTool = acc.popPrivateTools() FastShowerCellBuilderTool.Invisibles += [13] return acc + def PileupFastShowerCellBuilderToolCfg(flags, name="ISF_PileupFastShowerCellBuilderTool", **kwargs): # weights from: # https://acode-browser.usatlas.bnl.gov/lxr/source/athena/Simulation/FastShower/FastCaloSim/FastCaloSim/FastCaloSim_CaloCell_ID.h weightsfcs = [ - ### LAr presampler - #FirstSample=CaloCell_ID::PreSamplerB, - 2.0, - ### LAr barrel - #PreSamplerB=CaloCell_ID::PreSamplerB, - #EMB1=CaloCell_ID::EMB1, - #EMB2=CaloCell_ID::EMB2, - #EMB3=CaloCell_ID::EMB3, - 2.0, 2.0, 2.0, 2.0, - ### LAr EM endcap - #PreSamplerE=CaloCell_ID::PreSamplerE, - #EME1=CaloCell_ID::EME1, - #EME2=CaloCell_ID::EME2, - #EME3=CaloCell_ID::EME3, - 2.0, 2.0, 2.0, 2.0, - ### Hadronic end cap cal. - #HEC0=CaloCell_ID::HEC0, - #HEC1=CaloCell_ID::HEC1, - #HEC2=CaloCell_ID::HEC2, - #HEC3=CaloCell_ID::HEC3, - 2.0, 2.0, 2.0, 2.0, - ### Tile barrel - #TileBar0=CaloCell_ID::TileBar0, - #TileBar1=CaloCell_ID::TileBar1, - #TileBar2=CaloCell_ID::TileBar2, - 1.0, 1.0, 1.0, - ### Tile gap (ITC & scint) - #TileGap1=CaloCell_ID::TileGap1, - #TileGap2=CaloCell_ID::TileGap2, - #TileGap3=CaloCell_ID::TileGap3, - 1.0, 1.0, 1.0, - ### Tile extended barrel - #TileExt0=CaloCell_ID::TileExt0, - #TileExt1=CaloCell_ID::TileExt1, - #TileExt2=CaloCell_ID::TileExt2, - 1.0, 1.0, 1.0, - ### Forward EM endcap - #FCAL0=CaloCell_ID::FCAL0, - #FCAL1=CaloCell_ID::FCAL1, - #FCAL2=CaloCell_ID::FCAL2, - 1.0, 1.0, 1.0, - ### Beware of MiniFCAL! We don"t have it, so different numbers after FCAL2 - #LastSample = CaloCell_ID::FCAL2, - #MaxSample = LastSample+1 - 1.0, 1.0, + ### LAr presampler + #FirstSample=CaloCell_ID::PreSamplerB, + 2.0, + ### LAr barrel + #PreSamplerB=CaloCell_ID::PreSamplerB, + #EMB1=CaloCell_ID::EMB1, + #EMB2=CaloCell_ID::EMB2, + #EMB3=CaloCell_ID::EMB3, + 2.0, 2.0, 2.0, 2.0, + ### LAr EM endcap + #PreSamplerE=CaloCell_ID::PreSamplerE, + #EME1=CaloCell_ID::EME1, + #EME2=CaloCell_ID::EME2, + #EME3=CaloCell_ID::EME3, + 2.0, 2.0, 2.0, 2.0, + ### Hadronic end cap cal. + #HEC0=CaloCell_ID::HEC0, + #HEC1=CaloCell_ID::HEC1, + #HEC2=CaloCell_ID::HEC2, + #HEC3=CaloCell_ID::HEC3, + 2.0, 2.0, 2.0, 2.0, + ### Tile barrel + #TileBar0=CaloCell_ID::TileBar0, + #TileBar1=CaloCell_ID::TileBar1, + #TileBar2=CaloCell_ID::TileBar2, + 1.0, 1.0, 1.0, + ### Tile gap (ITC & scint) + #TileGap1=CaloCell_ID::TileGap1, + #TileGap2=CaloCell_ID::TileGap2, + #TileGap3=CaloCell_ID::TileGap3, + 1.0, 1.0, 1.0, + ### Tile extended barrel + #TileExt0=CaloCell_ID::TileExt0, + #TileExt1=CaloCell_ID::TileExt1, + #TileExt2=CaloCell_ID::TileExt2, + 1.0, 1.0, 1.0, + ### Forward EM endcap + #FCAL0=CaloCell_ID::FCAL0, + #FCAL1=CaloCell_ID::FCAL1, + #FCAL2=CaloCell_ID::FCAL2, + 1.0, 1.0, 1.0, + ### Beware of MiniFCAL! We don"t have it, so different numbers after FCAL2 + #LastSample = CaloCell_ID::FCAL2, + #MaxSample = LastSample+1 + 1.0, 1.0, ] kwargs.setdefault("sampling_energy_reweighting", weightsfcs ) - return FastShowerCellBuilderToolCfg(flags, name, **kwargs) + return FastShowerCellBuilderToolBaseCfg(flags, name, **kwargs) + def FastHitConvertToolCfg(flags, name="ISF_FastHitConvertTool", **kwargs): from ISF_Algorithms.collection_merger_helpersNew import CollectionMergerCfg @@ -171,75 +172,64 @@ def FastHitConvertToolCfg(flags, name="ISF_FastHitConvertTool", **kwargs): kwargs.setdefault("hecHitContainername", HEC_hits_collection_name) kwargs.setdefault("tileHitContainername", tile_hits_collection_name) - acc.addPublicTool(CompFactory.FastHitConvertTool(name, **kwargs)) + acc.setPrivateTools(CompFactory.FastHitConvertTool(name, **kwargs)) return acc -# TODO: do we need this - nowhere called? -# def CaloNoiseToolCfg(flags, name="ISF_FCS_CaloNoiseTool", **kwargs): -# from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault -# return CaloNoiseToolDefault(name, **kwargs) -def AddNoiseCellBuilderPublicToolCfg(flags, name="ISF_AddNoiseCellBuilderTool", **kwargs): - acc = AddNoiseCellBuilderToolCfg(flags) - tool = acc.popPrivateTools() - acc.addPublicTool(tool) - return acc +def AddNoiseCellBuilderToolCfg(flags, name="ISF_AddNoiseCellBuilderTool", **kwargs): + from FastCaloSim.AddNoiseCellBuilderToolConfig import AddNoiseCellBuilderToolCfg + return AddNoiseCellBuilderToolCfg(flags) def CaloCellContainerFinalizerToolCfg(flags, name="ISF_CaloCellContainerFinalizerTool", **kwargs): acc = ComponentAccumulator() - acc.addPublicTool(CompFactory.CaloCellContainerFinalizerTool(name, **kwargs)) + acc.setPrivateTools(CompFactory.CaloCellContainerFinalizerTool(name, **kwargs)) return acc def CaloCellContainerFCSFinalizerToolCfg(flags, name="ISF_CaloCellContainerFCSFinalizerTool", **kwargs): acc = ComponentAccumulator() - acc.addPublicTool(CompFactory.CaloCellContainerFCSFinalizerTool(name, **kwargs)) + acc.setPrivateTools(CompFactory.CaloCellContainerFCSFinalizerTool(name, **kwargs)) return acc def FastHitConvAlgCfg(flags, name="ISF_FastHitConvAlg", **kwargs): acc = ComponentAccumulator() kwargs.setdefault("CaloCellsInputName" , flags.Sim.FastCalo.CaloCellsName) - # TODO: do we need this? - #from AthenaCommon.DetFlags import DetFlags - #if DetFlags.pileup.LAr_on() or DetFlags.pileup.Tile_on(): - # kwargs.setdefault("doPileup", True) - #else: - # kwargs.setdefault("doPileup", False) acc.addEventAlgo(CompFactory.FastHitConv(name, **kwargs)) return acc def FastCaloToolBaseCfg(flags, name="ISF_FastCaloTool", **kwargs): acc = ComponentAccumulator() - - acc.merge(PunchThroughToolCfg(flags)) - acc.merge(FastShowerCellBuilderToolCfg(flags)) - acc.merge(FastHitConvertToolCfg(flags)) - acc.merge(EmptyCellBuilderToolCfg(flags)) - acc.merge(CaloCellContainerFinalizerToolCfg(flags)) + + PT_tool = acc.popToolsAndMerge(PunchThroughToolCfg(flags)) + acc.addPublicTool(PT_tool) + FastHit = acc.popToolsAndMerge(FastHitConvertToolCfg(flags)) + acc.addPublicTool(FastHit) + EmptyCellBuilder = acc.popToolsAndMerge(EmptyCellBuilderToolCfg(flags)) + acc.addPublicTool(EmptyCellBuilder) + CaloCellContainer = acc.popToolsAndMerge(CaloCellContainerFinalizerToolCfg(flags)) + acc.addPublicTool(CaloCellContainer) + FastShowerCell_tool = acc.popToolsAndMerge(FastShowerCellBuilderToolBaseCfg(flags)) + acc.addPublicTool(FastShowerCell_tool) + Extrapolator = acc.popToolsAndMerge(NITimedExtrapolatorCfg(flags)) + acc.addPublicTool(Extrapolator) + kwargs.setdefault("BatchProcessMcTruth" , False) kwargs.setdefault("SimulateUndefinedBarcodeParticles", False) - kwargs.setdefault("CaloCellsOutputName" , flags.Sim.FastCalo.CaloCellsName) - kwargs.setdefault("PunchThroughTool" , acc.getPublicTool("ISF_PunchThroughTool")) - kwargs.setdefault("DoPunchThroughSimulation" , False) - kwargs.setdefault("CaloCellMakerTools_setup" , [acc.getPublicTool("ISF_EmptyCellBuilderTool")]) - kwargs.setdefault("CaloCellMakerTools_simulate", [acc.getPublicTool("ISF_FastShowerCellBuilderTool")]) - kwargs.setdefault("CaloCellMakerTools_release" , [acc.getPublicTool("ISF_CaloCellContainerFinalizerTool"), - acc.getPublicTool("ISF_FastHitConvertTool")]) - kwargs.setdefault("Extrapolator", NITimedExtrapolatorCfg(flags)) - # FIXME not migrated. Remove or replace - # register the FastCaloSim random number streams - #from G4AtlasApps.SimFlags import simFlags - #if not simFlags.RandomSeedList.checkForExistingSeed(ISF_FastCaloSimFlags.RandomStreamName()): - #simFlags.RandomSeedList.addSeed( ISF_FastCaloSimFlags.RandomStreamName(), 98346412, 12461240) - acc.addPublicTool(CompFactory.ISF.FastCaloTool(name, **kwargs)) + kwargs.setdefault("CaloCellsOutputName" , flags.Sim.FastCalo.CaloCellsName) + kwargs.setdefault("PunchThroughTool" , acc.getPublicTool(PT_tool.name)) + kwargs.setdefault("DoPunchThroughSimulation" , False) + kwargs.setdefault("CaloCellMakerTools_setup" , [acc.getPublicTool(EmptyCellBuilder.name)]) + kwargs.setdefault("CaloCellMakerTools_simulate" , [acc.getPublicTool(FastShowerCell_tool.name)]) + kwargs.setdefault("CaloCellMakerTools_release" , [# AddNoiseCellBuilderToolCfg(flags)", + acc.getPublicTool(CaloCellContainer.name), + acc.getPublicTool(FastHit.name)]) + kwargs.setdefault("Extrapolator", acc.getPublicTool(Extrapolator.name)) + acc.setPrivateTools(CompFactory.ISF.FastCaloTool(name, **kwargs)) return acc -# TODO: Do we need this - can we only call FastCaloToolBaseCfg? -# def FastCaloToolCfg(flags, name="ISF_FastCaloTool", **kwargs): -# return FastCaloToolBaseCfg(flags, name, **kwargs) def FastCaloPileupToolCfg(flags, name="ISF_FastCaloPileupTool", **kwargs): acc = ComponentAccumulator() @@ -247,111 +237,120 @@ def FastCaloPileupToolCfg(flags, name="ISF_FastCaloPileupTool", **kwargs): acc.merge(PileupFastShowerCellBuilderToolCfg(flags)) tool = acc.getPublicTool("ISF_PileupFastShowerCellBuilderTool") kwargs.setdefault("CaloCellMakerTools_simulate", [tool]) - acc.merge(FastCaloToolBaseCfg(name, **kwargs)) + acc.popToolsAndMerge(FastCaloToolBaseCfg(flags, name, **kwargs)) return acc + def LegacyAFIIFastCaloToolCfg(flags, name="ISF_LegacyAFIIFastCaloTool", **kwargs): acc = ComponentAccumulator() kwargs.setdefault("BatchProcessMcTruth", True) acc.merge(LegacyFastShowerCellBuilderToolCfg(flags)) tool = acc.getPublicTool("ISF_LegacyFastShowerCellBuilderTool") kwargs.setdefault("CaloCellMakerTools_simulate", [tool]) - acc.merge(FastCaloToolBaseCfg(name, **kwargs)) + acc.popToolsAndMerge(FastCaloToolBaseCfg(flags, name, **kwargs)) return acc + def FastCaloSimV2ToolCfg(flags, name="ISF_FastCaloSimV2Tool", **kwargs): acc = ComponentAccumulator() - - acc.merge(FastHitConvertToolCfg(flags)) - acc.merge(EmptyCellBuilderToolCfg(flags)) - acc.merge(CaloCellContainerFCSFinalizerToolCfg(flags)) + + FastHit = acc.popToolsAndMerge(FastHitConvertToolCfg(flags)) + acc.addPublicTool(FastHit) + EmptyCellBuilder = acc.popToolsAndMerge(EmptyCellBuilderToolCfg(flags)) + acc.addPublicTool(EmptyCellBuilder) + CaloCellContainer = acc.popToolsAndMerge(CaloCellContainerFCSFinalizerToolCfg(flags)) + acc.addPublicTool(CaloCellContainer) + Extrapolator = acc.popToolsAndMerge(FastCaloSimCaloExtrapolationCfg(flags)) + acc.addPublicTool(Extrapolator) + acc.merge(FastCaloSimV2ParamSvcCfg(flags)) + kwargs.setdefault("CaloCellsOutputName", flags.Sim.FastCalo.CaloCellsName) - kwargs.setdefault("CaloCellMakerTools_setup", [acc.getPublicTool("ISF_EmptyCellBuilderTool")]) - kwargs.setdefault("CaloCellMakerTools_release", [acc.getPublicTool("ISF_CaloCellContainerFCSFinalizerTool"), - acc.getPublicTool("ISF_FastHitConvertTool")]) - kwargs.setdefault("FastCaloSimCaloExtrapolation", FastCaloSimCaloExtrapolationCfg(flags)) - kwargs.setdefault("ParamSvc", acc.popToolsAndMerge(FastCaloSimV2ParamSvcCfg(flags))) + kwargs.setdefault("CaloCellMakerTools_setup", [acc.getPublicTool(EmptyCellBuilder.name)]) + kwargs.setdefault("CaloCellMakerTools_release", [acc.getPublicTool(CaloCellContainer.name), + acc.getPublicTool(FastHit.name)]) + kwargs.setdefault("FastCaloSimCaloExtrapolation", acc.getPublicTool(Extrapolator.name)) + kwargs.setdefault("ParamSvc", acc.getService("ISF_FastCaloSimV2ParamSvc")) acc.merge(RNG(flags.Random.Engine)) kwargs.setdefault("RandomSvc", acc.getService("AthRNGSvc")) kwargs.setdefault("RandomStream", "AthRNGSvc") - kwargs.setdefault("PunchThroughTool", acc.merge(PunchThroughToolCfg(flags))) + kwargs.setdefault("PunchThroughTool", "") acc.setPrivateTools(CompFactory.ISF.FastCaloSimV2Tool(name, **kwargs)) return acc + ################################################################################################### # Config def FastCaloSimSvcCfg(flags, name="ISF_FastCaloSimSvc", **kwargs): acc = ComponentAccumulator() - + if "SimulatorTool" not in kwargs: - acc.merge(FastCaloToolBaseCfg(flags)) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("ISF_FastCaloTool")) + kwargs.setdefault("SimulatorTool", acc.popToolsAndMerge(FastCaloToolBaseCfg(flags))) kwargs.setdefault("Identifier", "FastCaloSim") acc.addService(CompFactory.ISF.LegacySimSvc(name, **kwargs)) return acc def FastCaloSimPileupSvcCfg(flags, name="ISF_FastCaloSimPileupSvc", **kwargs): - acc = FastCaloPileupToolCfg(flags) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("ISF_FastCaloTool")) + acc = ComponentAccumulator() + kwargs.setdefault("SimulatorTool", acc.popToolsAndMerge(FastCaloPileupToolCfg(flags))) acc.merge(FastCaloSimSvcCfg(flags, name, **kwargs)) return acc def LegacyAFIIFastCaloSimSvcCfg(flags, name="ISF_LegacyAFIIFastCaloSimSvc", **kwargs): - acc = LegacyAFIIFastCaloToolCfg(flags) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("ISF_FastCaloTool")) + acc = ComponentAccumulator() + kwargs.setdefault("SimulatorTool", acc.popToolsAndMerge(LegacyAFIIFastCaloToolCfg(flags))) acc.merge(FastCaloSimSvcCfg(flags, name, **kwargs)) return acc def FastHitConvAlgFastCaloSimSvcCfg(flags, name="ISF_FastHitConvAlgFastCaloSimSvc",**kwargs): acc = FastHitConvAlgCfg(flags) - acc.merge(AddNoiseCellBuilderPublicToolCfg(flags)) - acc.merge(CaloCellContainerFCSFinalizerToolCfg(flags)) + acc.merge(AddNoiseCellBuilderToolCfg(flags)) + CaloCellContainer = acc.popToolsAndMerge(CaloCellContainerFCSFinalizerToolCfg(flags)) + acc.addPublicTool(CaloCellContainer) kwargs.setdefault("CaloCellMakerTools_release", [acc.getPublicTool("AddNoiseCellBuilderTool"), - acc.getPublicTool("ISF_CaloCellContainerFCSFinalizerTool")]) + acc.getPublicTool(CaloCellContainer.name)]) # setup FastCaloSim hit converter and add it to the alg sequence: # -> creates HITS from reco cells acc.merge(FastCaloSimSvcCfg(flags, name, **kwargs)) return acc -def FastHitConvAlgLegacyAFIIFastCaloSimSvcCfg(flags, name="ISF_FastHitConvAlgLegacyAFIIFastCaloSimSvc", **kwargs): - kwargs.setdefault("BatchProcessMcTruth", True) #TODO: This seems not to exist - return FastHitConvAlgFastCaloSimSvcCfg(flags, name, **kwargs) - - def FastCaloSimPileupOTSvcCfg(flags, name="ISF_FastCaloSimPileupOTSvc", **kwargs): acc = ComponentAccumulator() - acc.merge(PunchThroughToolCfg(flags)) - acc.merge(FastShowerCellBuilderToolCfg(flags)) - acc.merge(FastHitConvertToolCfg(flags)) - acc.merge(EmptyCellBuilderToolCfg(flags)) - acc.merge(CaloCellContainerFCSFinalizerToolCfg(flags)) + PT_tool = acc.popToolsAndMerge(PunchThroughToolCfg(flags)) + acc.addPublicTool(PT_tool) + FastHit = acc.popToolsAndMerge(FastHitConvertToolCfg(flags)) + acc.addPublicTool(FastHit) + EmptyCellBuilder = acc.popToolsAndMerge(EmptyCellBuilderToolCfg(flags)) + acc.addPublicTool(EmptyCellBuilder) + CaloCellContainer = acc.popToolsAndMerge(CaloCellContainerFCSFinalizerToolCfg(flags)) + acc.addPublicTool(CaloCellContainer) + FastShowerCell_tool = acc.popToolsAndMerge(FastShowerCellBuilderToolBaseCfg(flags)) + acc.addPublicTool(FastShowerCell_tool) + Extrapolator = acc.popToolsAndMerge(NITimedExtrapolatorCfg(flags)) + acc.addPublicTool(Extrapolator) + kwargs.setdefault("BatchProcessMcTruth", False) kwargs.setdefault("SimulateUndefinedBarcodeParticles", False) kwargs.setdefault("Identifier", "FastCaloSim") kwargs.setdefault("CaloCellsOutputName", flags.Sim.FastCalo.CaloCellsName + "PileUp") - kwargs.setdefault("PunchThroughTool", acc.getPublicTool("ISF_PunchThroughTool")) + kwargs.setdefault("PunchThroughTool", acc.getPublicTool(PT_tool.name)) kwargs.setdefault("DoPunchThroughSimulation", False) kwargs.setdefault("PUWeights_lar_bapre", flags.Sim.FastChain.PUWeights_lar_bapre) kwargs.setdefault("PUWeights_lar_hec", flags.Sim.FastChain.PUWeights_lar_hec) kwargs.setdefault("PUWeights_lar_em", flags.Sim.FastChain.PUWeights_lar_em) kwargs.setdefault("PUWeights_tile", flags.Sim.FastChain.PUWeights_tile) - kwargs.setdefault("CaloCellMakerTools_setup", [acc.getPublicTool("ISF_EmptyCellBuilderTool")]) - kwargs.setdefault("CaloCellMakerTools_simulate", [acc.getPublicTool("ISF_FastShowerCellBuilderTool")]) - kwargs.setdefault("CaloCellMakerTools_release", [acc.getPublicTool("ISF_CaloCellContainerFCSFinalizerTool"), - acc.getPublicTool("ISF_FastHitConvertTool")]) - kwargs.setdefault("Extrapolator", NITimedExtrapolatorCfg(flags)) - # FIXME not migrated. Remove or replace - # register the FastCaloSim random number streams - #from G4AtlasApps.SimFlags import simFlags - #if not simFlags.RandomSeedList.checkForExistingSeed(ISF_FastCaloSimFlags.RandomStreamName()): - #simFlags.RandomSeedList.addSeed( ISF_FastCaloSimFlags.RandomStreamName(), 98346412, 12461240) + kwargs.setdefault("CaloCellMakerTools_setup", [acc.getPublicTool(EmptyCellBuilder.name)]) + kwargs.setdefault("CaloCellMakerTools_simulate", [acc.getPublicTool(FastShowerCell_tool.name)]) + kwargs.setdefault("CaloCellMakerTools_release", [ # AddNoiseCellBuilderToolCfg(flags), + acc.getPublicTool(CaloCellContainer.name), + acc.getPublicTool(FastHit.name)]) + kwargs.setdefault("Extrapolator", acc.getPublicTool(Extrapolator.name)) acc.addService(CompFactory.ISF.FastCaloSimSvcPU(name, **kwargs)) return acc @@ -374,23 +373,23 @@ def FastCaloSimV2SvcCfg(flags, name="ISF_FastCaloSimSvcV2", **kwargs): def DNNCaloSimSvcCfg(flags, name="ISF_DNNCaloSimSvc", **kwargs): acc = ComponentAccumulator() - - acc.merge(FastHitConvertToolCfg(flags)) - acc.merge(EmptyCellBuilderToolCfg(flags)) - acc.merge(CaloCellContainerFinalizerToolCfg(flags)) + + FastHit = acc.popToolsAndMerge(FastHitConvertToolCfg(flags)) + acc.addPublicTool(FastHit) + EmptyCellBuilder = acc.popToolsAndMerge(EmptyCellBuilderToolCfg(flags)) + acc.addPublicTool(EmptyCellBuilder) + CaloCellContainer = acc.popToolsAndMerge(CaloCellContainerFinalizerToolCfg(flags)) + acc.addPublicTool(CaloCellContainer) + Extrapolator = acc.popToolsAndMerge(FastCaloSimCaloExtrapolationCfg(flags)) + acc.addPublicTool(Extrapolator) + kwargs.setdefault("CaloCellsOutputName", flags.Sim.FastCalo.CaloCellsName) - kwargs.setdefault("CaloCellMakerTools_setup", [acc.getPublicTool("ISF_EmptyCellBuilderTool")]) - kwargs.setdefault("CaloCellMakerTools_release", [acc.getPublicTool("ISF_CaloCellContainerFinalizerTool"), - acc.getPublicTool("ISF_FastHitConvertTool")]) #DR needed ? + kwargs.setdefault("CaloCellMakerTools_setup", [acc.getPublicTool(EmptyCellBuilder.name)]) + kwargs.setdefault("CaloCellMakerTools_release", [acc.getPublicTool(CaloCellContainer.name), + acc.getPublicTool(FastHit.name)]) #DR needed ? kwargs.setdefault("ParamsInputFilename", flags.Sim.FastCalo.ParamsInputFilename) - kwargs.setdefault("FastCaloSimCaloExtrapolation", FastCaloSimCaloExtrapolationCfg(flags)) - - # FIXME not migrated. Remove or replace - # register the FastCaloSim random number streams - #from G4AtlasApps.SimFlags import simFlags - #if not simFlags.RandomSeedList.checkForExistingSeed(ISF_FastCaloSimFlags.RandomStreamName()): - #simFlags.RandomSeedList.addSeed( ISF_FastCaloSimFlags.RandomStreamName(), 98346412, 12461240) - #kwargs.setdefault("RandomStream", ISF_FastCaloSimFlags.RandomStreamName()) + kwargs.setdefault("FastCaloSimCaloExtrapolation", acc.getPublicTool(Extrapolator.name)) + kwargs.setdefault("RandomStream", "AthRNGSvc") # TODO check acc.merge(RNG(flags.Random.Engine)) kwargs.setdefault("RandomSvc", acc.getService("AthRNGSvc")) acc.addService(CompFactory.ISF.DNNCaloSimSvc(name, **kwargs)) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesTestHelpers.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesTestHelpers.py new file mode 100644 index 0000000000000000000000000000000000000000..5ddc801301c8a05094dba6e6029fad4ee8323d0d --- /dev/null +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesTestHelpers.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python +"""FastCaloSimServices test helpers + +Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +""" + +from argparse import ArgumentParser +from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + + +def JobOptsDumperCfg(flags): + """Configure event loop for FCSServices""" + JobOptsDumperAlg = CompFactory.JobOptsDumperAlg + acc = ComponentAccumulator() + acc.addEventAlgo(JobOptsDumperAlg(FileName="FCSServicesTestConfig.txt")) + return acc + + +def TestMessageSvcCfg(flags): + """MessageSvc for FCSServices""" + MessageSvc = CompFactory.MessageSvc + acc = ComponentAccumulator() + acc.addService(MessageSvc(setError=["HepMcParticleLink"])) + return acc + + +def CommonTestArgumentParser(): + """FCSServices test argument parser""" + parser = ArgumentParser() + parser.add_argument("-n", "--maxEvents", default=3, type=int, + help="The number of events to run. 0 skips execution") + parser.add_argument("-t", "--threads", default=1, type=int, + help="The number of concurrent threads to run. 0 uses serial Athena.") + parser.add_argument("-V", "--verboseAccumulators", default=False, action="store_true", + help="Print full details of the AlgSequence for each accumulator") + parser.add_argument("-S", "--verboseStoreGate", default=False, action="store_true", + help="Dump the StoreGate(s) each event iteration") + parser.add_argument("-o", "--output", default='', type=str, + help="Output RDO file") + parser.add_argument("-s", "--outputSig", default='', type=str, + help="Output RDO_SGNL file") + return parser + + +def defaultTestFlags(configFlags, args): + """Fill default FCSServices flags for testing""" + + from AthenaConfiguration.TestDefaults import defaultTestFiles + configFlags.Input.RunNumber = [284500] + configFlags.Input.OverrideRunNumber = True + configFlags.Input.Files = defaultTestFiles.EVNT # ["root://eosuser.cern.ch///eos/atlas/atlascerngroupdisk/proj-simul/OutputSamples/rel21/mc16_13TeV.photon.E65536.eta20_25.EVNT.merged.pool.root"] + configFlags.Output.HITSFileName = "myHITSnew.pool.root" + + # Sim configFlags + # Flags taken from old config: + configFlags.Sim.TruthStrategy = "MC15aPlus" + configFlags.Sim.PhysicsList = "FTFP_BERT_ATL" + configFlags.Sim.CalibrationRun = "Off" #"DeadLAr" + configFlags.Sim.RecordStepInfo = False + configFlags.Sim.CavernBG = "Signal" + configFlags.Sim.BeamPipeSimMode = 'FastSim' + configFlags.Sim.ReleaseGeoModel = False + configFlags.Sim.ISFRun = True + configFlags.Sim.ISF.Simulator = "G4FastCaloMT" + configFlags.Sim.FastCalo.ParamsInputFilename = "FastCaloSim/MC16/TFCSparam_v011.root" + configFlags.Sim.FastCalo.CaloCellsName = "AllCalo" + + configFlags.IOVDb.GlobalTag = "OFLCOND-MC16-SDR-14" + configFlags.GeoModel.Align.Dynamic = False + configFlags.GeoModel.AtlasVersion = 'ATLAS-R2-2016-01-00-01' + + # Set the detector flags: + # Beam pipe + configFlags.Detector.SimulateBpipe = True + configFlags.Detector.GeometryBpipe = True + + # Inner detectors + configFlags.Detector.SimulateBCM = True + configFlags.Detector.GeometryBCM = True + configFlags.Detector.SimulateDBM = True + configFlags.Detector.GeometryDBM = True + configFlags.Detector.SimulatePixel = True + configFlags.Detector.GeometryPixel = True + configFlags.Detector.SimulateSCT = True + configFlags.Detector.GeometrySCT = True + configFlags.Detector.SimulateTRT = True + configFlags.Detector.GeometryTRT = True + + # Muon + configFlags.Detector.SimulateMuon = True + configFlags.Detector.GeometryMuon = True + configFlags.Detector.SimulateMDT = True + configFlags.Detector.GeometryMDT = True + configFlags.Detector.SimulateRPC = True + configFlags.Detector.GeometryRPC = True + configFlags.Detector.SimulateTGC = True + configFlags.Detector.GeometryTGC = True + configFlags.Detector.SimulateCSC = True + configFlags.Detector.GeometryCSC = True + + # LAr + configFlags.Detector.SimulateLAr = True + configFlags.Detector.GeometryLAr = True + configFlags.Detector.SimulateTile = True + configFlags.Detector.GeometryTile = True + + # Frozen showers OFF = 0 + configFlags.Sim.LArParameterization = 0 + + if args.output: + if args.output == 'None': + configFlags.Output.RDOFileName = '' + else: + configFlags.Output.RDOFileName = args.output + + if args.outputSig: + configFlags.Output.RDO_SGNLFileName = args.outputSig + + +def postprocessAndLockFlags(configFlags, args): + """Postprocess and lock config flags for FCSServices""" + # Flags relating to multithreaded execution + configFlags.Concurrency.NumThreads = args.threads + if args.threads > 0: + configFlags.Scheduler.ShowDataDeps = True + configFlags.Scheduler.ShowDataFlow = True + configFlags.Scheduler.ShowControlFlow = True + configFlags.Concurrency.NumConcurrentEvents = args.threads + + configFlags.lock() + + +def printAndRun(accessor, configFlags, args): + """Common debugging and execution for FCSServices tests""" + # Dump config + if args.verboseAccumulators: + accessor.printConfig(withDetails=True) + if args.verboseStoreGate: + accessor.getService("StoreGateSvc").Dump = True + configFlags.dump() + + # Execute and finish + sc = accessor.run(maxEvents=args.maxEvents) + + # Dump config summary + accessor.printConfig(withDetails=False) + + # Success should be 0 + return not sc.isSuccess() diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/test/FastCaloSimServicesTest.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/test/FastCaloSimServicesTest.py new file mode 100755 index 0000000000000000000000000000000000000000..a21c9c5ae891d8f549b820b3f14f8718fec8e57e --- /dev/null +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/test/FastCaloSimServicesTest.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python +"""Run tests for FastCaloSimServices configuration + +Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +""" + + +def FCSServicesMainCfg(flags): + """Configure event loop for FCSServices""" + acc = MainServicesCfg(flags) + if flags.Concurrency.NumThreads > 0: + AthenaHiveEventLoopMgr = CompFactory.AthenaHiveEventLoopMgr + elmgr = AthenaHiveEventLoopMgr() + else: + AthenaEventLoopMgr = CompFactory.AthenaEventLoopMgr + elmgr = AthenaEventLoopMgr() + elmgr.UseSecondaryEventNumber = True + acc.addService(elmgr) + return acc + + +def FastCaloSimServicesMainCfg(ConfigFlags): + """Main FCSServices configuration""" + + # Construct our accumulator to run + acc = FCSServicesMainCfg(ConfigFlags) + acc.merge(PoolReadCfg(ConfigFlags)) + acc.merge(PoolWriteCfg(ConfigFlags)) + + # Add TileInfoLoader + from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg + acc.merge(TileInfoLoaderCfg(ConfigFlags)) + + # Add BeamEffectsAlg + from BeamEffects.BeamEffectsAlgConfig import BeamEffectsAlgCfg + acc.merge(BeamEffectsAlgCfg(ConfigFlags)) + + # Add Kernel_G4FastCaloMT from ISF_MainConfig + from ISF_Config.ISF_MainConfigNew import Kernel_G4FastCaloMT + acc.merge(Kernel_G4FastCaloMT(ConfigFlags)) + + ItemList = ["EventInfo#*", + "McEventCollection#TruthEvent", + "JetCollection#*"] + + if ConfigFlags.Sim.IncludeParentsInG4Event: + ItemList += ["McEventCollection#GEN_EVENT"] + + ItemList += ["xAOD::JetContainer#*", + "xAOD::JetAuxContainer#*"] + + if ConfigFlags.Detector.SimulateID: + ItemList += ["SiHitCollection#*", + "TRTUncompressedHitCollection#*", + "TrackRecordCollection#CaloEntryLayer"] + + if ConfigFlags.Detector.SimulateITk: + ItemList += ["SiHitCollection#*", + "TrackRecordCollection#CaloEntryLayer"] + + if ConfigFlags.Detector.SimulateCalo: + ItemList += ["CaloCalibrationHitContainer#*", + "LArHitContainer#*", + "TileHitVector#*", + "TrackRecordCollection#MuonEntryLayer"] + + if ConfigFlags.Detector.SimulateMuon: + ItemList += ["RPCSimHitCollection#*", + "TGCSimHitCollection#*", + "MDTSimHitCollection#*", + "TrackRecordCollection#MuonExitLayer"] + if ConfigFlags.Detector.GeometryCSC: + ItemList += ["CSCSimHitCollection#*"] + if ConfigFlags.Detector.GeometrysTGC: + ItemList += ["sTGCSimHitCollection#*"] + if ConfigFlags.Detector.GeometryMM: + ItemList += ["MMSimHitCollection#*"] + + if ConfigFlags.Detector.SimulateLucid: + ItemList += ["LUCID_SimHitCollection#*"] + + if ConfigFlags.Detector.SimulateFwdRegion: + ItemList += ["SimulationHitCollection#*"] + + if ConfigFlags.Detector.SimulateZDC: + ItemList += ["ZDC_SimPixelHit_Collection#*", + "ZDC_SimStripHit_Collection#*"] + + if ConfigFlags.Detector.SimulateALFA: + ItemList += ["ALFA_HitCollection#*", + "ALFA_ODHitCollection#*"] + + if ConfigFlags.Detector.SimulateAFP: + ItemList += ["AFP_TDSimHitCollection#*", + "AFP_SIDSimHitCollection#*"] + + # TimingAlg + ItemList += ["RecoTimingObj#EVNTtoHITS_timings"] + + from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg + acc.merge( OutputStreamCfg(ConfigFlags,"HITS", ItemList=ItemList, disableEventTag=True) ) + + + # FIXME hack to match to buggy behaviour in old style configuration + OutputStreamHITS = acc.getEventAlgo("OutputStreamHITS") + OutputStreamHITS.ItemList.remove("xAOD::EventInfo#EventInfo") + OutputStreamHITS.ItemList.remove("xAOD::EventAuxInfo#EventInfoAux.") + + # FIXME hack because deduplication is broken + PoolAttributes = ["TREE_BRANCH_OFFSETTAB_LEN = '100'"] + PoolAttributes += ["DatabaseName = '" + ConfigFlags.Output.HITSFileName + "'; ContainerName = 'TTree=CollectionTree'; TREE_AUTO_FLUSH = '1'"] + acc.getService("AthenaPoolCnvSvc").PoolAttributes += PoolAttributes + + # Dump config + acc.getService("StoreGateSvc").Dump = True + acc.getService("ConditionStore").Dump = True + acc.printConfig(withDetails=True, summariseProps=True) + + return acc + +if __name__ == '__main__': + + import sys + from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg + from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg + from AthenaConfiguration.MainServicesConfig import MainServicesCfg + + from ISF_FastCaloSimServices.ISF_FastCaloSimServicesTestHelpers import ( + CommonTestArgumentParser, JobOptsDumperCfg, TestMessageSvcCfg, + defaultTestFlags, postprocessAndLockFlags, printAndRun + ) + + + from AthenaCommon.Configurable import Configurable + from AthenaConfiguration.AllConfigFlags import ConfigFlags + from AthenaConfiguration.ComponentFactory import CompFactory + + # Set up new style config + Configurable.configurableRun3Behavior = True + # Configure + args = CommonTestArgumentParser().parse_args() + defaultTestFlags(ConfigFlags, args) + postprocessAndLockFlags(ConfigFlags, args) + + # Construct our accumulator to run + acc = FastCaloSimServicesMainCfg(ConfigFlags) + acc.merge(JobOptsDumperCfg(ConfigFlags)) + acc.merge(TestMessageSvcCfg(ConfigFlags)) + + # Dump pickle + with open("FCSServices_Config.pkl", "wb") as f: + acc.store(f) + + # Print and run + sys.exit(printAndRun(acc, ConfigFlags, args)) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/test/FastCaloSimServices_test.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/test/FastCaloSimServices_test.py deleted file mode 100755 index e14ca0c937f02fc8378b260372877e539516fe23..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/test/FastCaloSimServices_test.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -"""Run tests for FastCaloSimServices configuration - -Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -""" - -from AthenaCommon.Logging import log -from AthenaCommon.Constants import DEBUG -# log.setLevel(DEBUG) - -from AthenaCommon.Configurable import Configurable -from AthenaConfiguration.AllConfigFlags import ConfigFlags -from AthenaConfiguration.MainServicesConfig import MainServicesCfg -from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg -from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg -from ISF_FastCaloSimServices.ISF_FastCaloSimServicesConfigNew import FastCaloSimV2ParamSvcCfg, FastCaloSimV2SvcCfg, DNNCaloSimSvcCfg, FastCaloSimPileupOTSvcCfg, FastCaloToolBaseCfg - -# Set up new style config -Configurable.configurableRun3Behavior = True - -# Configure -ConfigFlags.Input.Files = ['/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'] #defaultTestFiles.EVNT -ConfigFlags.Output.HITSFileName = "myHITSnew.pool.root" -ConfigFlags.Sim.CalibrationRun = "Off" -ConfigFlags.Sim.RecordStepInfo = False -ConfigFlags.Sim.CavernBG = "Signal" -ConfigFlags.Sim.ISFRun = True -ConfigFlags.Sim.BeamPipeSimMode = 'FastSim' -ConfigFlags.Sim.ReleaseGeoModel = False -ConfigFlags.GeoModel.AtlasVersion = 'ATLAS-R2-2015-03-01-00' - -ConfigFlags.lock() - -# Function tests -accAlg = FastCaloSimV2ParamSvcCfg(ConfigFlags) -accAlg.__init__() - -accAlg = FastCaloSimV2SvcCfg(ConfigFlags) -accAlg.__init__() - -accAlg = DNNCaloSimSvcCfg(ConfigFlags) -accAlg.__init__() - -# # Construct our accumulator to run -# acc = MainServicesCfg(ConfigFlags) -# acc.merge(PoolReadCfg(ConfigFlags)) -# acc.merge(PoolWriteCfg(ConfigFlags)) - -# # Dump config -# accAlg.addEventAlgo(CompFactory.JobOptsDumperAlg(FileName="FCS_TestConfig.txt")) -# accAlg.getService("StoreGateSvc").Dump = True -# accAlg.getService("ConditionStore").Dump = True -# accAlg.printConfig(withDetails=True, summariseProps = True) - -# ConfigFlags.dump() - -# # Execute and finish -# sc = accAlg.run(maxEvents=4) - -# # Print and run -# f = open("test.pkl","wb") -# accAlg.store(f) -# f.close() - diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/python/ISF_FatrasConfig.py b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/python/ISF_FatrasConfig.py index 4214e0f529896c4bbdbc1e7cda99c4dd7e6a1335..e6c73291de0781ce29a244d1a4e46f198c91d341 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/python/ISF_FatrasConfig.py +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/python/ISF_FatrasConfig.py @@ -958,7 +958,7 @@ def fatrasSimToolCfg(flags, name="ISF_FatrasSimTool", **kwargs): kwargs.setdefault("RandomNumberService", result.getService("AthRNGSvc")) iFatras__TransportTool = CompFactory.iFatras.TransportTool - result.addPublicTool(iFatras__TransportTool(name=name, **kwargs)) + result.setPrivateTools(iFatras__TransportTool(name=name, **kwargs)) return result diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/python/ISF_Geant4CommonToolsConfigNew.py b/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/python/ISF_Geant4CommonToolsConfigNew.py index 59a6c1bc07d0d833dcd988e3305626ae402f9424..2b0f8fb50f314f2bfcd4291f7ef5c8e72aa2bf00 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/python/ISF_Geant4CommonToolsConfigNew.py +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/python/ISF_Geant4CommonToolsConfigNew.py @@ -22,7 +22,7 @@ def EntryLayerToolCfg(flags, name="ISF_EntryLayerTool", **kwargs): acc.addService(OEsvc) kwargs.setdefault("EvtStore", OEsvc) # For Fast Chain - acc.addPublicTool(CompFactory.ISF.EntryLayerTool(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.EntryLayerTool(name, **kwargs)) return acc @@ -40,7 +40,7 @@ def EntryLayerToolMTCfg(flags, name="ISF_EntryLayerToolMT", **kwargs): acc.addService(OEsvc) kwargs.setdefault("EvtStore", OEsvc) # For Fast Chain - acc.addPublicTool(CompFactory.ISF.EntryLayerToolMT(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.EntryLayerToolMT(name, **kwargs)) return acc @@ -58,7 +58,7 @@ def AFIIEntryLayerToolCfg(flags, name="ISF_AFIIEntryLayerTool", **kwargs): acc.addService(OEsvc) kwargs.setdefault("EvtStore", OEsvc) # For Fast Chain - acc.addPublicTool(CompFactory.ISF.EntryLayerTool(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.EntryLayerTool(name, **kwargs)) return acc @@ -76,5 +76,5 @@ def AFIIEntryLayerToolMTCfg(flags, name="ISF_AFIIEntryLayerToolMT", **kwargs): acc.addService(OEsvc) kwargs.setdefault("EvtStore", OEsvc) # For Fast Chain - acc.addPublicTool(CompFactory.ISF.EntryLayerToolMT(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.EntryLayerToolMT(name, **kwargs)) return acc diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/python/ISF_Geant4ServicesConfigNew.py b/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/python/ISF_Geant4ServicesConfigNew.py index b08091118b5ce69addb4fc119561948b00c0f43e..4aa7376992c2157e172be7f53edb85b5116d049b 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/python/ISF_Geant4ServicesConfigNew.py +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/python/ISF_Geant4ServicesConfigNew.py @@ -22,8 +22,9 @@ def Geant4SimCfg(flags, name="ISFG4SimSvc", **kwargs): acc.addService(G4_DDDBEnvelopeDefSvc) if "SimulatorTool" not in kwargs: - acc.merge(Geant4ToolCfg(flags)) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("ISF_Geant4Tool")) + tool = acc.popToolsAndMerge(Geant4ToolCfg(flags)) + acc.addPublicTool(tool) + kwargs.setdefault("SimulatorTool", acc.getPublicTool(tool.name)) kwargs.setdefault("Identifier", "Geant4") Geant4SimService = CompFactory.iGeant4.Geant4SimSvc(name, **kwargs) acc.addService(Geant4SimService) @@ -31,35 +32,47 @@ def Geant4SimCfg(flags, name="ISFG4SimSvc", **kwargs): def FullGeant4SimCfg(flags, name="ISF_FullGeant4SimSvc", **kwargs): - acc = FullGeant4ToolCfg(flags) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("ISF_FullGeant4Tool")) + acc = ComponentAccumulator() + if "SimulatorTool" not in kwargs: + tool = acc.popToolsAndMerge(FullGeant4ToolCfg(flags)) + acc.addPublicTool(tool) + kwargs.setdefault("SimulatorTool", acc.getPublicTool(tool.name)) acc.merge(Geant4SimCfg(flags, name, **kwargs)) return acc def LongLivedGeant4SimCfg(flags, name="ISF_LongLivedGeant4SimSvc", **kwargs): - acc = LongLivedGeant4ToolCfg(flags) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("ISF_LongLivedGeant4Tool")) + acc = ComponentAccumulator() + tool = acc.popToolsAndMerge(LongLivedGeant4ToolCfg(flags)) + acc.addPublicTool(tool) + kwargs.setdefault("SimulatorTool", acc.getPublicTool(tool.name)) acc.merge(FullGeant4SimCfg(flags, name, **kwargs)) return acc def PassBackGeant4SimCfg(flags, name="ISF_PassBackGeant4SimSvc", **kwargs): - acc = PassBackGeant4ToolCfg(flags) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("ISF_PassBackGeant4Tool")) + acc = ComponentAccumulator() + if "SimulatorTool" not in kwargs: + tool = acc.popToolsAndMerge(PassBackGeant4ToolCfg(flags)) + acc.addPublicTool(tool) + kwargs.setdefault("SimulatorTool", acc.getPublicTool(tool.name)) acc.merge(Geant4SimCfg(flags, name, **kwargs)) return acc def AFIIGeant4SimCfg(flags, name="ISF_AFIIGeant4SimSvc", **kwargs): - acc = AFIIGeant4ToolCfg(flags) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("ISF_AFIIGeant4Tool")) + acc = ComponentAccumulator() + tool = acc.popToolsAndMerge(AFIIGeant4ToolCfg(flags)) + acc.addPublicTool(tool) + kwargs.setdefault("SimulatorTool", acc.getPublicTool(tool.name)) acc.merge(PassBackGeant4SimCfg(flags, name, **kwargs)) return acc def AFII_QS_Geant4SimCfg(flags, name="ISF_AFII_QS_Geant4SimSvc", **kwargs): - acc = AFII_QS_Geant4ToolCfg(flags) - kwargs.setdefault("SimulatorTool", acc.getPublicTool("AFII_QS_Geant4Tool")) + acc = ComponentAccumulator() + tool = acc.popToolsAndMerge(AFII_QS_Geant4ToolCfg(flags)) + acc.addPublicTool(tool) + kwargs.setdefault("SimulatorTool", acc.getPublicTool(tool.name)) acc.merge(PassBackGeant4SimCfg(flags, name, **kwargs)) return acc diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/python/ISF_Geant4ToolsConfigNew.py b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/python/ISF_Geant4ToolsConfigNew.py index 480d0a898236be71e60de48fac4c120af267ed1f..cf24f98697112530cac0b10a0ee2775e5ca3a064 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/python/ISF_Geant4ToolsConfigNew.py +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/python/ISF_Geant4ToolsConfigNew.py @@ -73,26 +73,30 @@ def FullGeant4ToolCfg(flags, name="ISF_FullGeant4Tool", **kwargs): def PassBackGeant4ToolCfg(flags, name="ISF_PassBackGeant4Tool", **kwargs): acc = ISFPassBackUserActionSvcCfg(flags) kwargs.setdefault("UserActionSvc", acc.getService("G4UA::ISFPassBackUserActionSvc")) - acc.merge(Geant4ToolCfg(flags, name, **kwargs)) + PassBackGeant4Tool = acc.popToolsAndMerge(Geant4ToolCfg(flags, name, **kwargs)) + acc.setPrivateTools(PassBackGeant4Tool) return acc def AFIIGeant4ToolCfg(flags, name="ISF_AFIIGeant4Tool", **kwargs): acc = ISF_AFIIUserActionSvcCfg(flags) kwargs.setdefault("UserActionSvc", acc.getService("G4UA::ISF_AFIIUserActionSvc")) - acc.merge(PassBackGeant4ToolCfg(flags, name, **kwargs)) + PassBackGeant4Tool = acc.popToolsAndMerge(PassBackGeant4ToolCfg(flags, name, **kwargs)) + acc.setPrivateTools(PassBackGeant4Tool) return acc def LongLivedGeant4ToolCfg(flags, name="ISF_LongLivedGeant4Tool", **kwargs): acc = LongLivedInputConverterCfg(flags) kwargs.setdefault("InputConverter", acc.getService("ISF_LongLivedInputConverter")) - acc.merge(FullGeant4ToolCfg(flags, name, **kwargs)) + FullGeant4Tool = acc.popToolsAndMerge(FullGeant4ToolCfg(flags, name, **kwargs)) + acc.setPrivateTools(FullGeant4Tool) return acc def AFII_QS_Geant4ToolCfg(flags, name="AFII_QS_Geant4Tool", **kwargs): acc = LongLivedInputConverterCfg(flags) kwargs.setdefault("InputConverter", acc.getService("ISF_LongLivedInputConverter")) - acc.merge(AFIIGeant4ToolCfg(flags, name, **kwargs)) + AFIIGeant4Tool = acc.popToolsAndMerge(AFIIGeant4ToolCfg(flags, name, **kwargs)) + acc.setPrivateTools(AFIIGeant4Tool) return acc diff --git a/Simulation/ISF/ISF_SimulationSelectors/python/ISF_SimulationSelectorsConfigNew.py b/Simulation/ISF/ISF_SimulationSelectors/python/ISF_SimulationSelectorsConfigNew.py index 5085814f5c9819e58bda06d424f6aec7f0e79b62..20c545bce521698ae29d1f5e25f987e2f65a014a 100644 --- a/Simulation/ISF/ISF_SimulationSelectors/python/ISF_SimulationSelectorsConfigNew.py +++ b/Simulation/ISF/ISF_SimulationSelectors/python/ISF_SimulationSelectorsConfigNew.py @@ -16,7 +16,6 @@ from ISF_FastCaloSimServices.ISF_FastCaloSimServicesConfigNew import ( FastCaloSimSvcCfg, LegacyAFIIFastCaloSimSvcCfg, FastCaloSimV2SvcCfg, DNNCaloSimSvcCfg, FastHitConvAlgFastCaloSimSvcCfg, - FastHitConvAlgLegacyAFIIFastCaloSimSvcCfg, FastCaloSimPileupSvcCfg, FastCaloSimPileupOTSvcCfg, ) from ISF_FatrasServices.ISF_FatrasConfig import ( @@ -25,18 +24,12 @@ from ISF_FatrasServices.ISF_FatrasConfig import ( ) -def DefaultSimSelectorCfg(flags, name="ISF_DefaultSimSelector", **kwargs): - acc = ComponentAccumulator() - acc.addPublicTool(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) - return acc - - def DefaultParticleKillerSelectorCfg(flags, name="ISF_DefaultParticleKillerSelector", **kwargs): acc = ParticleKillerSvcCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_ParticleKillerSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.ParticleKiller) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -46,7 +39,7 @@ def PileupParticleKillerSelectorCfg(flags, name="ISF_PileupParticleKillerSelecto if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_ParticleKillerSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.ParticleKiller) - acc.addPublicTool(CompFactory.ISF.KinematicPileupSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicPileupSimSelector(name, **kwargs)) return acc @@ -55,7 +48,7 @@ def DefaultGeant4SelectorCfg(flags, name="ISF_DefaultGeant4Selector", **kwargs): if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -63,7 +56,8 @@ def DefaultAFIIGeant4SelectorCfg(flags, name="ISF_DefaultAFIIGeant4Selector", ** acc = AFIIGeant4SimCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) - acc.merge(DefaultGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(DefaultGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -71,7 +65,8 @@ def DefaultLongLivedGeant4SelectorCfg(flags, name="ISF_DefaultLongLivedGeant4Sel acc = LongLivedGeant4SimCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_LongLivedGeant4SimSvc")) - acc.merge(DefaultGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(DefaultGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -79,7 +74,8 @@ def DefaultAFII_QS_Geant4SelectorCfg(flags, name="ISF_DefaultAFII_QS_Geant4Selec acc = AFII_QS_Geant4SimCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFII_QS_Geant4SimSvc")) - acc.merge(DefaultGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(DefaultGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -89,7 +85,7 @@ def FullGeant4SelectorCfg(flags, name="ISF_FullGeant4Selector", **kwargs): acc.merge(FullGeant4SimCfg(flags)) kwargs.setdefault("Simulator", acc.getService("ISF_FullGeant4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -98,7 +94,7 @@ def PassBackGeant4SelectorCfg(flags, name="ISF_PassBackGeant4Selector", **kwargs if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_PassBackGeant4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -107,7 +103,7 @@ def DefaultFastCaloSimSelectorCfg(flags, name="ISF_DefaultFastCaloSimSelector", if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FastCaloSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.FastCaloSim) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -116,7 +112,7 @@ def DefaultLegacyAFIIFastCaloSimSelectorCfg(flags, name="ISF_DefaultLegacyAFIIFa if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_LegacyAFIIFastCaloSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.FastCaloSim) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -125,7 +121,7 @@ def DefaultFastCaloSimV2SelectorCfg(flags, name="ISF_DefaultFastCaloSimV2Selecto if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FastCaloSimSvcV2")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.FastCaloSimV2) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -133,7 +129,7 @@ def DefaultDNNCaloSimSelectorCfg(flags, name="ISF_DefaultDNNCaloSimSelector", ** acc = DNNCaloSimSvcCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_DNNCaloSimSvc")) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -143,17 +139,7 @@ def FastHitConvAlgFastCaloSimSelectorCfg(flags, name="ISF_FastHitConvAlgFastCalo if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FastHitConvAlgFastCaloSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.FastCaloSim) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) - return acc - - -def FastHitConvAlgLegacyAFIIFastCaloSimSelectorCfg(flags, name="ISF_FastHitConvAlgLegacyAFIIFastCaloSimSelector", **kwargs): - acc = ComponentAccumulator() - acc.merge(FastHitConvAlgLegacyAFIIFastCaloSimSvcCfg(flags)) - if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: - kwargs.setdefault("Simulator", acc.getService("ISF_FastHitConvAlgLegacyAFIIFastCaloSimSvc")) - kwargs.setdefault("SimulationFlavor", SimulationFlavor.FastCaloSim) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -162,7 +148,7 @@ def DefaultFatrasSelectorCfg(flags, name="ISF_DefaultFatrasSelector", **kwargs): if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FatrasSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Fatras) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -172,7 +158,7 @@ def DefaultFatrasNewExtrapolationSelectorCfg(flags, name="ISF_DefaultFatrasNewEx if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FatrasNewExtrapolationSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Fatras) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc @@ -181,14 +167,14 @@ def DefaultParametricSimulationSelectorCfg(flags, name="ISF_DefaultParametricSim if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", "ISF_ParametricSimSvc") # TODO kwargs.setdefault("SimulationFlavor", SimulationFlavor.Parametric) - acc.merge(DefaultSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.DefaultSimSelector(name, **kwargs)) return acc # PileUpSimSelector Configurations def PileupSimSelectorCfg(flags, name="ISF_PileupSimSelector", **kwargs): acc = ComponentAccumulator() - acc.addPublicTool(CompFactory.ISF.KinematicPileupSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicPileupSimSelector(name, **kwargs)) return acc @@ -199,7 +185,8 @@ def FatrasPileupSelectorCfg(flags, name="ISF_FatrasPileupSelector", **kwargs): if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FatrasPileupSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.FatrasPileup) - acc.merge(PileupSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(PileupSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -213,7 +200,8 @@ def FastCaloSimPileupSelectorCfg(flags, name="ISF_FastCaloSimPileupSelector", ** if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FastCaloSimPileupSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.FastCaloSimPileup) - acc.merge(PileupSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(PileupSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -223,7 +211,8 @@ def FastCaloSimPileupOTSelectorCfg(flags, name="ISF_FastCaloSimPileupOTSelector" if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FastCaloSimPileupOTSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.FastCaloSimPileup) - acc.merge(PileupSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(PileupSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -234,7 +223,7 @@ def ElectronGeant4SelectorCfg(flags, name="ISF_ElectronGeant4Selector", **kwargs if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -244,7 +233,7 @@ def NeutralGeant4SelectorCfg(flags, name="ISF_NeutralGeant4Selector", **kwargs): if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -255,7 +244,7 @@ def ProtonAFIIGeant4SelectorCfg(flags, name="ISF_ProtonAFIIGeant4Selector", **kw if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -263,7 +252,8 @@ def ProtonAFII_QS_Geant4SelectorCfg(flags, name="ISF_ProtonAFII_QS_Geant4Selecto acc = AFII_QS_Geant4SimCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFII_QS_Geant4SimSvc")) - acc.merge(ProtonAFIIGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(ProtonAFIIGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -274,7 +264,7 @@ def PionAFIIGeant4SelectorCfg(flags, name="ISF_PionAFIIGeant4Selector", **kwargs if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -284,7 +274,8 @@ def PionG4FastCaloGeant4Selector(flags, name="ISF_PionG4FastCaloGeant4Selector", kwargs.setdefault("ParticlePDG", 211) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -294,7 +285,8 @@ def ProtonG4FastCaloGeant4Selector(flags, name="ISF_ProtonG4FastCaloGeant4Select kwargs.setdefault("ParticlePDG", 2212) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -304,7 +296,8 @@ def NeutronG4FastCaloGeant4Selector(flags, name="ISF_NeutronG4FastCaloGeant4Sele kwargs.setdefault("ParticlePDG", 2112) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -314,7 +307,8 @@ def ChargedKaonG4FastCaloGeant4Selector(flags, name="ISF_ChargedKaonG4FastCaloGe kwargs.setdefault("ParticlePDG", 321) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -324,7 +318,8 @@ def KLongG4FastCaloGeant4Selector(flags, name="ISF_KLongG4FastCaloGeant4Selector kwargs.setdefault("ParticlePDG", 130) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -332,7 +327,8 @@ def PionAFII_QS_Geant4SelectorCfg(flags, name="ISF_PionAFII_QS_Geant4Selector", acc = AFII_QS_Geant4SimCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFII_QS_Geant4SimSvc")) - acc.merge(PionAFIIGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(PionAFIIGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -343,7 +339,7 @@ def ChargedKaonAFIIGeant4SelectorCfg(flags, name="ISF_ChargedKaonAFIIGeant4Selec if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -351,7 +347,8 @@ def ChargedKaonAFII_QS_Geant4SelectorCfg(flags, name="ISF_ChargedKaonAFII_QS_Gea acc = AFII_QS_Geant4SimCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFII_QS_Geant4SimSvc")) - acc.merge(ChargedKaonAFIIGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(ChargedKaonAFIIGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -362,7 +359,7 @@ def KLongAFIIGeant4SelectorCfg(flags, name="ISF_KLongAFIIGeant4Selector", **kwar if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -370,14 +367,15 @@ def KLongAFII_QS_Geant4SelectorCfg(flags, name="ISF_KLongAFII_QS_Geant4Selector" acc = AFII_QS_Geant4SimCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFII_QS_Geant4SimSvc")) - acc.merge(KLongAFIIGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(KLongAFIIGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc def MuonSelectorCfg(flags, name="ISF_MuonSelector", **kwargs): acc = ComponentAccumulator() kwargs.setdefault("ParticlePDG", 13) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -386,7 +384,8 @@ def MuonGeant4SelectorCfg(flags, name="ISF_MuonGeant4Selector", **kwargs): if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(MuonSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(MuonSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -395,7 +394,8 @@ def MuonAFIIGeant4SelectorCfg(flags, name="ISF_MuonAFIIGeant4Selector", **kwargs if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFIIGeant4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(MuonGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(MuonGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -403,7 +403,8 @@ def MuonAFII_QS_Geant4SelectorCfg(flags, name="ISF_MuonAFII_QS_Geant4Selector", acc = AFII_QS_Geant4SimCfg(flags) if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_AFII_QS_Geant4SimSvc")) - acc.merge(MuonGeant4SelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(MuonGeant4SelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -412,7 +413,8 @@ def MuonFatrasSelectorCfg(flags, name="ISF_MuonFatrasSelector", **kwargs): if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FatrasSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Fatras) - acc.merge(MuonSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(MuonSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -424,7 +426,8 @@ def MuonFatrasPileupSelectorCfg(flags, name="ISF_MuonFatrasPileupSelector", **kw kwargs.setdefault("PileupBCID", [1]) kwargs.setdefault("ParticlePDG", 13) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Fatras) - acc.merge(PileupSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(PileupSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -435,7 +438,7 @@ def WithinEta5FastCaloSimSelectorCfg(flags, name="ISF_WithinEta5FastCaloSimSelec kwargs.setdefault("MinPosEta", -5.0) kwargs.setdefault("MaxPosEta", 5.0) kwargs.setdefault("SimulationFlavor", SimulationFlavor.FastCaloSim) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -447,7 +450,7 @@ def EtaGreater5ParticleKillerSimSelectorCfg(flags, name="ISF_EtaGreater5Particle kwargs.setdefault("MaxPosEta", 5.0) kwargs.setdefault("InvertCuts", True) kwargs.setdefault("SimulationFlavor", SimulationFlavor.ParticleKiller) - acc.addPublicTool(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicSimSelector(name, **kwargs)) return acc @@ -459,7 +462,7 @@ def EtaGreater5PileupParticleKillerSimSelectorCfg(flags, name="ISF_EtaGreater5Pi kwargs.setdefault("MaxPosEta", 5.0) kwargs.setdefault("InvertCuts", True) kwargs.setdefault("SimulationFlavor", SimulationFlavor.ParticleKiller) - acc.addPublicTool(CompFactory.ISF.KinematicPileupSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.KinematicPileupSimSelector(name, **kwargs)) return acc @@ -470,7 +473,7 @@ def PhotonConeSelectorCfg(flags, name="ISF_PhotonConeSelector", **kwargs): kwargs.setdefault("ConeCreatorMinPt", 20.*GeV) kwargs.setdefault("ConeSize", 0.6) kwargs.setdefault("CheckConeCreatorAncestors", False) - acc.addPublicTool(CompFactory.ISF.ConeSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.ConeSimSelector(name, **kwargs)) return acc @@ -479,7 +482,8 @@ def PhotonConeFatrasSelectorCfg(flags, name="ISF_PhotonConeFatrasSelector", **kw if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FatrasSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Fatras) - acc.merge(PhotonConeSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(PhotonConeSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -488,7 +492,8 @@ def PhotonConeGeant4SelectorCfg(flags, name="ISF_PhotonConeGeant4Selector", **kw if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(PhotonConeSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(PhotonConeSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -502,7 +507,7 @@ def HiggsLeptonsConeSimSelectorCfg(flags, name="ISF_HiggsLeptonsConeSimSelector" # see HepMC manual for HepMC::GenVertex::particle iterator # 0=parents, 1=family, 2=ancestors, 3=relatives kwargs.setdefault("ConeCreatorAncestorRelation", 1) - acc.addPublicTool(CompFactory.ISF.ConeSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.ConeSimSelector(name, **kwargs)) return acc @@ -511,14 +516,15 @@ def HiggsLeptonsConeGeant4SelectorCfg(flags, name="ISF_HiggsLeptonsConeGeant4Sel if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(HiggsLeptonsConeSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(HiggsLeptonsConeSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc def ElectronsMuonsConeSimSelectorCfg(flags, name="ISF_ElectronsMuonsConeSimSelector", **kwargs): acc = ComponentAccumulator() kwargs.setdefault("ConeCreatorPDGs", [11, 13]) # e, mu - acc.addPublicTool(CompFactory.ISF.ConeSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.ConeSimSelector(name, **kwargs)) return acc @@ -540,7 +546,8 @@ def WLeptonsConeGeant4SelectorCfg(flags, name="ISF_WLeptonsConeGeant4Selector", # see HepMC manual for HepMC::GenVertex::particle iterator # 0=parents, 1=family, 2=ancestors, 3=relatives kwargs.setdefault("ConeCreatorAncestorRelation", 0) - acc.merge(ElectronsMuonsConeSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(ElectronsMuonsConeSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -558,7 +565,8 @@ def ZLeptonsDirectionConeGeant4SelectorCfg(flags, name="ISF_ZLeptonsDirectionCon # see HepMC manual for HepMC::GenVertex::particle iterator # 0=parents, 1=family, 2=ancestors, 3=relatives kwargs.setdefault("ConeCreatorAncestorRelation", 0) - acc.merge(ElectronsMuonsConeSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(ElectronsMuonsConeSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -581,7 +589,8 @@ def JPsiLeptonsConeGeant4SelectorCfg(flags, name="ISF_JPsiLeptonsConeGeant4Selec # see HepMC manual for HepMC::GenVertex::particle iterator # 0=parents, 1=family, 2=ancestors, 3=relatives kwargs.setdefault("ConeCreatorAncestorRelation", 0) - acc.merge(ElectronsMuonsConeSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(ElectronsMuonsConeSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -597,7 +606,7 @@ def BHadronProductsSimSelectorCfg(flags, name="ISF_BHadronProductsSimSelector", # see HepMC manual for HepMC::GenVertex::particle iterator # 0=parents, 1=family, 2=ancestors, 3=relatives kwargs.setdefault("Relation", 2) - acc.addPublicTool(CompFactory.ISF.TruthAssocSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.TruthAssocSimSelector(name, **kwargs)) return acc @@ -606,7 +615,8 @@ def BHadronProductsGeant4SelectorCfg(flags, name="ISF_BHadronProductsGeant4Selec if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(BHadronProductsSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(BHadronProductsSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -615,7 +625,8 @@ def BHadronProductsFatrasSelectorCfg(flags, name="ISF_BHadronProductsFatrasSelec if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISF_FatrasSimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Fatras) - acc.merge(BHadronProductsSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(BHadronProductsSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -625,7 +636,7 @@ def TauProductsSimSelectorCfg(flags, name="ISF_TauProductsSimSelector", **kwargs # see HepMC manual for HepMC::GenVertex::particle iterator # 0=parents, 1=family, 2=ancestors, 3=relatives kwargs.setdefault("Relation", 0) - acc.addPublicTool(CompFactory.ISF.TruthAssocSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.TruthAssocSimSelector(name, **kwargs)) return acc @@ -634,7 +645,8 @@ def TauProductsGeant4SelectorCfg(flags, name="ISF_TauProductsGeant4Selector", ** if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(TauProductsSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(TauProductsSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -644,7 +656,7 @@ def ZProductsSimSelectorCfg(flags, name="ISF_ZProductsSimSelector", **kwargs): # see HepMC manual for HepMC::GenVertex::particle iterator # 0=parents, 1=family, 2=ancestors, 3=relatives kwargs.setdefault("Relation", 0) - acc.addPublicTool(CompFactory.ISF.TruthAssocSimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.TruthAssocSimSelector(name, **kwargs)) return acc @@ -653,7 +665,8 @@ def ZProductsGeant4SelectorCfg(flags, name="ISF_ZProductsGeant4Selector", **kwar if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.merge(ZProductsSimSelectorCfg(flags, name, **kwargs)) + tool = acc.popToolsAndMerge(ZProductsSimSelectorCfg(flags, name, **kwargs)) + acc.setPrivateTools(tool) return acc @@ -665,7 +678,7 @@ def SubDetStickyGeant4SimSelectorCfg(flags, name="ISF_SubDetStickyGeant4SimSelec kwargs.setdefault("PrevSimSvc", acc.getService("ISFG4SimSvc")) kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.addPublicTool(CompFactory.ISF.HistorySimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.HistorySimSelector(name, **kwargs)) return acc @@ -676,5 +689,5 @@ def GlobalStickyGeant4SimSelectorCfg(flags, name="ISF_GlobalStickyGeant4SimSelec if flags.Concurrency.NumThreads == 0 and 'MT' not in flags.Sim.ISF.Simulator: kwargs.setdefault("Simulator", acc.getService("ISFG4SimSvc")) kwargs.setdefault("SimulationFlavor", SimulationFlavor.Geant4) - acc.addPublicTool(CompFactory.ISF.HistorySimSelector(name, **kwargs)) + acc.setPrivateTools(CompFactory.ISF.HistorySimSelector(name, **kwargs)) return acc