File indexing completed on 2025-01-30 09:13:26
0001
0002
0003 import tempfile
0004 from pathlib import Path
0005 import shutil
0006
0007 import acts
0008 from acts.examples.simulation import (
0009 addParticleGun,
0010 MomentumConfig,
0011 EtaConfig,
0012 PhiConfig,
0013 ParticleConfig,
0014 addFatras,
0015 addDigitization,
0016 ParticleSelectorConfig,
0017 addDigiParticleSelection,
0018 )
0019 from acts.examples.reconstruction import (
0020 addSeeding,
0021 SeedFinderConfigArg,
0022 SeedFinderOptionsArg,
0023 SeedingAlgorithm,
0024 CkfConfig,
0025 addCKFTracks,
0026 addAmbiguityResolution,
0027 AmbiguityResolutionConfig,
0028 addVertexFitting,
0029 VertexFinder,
0030 TrackSelectorConfig,
0031 )
0032
0033 from physmon_common import makeSetup
0034
0035 u = acts.UnitConstants
0036
0037 setup = makeSetup()
0038
0039
0040 with tempfile.TemporaryDirectory() as temp:
0041 s = acts.examples.Sequencer(
0042 events=3,
0043 numThreads=-1,
0044 logLevel=acts.logging.INFO,
0045 )
0046
0047 tp = Path(temp)
0048
0049 for d in setup.decorators:
0050 s.addContextDecorator(d)
0051
0052 rnd = acts.examples.RandomNumbers(seed=42)
0053
0054 addParticleGun(
0055 s,
0056 MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, transverse=True),
0057 EtaConfig(-3.0, 3.0, uniform=True),
0058 PhiConfig(0.0, 360.0 * u.degree),
0059 ParticleConfig(10, acts.PdgParticle.eMuon, randomizeCharge=True),
0060 vtxGen=acts.examples.GaussianVertexGenerator(
0061 mean=acts.Vector4(0, 0, 0, 0),
0062 stddev=acts.Vector4(0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 1.0 * u.ns),
0063 ),
0064 multiplicity=50,
0065 rnd=rnd,
0066 )
0067
0068 addFatras(
0069 s,
0070 setup.trackingGeometry,
0071 setup.field,
0072 rnd=rnd,
0073 )
0074
0075 addDigitization(
0076 s,
0077 setup.trackingGeometry,
0078 setup.field,
0079 digiConfigFile=setup.digiConfig,
0080 rnd=rnd,
0081 )
0082
0083 addDigiParticleSelection(
0084 s,
0085 ParticleSelectorConfig(
0086 pt=(0.9 * u.GeV, None),
0087 measurements=(9, None),
0088 removeNeutral=True,
0089 ),
0090 )
0091
0092 addSeeding(
0093 s,
0094 setup.trackingGeometry,
0095 setup.field,
0096 SeedFinderConfigArg(
0097 r=(33 * u.mm, 200 * u.mm),
0098 deltaR=(1 * u.mm, 60 * u.mm),
0099 collisionRegion=(-250 * u.mm, 250 * u.mm),
0100 z=(-2000 * u.mm, 2000 * u.mm),
0101 maxSeedsPerSpM=1,
0102 sigmaScattering=5,
0103 radLengthPerSeed=0.1,
0104 minPt=0.5 * u.GeV,
0105 impactMax=3 * u.mm,
0106 ),
0107 SeedFinderOptionsArg(bFieldInZ=2 * u.T, beamPos=(0.0, 0.0)),
0108 seedingAlgorithm=SeedingAlgorithm.Default,
0109 initialSigmas=[
0110 1 * u.mm,
0111 1 * u.mm,
0112 1 * u.degree,
0113 1 * u.degree,
0114 0.1 * u.e / u.GeV,
0115 1 * u.ns,
0116 ],
0117 initialSigmaPtRel=0.01,
0118 initialVarInflation=[1.0] * 6,
0119 geoSelectionConfigFile=setup.geoSel,
0120 outputDirRoot=tp,
0121 )
0122
0123 addCKFTracks(
0124 s,
0125 setup.trackingGeometry,
0126 setup.field,
0127 TrackSelectorConfig(
0128 pt=(0.9 * u.GeV, None),
0129 loc0=(-4.0 * u.mm, 4.0 * u.mm),
0130 nMeasurementsMin=6,
0131 maxHoles=2,
0132 maxOutliers=2,
0133 ),
0134 CkfConfig(
0135 chi2CutOffMeasurement=15.0,
0136 chi2CutOffOutlier=25.0,
0137 numMeasurementsCutOff=10,
0138 seedDeduplication=True,
0139 stayOnSeed=True,
0140 ),
0141 outputDirRoot=tp,
0142 )
0143
0144 addAmbiguityResolution(
0145 s,
0146 AmbiguityResolutionConfig(
0147 maximumSharedHits=3,
0148 maximumIterations=100000,
0149 nMeasurementsMin=6,
0150 ),
0151 outputDirRoot=tp,
0152 )
0153
0154 s.addAlgorithm(
0155 acts.examples.TracksToParameters(
0156 level=acts.logging.INFO,
0157 inputTracks="tracks",
0158 outputTrackParameters="trackParameters",
0159 )
0160 )
0161
0162
0163
0164
0165
0166
0167 addVertexFitting(
0168 s,
0169 setup.field,
0170 trackParameters="trackParameters",
0171 outputProtoVertices="ivf_notime_protovertices",
0172 outputVertices="ivf_notime_fittedVertices",
0173 vertexFinder=VertexFinder.Iterative,
0174 outputDirRoot=tp / "ivf_notime",
0175 )
0176
0177 addVertexFitting(
0178 s,
0179 setup.field,
0180 trackParameters="trackParameters",
0181 outputProtoVertices="amvf_gauss_notime_protovertices",
0182 outputVertices="amvf_gauss_notime_fittedVertices",
0183 seeder=acts.VertexSeedFinder.GaussianSeeder,
0184 useTime=False,
0185 vertexFinder=VertexFinder.AMVF,
0186 outputDirRoot=tp / "amvf_gauss_notime",
0187 )
0188
0189 addVertexFitting(
0190 s,
0191 setup.field,
0192 trackParameters="trackParameters",
0193 outputProtoVertices="amvf_grid_time_protovertices",
0194 outputVertices="amvf_grid_time_fittedVertices",
0195 seeder=acts.VertexSeedFinder.AdaptiveGridSeeder,
0196 useTime=True,
0197 vertexFinder=VertexFinder.AMVF,
0198 outputDirRoot=tp / "amvf_grid_time",
0199 )
0200
0201 s.run()
0202
0203 shutil.move(
0204 tp / "performance_finding_ambi.root",
0205 tp / "performance_finding_ckf_ambi.root",
0206 )
0207 shutil.move(
0208 tp / "performance_fitting_ambi.root",
0209 tp / "performance_fitting_ckf_ambi.root",
0210 )
0211 for vertexing in ["ivf_notime", "amvf_gauss_notime", "amvf_grid_time"]:
0212 shutil.move(
0213 tp / f"{vertexing}/performance_vertexing.root",
0214 tp / f"performance_vertexing_{vertexing}.root",
0215 )
0216
0217 for file in [
0218 "performance_seeding.root",
0219 "tracksummary_ckf.root",
0220 "performance_finding_ckf.root",
0221 "performance_fitting_ckf.root",
0222 "performance_finding_ckf_ambi.root",
0223 "performance_fitting_ckf_ambi.root",
0224 "performance_vertexing_ivf_notime.root",
0225 "performance_vertexing_amvf_gauss_notime.root",
0226 "performance_vertexing_amvf_grid_time.root",
0227 ]:
0228 perf_file = tp / file
0229 assert perf_file.exists(), f"Performance file not found {perf_file}"
0230 shutil.copy(perf_file, setup.outdir / file)