Skip to content

Commit

Permalink
Merge branch 'main' into refactor/detray-sensitive-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger authored Dec 13, 2024
2 parents dd1c3cb + 2d5ed72 commit 837c2dd
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ genConf
x86_64-slc6-gcc48-opt
x86_64-slc6-gcc49-opt
.*
build*
/build*
.asetup.save

#json output
Expand All @@ -30,7 +30,7 @@ build*

# dont ignore hidden configs
!.clang-format
!.github/**
!.github
!.gitignore
!.gitlab-ci.yml
!.clang-tidy
Expand Down
13 changes: 9 additions & 4 deletions Core/include/Acts/EventData/detail/GenerateParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,24 @@ template <typename generator_t>
inline std::pair<double, double> generateBoundDirection(
generator_t& rng, const GenerateBoundDirectionOptions& options) {
using UniformReal = std::uniform_real_distribution<double>;
assert(options.thetaMin >= 0.f);
assert(options.thetaMax <= std::numbers::pi);
assert(options.thetaMin <= options.thetaMax);

// since we want to draw the direction uniform on the unit sphere, we must
// draw from cos(theta) instead of theta. see e.g.
// https://mathworld.wolfram.com/SpherePointPicking.html
double cosThetaMin = std::cos(options.thetaMin);
// Get cosThetaMin from thetaMax and vice versa, because cos is
// monothonical decreasing between [0, pi]
double cosThetaMin = std::cos(options.thetaMax);
// ensure upper bound is included. see e.g.
// https://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution
double cosThetaMax = std::nextafter(std::cos(options.thetaMax),
double cosThetaMax = std::nextafter(std::cos(options.thetaMin),
std::numeric_limits<double>::max());

// in case we force uniform eta generation
double etaMin = Acts::AngleHelpers::etaFromTheta(options.thetaMin);
double etaMax = Acts::AngleHelpers::etaFromTheta(options.thetaMax);
double etaMin = Acts::AngleHelpers::etaFromTheta(options.thetaMax);
double etaMax = Acts::AngleHelpers::etaFromTheta(options.thetaMin);

UniformReal phiDist(options.phiMin, options.phiMax);
UniformReal cosThetaDist(cosThetaMin, cosThetaMax);
Expand Down
2 changes: 1 addition & 1 deletion Core/src/Visualization/ObjVisualization3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void ObjVisualization3D::faces(const std::vector<Vector3>& vtxs,
o.vertices.insert(o.vertices.end(), vtxs.begin(), vtxs.end());
for (const auto& face : faces) {
if (face.size() == 2) {
o.lines.push_back({face[0] + vtxoffs, face[2] + vtxoffs});
o.lines.push_back({face[0] + vtxoffs, face[1] + vtxoffs});
} else {
FaceType rawFace;
std::ranges::transform(
Expand Down
51 changes: 45 additions & 6 deletions Examples/Scripts/Python/full_chain_odd_LRT.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import argparse
import pathlib
import math

import acts
import acts.examples
Expand All @@ -12,6 +13,7 @@
EtaConfig,
PhiConfig,
ParticleConfig,
ParticleSelectorConfig,
addPythia8,
addFatras,
addGeant4,
Expand Down Expand Up @@ -134,6 +136,12 @@
default=True,
action=argparse.BooleanOptionalAction,
)
parser.add_argument(
"--output-obj",
help="Switch obj output on/off",
default=True,
action=argparse.BooleanOptionalAction,
)

args = parser.parse_args()

Expand Down Expand Up @@ -224,7 +232,6 @@
ParticleConfig(
args.gun_particles, acts.PdgParticle.eMuon, randomizeCharge=True
),
outputDirRoot=pathlib.Path("/home/aicha/Atlas/NewVertices"),
vtxGen=acts.examples.GaussianDisplacedVertexPositionGenerator(
rMean=2,
rStdDev=0.0125 * u.mm,
Expand Down Expand Up @@ -278,6 +285,7 @@
),
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
outputDirObj=outputDir if args.output_obj else None,
rnd=rnd,
killVolume=trackingGeometry.highestTrackingVolume,
killAfterTime=25 * u.ns,
Expand Down Expand Up @@ -306,6 +314,7 @@
enableInteractions=True,
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
outputDirObj=outputDir if args.output_obj else None,
rnd=rnd,
)

Expand All @@ -324,6 +333,16 @@
s,
trackingGeometry,
field,
initialSigmas=[
1 * u.mm,
1 * u.mm,
1 * u.degree,
1 * u.degree,
0.1 * u.e / u.GeV,
1 * u.ns,
],
initialSigmaPtRel=0.1,
initialVarInflation=[1.0] * 6,
geoSelectionConfigFile=oddSeedingSel,
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
Expand Down Expand Up @@ -354,12 +373,32 @@
maxOutliers=2,
),
CkfConfig(
chi2CutOffMeasurement=15.0,
chi2CutOffOutlier=25.0,
numMeasurementsCutOff=10,
seedDeduplication=True,
stayOnSeed=True,
pixelVolumes={16, 17, 18},
stripVolumes={23, 24, 25},
pixelVolumes=[16, 17, 18],
stripVolumes=[23, 24, 25],
maxPixelHoles=1,
maxStripHoles=2,
constrainToVolumes=[
2, # beam pipe
32,
4, # beam pip gap
16,
17,
18, # pixel
20, # PST
23,
24,
25, # short strip
26,
8, # long strip gap
28,
29,
30, # long strip
],
),
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
Expand Down Expand Up @@ -388,8 +427,8 @@
maxSharedTracksPerMeasurement=2,
pTMax=1400,
pTMin=0.5,
phiMax=3.14,
phiMin=-3.14,
phiMax=math.pi,
phiMin=-math.pi,
etaMax=4,
etaMin=-4,
useAmbiguityFunction=False,
Expand All @@ -413,7 +452,7 @@
addVertexFitting(
s,
field,
vertexFinder=VertexFinder.Iterative,
vertexFinder=VertexFinder.AMVF,
outputDirRoot=outputDir if args.output_root else None,
)

Expand Down
17 changes: 14 additions & 3 deletions Examples/Scripts/Python/full_chain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ def parse_args():
"--output-csv",
action="count",
default=0,
help="Use CSV output instead of ROOT. Specify -cc to output both.",
help="Use CSV output instead of ROOT. Specify -cc to output all formats (ROOT, CSV, and obj).",
)
parser.add_argument(
"--output-obj",
action="store_true",
help="Enable obj output",
)
parser.add_argument(
"-n",
Expand Down Expand Up @@ -272,6 +277,11 @@ def full_chain(args):
outputDirCsv = outputDir if args.output_csv != 0 else None
outputDirLessCsv = outputDirLess if args.output_csv != 0 else None
outputDirMoreCsv = outputDirMore if args.output_csv != 0 else None
outputDirObj = (
outputDirLess
if args.output_obj
else outputDir if args.output_csv == 2 else None
)

# fmt: off
if args.generic_detector:
Expand Down Expand Up @@ -392,8 +402,7 @@ def full_chain(args):
"LongStripEndcapReadout",
],
outputParticlesGenerator="particles_input",
outputParticlesInitial="particles_initial",
outputParticlesFinal="particles_final",
outputParticlesSimulation="particles_simulated",
outputSimHits="simhits",
graphvizOutput="graphviz",
dd4hepDetector=detector,
Expand Down Expand Up @@ -483,6 +492,7 @@ def full_chain(args):
postSelectParticles=postSelectParticles,
outputDirRoot=outputDirRoot,
outputDirCsv=outputDirCsv,
outputDirObj=outputDirObj,
)
else:
if s.config.numThreads != 1:
Expand All @@ -508,6 +518,7 @@ def full_chain(args):
killAfterTime=25 * u.ns,
outputDirRoot=outputDirRoot,
outputDirCsv=outputDirCsv,
outputDirObj=outputDirObj,
)

addDigitization(
Expand Down
7 changes: 7 additions & 0 deletions Plugins/Json/src/DetrayJsonHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// For whatever reason, this compilation unit does not compile
// with those assertions and GCC 13. For now just disable the
// flags in this case.
#if defined(_GLIBCXX_ASSERTIONS) && __GNUC__ == 13
#undef _GLIBCXX_ASSERTIONS
#endif

#include "Acts/Plugins/Json/DetrayJsonHelper.hpp"

namespace Acts::DetrayJsonHelper {
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Core/Geometry/CylinderVolumeBuilderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BOOST_DATA_TEST_CASE(
CylinderVolumeBuilder_wraps,
bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1,
bdata::distribution =
std::uniform_real_distribution<double>(-11., -15.))) ^
std::uniform_real_distribution<double>(-15., -11.))) ^
bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
bdata::distribution =
std::uniform_real_distribution<double>(11., 15.))) ^
Expand Down Expand Up @@ -114,7 +114,7 @@ BOOST_DATA_TEST_CASE(
CylinderVolumeBuilder_containes,
bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1,
bdata::distribution =
std::uniform_real_distribution<double>(-11., -15.))) ^
std::uniform_real_distribution<double>(-15., -11.))) ^
bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
bdata::distribution =
std::uniform_real_distribution<double>(11., 15.))) ^
Expand Down Expand Up @@ -285,7 +285,7 @@ BOOST_DATA_TEST_CASE(
CylinderVolumeBuilder_overlapsInZ,
bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1,
bdata::distribution =
std::uniform_real_distribution<double>(-11., -15.))) ^
std::uniform_real_distribution<double>(-15., -11.))) ^
bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
bdata::distribution =
std::uniform_real_distribution<double>(11., 15.))) ^
Expand Down
11 changes: 3 additions & 8 deletions Tests/UnitTests/Core/Utilities/AlgebraHelpersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,15 @@ BOOST_AUTO_TEST_CASE(SafeInverseFPESmallMatrix) {
m(1, 1) = 1;

auto mInv = Acts::safeInverse(m);
BOOST_REQUIRE(mInv.has_value());
auto mInvInv = Acts::safeInverse(*mInv);

BOOST_CHECK(mInv);
BOOST_CHECK(!mInvInv);

ACTS_VERBOSE("Test: SafeInverseFPESmallMatrix" << "\n"
<< "m:\n"
<< m << "\n"
<< "mInv:\n"
<< *mInv << "\n"
<< "mInvInv [garbage]:\n"
<< *mInvInv);
<< *mInv);
}

BOOST_AUTO_TEST_CASE(SafeInverseFPELargeMatrix) {
Expand All @@ -107,9 +104,7 @@ BOOST_AUTO_TEST_CASE(SafeInverseFPELargeMatrix) {

ACTS_VERBOSE("Test: SafeInverseFPELargeMatrix" << "\n"
<< "m:\n"
<< m << "\n"
<< "mInv [garbage]:\n"
<< *mInv);
<< m);
}

/// This test should not compile
Expand Down
5 changes: 5 additions & 0 deletions cmake/ActsCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ set(cxx_flags
"-Wall -Wextra -Wpedantic -Wshadow -Wzero-as-null-pointer-constant -Wold-style-cast"
)

# Add assertions to standard libraries
if(ACTS_FORCE_ASSERTIONS)
set(cxx_flags "${cxx_flags} -D_GLIBCXX_ASSERTIONS -D_LIBCPP_DEBUG")
endif()

# This adds some useful conversion checks like float-to-bool, float-to-int, etc.
# However, at the moment this is only added to clang builds, since GCC's -Wfloat-conversion
# is much more aggressive and also triggers on e.g., double-to-float
Expand Down

0 comments on commit 837c2dd

Please sign in to comment.