1 """Main ISF tools configuration with ComponentAccumulator
3 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from SimulationConfig.SimulationMetadata
import writeSimulationParametersMetadata, readSimulationParameters
8 from ISF_Services.ISF_ServicesCoreConfig
import GeoIDSvcCfg
9 from ISF_Services.ISF_ServicesConfig
import (
10 InputConverterCfg, TruthServiceCfg,
11 ATLFAST_ParticleBrokerSvcCfg, ParticleBrokerSvcNoOrderingCfg
13 from ISF_Tools.ISF_ToolsConfig
import (
14 ParticleKillerToolCfg, EnergyParticleOrderingToolCfg,
15 ParticleOrderingToolCfg, MemoryMonitorToolCfg
17 from ISF_SimulationSelectors.ISF_SimulationSelectorsConfig
import (
18 DefaultATLFAST_Geant4SelectorCfg,
19 DefaultParticleKillerSelectorCfg,
20 EtaGreater5ParticleKillerSimSelectorCfg,
21 FullGeant4SelectorCfg,
22 MuonATLFAST_Geant4SelectorCfg,
23 PassBackGeant4SelectorCfg,
24 DefaultFastCaloSimV2SelectorCfg,
25 PionATLFAST_Geant4SelectorCfg,
26 ProtonATLFAST_Geant4SelectorCfg,
27 NeutronATLFAST_Geant4SelectorCfg,
28 ChargedKaonATLFAST_Geant4SelectorCfg,
29 KLongATLFAST_Geant4SelectorCfg,
30 DefaultFatrasSelectorCfg,
31 DefaultActsSelectorCfg
33 from ISF_Geant4Tools.ISF_Geant4ToolsConfig
import (
34 ATLFAST_Geant4ToolCfg,
36 PassBackGeant4ToolCfg,
38 from ISF_Geant4CommonTools.ISF_Geant4CommonToolsConfig
import (
40 ATLFAST_EntryLayerToolMTCfg
42 AthSequencer=CompFactory.AthSequencer
47 kwargs.setdefault(
"UseShadowEvent", flags.Sim.UseShadowEvent)
48 if flags.Sim.UseShadowEvent
and "TruthPreselectionTool" not in kwargs:
49 from ISF_HepMC_Tools.ISF_HepMC_ToolsConfig
import TruthPreselectionToolCfg
52 if "GeoIDSvc" not in kwargs:
53 kwargs.setdefault(
"GeoIDSvc", acc.getPrimaryAndMerge(
GeoIDSvcCfg(flags)).name)
55 if "TruthRecordService" not in kwargs:
56 kwargs.setdefault(
"TruthRecordService", acc.getPrimaryAndMerge(
TruthServiceCfg(flags)).name)
58 if "EntryLayerTool" not in kwargs:
59 kwargs.setdefault(
"EntryLayerTool", acc.addPublicTool(acc.popToolsAndMerge(
EntryLayerToolMTCfg(flags))))
61 from AthenaConfiguration.Enums
import ProductionStep
62 if flags.Common.ProductionStep == ProductionStep.FastChain:
63 if flags.Digitization.PileUp:
64 OEsvc = CompFactory.StoreGateSvc(
"OriginalEvent_SG")
66 kwargs.setdefault(
"EvtStore", OEsvc.name)
68 kwargs.setdefault(
"Cardinality", flags.Concurrency.NumThreads)
69 kwargs.setdefault(
"InputEvgenCollection",
"BeamTruthEvent")
70 kwargs.setdefault(
"OutputTruthCollection",
"TruthEvent")
71 from SimulationConfig.SimEnums
import CalibrationRun
72 from G4AtlasTools.G4AtlasToolsConfig
import SimHitContainerListCfg, InputContainerListCfg
74 if flags.Sim.CalibrationRun
in [CalibrationRun.LAr, CalibrationRun.LArTile, CalibrationRun.LArTileZDC]:
77 (
'CaloCalibrationHitContainer',
'StoreGateSvc+LArCalibrationHitActive_DEAD' ),
78 (
'CaloCalibrationHitContainer',
'StoreGateSvc+LArCalibrationHitDeadMaterial_DEAD' ),
79 (
'CaloCalibrationHitContainer',
'StoreGateSvc+LArCalibrationHitInactive_DEAD' )
81 kwargs.setdefault(
"ExtraOutputs", ExtraOutputs )
83 if flags.Sim.ISF.Simulator.isQuasiStable():
84 if "QuasiStablePatcher" not in kwargs:
85 from BeamEffects.BeamEffectsAlgConfig
import ZeroLifetimePositionerCfg
87 if "InputConverter" not in kwargs:
88 kwargs.setdefault(
"InputConverter", acc.getPrimaryAndMerge(
InputConverterCfg(flags)).name)
90 if flags.Sim.ISF.ReSimulation:
91 acc.addSequence(
AthSequencer(
'SimSequence'), parentName=
'AthAlgSeq')
92 acc.addEventAlgo(CompFactory.ISF.SimKernelMT(name, **kwargs),
'SimSequence')
94 acc.addEventAlgo(CompFactory.ISF.SimKernelMT(name, **kwargs))
105 defaultG4SelectorRegions =
set([
"BeamPipeSimulationSelectors",
"IDSimulationSelectors",
"CaloSimulationSelectors",
"MSSimulationSelectors"])
106 if flags.Detector.GeometryCavern:
108 defaultG4SelectorRegions.add(
"CavernSimulationSelectors")
109 if defaultG4SelectorRegions - kwargs.keys():
112 for selectorRegion
in defaultG4SelectorRegions:
113 kwargs.setdefault(selectorRegion, [pubTool])
115 if "CavernSimulationSelectors" not in kwargs:
116 kwargs.setdefault(
"CavernSimulationSelectors",
126 if "SimulationTools" not in kwargs:
127 kwargs.setdefault(
"SimulationTools", [
139 kwargs.setdefault(
"SimulationTools", [
152 defaultG4SelectorRegions =
set([
"BeamPipeSimulationSelectors",
"IDSimulationSelectors",
"CaloSimulationSelectors",
"MSSimulationSelectors"])
153 if defaultG4SelectorRegions - kwargs.keys():
155 kwargs.setdefault(
"BeamPipeSimulationSelectors", [passBackG4Selector])
156 kwargs.setdefault(
"IDSimulationSelectors", [passBackG4Selector])
157 kwargs.setdefault(
"CaloSimulationSelectors", [passBackG4Selector])
158 kwargs.setdefault(
"MSSimulationSelectors", [passBackG4Selector])
160 if "CavernSimulationSelectors" not in kwargs:
161 kwargs.setdefault(
"CavernSimulationSelectors",
164 if "SimulationTools" not in kwargs:
165 kwargs.setdefault(
"SimulationTools", [
170 if "ParticleOrderingTool" not in kwargs:
185 defaultG4SelectorRegions =
set([
"BeamPipeSimulationSelectors",
"IDSimulationSelectors",
"MSSimulationSelectors"])
186 if defaultG4SelectorRegions - kwargs.keys():
188 kwargs.setdefault(
"BeamPipeSimulationSelectors", [pubTool])
189 kwargs.setdefault(
"IDSimulationSelectors", [pubTool])
190 kwargs.setdefault(
"MSSimulationSelectors", [pubTool])
193 kwargs.setdefault(
"CaloSimulationSelectors", [
207 from ISF_FastCaloSimServices.ISF_FastCaloSimServicesConfig
import FastCaloSimV2ToolCfg
208 kwargs.setdefault(
"SimulationTools", [
226 defaultG4SelectorRegions =
set([
"BeamPipeSimulationSelectors",
"IDSimulationSelectors",
"MSSimulationSelectors"])
227 if defaultG4SelectorRegions - kwargs.keys():
229 kwargs.setdefault(
"BeamPipeSimulationSelectors", [pubTool])
230 kwargs.setdefault(
"IDSimulationSelectors", [pubTool])
231 kwargs.setdefault(
"MSSimulationSelectors", [pubTool])
234 kwargs.setdefault(
"CaloSimulationSelectors", [
246 kwargs.setdefault(
"CavernSimulationSelectors",
249 from ISF_FastCaloSimServices.ISF_FastCaloSimServicesConfig
import FastCaloSimV2ToolCfg
259 kwargs.setdefault(
"UseShadowEvent", flags.Sim.UseShadowEvent)
260 if flags.Sim.UseShadowEvent
and "TruthPreselectionTool" not in kwargs:
261 from ISF_HepMC_Tools.ISF_HepMC_ToolsConfig
import TruthPreselectionToolCfg
264 if "TruthRecordService" not in kwargs:
265 kwargs.setdefault(
"TruthRecordService", acc.getPrimaryAndMerge(
TruthServiceCfg(flags)).name)
267 if "MemoryMonitoringTool" not in kwargs:
268 kwargs.setdefault(
"MemoryMonitoringTool", acc.addPublicTool(acc.popToolsAndMerge(
MemoryMonitorToolCfg(flags))))
270 if "ParticleBroker" not in kwargs:
273 if flags.Sim.ISF.Simulator.isQuasiStable():
274 if "QuasiStablePatcher" not in kwargs:
275 from BeamEffects.BeamEffectsAlgConfig
import ZeroLifetimePositionerCfg
277 if "InputConverter" not in kwargs:
278 kwargs.setdefault(
"InputConverter", acc.getPrimaryAndMerge(
InputConverterCfg(flags)).name)
280 kwargs.setdefault(
"InputHardScatterCollection",
"BeamTruthEvent")
281 kwargs.setdefault(
"OutputHardScatterTruthCollection",
"TruthEvent")
282 kwargs.setdefault(
"DoCPUMonitoring", flags.Sim.ISF.DoTimeMonitoring)
283 kwargs.setdefault(
"DoMemoryMonitoring", flags.Sim.ISF.DoMemoryMonitoring)
285 if flags.Sim.ISF.ReSimulation:
286 acc.addSequence(
AthSequencer(
'SimSequence'), parentName=
'AthAlgSeq')
287 acc.addEventAlgo(CompFactory.ISF.SimKernel(name, **kwargs),
'SimSequence')
289 acc.addEventAlgo(CompFactory.ISF.SimKernel(name, **kwargs))
298 kwargs.setdefault(
"IDSimulationSelectors", [ acc.addPublicTool(acc.popToolsAndMerge(
DefaultFatrasSelectorCfg(flags))) ])
299 kwargs.setdefault(
"CaloSimulationSelectors", [
326 kwargs.setdefault(
"BeamPipeSimulationSelectors", [ defPartKillerSelector ])
328 kwargs.setdefault(
"IDSimulationSelectors", [
330 defPartKillerSelector
333 kwargs.setdefault(
"CaloSimulationSelectors", [
346 kwargs.setdefault(
"CavernSimulationSelectors", [ defPartKillerSelector ])
348 from ISF_FastCaloSimServices.ISF_FastCaloSimServicesConfig
import FastCaloSimV2ToolCfg
349 from ISF_ActsTools.ISF_ActsToolsConfig
import ActsFatrasSimToolCfg
350 kwargs.setdefault(
"SimulationTools", [
363 from ISF_Tools.ISF_ToolsConfig
import CosmicEventFilterToolCfg
364 kwargs.setdefault(
"EventFilterTools" , [ acc.addPublicTool(acc.popToolsAndMerge(
CosmicEventFilterToolCfg(flags))) ] )
366 kwargs.setdefault(
"MaximumParticleVectorSize" , 1000000)
368 kwargs.setdefault(
"BeamPipeSimulationSelectors" , [ pubTool ] )
369 kwargs.setdefault(
"IDSimulationSelectors" , [ pubTool ] )
370 kwargs.setdefault(
"CaloSimulationSelectors" , [ pubTool ] )
371 kwargs.setdefault(
"MSSimulationSelectors" , [ pubTool ] )
372 kwargs.setdefault(
"CavernSimulationSelectors" , [ pubTool ] )
373 kwargs.setdefault(
"DoMemoryMonitoring",
False)
385 from SimulationConfig.SimEnums
import SimulationFlavour
386 if flags.Sim.ISF.Simulator
is SimulationFlavour.FullG4MT:
388 elif flags.Sim.ISF.Simulator
is SimulationFlavour.FullG4MT_QS:
390 elif flags.Sim.ISF.Simulator
is SimulationFlavour.PassBackG4MT:
392 elif flags.Sim.ISF.Simulator
is SimulationFlavour.ATLFAST3MT:
394 elif flags.Sim.ISF.Simulator
is SimulationFlavour.ATLFAST3MT_QS:
396 elif flags.Sim.ISF.Simulator
is SimulationFlavour.ATLFAST3F_G4MS:
398 elif flags.Sim.ISF.Simulator
is SimulationFlavour.ATLFAST3F_ACTSMT:
400 elif flags.Sim.ISF.Simulator
is SimulationFlavour.CosmicsG4:
403 raise ValueError(
'Unknown Simulator set, bailing out')