forked from acts-project/acts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Physmon for KF and GSF refitting (acts-project#3733)
Adds KF and GSF refitting to physmon. This allows us to also track physics related changes with fitters and direct navigation. In principle we could monitor the output by comparing it to the normal navigation ones but for now I would opt for creating additional reference files. Later we can converge on the outputs if we want to.
- Loading branch information
Showing
9 changed files
with
255 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+184 KB
CI/physmon/reference/trackrefitting_gsf/performance_trackrefitting.root
Binary file not shown.
Binary file added
BIN
+195 KB
CI/physmon/reference/trackrefitting_kf/performance_trackrefitting.root
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import tempfile | ||
from pathlib import Path | ||
import shutil | ||
|
||
import acts | ||
from truth_tracking_gsf_refitting import runRefittingGsf | ||
|
||
from physmon_common import makeSetup | ||
|
||
setup = makeSetup() | ||
|
||
with tempfile.TemporaryDirectory() as temp: | ||
s = acts.examples.Sequencer( | ||
events=10000, | ||
numThreads=-1, | ||
logLevel=acts.logging.INFO, | ||
) | ||
|
||
tp = Path(temp) | ||
runRefittingGsf( | ||
trackingGeometry=setup.trackingGeometry, | ||
field=setup.field, | ||
digiConfigFile=setup.digiConfig, | ||
outputDir=tp, | ||
s=s, | ||
) | ||
|
||
s.run() | ||
|
||
perf_file = tp / "performance_gsf_refit.root" | ||
assert perf_file.exists(), "Performance file not found" | ||
shutil.copy(perf_file, setup.outdir / "performance_trackrefitting.root") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import tempfile | ||
from pathlib import Path | ||
import shutil | ||
|
||
import acts | ||
from truth_tracking_kalman_refitting import runRefittingKf | ||
|
||
from physmon_common import makeSetup | ||
|
||
setup = makeSetup() | ||
|
||
with tempfile.TemporaryDirectory() as temp: | ||
s = acts.examples.Sequencer( | ||
events=10000, | ||
numThreads=-1, | ||
logLevel=acts.logging.INFO, | ||
) | ||
|
||
tp = Path(temp) | ||
runRefittingKf( | ||
trackingGeometry=setup.trackingGeometry, | ||
field=setup.field, | ||
digiConfigFile=setup.digiConfig, | ||
outputDir=tp, | ||
s=s, | ||
) | ||
|
||
s.run() | ||
|
||
perf_file = tp / "performance_kf_refit.root" | ||
assert perf_file.exists(), "Performance file not found" | ||
shutil.copy(perf_file, setup.outdir / "performance_trackrefitting.root") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
Examples/Scripts/Python/truth_tracking_kalman_refitting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from pathlib import Path | ||
|
||
import acts | ||
import acts.examples | ||
|
||
from truth_tracking_kalman import runTruthTrackingKalman | ||
|
||
u = acts.UnitConstants | ||
|
||
|
||
def runRefittingKf( | ||
trackingGeometry: acts.TrackingGeometry, | ||
field: acts.MagneticFieldProvider, | ||
digiConfigFile: Path, | ||
outputDir: Path, | ||
multipleScattering: bool = True, | ||
energyLoss: bool = True, | ||
reverseFilteringMomThreshold=0 * u.GeV, | ||
s: acts.examples.Sequencer = None, | ||
): | ||
s = runTruthTrackingKalman( | ||
trackingGeometry, | ||
field, | ||
digiConfigFile=digiConfigFile, | ||
outputDir=outputDir, | ||
s=s, | ||
) | ||
|
||
kalmanOptions = { | ||
"multipleScattering": multipleScattering, | ||
"energyLoss": energyLoss, | ||
"reverseFilteringMomThreshold": reverseFilteringMomThreshold, | ||
"freeToBoundCorrection": acts.examples.FreeToBoundCorrection(False), | ||
"level": acts.logging.INFO, | ||
} | ||
|
||
s.addAlgorithm( | ||
acts.examples.RefittingAlgorithm( | ||
level=acts.logging.INFO, | ||
inputTracks="kf_tracks", | ||
outputTracks="kf_refit_tracks", | ||
fit=acts.examples.makeKalmanFitterFunction( | ||
trackingGeometry, field, **kalmanOptions | ||
), | ||
) | ||
) | ||
|
||
s.addAlgorithm( | ||
acts.examples.TrackTruthMatcher( | ||
level=acts.logging.INFO, | ||
inputTracks="kf_refit_tracks", | ||
inputParticles="truth_seeds_selected", | ||
inputMeasurementParticlesMap="measurement_particles_map", | ||
outputTrackParticleMatching="refit_track_particle_matching", | ||
outputParticleTrackMatching="refit_particle_track_matching", | ||
) | ||
) | ||
|
||
s.addWriter( | ||
acts.examples.RootTrackStatesWriter( | ||
level=acts.logging.INFO, | ||
inputTracks="kf_refit_tracks", | ||
inputParticles="truth_seeds_selected", | ||
inputTrackParticleMatching="refit_track_particle_matching", | ||
inputSimHits="simhits", | ||
inputMeasurementSimHitsMap="measurement_simhits_map", | ||
filePath=str(outputDir / "trackstates_kf_refit.root"), | ||
) | ||
) | ||
|
||
s.addWriter( | ||
acts.examples.RootTrackSummaryWriter( | ||
level=acts.logging.INFO, | ||
inputTracks="tracks", | ||
inputParticles="truth_seeds_selected", | ||
inputTrackParticleMatching="refit_track_particle_matching", | ||
filePath=str(outputDir / "tracksummary_kf_refit.root"), | ||
) | ||
) | ||
|
||
s.addWriter( | ||
acts.examples.TrackFitterPerformanceWriter( | ||
level=acts.logging.INFO, | ||
inputTracks="tracks", | ||
inputParticles="truth_seeds_selected", | ||
inputTrackParticleMatching="track_particle_matching", | ||
filePath=str(outputDir / "performance_kf_refit.root"), | ||
) | ||
) | ||
|
||
return s | ||
|
||
|
||
if __name__ == "__main__": | ||
srcdir = Path(__file__).resolve().parent.parent.parent.parent | ||
outputDir = Path.cwd() | ||
|
||
# ODD | ||
from acts.examples.odd import getOpenDataDetector | ||
|
||
detector, trackingGeometry, decorators = getOpenDataDetector() | ||
digiConfigFile = ( | ||
srcdir / "thirdparty/OpenDataDetector/config/odd-digi-smearing-config.json" | ||
) | ||
|
||
## GenericDetector | ||
# detector, trackingGeometry, _ = acts.examples.GenericDetector.create() | ||
# digiConfigFile = ( | ||
# srcdir | ||
# / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json" | ||
# ) | ||
|
||
field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) | ||
|
||
runRefittingKf( | ||
trackingGeometry=trackingGeometry, | ||
field=field, | ||
digiConfigFile=digiConfigFile, | ||
outputDir=Path.cwd(), | ||
).run() |