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