File indexing completed on 2025-08-05 08:09:09
0001
0002
0003 import tempfile
0004 from pathlib import Path
0005 import shutil
0006
0007 import acts
0008 from acts.examples.simulation import (
0009 addPythia8,
0010 addFatras,
0011 addDigitization,
0012 )
0013 from acts.examples.reconstruction import (
0014 addSeeding,
0015 TruthSeedRanges,
0016 SeedFinderConfigArg,
0017 SeedFinderOptionsArg,
0018 SeedingAlgorithm,
0019 CkfConfig,
0020 addCKFTracks,
0021 addAmbiguityResolution,
0022 AmbiguityResolutionConfig,
0023 addVertexFitting,
0024 VertexFinder,
0025 TrackSelectorConfig,
0026 )
0027
0028 from physmon_common import makeSetup
0029
0030 u = acts.UnitConstants
0031
0032 setup = makeSetup()
0033
0034
0035 with tempfile.TemporaryDirectory() as temp:
0036 s = acts.examples.Sequencer(
0037 events=3,
0038 numThreads=-1,
0039 logLevel=acts.logging.INFO,
0040 )
0041
0042 tp = Path(temp)
0043
0044 for d in setup.decorators:
0045 s.addContextDecorator(d)
0046
0047 rnd = acts.examples.RandomNumbers(seed=42)
0048
0049 addPythia8(
0050 s,
0051 hardProcess=["Top:qqbar2ttbar=on"],
0052 npileup=200,
0053 vtxGen=acts.examples.GaussianVertexGenerator(
0054 mean=acts.Vector4(0, 0, 0, 0),
0055 stddev=acts.Vector4(0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 5.0 * u.ns),
0056 ),
0057 rnd=rnd,
0058 )
0059
0060 addFatras(
0061 s,
0062 setup.trackingGeometry,
0063 setup.field,
0064 rnd=rnd,
0065 )
0066
0067 addDigitization(
0068 s,
0069 setup.trackingGeometry,
0070 setup.field,
0071 digiConfigFile=setup.digiConfig,
0072 rnd=rnd,
0073 )
0074
0075 addSeeding(
0076 s,
0077 setup.trackingGeometry,
0078 setup.field,
0079 TruthSeedRanges(pt=(500.0 * u.MeV, None), nHits=(9, None)),
0080 SeedFinderConfigArg(
0081 r=(33 * u.mm, 200 * u.mm),
0082 deltaR=(1 * u.mm, 60 * u.mm),
0083 collisionRegion=(-250 * u.mm, 250 * u.mm),
0084 z=(-2000 * u.mm, 2000 * u.mm),
0085 maxSeedsPerSpM=1,
0086 sigmaScattering=5,
0087 radLengthPerSeed=0.1,
0088 minPt=500 * u.MeV,
0089 impactMax=3 * u.mm,
0090 ),
0091 SeedFinderOptionsArg(bFieldInZ=2 * u.T, beamPos=(0.0, 0.0)),
0092 seedingAlgorithm=SeedingAlgorithm.Default,
0093 geoSelectionConfigFile=setup.geoSel,
0094 outputDirRoot=tp,
0095 )
0096
0097 addCKFTracks(
0098 s,
0099 setup.trackingGeometry,
0100 setup.field,
0101 TrackSelectorConfig(
0102 pt=(500 * u.MeV, None),
0103 loc0=(-4.0 * u.mm, 4.0 * u.mm),
0104 nMeasurementsMin=6,
0105 maxHoles=2,
0106 maxOutliers=2,
0107 ),
0108 CkfConfig(
0109 seedDeduplication=True,
0110 stayOnSeed=True,
0111 ),
0112 outputDirRoot=tp,
0113 )
0114
0115 addAmbiguityResolution(
0116 s,
0117 AmbiguityResolutionConfig(
0118 maximumSharedHits=3,
0119 maximumIterations=100000,
0120 nMeasurementsMin=6,
0121 ),
0122 outputDirRoot=tp,
0123 )
0124
0125 s.addAlgorithm(
0126 acts.examples.TracksToParameters(
0127 level=acts.logging.INFO,
0128 inputTracks="tracks",
0129 outputTrackParameters="trackParameters",
0130 )
0131 )
0132
0133 addVertexFitting(
0134 s,
0135 setup.field,
0136 tracks="tracks",
0137 trackParameters="trackParameters",
0138 outputProtoVertices="amvf_protovertices",
0139 outputVertices="amvf_fittedVertices",
0140 seeder=acts.VertexSeedFinder.GaussianSeeder,
0141 vertexFinder=VertexFinder.AMVF,
0142 outputDirRoot=tp / "amvf",
0143 )
0144
0145 addVertexFitting(
0146 s,
0147 setup.field,
0148 tracks="tracks",
0149 trackParameters="trackParameters",
0150 outputProtoVertices="amvf_gridseeder_protovertices",
0151 outputVertices="amvf_gridseeder_fittedVertices",
0152 seeder=acts.VertexSeedFinder.AdaptiveGridSeeder,
0153 useTime=True,
0154 vertexFinder=VertexFinder.AMVF,
0155 outputDirRoot=tp / "amvf_gridseeder",
0156 )
0157
0158 s.run()
0159 del s
0160
0161 for vertexing in ["amvf", "amvf_gridseeder"]:
0162 shutil.move(
0163 tp / f"{vertexing}/performance_vertexing.root",
0164 tp / f"performance_{vertexing}.root",
0165 )
0166
0167 for stem in [
0168 "performance_ckf",
0169 "tracksummary_ckf",
0170 "performance_amvf",
0171 "performance_amvf_gridseeder",
0172 ] + (["performance_seeding", "performance_ambi"]):
0173 perf_file = tp / f"{stem}.root"
0174 assert perf_file.exists(), "Performance file not found"
0175 shutil.copy(perf_file, setup.outdir / f"{stem}_ttbar.root")