File indexing completed on 2025-01-18 09:12:09
0001
0002
0003 from pathlib import Path
0004
0005 import acts
0006 import acts.examples
0007
0008 from truth_tracking_kalman import runTruthTrackingKalman
0009
0010 u = acts.UnitConstants
0011
0012
0013 def runRefittingGsf(
0014 trackingGeometry: acts.TrackingGeometry,
0015 field: acts.MagneticFieldProvider,
0016 digiConfigFile: Path,
0017 outputDir: Path,
0018 s: acts.examples.Sequencer = None,
0019 ):
0020 s = runTruthTrackingKalman(
0021 trackingGeometry,
0022 field,
0023 digiConfigFile=digiConfigFile,
0024 outputDir=outputDir,
0025 s=s,
0026 )
0027
0028
0029
0030
0031 bha = acts.examples.AtlasBetheHeitlerApprox.makeDefault(clampToRange=True)
0032
0033 gsfOptions = {
0034 "betheHeitlerApprox": bha,
0035 "maxComponents": 12,
0036 "componentMergeMethod": acts.examples.ComponentMergeMethod.maxWeight,
0037 "mixtureReductionAlgorithm": acts.examples.MixtureReductionAlgorithm.KLDistance,
0038 "weightCutoff": 1.0e-4,
0039 "level": acts.logging.INFO,
0040 }
0041
0042 s.addAlgorithm(
0043 acts.examples.RefittingAlgorithm(
0044 acts.logging.INFO,
0045 inputTracks="kf_tracks",
0046 outputTracks="gsf_refit_tracks",
0047 fit=acts.examples.makeGsfFitterFunction(
0048 trackingGeometry, field, **gsfOptions
0049 ),
0050 )
0051 )
0052
0053 s.addAlgorithm(
0054 acts.examples.TrackTruthMatcher(
0055 level=acts.logging.INFO,
0056 inputTracks="gsf_refit_tracks",
0057 inputParticles="particles_selected",
0058 inputMeasurementParticlesMap="measurement_particles_map",
0059 outputTrackParticleMatching="refit_track_particle_matching",
0060 outputParticleTrackMatching="refit_particle_track_matching",
0061 )
0062 )
0063
0064 s.addWriter(
0065 acts.examples.RootTrackStatesWriter(
0066 level=acts.logging.INFO,
0067 inputTracks="gsf_refit_tracks",
0068 inputParticles="particles_selected",
0069 inputTrackParticleMatching="refit_track_particle_matching",
0070 inputSimHits="simhits",
0071 inputMeasurementSimHitsMap="measurement_simhits_map",
0072 filePath=str(outputDir / "trackstates_gsf_refit.root"),
0073 )
0074 )
0075
0076 s.addWriter(
0077 acts.examples.RootTrackSummaryWriter(
0078 level=acts.logging.INFO,
0079 inputTracks="tracks",
0080 inputParticles="particles_selected",
0081 inputTrackParticleMatching="refit_track_particle_matching",
0082 filePath=str(outputDir / "tracksummary_gsf_refit.root"),
0083 )
0084 )
0085
0086 s.addWriter(
0087 acts.examples.TrackFitterPerformanceWriter(
0088 level=acts.logging.INFO,
0089 inputTracks="tracks",
0090 inputParticles="particles_selected",
0091 inputTrackParticleMatching="track_particle_matching",
0092 filePath=str(outputDir / "performance_gsf_refit.root"),
0093 )
0094 )
0095
0096 return s
0097
0098
0099 if __name__ == "__main__":
0100 srcdir = Path(__file__).resolve().parent.parent.parent.parent
0101
0102
0103 from acts.examples.odd import getOpenDataDetector
0104
0105 detector = getOpenDataDetector()
0106 trackingGeometry = detector.trackingGeometry()
0107 digiConfigFile = (
0108 srcdir / "thirdparty/OpenDataDetector/config/odd-digi-smearing-config.json"
0109 )
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T))
0120
0121 runRefittingGsf(
0122 trackingGeometry=trackingGeometry,
0123 field=field,
0124 digiConfigFile=digiConfigFile,
0125 outputDir=Path.cwd(),
0126 ).run()