ATLAS Offline Software
Loading...
Searching...
No Matches
ISF_ServicesConfig.py
Go to the documentation of this file.
1"""ComponentAccumulator service configuration for ISF
2
3Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4"""
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7from SimulationConfig.SimEnums import TruthStrategy
8from ISF_HepMC_Tools.ISF_HepMC_ToolsConfig import (
9 KeepLLPDecayChildrenStrategyCfg,
10 KeepLLPHadronicInteractionChildrenStrategyCfg,
11 TruthStrategyGroupID_MC15Cfg,
12 TruthStrategyGroupIDHadInt_MC15Cfg,
13 #TruthStrategyGroupCaloMuBrem_MC15Cfg,
14 TruthStrategyGroupCaloDecay_MC15Cfg,
15 LLPTruthStrategyCfg,
16 TruthStrategyGroupIDCfg,
17 TruthStrategyGroupIDHadIntCfg,
18 TruthStrategyGroupCaloMuBremCfg,
19 TruthStrategyGroupCaloMSBroadCfg,
20 TruthStrategyGroupCaloMSHadIntCfg,
21 ValidationTruthStrategyCfg,
22 FCSParamTruthStrategyCfg
23)
24from BarcodeServices.BarcodeServicesConfig import BarcodeSvcCfg
25from ISF_Geant4CommonTools.ISF_Geant4CommonToolsConfig import (
26 EntryLayerToolCfg, ATLFAST_EntryLayerToolCfg
27)
28from ISF_Tools.ISF_ToolsConfig import ParticleOrderingToolCfg
29
30#include file to access AtlasDetDescr::AtlasRegion enum
31import ROOT,cppyy
32cppyy.include("AtlasDetDescr/AtlasRegion.h")
33
34
35def InputConverterCfg(flags, name="ISF_InputConverter", **kwargs):
36 result = ComponentAccumulator()
37 kwargs.setdefault("QuasiStableParticlesIncluded", flags.Sim.ISF.Simulator.isQuasiStable())
38 kwargs.setdefault("UseShadowEvent", flags.Sim.UseShadowEvent)
39 kwargs.setdefault("UseGeneratedParticleMass", False)
40 if "GenParticleFilters" not in kwargs:
41 from ISF_HepMC_Tools.ISF_HepMC_ToolsConfig import GenParticleFilterToolsCfg
42 kwargs.setdefault("GenParticleFilters", result.popToolsAndMerge(GenParticleFilterToolsCfg(flags)) )
43 result.addService(CompFactory.ISF.InputConverter(name, **kwargs), primary = True)
44 return result
45
46
47def ParticleBrokerSvcNoOrderingCfg(flags, name="ISF_ParticleBrokerSvcNoOrdering", **kwargs):
48 result = ComponentAccumulator()
49 if "EntryLayerTool" not in kwargs:
50 kwargs.setdefault("EntryLayerTool", result.addPublicTool(result.popToolsAndMerge(EntryLayerToolCfg(flags))))
51 kwargs.setdefault("GeoIDSvc", result.getService("ISF_GeoIDSvc")) # FIXME
52 # assume "GeoIDSvc" has been set alongside "EntryLayerTool"
53 kwargs.setdefault("AlwaysUseGeoIDSvc", False)
54 kwargs.setdefault("ValidateGeoIDs", flags.Sim.ISF.ValidationMode)
55 kwargs.setdefault("ValidationOutput", flags.Sim.ISF.ValidationMode)
56 kwargs.setdefault("ValidationStreamName", "ParticleBroker")
57
58 result.addService(CompFactory.ISF.ParticleBrokerDynamicOnReadIn(name, **kwargs), primary = True)
59 return result
60
61
62def ParticleBrokerSvcCfg(flags, name="ISF_ParticleBrokerSvc", **kwargs):
63 # comment copied from old config
64 #kwargs.setdefault("ParticleOrderingTool", "ISF_InToOutSubDetOrderingTool")
65 result = ComponentAccumulator()
66 kwargs.setdefault("ParticleOrderingTool", result.popToolsAndMerge(ParticleOrderingToolCfg(flags)))
67 pbsvc = result.getPrimaryAndMerge(ParticleBrokerSvcNoOrderingCfg(flags, name, **kwargs))
68 result.addService(pbsvc, primary = True)
69 return result
70
71
72def ATLFAST_ParticleBrokerSvcCfg(flags, name="ISF_ATLFAST_ParticleBrokerSvc", **kwargs):
73 result = ComponentAccumulator()
74 kwargs.setdefault("EntryLayerTool", result.addPublicTool(result.popToolsAndMerge(ATLFAST_EntryLayerToolCfg(flags))))
75 kwargs.setdefault("GeoIDSvc", result.getService("ISF_ATLFAST_GeoIDSvc")) # FIXME
76 pbsvc = result.getPrimaryAndMerge(ParticleBrokerSvcCfg(flags, name, **kwargs))
77 result.addService(pbsvc, primary = True)
78 return result
79
80
81# Generic Truth Service Configurations
82def TruthServiceCfg(flags, **kwargs):
83 """Return the TruthService config flagged by Sim.TruthStrategy"""
84 stratmap = {
85 TruthStrategy.MC12: MC12TruthServiceCfg,
86 TruthStrategy.MC12LLP: MC12LLPTruthServiceCfg,
87 TruthStrategy.MC12Plus: MC12PlusTruthServiceCfg,
88 TruthStrategy.MC15: MC15TruthServiceCfg,
89 TruthStrategy.MC15a: MC15aTruthServiceCfg,
90 TruthStrategy.MC15aPlus: MC15aPlusTruthServiceCfg,
91 TruthStrategy.MC15aPlusLLP: MC15aPlusLLPTruthServiceCfg,
92 TruthStrategy.MC16: MC16TruthServiceCfg,
93 TruthStrategy.MC16LLP: MC16LLPTruthServiceCfg,
94 TruthStrategy.MC18: MC18TruthServiceCfg,
95 TruthStrategy.MC18LLP: MC18LLPTruthServiceCfg,
96 # TruthStrategy.PhysicsProcess: PhysicsProcessTruthServiceCfg,
97 # TruthStrategy.Global: GlobalTruthServiceCfg,
98 TruthStrategy.Validation: ValidationTruthServiceCfg,
99 TruthStrategy.MSLLPValidation: MSLLPValidationTruthServiceCfg,
100 # TruthStrategy.Cosmic: CosmicTruthServiceCfg,
101 }
102 xCfg = stratmap[flags.Sim.TruthStrategy]
103 return xCfg(flags, **kwargs)
104
105
106def GenericTruthServiceCfg(flags, name="ISF_TruthService", **kwargs):
107 result = ComponentAccumulator()
108 kwargs.setdefault("BarcodeSvc", result.getPrimaryAndMerge(BarcodeSvcCfg(flags)))
109
110 kwargs.setdefault("SkipIfNoChildren", True)
111 kwargs.setdefault("SkipIfNoParentId", True)
112 kwargs.setdefault("ForceEndVtxInRegions", [])
113
114 if flags.Sim.ISF.Simulator.isQuasiStable():
115 kwargs.setdefault("QuasiStableParticlesIncluded", True)
116 kwargs.setdefault("QuasiStableParticleOverwrite", not flags.Sim.UseShadowEvent)
117 svc = CompFactory.ISF.TruthSvc(name, **kwargs)
118 result.addService(svc, primary=True)
119 return result
120
121
122def ValidationTruthServiceCfg(flags, name="ISF_ValidationTruthService", **kwargs):
123 result = ComponentAccumulator()
124 kwargs.setdefault("TruthStrategies", [result.popToolsAndMerge(ValidationTruthStrategyCfg(flags))] )
125 kwargs.setdefault("IgnoreUndefinedBarcodes", True)
126 kwargs.setdefault("PassWholeVertices", True)
127 truthService = result.getPrimaryAndMerge(GenericTruthServiceCfg(flags, name, **kwargs))
128 result.addService(truthService, primary=True)
129 return result
130
131
132# MC12 Truth Service Configurations
134 return ["ISF_MCTruthStrategyGroupID"]
135
136
138 return ["ISF_MCTruthStrategyGroupID", "ISF_MCTruthStrategyGroupIDHadInt"]
139
140
142 return ["ISF_MCTruthStrategyGroupCaloMuBrem"]
143
144
146 return []
147
148
149def MC12TruthServiceCfg(flags, name="ISF_MC12TruthService", **kwargs):
150 result = ComponentAccumulator()
151 if "TruthStrategies" not in kwargs:
152 truthCfgs = [
153 TruthStrategyGroupIDCfg,
154 TruthStrategyGroupIDHadIntCfg,
155 TruthStrategyGroupCaloMuBremCfg,
156 ]
157 truthStrats = [result.popToolsAndMerge(cfg(flags)) for cfg in truthCfgs]
158 kwargs.setdefault("TruthStrategies", truthStrats)
159 kwargs.setdefault("IgnoreUndefinedBarcodes", False)
160 kwargs.setdefault("PassWholeVertices", True)
161 truthService = result.getPrimaryAndMerge(GenericTruthServiceCfg(flags, name, **kwargs))
162 result.addService(truthService, primary=True)
163 return result
164
165
166def MC12LLPTruthServiceCfg(flags, name="ISF_MC12TruthLLPService", **kwargs):
167 result = ComponentAccumulator()
168 truthCfgs = [
169 TruthStrategyGroupIDCfg,
170 TruthStrategyGroupIDHadIntCfg,
171 TruthStrategyGroupCaloMuBremCfg,
172 LLPTruthStrategyCfg,
173 ]
174 truthStrats = [result.popToolsAndMerge(cfg(flags)) for cfg in truthCfgs]
175 kwargs.setdefault("TruthStrategies", truthStrats)
176 truthService = result.getPrimaryAndMerge(MC12TruthServiceCfg(flags, name, **kwargs))
177 result.addService(truthService, primary = True)
178 return result
179
180
181def MC12PlusTruthServiceCfg(flags, name="ISF_MC12PlusTruthService", **kwargs):
182 AtlasRegion = ROOT.AtlasDetDescr.AtlasRegion
183 kwargs.setdefault("ForceEndVtxInRegions", [AtlasRegion.fAtlasID] )
184 return MC12TruthServiceCfg(flags, name, **kwargs)
185
186
187# MC15 Truth Service Configurations
189 return ["ISF_MCTruthStrategyGroupID_MC15"]
190
191
193 return ["ISF_MCTruthStrategyGroupID_MC15", "ISF_MCTruthStrategyGroupIDHadInt_MC15"]
194
195
197 return ["ISF_MCTruthStrategyGroupCaloMuBrem", "ISF_MCTruthStrategyGroupCaloMuBrem_MC15"]
198
200 return []
201
202
203def MC15TruthServiceCfg(flags, name="ISF_MC15TruthService", **kwargs):
204 result = ComponentAccumulator()
205 AtlasRegion = ROOT.AtlasDetDescr.AtlasRegion
206
207 if "TruthStrategies" not in kwargs:
208 truthCfgs = [
209 TruthStrategyGroupID_MC15Cfg,
210 TruthStrategyGroupIDHadInt_MC15Cfg,
211 TruthStrategyGroupCaloMuBremCfg, # FIXME - should be TruthStrategyGroupCaloMuBrem_MC15Cfg but keeping this for consistency with old style
212 TruthStrategyGroupCaloDecay_MC15Cfg ]
213 if flags.Sim.RecordStepInfo:
214 # Override Truth strategies for FCS Parameterization input samples
215 truthCfgs = [ FCSParamTruthStrategyCfg ]
216 truthStrats = [result.popToolsAndMerge(cfg(flags)) for cfg in truthCfgs]
217 kwargs.setdefault("TruthStrategies", truthStrats)
218
219 kwargs.setdefault("IgnoreUndefinedBarcodes", False)
220 kwargs.setdefault("PassWholeVertices", False) # new for MC15 - can write out partial vertices.
221 kwargs.setdefault("ForceEndVtxInRegions", [AtlasRegion.fAtlasID])
222 truthService = result.getPrimaryAndMerge(GenericTruthServiceCfg(flags, name, **kwargs))
223 result.addService(truthService, primary=True)
224 return result
225
226
227def MC15aTruthServiceCfg(flags, name="ISF_MC15aTruthService", **kwargs):
228 kwargs.setdefault("ForceEndVtxInRegions", [])
229 return MC15TruthServiceCfg(flags, name, **kwargs)
230
231
232def MC15aPlusTruthServiceCfg(flags, name="ISF_MC15aPlusTruthService", **kwargs):
233 AtlasRegion = ROOT.AtlasDetDescr.AtlasRegion
234
235 kwargs.setdefault("ForceEndVtxInRegions", [AtlasRegion.fAtlasID])
236 return MC15TruthServiceCfg(flags, name, **kwargs)
237
238
239def MC15aPlusLLPTruthServiceCfg(flags, name="ISF_MC15aPlusLLPTruthService", **kwargs):
240 result = ComponentAccumulator()
241 truthCfgs = [
242 KeepLLPDecayChildrenStrategyCfg,
243 KeepLLPHadronicInteractionChildrenStrategyCfg,
244 TruthStrategyGroupID_MC15Cfg,
245 TruthStrategyGroupIDHadInt_MC15Cfg,
246 TruthStrategyGroupCaloMuBremCfg, # FIXME - should be TruthStrategyGroupCaloDecay_MC15Cfg but keeping this for consistency with old style
247 TruthStrategyGroupCaloDecay_MC15Cfg,
248 LLPTruthStrategyCfg,
249 ]
250 truthStrats = [result.popToolsAndMerge(cfg(flags)) for cfg in truthCfgs]
251 kwargs.setdefault("TruthStrategies", truthStrats)
252 truthService = result.getPrimaryAndMerge(MC15aPlusTruthServiceCfg(flags, name, **kwargs))
253 result.addService(truthService, primary = True)
254 return result
255
256
257# MC16 Truth Service Configurations
258def MC16TruthServiceCfg(flags, name="ISF_MC16TruthService", **kwargs):
259 return MC15aPlusTruthServiceCfg(flags, name, **kwargs)
260
261
262def MC16LLPTruthServiceCfg(flags, name="ISF_MC16LLPTruthService", **kwargs):
263 return MC15aPlusLLPTruthServiceCfg(flags, name, **kwargs)
264
265
266# MC18 Truth Service Configurations
267def MC18TruthServiceCfg(flags, name="ISF_MC18TruthService", **kwargs):
268 return MC15aPlusTruthServiceCfg(flags, name, **kwargs)
269
270
271def MC18LLPTruthServiceCfg(flags, name="ISF_MC18LLPTruthService", **kwargs):
272 return MC15aPlusLLPTruthServiceCfg(flags, name, **kwargs)
273
274
275# MSLLPValidation Truth Service Configuration
276def MSLLPValidationTruthServiceCfg(flags, name="ISF_MSLLPValidationTruthService", **kwargs):
277 result = ComponentAccumulator()
278 AtlasRegion = ROOT.AtlasDetDescr.AtlasRegion
279
280 if "TruthStrategies" not in kwargs:
281 truthCfgs = [
282 # MC15aPlusLLP strategies
283 KeepLLPDecayChildrenStrategyCfg,
284 KeepLLPHadronicInteractionChildrenStrategyCfg,
285 TruthStrategyGroupID_MC15Cfg,
286 TruthStrategyGroupIDHadInt_MC15Cfg,
287 TruthStrategyGroupCaloMuBremCfg,
288 TruthStrategyGroupCaloDecay_MC15Cfg,
289 LLPTruthStrategyCfg,
290 # Broad Calo+MS strategies (500 MeV pT threshold)
291 TruthStrategyGroupCaloMSBroadCfg,
292 TruthStrategyGroupCaloMSHadIntCfg,
293 ]
294 truthStrats = [result.popToolsAndMerge(cfg(flags)) for cfg in truthCfgs]
295 kwargs.setdefault("TruthStrategies", truthStrats)
296
297 kwargs.setdefault("ForceEndVtxInRegions",
298 [AtlasRegion.fAtlasID, AtlasRegion.fAtlasCalo, AtlasRegion.fAtlasMS])
299 truthService = result.getPrimaryAndMerge(
300 MC15aPlusTruthServiceCfg(flags, name, **kwargs))
301 result.addService(truthService, primary=True)
302 return result
ParticleBrokerSvcNoOrderingCfg(flags, name="ISF_ParticleBrokerSvcNoOrdering", **kwargs)
GenericTruthServiceCfg(flags, name="ISF_TruthService", **kwargs)
MC15aTruthServiceCfg(flags, name="ISF_MC15aTruthService", **kwargs)
MC15TruthServiceCfg(flags, name="ISF_MC15TruthService", **kwargs)
MSLLPValidationTruthServiceCfg(flags, name="ISF_MSLLPValidationTruthService", **kwargs)
MC15aPlusLLPTruthServiceCfg(flags, name="ISF_MC15aPlusLLPTruthService", **kwargs)
MC15aPlusTruthServiceCfg(flags, name="ISF_MC15aPlusTruthService", **kwargs)
MC12LLPTruthServiceCfg(flags, name="ISF_MC12TruthLLPService", **kwargs)
MC12PlusTruthServiceCfg(flags, name="ISF_MC12PlusTruthService", **kwargs)
ParticleBrokerSvcCfg(flags, name="ISF_ParticleBrokerSvc", **kwargs)
MC18LLPTruthServiceCfg(flags, name="ISF_MC18LLPTruthService", **kwargs)
InputConverterCfg(flags, name="ISF_InputConverter", **kwargs)
MC18TruthServiceCfg(flags, name="ISF_MC18TruthService", **kwargs)
MC16TruthServiceCfg(flags, name="ISF_MC16TruthService", **kwargs)
MC16LLPTruthServiceCfg(flags, name="ISF_MC16LLPTruthService", **kwargs)
ValidationTruthServiceCfg(flags, name="ISF_ValidationTruthService", **kwargs)
MC12TruthServiceCfg(flags, name="ISF_MC12TruthService", **kwargs)
ATLFAST_ParticleBrokerSvcCfg(flags, name="ISF_ATLFAST_ParticleBrokerSvc", **kwargs)
TruthServiceCfg(flags, **kwargs)