ATLAS Offline Software
Loading...
Searching...
No Matches
python.CommonSimulationSteering Namespace Reference

Functions

 specialConfigPreInclude (flags)
 specialConfigPostInclude (flags, cfg)
 CommonSimulationCfg (flags, log)

Function Documentation

◆ CommonSimulationCfg()

CommonSimulationCfg ( flags,
log )

Definition at line 34 of file CommonSimulationSteering.py.

34def CommonSimulationCfg(flags, log):
35 # Configure main services and input reading (if required)
36 if not flags.Input.Files:
37 # Cases 3a, 3b
38 from AthenaConfiguration.MainServicesConfig import MainEvgenServicesCfg
39 cfg = MainEvgenServicesCfg(flags)
40 # Make sure we get xAOD::EventInfo
41 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
42 cfg.merge(EventInfoCnvAlgCfg(flags, name="xAODMaker::EventInfoCnvAlg", disableBeamSpot = True))
43
44 # For Simulation we need to override the RunNumber to pick up
45 # the right conditions. These next two lines are required for
46 # this to work.
47 cfg.getService("EventSelector").FirstLB = flags.Input.LumiBlockNumbers[0]
48 cfg.getService("EventSelector").OverrideRunNumber = True
49 from AthenaKernel.EventIdOverrideConfig import EvtIdModifierSvcCfg
50 cfg.merge(EvtIdModifierSvcCfg(flags))
51 if flags.Beam.Type is BeamType.Cosmics:
52 # Case 3b: Configure the cosmic Generator
53 from CosmicGenerator.CosmicGeneratorConfig import CosmicGeneratorCfg
54 cfg.merge(CosmicGeneratorCfg(flags))
55 else:
56 # Case 3a: Configure ParticleGun
57 fragment = flags.Sim.GenerationConfiguration
58 if fragment and fragment != 'NONE':
59 executeFromFragment(fragment, flags, cfg)
60 log.info("On-the-fly generation using ParticleGun!")
61 else:
62 log.error("No input file or on-the-fly generation configuration provided!")
63 else:
64 # Cases 1, 2a, 2b, 2c, 4
65 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
66 cfg = MainServicesCfg(flags)
67 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
68 cfg.merge(PoolReadCfg(flags))
69 if flags.Sim.ReadTR or flags.Sim.CavernBackground is CavernBackground.Read:
70 # Cases 2a, 2b, 2c
71 from TrackRecordGenerator.TrackRecordGeneratorConfig import Input_TrackRecordGeneratorCfg
72 cfg.merge(Input_TrackRecordGeneratorCfg(flags))
73 if flags.Sim.ISF.ReSimulation:
74 # Case 4
75 if "xAOD::EventInfo#EventInfo" not in flags.Input.TypedCollections:
76 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
77 cfg.merge(EventInfoCnvAlgCfg(flags))
78 else:
79 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoUpdateFromContextAlgCfg
80 cfg.merge(EventInfoUpdateFromContextAlgCfg(flags))
81 from McEventCollectionFilter.McEventCollectionFilterConfig import TruthResetAlgCfg
82 cfg.merge(TruthResetAlgCfg(flags))
83 cfg.addSequence(CompFactory.AthSequencer('SimSequence'), parentName='AthAlgSeq')
84 cfg.addSequence(CompFactory.AthSequencer('CopyHitSequence'), parentName='AthAlgSeq')
85
86 if flags.Sim.ISF.ReSimulation:
87 # Case 4
88 from ISF_Algorithms.ISF_AlgorithmsConfig import SimEventFilterCfg, InvertedSimEventFilterCfg, RenameHitCollectionsCfg
89 cfg.merge(SimEventFilterCfg(flags, sequenceName='SimSequence'))
90 cfg.merge(InvertedSimEventFilterCfg(flags, sequenceName='CopyHitSequence'))
91 cfg.merge(RenameHitCollectionsCfg(flags, sequenceName='CopyHitSequence'))
92 else:
93 #Cases 1, 2, 3
94 # add BeamEffectsAlg
95 from BeamEffects.BeamEffectsAlgConfig import BeamEffectsAlgCfg
96 cfg.merge(BeamEffectsAlgCfg(flags))
97 if flags.Input.Files:
98 #Cases 1, 2
99 if "xAOD::EventInfo#EventInfo" not in flags.Input.TypedCollections:
100 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
101 cfg.merge(EventInfoCnvAlgCfg(flags))
102 else:
103 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoUpdateFromContextAlgCfg
104 cfg.merge(EventInfoUpdateFromContextAlgCfg(flags))
105 else:
106 #Case 3: xAOD::EventInfo#EventInfo will have already been created
107 pass
108
109 if flags.Beam.Type is BeamType.TestBeam:
110 from TBDetDescrAlg.TBDetDescrAlgConfig import TBDetDescrLoaderCfg
111 cfg.merge(TBDetDescrLoaderCfg(flags))
112 AcceptAlgNames=[]
113 if flags.Sim.ISFRun:
114 # add the ISF_MainConfig
115 from ISF_Config.ISF_MainConfig import ISF_KernelCfg
116 cfg.merge(ISF_KernelCfg(flags))
117 AcceptAlgNames = ['ISF_Kernel_' + flags.Sim.ISF.Simulator.value]
118 if flags.Sim.ISF.ReSimulation:
119 AcceptAlgNames += ['RenameHitCollections']
120 else:
121 if not flags.Sim.UseG4Workers:
122 AcceptAlgNames = ['G4AtlasAlg']
123 #add the G4AtlasAlg
124 from G4AtlasAlg.G4AtlasAlgConfig import G4AtlasAlgCfg
125 cfg.merge(G4AtlasAlgCfg(flags))
126 else:
127 AcceptAlgNames = ['G4RunAlg']
128 #add the G4AtlasAlg
129 from G4AtlasAlg.G4RunAlgConfig import G4RunAlgCfg
130 cfg.merge(G4RunAlgCfg(flags))
131
132 if flags.Sim.LArParameterization is LArParameterization.FastCaloSim:
133 cfg.getEventAlgo("ISF_CollectionMerger").InputLArEMBHits.data.sort() # temporary workaround
134 cfg.getEventAlgo("ISF_CollectionMerger").InputLArEMECHits.data.sort() # temporary workaround
135 cfg.getEventAlgo("ISF_CollectionMerger").InputLArFCALHits.data.sort() # temporary workaround
136 cfg.getEventAlgo("ISF_CollectionMerger").InputLArHECHits.data.sort() # temporary workaround
137 cfg.getEventAlgo("ISF_CollectionMerger").InputTileHits.data.sort() # temporary workaround
138 cfg.getEventAlgo("ISF_CollectionMerger").InputMBTSHits.data.sort() # temporary workaround
139
140 from SimulationConfig.SimEnums import CalibrationRun
141 if flags.Sim.CalibrationRun in [CalibrationRun.LAr, CalibrationRun.LArTile, CalibrationRun.LArTileZDC]:
142 from LArG4SD.LArG4SDToolConfig import DeadMaterialCalibrationHitMergerCfg
143 cfg.merge(DeadMaterialCalibrationHitMergerCfg(flags))
144
145 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg, outputStreamName
146 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
147
148 if flags.Output.HITSFileName:
149 from SimuJobTransforms.SimOutputConfig import getStreamHITS_ItemList
150 cfg.merge( OutputStreamCfg(flags,"HITS", ItemList=getStreamHITS_ItemList(flags), disableEventTag=False, AcceptAlgs=AcceptAlgNames) )
151 cfg.merge(SetupMetaDataForStreamCfg(flags, "HITS", AcceptAlgs=AcceptAlgNames, createMetadata=[MetadataCategory.IOVMetaData]))
152 if flags.Sim.ISF.ReSimulation:
153 cfg.getEventAlgo(outputStreamName("HITS")).TakeItemsFromInput=False
154
155 if flags.Output.EVNT_TRFileName:
156 from SimuJobTransforms.SimOutputConfig import getStreamEVNT_TR_ItemList
157 cfg.merge( OutputStreamCfg(flags,"EVNT_TR", ItemList=getStreamEVNT_TR_ItemList(flags), disableEventTag=True, AcceptAlgs=AcceptAlgNames) )
158 cfg.merge(SetupMetaDataForStreamCfg(flags, "EVNT_TR", AcceptAlgs=AcceptAlgNames, createMetadata=[MetadataCategory.IOVMetaData]))
159
160 return cfg

◆ specialConfigPostInclude()

specialConfigPostInclude ( flags,
cfg )

Definition at line 28 of file CommonSimulationSteering.py.

28def specialConfigPostInclude(flags, cfg):
29 fragment = flags.Input.SpecialConfiguration.get("postInclude", None)
30 if fragment and fragment != 'NONE':
31 executeFromFragment(fragment, flags, cfg) #FIXME assumes only one fragment?
32
33

◆ specialConfigPreInclude()

specialConfigPreInclude ( flags)

Definition at line 22 of file CommonSimulationSteering.py.

22def specialConfigPreInclude(flags):
23 fragment = flags.Input.SpecialConfiguration.get("preInclude", None)
24 if fragment and fragment != 'NONE':
25 executeFromFragment(fragment, flags) #FIXME assumes only one fragment?
26
27