File indexing completed on 2025-01-18 09:12:09
0001
0002
0003 import os
0004 import acts
0005 import acts.examples
0006 from acts.examples import GenericDetector, AlignedDetector
0007 from acts.examples.odd import getOpenDataDetectorDirectory
0008 from acts.examples.simulation import (
0009 addParticleGun,
0010 EtaConfig,
0011 ParticleConfig,
0012 MomentumConfig,
0013 )
0014
0015 u = acts.UnitConstants
0016
0017
0018 def runPropagation(trackingGeometry, field, outputDir, s=None, decorators=[]):
0019 s = s or acts.examples.Sequencer(events=100, numThreads=1)
0020
0021 for d in decorators:
0022 s.addContextDecorator(d)
0023
0024 rnd = acts.examples.RandomNumbers(seed=42)
0025
0026 addParticleGun(
0027 s,
0028 ParticleConfig(num=1000, pdg=acts.PdgParticle.eMuon, randomizeCharge=True),
0029 EtaConfig(-4.0, 4.0),
0030 MomentumConfig(1 * u.GeV, 100 * u.GeV, transverse=True),
0031 rnd=rnd,
0032 )
0033
0034 trkParamExtractor = acts.examples.ParticleTrackParamExtractor(
0035 level=acts.logging.WARNING,
0036 inputParticles="particles_input",
0037 outputTrackParameters="params_particles_input",
0038 )
0039 s.addAlgorithm(trkParamExtractor)
0040
0041 nav = acts.Navigator(trackingGeometry=trackingGeometry)
0042
0043 stepper = acts.EigenStepper(field)
0044
0045
0046
0047 propagator = acts.examples.ConcretePropagator(acts.Propagator(stepper, nav))
0048
0049 propagationAlgorithm = acts.examples.PropagationAlgorithm(
0050 propagatorImpl=propagator,
0051 level=acts.logging.INFO,
0052 sterileLogger=True,
0053 inputTrackParameters="params_particles_input",
0054 outputSummaryCollection="propagation_summary",
0055 )
0056 s.addAlgorithm(propagationAlgorithm)
0057
0058 s.addWriter(
0059 acts.examples.RootPropagationSummaryWriter(
0060 level=acts.logging.INFO,
0061 inputSummaryCollection="propagation_summary",
0062 filePath=outputDir + "/propagation_summary.root",
0063 )
0064 )
0065
0066 return s
0067
0068
0069 if "__main__" == __name__:
0070 matDeco = None
0071
0072
0073
0074
0075 detector = GenericDetector(mdecorator=matDeco)
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095 trackingGeometry = detector.trackingGeometry()
0096 contextDecorators = detector.contextDecorators()
0097
0098
0099 field = acts.ConstantBField(acts.Vector3(0, 0, 2 * acts.UnitConstants.T))
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118 os.makedirs(os.getcwd() + "/propagation", exist_ok=True)
0119
0120 runPropagation(
0121 trackingGeometry,
0122 field,
0123 os.getcwd() + "/propagation",
0124 decorators=contextDecorators,
0125 ).run()