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 # force CollectionType to be RootCollection to ensure Event Tag reading
87 if flags.Input.Files:
88 evSel = cfg.getService("EventSelector")
89 evSel.CollectionType = "RootCollection"
90
91 if flags.Sim.ISF.ReSimulation:
92 # Case 4
93 from ISF_Algorithms.ISF_AlgorithmsConfig import SimEventFilterCfg, InvertedSimEventFilterCfg, RenameHitCollectionsCfg
94 cfg.merge(SimEventFilterCfg(flags, sequenceName='SimSequence'))
95 cfg.merge(InvertedSimEventFilterCfg(flags, sequenceName='CopyHitSequence'))
96 cfg.merge(RenameHitCollectionsCfg(flags, sequenceName='CopyHitSequence'))
97 else:
98 #Cases 1, 2, 3
99 # add BeamEffectsAlg
100 from BeamEffects.BeamEffectsAlgConfig import BeamEffectsAlgCfg
101 cfg.merge(BeamEffectsAlgCfg(flags))
102 if flags.Input.Files:
103 #Cases 1, 2
104 if "xAOD::EventInfo#EventInfo" not in flags.Input.TypedCollections:
105 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
106 cfg.merge(EventInfoCnvAlgCfg(flags))
107 else:
108 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoUpdateFromContextAlgCfg
109 cfg.merge(EventInfoUpdateFromContextAlgCfg(flags))
110 else:
111 #Case 3: xAOD::EventInfo#EventInfo will have already been created
112 pass
113
114 if flags.Beam.Type is BeamType.TestBeam:
115 from TBDetDescrAlg.TBDetDescrAlgConfig import TBDetDescrLoaderCfg
116 cfg.merge(TBDetDescrLoaderCfg(flags))
117 AcceptAlgNames=[]
118 if flags.Sim.ISFRun:
119 # add the ISF_MainConfig
120 from ISF_Config.ISF_MainConfig import ISF_KernelCfg
121 cfg.merge(ISF_KernelCfg(flags))
122 AcceptAlgNames = ['ISF_Kernel_' + flags.Sim.ISF.Simulator.value]
123 if flags.Sim.ISF.ReSimulation:
124 AcceptAlgNames += ['RenameHitCollections']
125 else:
126 if not flags.Sim.UseG4Workers:
127 AcceptAlgNames = ['G4AtlasAlg']
128 #add the G4AtlasAlg
129 from G4AtlasAlg.G4AtlasAlgConfig import G4AtlasAlgCfg
130 cfg.merge(G4AtlasAlgCfg(flags))
131 else:
132 AcceptAlgNames = ['G4RunAlg']
133 #add the G4AtlasAlg
134 from G4AtlasAlg.G4RunAlgConfig import G4RunAlgCfg
135 cfg.merge(G4RunAlgCfg(flags))
136
137 if flags.Sim.LArParameterization is LArParameterization.FastCaloSim:
138 cfg.getEventAlgo("ISF_CollectionMerger").InputLArEMBHits.data.sort() # temporary workaround
139 cfg.getEventAlgo("ISF_CollectionMerger").InputLArEMECHits.data.sort() # temporary workaround
140 cfg.getEventAlgo("ISF_CollectionMerger").InputLArFCALHits.data.sort() # temporary workaround
141 cfg.getEventAlgo("ISF_CollectionMerger").InputLArHECHits.data.sort() # temporary workaround
142 cfg.getEventAlgo("ISF_CollectionMerger").InputTileHits.data.sort() # temporary workaround
143 cfg.getEventAlgo("ISF_CollectionMerger").InputMBTSHits.data.sort() # temporary workaround
144
145 from SimulationConfig.SimEnums import CalibrationRun
146 if flags.Sim.CalibrationRun in [CalibrationRun.LAr, CalibrationRun.LArTile, CalibrationRun.LArTileZDC]:
147 from LArG4SD.LArG4SDToolConfig import DeadMaterialCalibrationHitMergerCfg
148 cfg.merge(DeadMaterialCalibrationHitMergerCfg(flags))
149
150 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg, outputStreamName
151 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
152
153 if flags.Output.HITSFileName:
154 from SimuJobTransforms.SimOutputConfig import getStreamHITS_ItemList
155 cfg.merge( OutputStreamCfg(flags,"HITS", ItemList=getStreamHITS_ItemList(flags), disableEventTag=False, AcceptAlgs=AcceptAlgNames) )
156 cfg.merge(SetupMetaDataForStreamCfg(flags, "HITS", AcceptAlgs=AcceptAlgNames, createMetadata=[MetadataCategory.IOVMetaData]))
157 if flags.Sim.ISF.ReSimulation:
158 cfg.getEventAlgo(outputStreamName("HITS")).TakeItemsFromInput=False
159
160 if flags.Output.EVNT_TRFileName:
161 from SimuJobTransforms.SimOutputConfig import getStreamEVNT_TR_ItemList
162 cfg.merge( OutputStreamCfg(flags,"EVNT_TR", ItemList=getStreamEVNT_TR_ItemList(flags), disableEventTag=True, AcceptAlgs=AcceptAlgNames) )
163 cfg.merge(SetupMetaDataForStreamCfg(flags, "EVNT_TR", AcceptAlgs=AcceptAlgNames, createMetadata=[MetadataCategory.IOVMetaData]))
164
165 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