Skip to content

Commit

Permalink
feat: Floating point exception monitoring (#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Dec 19, 2022
1 parent cb90440 commit 651f970
Show file tree
Hide file tree
Showing 26 changed files with 616 additions and 281 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ jobs:
&& source build/python/setup.sh
&& export LD_LIBRARY_PATH=$PWD/build/thirdparty/OpenDataDetector/factory:$LD_LIBRARY_PATH
&& pip3 install -r Examples/Python/tests/requirements.txt
&& pytest -rFsv
&& pytest -rFsv -v
linux_physmon:
runs-on: ubuntu-latest
Expand Down
306 changes: 164 additions & 142 deletions CI/physmon/physmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,63 +72,55 @@
digiConfig = srcdir / "thirdparty/OpenDataDetector/config/odd-digi-smearing-config.json"
geoSel = srcdir / "thirdparty/OpenDataDetector/config/odd-seeding-config.json"


field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T))


### Truth tracking with Kalman Filter

with tempfile.TemporaryDirectory() as temp:
s = acts.examples.Sequencer(events=10000, numThreads=-1, logLevel=acts.logging.INFO)
tp = Path(temp)
runTruthTrackingKalman(
trackingGeometry,
field,
digiConfigFile=digiConfig,
outputDir=tp,
s=s,
)

s.run()
del s

perf_file = tp / "performance_track_fitter.root"
assert perf_file.exists(), "Performance file not found"
shutil.copy(perf_file, outdir / "performance_truth_tracking.root")
def truth_tracking_kalman():
with tempfile.TemporaryDirectory() as temp:
s = acts.examples.Sequencer(
events=10000, numThreads=-1, logLevel=acts.logging.INFO
)
tp = Path(temp)
runTruthTrackingKalman(
trackingGeometry,
field,
digiConfigFile=digiConfig,
outputDir=tp,
s=s,
)

s.run()
del s

### GSF
perf_file = tp / "performance_track_fitter.root"
assert perf_file.exists(), "Performance file not found"
shutil.copy(perf_file, outdir / "performance_truth_tracking.root")

with tempfile.TemporaryDirectory() as temp:
s = acts.examples.Sequencer(events=500, numThreads=-1, logLevel=acts.logging.INFO)

tp = Path(temp)
runTruthTrackingGsf(
trackingGeometry,
digiConfig,
field,
outputDir=tp,
s=s,
)
def truth_tracking_gsf():
with tempfile.TemporaryDirectory() as temp:
s = acts.examples.Sequencer(
events=500, numThreads=-1, logLevel=acts.logging.INFO
)

s.run()
del s
tp = Path(temp)
runTruthTrackingGsf(
trackingGeometry,
digiConfig,
field,
outputDir=tp,
s=s,
)

perf_file = tp / "performance_gsf.root"
assert perf_file.exists(), "Performance file not found"
shutil.copy(perf_file, outdir / "performance_gsf.root")
s.run()
del s

perf_file = tp / "performance_gsf.root"
assert perf_file.exists(), "Performance file not found"
shutil.copy(perf_file, outdir / "performance_gsf.root")

### CKF track finding variations

for truthSmearedSeeded, truthEstimatedSeeded, label in [
(True, False, "truth_smeared"), # if first is true, second is ignored
(False, True, "truth_estimated"),
(False, False, "seeded"),
(False, False, "orthogonal"),
]:
# TODO There seems to be a difference to the reference files when using
# multithreading ActsAnalysisResidualsAndPulls
def run_ckf_tracking(truthSmearedSeeded, truthEstimatedSeeded, label):
s = acts.examples.Sequencer(events=500, numThreads=-1, logLevel=acts.logging.INFO)

with tempfile.TemporaryDirectory() as temp:
Expand Down Expand Up @@ -248,120 +240,150 @@
assert perf_file.exists(), "Performance file not found"
shutil.copy(perf_file, outdir / f"{stem}_{label}.root")

### VERTEX MU SCAN

for fitter in (VertexFinder.Iterative, VertexFinder.AMVF):
for mu in (1, 10, 25, 50, 75, 100, 125, 150, 175, 200):
start = datetime.datetime.now()
s = acts.examples.Sequencer(events=5, numThreads=-1, logLevel=acts.logging.INFO)
def run_vertexing(fitter, mu, events):
s = acts.examples.Sequencer(
events=events, numThreads=-1, logLevel=acts.logging.INFO
)

