3 __doc__ =
"New configuration for the ISF_FatrasSimTool"
5 from AthenaCommon.Logging
import logging
6 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
7 from AthenaConfiguration.ComponentFactory
import CompFactory
8 from ISF_Algorithms.CollectionMergerConfig
import CollectionMergerCfg
9 from ISF_Tools.ISF_ToolsConfig
import ParticleHelperCfg
10 from ISF_Services.ISF_ServicesConfig
import (
11 ATLFAST_ParticleBrokerSvcCfg, TruthServiceCfg
13 from ISF_Geant4Tools.ISF_Geant4ToolsConfig
import G4RunManagerHelperCfg
14 from RngComps.RngCompsConfig
import dSFMT, AthRNGSvcCfg
17 seed =
'TrkExRnd OFFSET 0 12412330 37849324'
26 seed =
'FatrasRnd OFFSET 0 81234740 23474923'
38 """Return ISF_FatrasHitCreatorPixel configured with ComponentAccumulator"""
39 mlog = logging.getLogger(name)
40 mlog.debug(
'Start configuration')
42 bare_collection_name =
"PixelHits"
43 mergeable_collection_suffix =
"_Fatras"
44 merger_input_property =
"PixelHits"
49 mergeable_collection_suffix,
50 merger_input_property,
53 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
54 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
55 kwargs.setdefault(
"IdHelperName",
'PixelID')
56 kwargs.setdefault(
"CollectionName", hits_collection_name)
58 kwargs.setdefault(
"ConditionsTool",
"")
59 kwargs.setdefault(
"UseConditionsTool",
False)
61 result.setPrivateTools(CompFactory.iFatras.HitCreatorSilicon(name=name, **kwargs))
66 """Return ISF_FatrasHitCreatorSCT configured with ComponentAccumulator"""
67 mlog = logging.getLogger(name)
68 mlog.debug(
'Start configuration')
70 bare_collection_name =
"SCT_Hits"
71 mergeable_collection_suffix =
"_Fatras"
72 merger_input_property =
"SCTHits"
77 mergeable_collection_suffix,
78 merger_input_property,
81 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
82 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
83 kwargs.setdefault(
"IdHelperName",
'SCT_ID')
84 kwargs.setdefault(
"CollectionName", hits_collection_name)
86 kwargs.setdefault(
"ConditionsTool",
"")
87 kwargs.setdefault(
"UseConditionsTool",
False)
89 result.setPrivateTools(CompFactory.iFatras.HitCreatorSilicon(name=name, **kwargs))
94 """Return ISF_FatrasHitCreatorTRT configured with ComponentAccumulator"""
95 mlog = logging.getLogger(name)
96 mlog.debug(
'Start configuration')
98 bare_collection_name =
"TRTUncompressedHits"
99 mergeable_collection_suffix =
"_Fatras"
100 merger_input_property =
"TRTUncompressedHits"
104 bare_collection_name,
105 mergeable_collection_suffix,
106 merger_input_property,
109 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
110 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
111 kwargs.setdefault(
"CollectionName", hits_collection_name)
113 kwargs.setdefault(
"StrawStatusSummaryTool",
"")
114 result.setPrivateTools(CompFactory.iFatras.HitCreatorTRT(name=name, **kwargs))
119 """Return ISF_FatrasHitCreatorPixel configured for pileup with ComponentAccumulator"""
120 kwargs.setdefault(
"CollectionName",
"PileupPixelHits")
125 """Return ISF_FatrasHitCreatorSCT configured for pileup with ComponentAccumulator"""
126 kwargs.setdefault(
"CollectionName",
"PileupSCT_Hits")
131 """Return ISF_FatrasHitCreatorTRT configured with ComponentAccumulator"""
132 kwargs.setdefault(
"CollectionName",
"PileupTRTUncompressedHits")
140 """Return ISF_FatrasSimHitCreatorID configured with ComponentAccumulator"""
142 mlog = logging.getLogger(name)
143 mlog.debug(
'Start configuration')
146 kwargs.setdefault(
"PixelHitCreator", result.addPublicTool(result.popToolsAndMerge(
fatrasHitCreatorPixelCfg(flags))))
147 kwargs.setdefault(
"SctHitCreator", result.addPublicTool(result.popToolsAndMerge(
fatrasHitCreatorSCTCfg(flags))))
148 kwargs.setdefault(
"TrtHitCreator", result.addPublicTool(result.popToolsAndMerge(
fatrasHitCreatorTRTCfg(flags))))
149 kwargs.setdefault(
"OutputLevel", flags.Exec.OutputLevel)
150 result.setPrivateTools(CompFactory.iFatras.SimHitCreatorID(name=name, **kwargs))
155 """Return ISF_FatrasSimHitCreatorID configured for pileup with ComponentAccumulator"""
157 mlog = logging.getLogger(name)
158 mlog.debug(
'Start configuration')
168 """Return ISF_FatrasSimHitCreatorMS configured with ComponentAccumulator"""
170 mlog = logging.getLogger(name)
171 mlog.debug(
'Start configuration')
175 mergeable_collection_suffix =
"_Fatras"
178 mdt_bare_collection_name=
"MDT_Hits"
179 mdt_merger_input_property=
"MDTHits"
181 mdt_bare_collection_name,
182 mergeable_collection_suffix,
183 mdt_merger_input_property,
185 result.merge(mdt_result)
187 rpc_bare_collection_name=
"RPC_Hits"
188 rpc_merger_input_property=
"RPCHits"
190 rpc_bare_collection_name,
191 mergeable_collection_suffix,
192 rpc_merger_input_property,
194 result.merge(rpc_result)
196 tgc_bare_collection_name=
"TGC_Hits"
197 tgc_merger_input_property=
"TGCHits"
199 tgc_bare_collection_name,
200 mergeable_collection_suffix,
201 tgc_merger_input_property,
203 result.merge(tgc_result)
205 csc_hits_collection_name =
""
206 if flags.Detector.EnableCSC:
207 csc_bare_collection_name=
"CSC_Hits"
208 csc_merger_input_property=
"CSCHits"
210 csc_bare_collection_name,
211 mergeable_collection_suffix,
212 csc_merger_input_property,
214 result.merge(csc_result)
216 stgc_hits_collection_name =
""
217 if flags.Detector.EnablesTGC:
218 stgc_bare_collection_name=
"sTGC_Hits"
219 stgc_merger_input_property=
"sTGCHits"
221 stgc_bare_collection_name,
222 mergeable_collection_suffix,
223 stgc_merger_input_property,
225 result.merge(stgc_result)
227 mm_hits_collection_name =
""
228 if flags.Detector.EnableMM:
229 mm_bare_collection_name=
"MM_Hits"
230 mm_merger_input_property=
"MMHits"
232 mm_bare_collection_name,
233 mergeable_collection_suffix,
234 mm_merger_input_property,
236 result.merge(mm_result)
238 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
239 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
241 kwargs.setdefault(
"Extrapolator" , result.addPublicTool(result.popToolsAndMerge(
fatrasExtrapolatorCfg(flags))))
243 kwargs.setdefault(
"MDTCollectionName", mdt_hits_collection_name)
244 kwargs.setdefault(
"RPCCollectionName", rpc_hits_collection_name)
245 kwargs.setdefault(
"TGCCollectionName", tgc_hits_collection_name)
246 kwargs.setdefault(
"CSCCollectionName", csc_hits_collection_name)
247 kwargs.setdefault(
"sTGCCollectionName", stgc_hits_collection_name)
248 kwargs.setdefault(
"MMCollectionName", mm_hits_collection_name)
250 Muon__MuonTGMeasurementTool = CompFactory.Muon.MuonTGMeasurementTool
251 muon_tgmeasurement_tool = Muon__MuonTGMeasurementTool(name=
'MuonTGMeasurementTool',
253 kwargs.setdefault(
"MeasurementTool", muon_tgmeasurement_tool)
255 result.setPrivateTools(CompFactory.iFatras.SimHitCreatorMS(name=name, **kwargs))
260 mlog = logging.getLogger(name)
261 mlog.debug(
'Start configuration')
265 result.setPrivateTools(CompFactory.iFatras.PDGToG4Particle(name=name, **kwargs))
274 mlog = logging.getLogger(name)
275 mlog.debug(
'Start configuration')
278 kwargs.setdefault(
"ValidationStreamName",
"ISFFatras")
280 result.setPrivateTools(CompFactory.iFatras.PhysicsValidationTool(name=name, **kwargs))
285 mlog = logging.getLogger(name)
286 mlog.debug(
'Start configuration')
290 seed =
'FatrasG4 OFFSET 0 23491234 23470291'
291 result.merge(
dSFMT(seed))
292 kwargs.setdefault(
"RandomNumberService", result.getService(
"AtDSFMTGenSvc").name)
293 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
294 kwargs.setdefault(
"G4RandomStreamName", flags.Sim.Fatras.G4RandomStreamName)
295 kwargs.setdefault(
"ValidationMode", flags.Sim.ISF.ValidationMode)
296 if flags.Sim.ISF.ValidationMode:
299 if "ParticleBroker" not in kwargs:
302 if "TruthRecordSvc" not in kwargs:
303 kwargs.setdefault(
"ParticleTruthSvc", result.getPrimaryAndMerge(
TruthServiceCfg(flags)).name)
305 kwargs.setdefault(
"PDGToG4ParticleConverter", result.addPublicTool(result.popToolsAndMerge(
fatrasPdgG4ParticleCfg(flags))))
306 kwargs.setdefault(
"G4RunManagerHelper", result.addPublicTool(result.popToolsAndMerge(
G4RunManagerHelperCfg(flags))))
307 result.setPrivateTools(CompFactory.iFatras.G4ParticleDecayHelper(name=name, **kwargs))
317 mlog = logging.getLogger(name)
318 mlog.debug(
'Start configuration')
322 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
323 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
325 kwargs.setdefault(
"UsePDG_EnergyLossFormula",
True)
326 kwargs.setdefault(
"EnergyLossDistribution", 2)
328 from TrkConfig.AtlasExtrapolatorToolsConfig
import AtlasEnergyLossUpdatorCfg
331 result.setPrivateTools(CompFactory.iFatras.McEnergyLossUpdator(name=name, **kwargs))
337 mlog = logging.getLogger(name)
338 mlog.debug(
'Start configuration')
342 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
343 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
344 if "ParticleBroker" not in kwargs:
347 if "TruthRecordSvc" not in kwargs:
348 kwargs.setdefault(
"TruthRecordSvc", result.getPrimaryAndMerge(
TruthServiceCfg(flags)).name)
351 if not flags.Sim.ISF.UseTrackingGeometryCond:
352 if 'TrackingGeometrySvc' not in kwargs:
353 from TrkConfig.AtlasTrackingGeometrySvcConfig
import TrackingGeometrySvcCfg
355 kwargs.setdefault(
"TrackingGeometryReadKey",
'')
357 if 'TrackingGeometryReadKey' not in kwargs:
358 from TrackingGeometryCondAlg.AtlasTrackingGeometryCondAlgConfig
import TrackingGeometryCondAlgCfg
360 geom_cond_key = acc.getPrimary().TrackingGeometryWriteKey
362 kwargs.setdefault(
"TrackingGeometryReadKey", geom_cond_key)
365 kwargs.setdefault(
"HadronicInteraction",
True)
367 kwargs.setdefault(
"HadronicInteractionProcessor", result.addPublicTool(result.popToolsAndMerge(
fatrasG4HadIntProcessorCfg(flags))))
370 kwargs.setdefault(
"EnergyLoss",
True)
374 kwargs.setdefault(
"MultipleScattering",
True)
375 from TrkConfig.AtlasExtrapolatorToolsConfig
import fatrasMultipleScatteringUpdatorCfg
382 kwargs.setdefault(
"ValidationMode", flags.Sim.ISF.ValidationMode)
383 kwargs.setdefault(
"BremPhotonValidation",
False)
384 kwargs.setdefault(
"EnergyDepositValidation",
False)
386 kwargs.setdefault(
"MomentumCut", flags.Sim.Fatras.MomCutOffSec)
387 kwargs.setdefault(
"MinimumBremPhotonMomentum", flags.Sim.Fatras.MomCutOffSec)
389 if flags.Sim.ISF.ValidationMode:
397 kwargs.setdefault(
"BremProcessCode", 3)
399 result.setPrivateTools(CompFactory.iFatras.McMaterialEffectsUpdator(name=name, **kwargs))
404 mlog = logging.getLogger(name)
405 mlog.debug(
'Start configuration')
411 from TrkConfig.AtlasExtrapolatorToolsConfig
import FastSimNavigatorCfg
412 kwargs.setdefault(
"Navigator", result.addPublicTool(result.popToolsAndMerge(
FastSimNavigatorCfg(flags))))
414 kwargs.setdefault(
"MaterialEffectsUpdators", [result.addPublicTool(result.popToolsAndMerge(
fatrasMaterialUpdatorCfg(flags)))])
416 from TrkConfig.TrkExRungeKuttaPropagatorConfig
import RungeKuttaPropagatorCfg
417 kwargs.setdefault(
"Propagators",
418 [result.addPublicTool(result.popToolsAndMerge(
RungeKuttaPropagatorCfg(flags, name=
"ISF_FatrasChargedPropagator")))])
420 from TrkConfig.TrkExSTEP_PropagatorConfig
import fatrasSTEP_PropagatorCfg
421 kwargs.setdefault(
"STEP_Propagator", result.addPublicTool(result.popToolsAndMerge(
fatrasSTEP_PropagatorCfg(flags))))
424 kwargs.setdefault(
"StopWithNavigationBreak",
True)
425 kwargs.setdefault(
"StopWithUpdateKill",
True)
426 kwargs.setdefault(
"RobustSampling",
True)
427 kwargs.setdefault(
"ResolveMuonStation",
True)
428 kwargs.setdefault(
"UseMuonMatApproximation",
True)
430 result.setPrivateTools(CompFactory.Trk.TimedExtrapolator(name=name, **kwargs))
438 mlog = logging.getLogger(name)
439 mlog.debug(
'Start configuration')
443 kwargs.setdefault(
"MaxEtaSymmetric", 10.)
444 kwargs.setdefault(
"MinMomentum", flags.Sim.Fatras.MomCutOffSec)
446 result.setPrivateTools(CompFactory.ISF.KinematicParticleFilter(name=name, **kwargs))
451 mlog = logging.getLogger(name)
452 mlog.debug(
'Start configuration')
456 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
457 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
459 if "ParticleBroker" not in kwargs:
462 if "TruthRecordSvc" not in kwargs:
463 kwargs.setdefault(
"TruthRecordSvc", result.getPrimaryAndMerge(
TruthServiceCfg(flags)).name)
465 if flags.Sim.ISF.ValidationMode:
468 kwargs.setdefault(
"PhysicsProcessCode", 14)
469 kwargs.setdefault(
"ValidationMode", flags.Sim.ISF.ValidationMode)
471 result.setPrivateTools(CompFactory.iFatras.PhotonConversionTool(name=name, **kwargs))
476 mlog = logging.getLogger(name)
477 mlog.debug(
'Start configuration')
481 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
482 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
484 if "ParticleBroker" not in kwargs:
487 if "TruthRecordSvc" not in kwargs:
488 kwargs.setdefault(
"TruthRecordSvc", result.getPrimaryAndMerge(
TruthServiceCfg(flags)).name)
490 kwargs.setdefault(
"MomentumCut", flags.Sim.Fatras.MomCutOffSec)
492 kwargs.setdefault(
"G4RunManagerHelper", result.addPublicTool(result.popToolsAndMerge(
G4RunManagerHelperCfg(flags))))
494 result.setPrivateTools(CompFactory.iFatras.G4HadIntProcessor(name=name, **kwargs))
500 mlog = logging.getLogger(name)
501 mlog.debug(
'Start configuration')
505 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
506 kwargs.setdefault(
"RandomStreamName", flags.Sim.Fatras.RandomStreamName)
508 if "ParticleBroker" not in kwargs:
511 if "TruthRecordSvc" not in kwargs:
512 kwargs.setdefault(
"TruthRecordSvc", result.getPrimaryAndMerge(
TruthServiceCfg(flags)).name)
514 kwargs.setdefault(
"HadronicInteractionScaleFactor", flags.Sim.Fatras.HadronIntProb)
515 kwargs.setdefault(
"MinimumHadronicInitialEnergy", flags.Sim.Fatras.MomCutOffSec)
516 kwargs.setdefault(
"MinimumHadronicOutEnergy", flags.Sim.Fatras.MomCutOffSec)
517 kwargs.setdefault(
"HadronicInteractionValidation",
False)
518 kwargs.setdefault(
"PhysicsProcessCode", 121)
519 kwargs.setdefault(
"ValidationMode", flags.Sim.ISF.ValidationMode)
520 if flags.Sim.ISF.ValidationMode:
522 result.setPrivateTools(CompFactory.iFatras.HadIntProcessorParametric(name, **kwargs))
527 mlog = logging.getLogger(name)
528 mlog.debug(
'Start configuration')
530 result.setPrivateTools(CompFactory.iFatras.ProcessSamplingTool(name=name, **kwargs))
535 mlog = logging.getLogger(name)
536 mlog.debug(
'Start configuration')
540 if "SimHitCreatorID" not in kwargs:
541 kwargs.setdefault(
"SimHitCreatorID", result.addPublicTool(result.popToolsAndMerge(
fatrasSimHitCreatorIDCfg(flags))))
543 kwargs.setdefault(
"SimHitCreatorMS", result.addPublicTool(result.popToolsAndMerge(
fatrasSimHitCreatorMSCfg(flags))))
547 kwargs.setdefault(
"ParticleHelper", result.addPublicTool(result.popToolsAndMerge(ParticleHelperCfg(flags))))
550 kwargs.setdefault(
"TrackFilter", publicKinFilter)
551 kwargs.setdefault(
"NeutralFilter", publicKinFilter)
552 kwargs.setdefault(
"PhotonFilter", publicKinFilter)
554 kwargs.setdefault(
"Extrapolator", result.addPublicTool(result.popToolsAndMerge(
fatrasExtrapolatorCfg(flags))))
556 if flags.Sim.ISF.ValidationMode:
561 kwargs.setdefault(
"OutputLevel", flags.Exec.OutputLevel)
562 kwargs.setdefault(
"ValidationOutput", flags.Sim.ISF.ValidationMode)
564 kwargs.setdefault(
"RandomNumberService", result.getPrimaryAndMerge(
FatrasRndSvcCfg(flags)).name)
566 result.setPrivateTools(CompFactory.iFatras.TransportTool(name=name, **kwargs))
571 mlog = logging.getLogger(name)
572 mlog.debug(
'Start configuration')
585 mlog = logging.getLogger(name)
586 mlog.debug(
'Start configuration')
590 if "IDSimulationTool" not in kwargs
or "SimulationTool" not in kwargs:
591 publicTransportTool = result.addPublicTool(result.popToolsAndMerge(
fatrasTransportToolCfg(flags, **kwargs)))
592 kwargs.setdefault(
"IDSimulationTool", publicTransportTool)
593 kwargs.setdefault(
"SimulationTool", publicTransportTool)
595 result.setPrivateTools(CompFactory.ISF.FatrasSimTool(name, **kwargs))
600 mlog = logging.getLogger(name)
601 mlog.debug(
'Start configuration')
605 kwargs.setdefault(
"IDSimulationTool", result.addPublicTool(result.popToolsAndMerge(
fatrasPileupSimToolCfg(flags))))
606 kwargs.setdefault(
"SimulationTool", result.addPublicTool(result.popToolsAndMerge(
fatrasTransportToolCfg(flags))))
614 mlog = logging.getLogger(name)
615 mlog.debug(
'Start configuration')
618 kwargs.setdefault(
"Identifier",
"Fatras")
620 result.addService(CompFactory.ISF.LegacySimSvc(name, **kwargs), primary =
True)
625 mlog = logging.getLogger(name)
626 mlog.debug(
'Start configuration')
631 result.merge(toolAcc)
635 if __name__ ==
"__main__":
636 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
637 from AthenaCommon.Logging
import log
639 from AthenaConfiguration.TestDefaults
import defaultTestFiles
644 flags.Input.isMC =
True
645 flags.Input.Files = defaultTestFiles.HITS_RUN2
646 flags.Exec.MaxEvents = 3
650 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
654 print(
"INFO_FatrasConfig: Dumping config flags")
656 print(
"INFO_FatrasConfig: Print config details")
657 acc.printConfig(withDetails=
True, summariseProps=
True)
658 acc.store(
open(
'fatrassimtool.pkl',
'wb'))
664 sys.exit(
not sc.isSuccess())