with tempfile.TemporaryDirectory() as temp:
tp = Path(temp)
with tempfile.TemporaryDirectory() as temp:
tp = Path(temp)

for d in decorators:
s.addContextDecorator(d)
for d in decorators:
s.addContextDecorator(d)

rnd = acts.examples.RandomNumbers(seed=42)
rnd = acts.examples.RandomNumbers(seed=42)

vtxGen = acts.examples.GaussianVertexGenerator(
stddev=acts.Vector4(10 * u.um, 10 * u.um, 50 * u.mm, 0),
mean=acts.Vector4(0, 0, 0, 0),
)
vtxGen = acts.examples.GaussianVertexGenerator(
stddev=acts.Vector4(10 * u.um, 10 * u.um, 50 * u.mm, 0),
mean=acts.Vector4(0, 0, 0, 0),
)

addParticleGun(
s,
EtaConfig(-4.0, 4.0),
ParticleConfig(4, acts.PdgParticle.eMuon, True),
PhiConfig(0.0, 360.0 * u.degree),
vtxGen=vtxGen,
multiplicity=mu,
rnd=rnd,
)
addParticleGun(
s,
EtaConfig(-4.0, 4.0),
ParticleConfig(4, acts.PdgParticle.eMuon, True),
PhiConfig(0.0, 360.0 * u.degree),
vtxGen=vtxGen,
multiplicity=mu,
rnd=rnd,
)

addFatras(
s,
trackingGeometry,
field,
rnd=rnd,
)
addFatras(
s,
trackingGeometry,
field,
rnd=rnd,
)

addDigitization(
s,
trackingGeometry,
field,
digiConfigFile=digiConfig,
rnd=rnd,
)
addDigitization(
s,
trackingGeometry,
field,
digiConfigFile=digiConfig,
rnd=rnd,
)

addSeeding(
s,
trackingGeometry,
field,
TruthSeedRanges(pt=(500.0 * u.MeV, None), nHits=(9, None)),
ParticleSmearingSigmas(
pRel=0.01
), # only used by SeedingAlgorithm.TruthSmeared
SeedFinderConfigArg(
r=(None, 200 * u.mm), # rMin=default, 33mm
deltaR=(1 * u.mm, 60 * u.mm),
collisionRegion=(-250 * u.mm, 250 * u.mm),
z=(-2000 * u.mm, 2000 * u.mm),
maxSeedsPerSpM=1,
sigmaScattering=5,
radLengthPerSeed=0.1,
minPt=500 * u.MeV,
impactMax=3 * u.mm,
),
SeedFinderOptionsArg(bFieldInZ=1.99724 * u.T),
TrackParamsEstimationConfig(deltaR=(10.0 * u.mm, None)),
seedingAlgorithm=SeedingAlgorithm.Default,
geoSelectionConfigFile=geoSel,
rnd=rnd, # only used by SeedingAlgorithm.TruthSmeared
outputDirRoot=None,
)
addSeeding(
s,
trackingGeometry,
field,
TruthSeedRanges(pt=(500.0 * u.MeV, None), nHits=(9, None)),
ParticleSmearingSigmas(
pRel=0.01
), # only used by SeedingAlgorithm.TruthSmeared
SeedFinderConfigArg(
r=(None, 200 * u.mm), # rMin=default, 33mm
deltaR=(1 * u.mm, 60 * u.mm),
collisionRegion=(-250 * u.mm, 250 * u.mm),
z=(-2000 * u.mm, 2000 * u.mm),
maxSeedsPerSpM=1,
sigmaScattering=5,
radLengthPerSeed=0.1,
minPt=500 * u.MeV,
impactMax=3 * u.mm,
),
SeedFinderOptionsArg(bFieldInZ=1.99724 * u.T),
TrackParamsEstimationConfig(deltaR=(10.0 * u.mm, None)),
seedingAlgorithm=SeedingAlgorithm.Default,
geoSelectionConfigFile=geoSel,
rnd=rnd, # only used by SeedingAlgorithm.TruthSmeared
outputDirRoot=None,
)

addCKFTracks(
s,
trackingGeometry,
field,
CKFPerformanceConfig(ptMin=400.0 * u.MeV, nMeasurementsMin=6),
TrackSelectorRanges(
removeNeutral=True,
loc0=(None, 4.0 * u.mm),
pt=(500 * u.MeV, None),
),
outputDirRoot=None,
outputDirCsv=None,
)
addCKFTracks(
s,
trackingGeometry,
field,
CKFPerformanceConfig(ptMin=400.0 * u.MeV, nMeasurementsMin=6),
TrackSelectorRanges(
removeNeutral=True,
loc0=(None, 4.0 * u.mm),
pt=(500 * u.MeV, None),
),
outputDirRoot=None,
outputDirCsv=None,
)

addAmbiguityResolution(
s,
AmbiguityResolutionConfig(maximumSharedHits=3),
CKFPerformanceConfig(ptMin=400.0 * u.MeV, nMeasurementsMin=6),
outputDirRoot=None,
)
addAmbiguityResolution(
s,
AmbiguityResolutionConfig(maximumSharedHits=3),
CKFPerformanceConfig(ptMin=400.0 * u.MeV, nMeasurementsMin=6),
outputDirRoot=None,
)

addVertexFitting(
s,
field,
vertexFinder=fitter,
outputDirRoot=tp,
)
addVertexFitting(
s,
field,
vertexFinder=fitter,
outputDirRoot=tp,
)

s.run()
s.run()

delta = datetime.datetime.now() - start
del s

duration = delta.total_seconds() / s.config.events
perf_file = tp / f"performance_vertexing.root"
assert perf_file.exists(), "Performance file not found"
shutil.copy(
perf_file,
outdir / f"performance_vertexing_{fitter.name}_mu{mu}.root",
)

perf_file = tp / f"performance_vertexing.root"
assert perf_file.exists(), "Performance file not found"
shutil.copy(
perf_file, outdir / f"performance_vertexing_{fitter.name}_mu{mu}.root"
)

with acts.FpeMonitor():

### Truth tracking with Kalman Filter

truth_tracking_kalman()

### GSF

truth_tracking_gsf()

### CKF track finding variations

for truthSmearedSeeded, truthEstimatedSeeded, label in [
(True, False, "truth_smeared"), # if first is true, second is ignored
(False, True, "truth_estimated"),
(False, False, "seeded"),
(False, False, "orthogonal"),
]:
run_ckf_tracking(truthSmearedSeeded, truthEstimatedSeeded, label)

### VERTEX MU SCAN

for fitter in (VertexFinder.Iterative, VertexFinder.AMVF):
for mu in (1, 10, 25, 50, 75, 100, 125, 150, 175, 200):
start = datetime.datetime.now()

events = 5
run_vertexing(fitter, mu, events)

delta = datetime.datetime.now() - start

duration = delta.total_seconds() / events

(
outdir / f"performance_vertexing_{fitter.name}_mu{mu}_time.txt"
).write_text(str(duration))

del s
29 changes: 29 additions & 0 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,35 @@ target_link_libraries(
ActsCore
PUBLIC Boost::boost Eigen3::Eigen)

# Fpe flags
set(_fpe_options "")

find_library(dl_LIBRARY dl)
find_package(Backtrace)
find_program(addr2line_EXECUTABLE addr2line)
if(APPLE)
list(APPEND _fpe_options -D_GNU_SOURCE)
else()
if(dl_LIBRARY)
target_link_libraries(ActsCore PUBLIC ${dl_LIBRARY})
if(addr2line_EXECUTABLE)
list(APPEND _fpe_options -DBOOST_STACKTRACE_USE_ADDR2LINE)
list(APPEND _fpe_options -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=${addr2line_EXECUTABLE})
elseif(Backtrace_FOUND)
list(APPEND _fpe_options -DBOOST_STACKTRACE_USE_BACKTRACE)
target_link_libraries(ActsCore PUBLIC ${Backtrace_LIBRARY})
else()
list(APPEND _fpe_options -BOOST_STACKTRACE_USE_NOOP)
endif()
else()
list(APPEND _fpe_options -BOOST_STACKTRACE_USE_NOOP)
endif()
endif()

message(STATUS ${_fpe_options})

set_source_files_properties(src/Utilities/FpeMonitor.cpp PROPERTIES COMPILE_OPTIONS "${_fpe_options}")

if(ACTS_PARAMETER_DEFINITIONS_HEADER)
target_compile_definitions(
ActsCore
Expand Down

0 comments on commit 651f970

Please sign in to comment.