Skip to content

Commit

Permalink
Merge branch 'main' of github.com:acts-project/acts into central-trut…
Browse files Browse the repository at this point in the history
…h-matching
  • Loading branch information
andiwand committed Mar 14, 2024
2 parents 60dd83d + 572c49a commit 8104ee3
Show file tree
Hide file tree
Showing 56 changed files with 1,024 additions and 839 deletions.
Binary file modified CI/physmon/reference/performance_amvf_gridseeder_seeded_hist.root
Binary file not shown.
13 changes: 12 additions & 1 deletion Core/include/Acts/Detector/DetectorVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
/// @brief A detector volume factory which first constructs the detector volume
/// and then constructs the portals. This ensures that the std::shared_ptr
/// holding the detector volume is not weak when assigning to the portals.
///
/// @note Optional containment check is invoked by setting the number
/// of segments nSeg to be greater than 0
class DetectorVolumeFactory {
public:
/// Create a detector volume - from factory
Expand All @@ -494,11 +497,19 @@ class DetectorVolumeFactory {
const std::vector<std::shared_ptr<Surface>>& surfaces,
const std::vector<std::shared_ptr<DetectorVolume>>& volumes,
DetectorVolumeUpdater detectorVolumeUpdater,
SurfaceCandidatesUpdater surfaceCandidateUpdater) {
SurfaceCandidatesUpdater surfaceCandidateUpdater, int nSeg = -1) {
auto dVolume = DetectorVolume::makeShared(
gctx, name, transform, std::move(bounds), surfaces, volumes,
std::move(detectorVolumeUpdater), std::move(surfaceCandidateUpdater));
dVolume->construct(gctx, portalGenerator);

/// Volume extent is constructed from the portals
/// So the surface/subvolume containment
/// check has to happen here
if (nSeg > 0 && !dVolume->checkContainment(gctx, nSeg)) {
throw std::invalid_argument(
"DetectorVolume: surfaces or subvolumes are not contained by volume");
}
return dVolume;
}

Expand Down
99 changes: 26 additions & 73 deletions Core/include/Acts/Geometry/ConeVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ class ConeVolumeBounds : public VolumeBounds {
/// @param halflengthZ The minimum z value of the inner and outer cones
/// @param averagePhi The phi orientation of the sector
/// @param halfPhiSector The opening angle phi sector
ConeVolumeBounds(double innerAlpha, double innerOffsetZ, double outerAlpha,
double outerOffsetZ, double halflengthZ, double averagePhi,
double halfPhiSector) noexcept(false);
ConeVolumeBounds(ActsScalar innerAlpha, ActsScalar innerOffsetZ,
ActsScalar outerAlpha, ActsScalar outerOffsetZ,
ActsScalar halflengthZ, ActsScalar averagePhi,
ActsScalar halfPhiSector) noexcept(false);

/// Constructor - for general cylidner-cone setups
///
Expand All @@ -71,14 +72,14 @@ class ConeVolumeBounds : public VolumeBounds {
///
/// @note depending on cylinderR > coneR it is constructing a cone with
/// cylindrical cutout or a cylinder with conical cutout
ConeVolumeBounds(double cylinderR, double alpha, double offsetZ,
double halflengthZ, double averagePhi,
double halfPhiSector) noexcept(false);
ConeVolumeBounds(ActsScalar cylinderR, ActsScalar alpha, ActsScalar offsetZ,
ActsScalar halflengthZ, ActsScalar averagePhi,
ActsScalar halfPhiSector) noexcept(false);

/// Constructor - from a fixed size array
///
/// @param values The bound values
ConeVolumeBounds(const std::array<double, eSize>& values) noexcept(false)
ConeVolumeBounds(const std::array<ActsScalar, eSize>& values) noexcept(false)
: m_values(values) {
checkConsistency();
buildSurfaceBounds();
Expand All @@ -93,14 +94,14 @@ class ConeVolumeBounds : public VolumeBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// This method checks if position in the 3D volume
/// frame is inside the cylinder
///
/// @param pos is the position in volume frame to be checked
/// @param tol is the absolute tolerance to be applied
bool inside(const Vector3& pos, double tol = 0.) const final;
bool inside(const Vector3& pos, ActsScalar tol = 0.) const final;

/// Oriented surfaces, i.e. the decomposed boundary surfaces and the
/// according navigation direction into the volume given the normal
Expand All @@ -126,30 +127,30 @@ class ConeVolumeBounds : public VolumeBounds {

/// Access to the bound values
/// @param bValue the class nested enum for the array access
double get(BoundValues bValue) const { return m_values[bValue]; }
ActsScalar get(BoundValues bValue) const { return m_values[bValue]; }

// Return the derived innerRmin
double innerRmin() const;
ActsScalar innerRmin() const;

// Return the derived innerRmin
double innerRmax() const;
ActsScalar innerRmax() const;

// Return the derived inner tan(alpha)
double innerTanAlpha() const;
ActsScalar innerTanAlpha() const;

// Return the derived outerRmin
double outerRmin() const;
ActsScalar outerRmin() const;

// Return the derived outerRmax
double outerRmax() const;
ActsScalar outerRmax() const;

// Return the derived outer tan(alpha)
double outerTanAlpha() const;
ActsScalar outerTanAlpha() const;

/// Output Method for std::ostream
///
/// @param sl is ostream operator to be dumped into
std::ostream& toStream(std::ostream& sl) const final;
/// @param os is ostream operator to be dumped into
std::ostream& toStream(std::ostream& os) const final;

private:
/// Check the input values for consistency,
Expand All @@ -159,14 +160,8 @@ class ConeVolumeBounds : public VolumeBounds {
/// Create the surface bounds
void buildSurfaceBounds();

/// Templated dump methods
/// @tparam stream_t The type of the stream for dumping
/// @param dt The stream object
template <class stream_t>
stream_t& dumpT(stream_t& dt) const;

/// The bound values
std::array<double, eSize> m_values;
std::array<ActsScalar, eSize> m_values;
std::shared_ptr<CylinderBounds> m_innerCylinderBounds{nullptr};
std::shared_ptr<ConeBounds> m_innerConeBounds{nullptr};
std::shared_ptr<ConeBounds> m_outerConeBounds{nullptr};
Expand All @@ -176,54 +171,12 @@ class ConeVolumeBounds : public VolumeBounds {
std::shared_ptr<PlanarBounds> m_sectorBounds{nullptr};

/// Derived values
double m_innerRmin = 0.;
double m_innerRmax = 0.;
double m_innerTanAlpha = 0.;
double m_outerRmin = 0.;
double m_outerRmax = 0.;
double m_outerTanAlpha = 0.;
ActsScalar m_innerRmin = 0.;
ActsScalar m_innerRmax = 0.;
ActsScalar m_innerTanAlpha = 0.;
ActsScalar m_outerRmin = 0.;
ActsScalar m_outerRmax = 0.;
ActsScalar m_outerTanAlpha = 0.;
};

inline double ConeVolumeBounds::innerRmin() const {
return m_innerRmin;
}

inline double ConeVolumeBounds::innerRmax() const {
return m_innerRmax;
}

inline double ConeVolumeBounds::innerTanAlpha() const {
return m_innerTanAlpha;
}

inline double ConeVolumeBounds::outerRmin() const {
return m_outerRmin;
}

inline double ConeVolumeBounds::outerRmax() const {
return m_outerRmax;
}

inline double ConeVolumeBounds::outerTanAlpha() const {
return m_outerTanAlpha;
}

inline std::vector<double> ConeVolumeBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}

template <class stream_t>
stream_t& ConeVolumeBounds::dumpT(stream_t& dt) const {
dt << std::setiosflags(std::ios::fixed);
dt << std::setprecision(5);
dt << "Acts::ConeVolumeBounds : (innerAlpha, innerOffsetZ, outerAlpha,";
dt << " outerOffsetZ, halflenghZ, averagePhi, halfPhiSector) = ";
dt << get(eInnerAlpha) << ", " << get(eInnerOffsetZ) << ", ";
dt << get(eOuterAlpha) << ", " << get(eOuterOffsetZ) << ", ";
dt << get(eHalfLengthZ) << ", " << get(eAveragePhi) << std::endl;
return dt;
}

} // namespace Acts
66 changes: 20 additions & 46 deletions Core/include/Acts/Geometry/CuboidVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ class CuboidVolumeBounds : public VolumeBounds {
/// @param halex is the half length of the cube in x
/// @param haley is the half length of the cube in y
/// @param halez is the half length of the cube in z
CuboidVolumeBounds(double halex, double haley, double halez) noexcept(false);
CuboidVolumeBounds(ActsScalar halex, ActsScalar haley,
ActsScalar halez) noexcept(false);

/// Constructor - from a fixed size array
///
/// @param values iw the bound values
CuboidVolumeBounds(const std::array<double, eSize>& values) noexcept(false)
CuboidVolumeBounds(const std::array<ActsScalar, eSize>& values) noexcept(
false)
: m_values(values) {
checkConsistency();
buildSurfaceBounds();
Expand All @@ -91,14 +93,14 @@ class CuboidVolumeBounds : public VolumeBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// This method checks if position in the 3D volume
/// frame is inside the cylinder
///
/// @param pos is the position in volume frame to be checked
/// @param tol is the absolute tolerance to be applied
bool inside(const Vector3& pos, double tol = 0.) const override;
bool inside(const Vector3& pos, ActsScalar tol = 0.) const override;

/// Oriented surfaces, i.e. the decomposed boundary surfaces and the
/// according navigation direction into the volume given the normal
Expand All @@ -122,31 +124,33 @@ class CuboidVolumeBounds : public VolumeBounds {
const Vector3& envelope = {0, 0, 0},
const Volume* entity = nullptr) const final;

/// Binning borders in double
/// Get the canonical binning values, i.e. the binning values
/// for that fully describe the shape's extent
///
/// @return vector of canonical binning values
std::vector<Acts::BinningValue> canonicalBinning() const override {
return {Acts::binX, Acts::binY, Acts::binZ};
};

/// Binning borders in ActsScalar
///
/// @param bValue is the binning schema used
///
/// @return float offset to be used for the binning
double binningBorder(BinningValue bValue) const final;
ActsScalar binningBorder(BinningValue bValue) const final;

/// Access to the bound values
/// @param bValue the class nested enum for the array access
double get(BoundValues bValue) const { return m_values[bValue]; }
ActsScalar get(BoundValues bValue) const { return m_values[bValue]; }

/// Output Method for std::ostream
///
/// @param sl is ostream operator to be dumped into
std::ostream& toStream(std::ostream& sl) const override;
/// @param os is ostream operator to be dumped into
std::ostream& toStream(std::ostream& os) const override;

private:
/// Templated dumpT method
/// @tparam stream_t The type for the dump stream
/// @param dt The dump stream object
template <class stream_t>
stream_t& dumpT(stream_t& dt) const;

/// The bound values ordered in a fixed size array
std::array<double, eSize> m_values;
std::array<ActsScalar, eSize> m_values;

std::shared_ptr<const RectangleBounds> m_xyBounds{nullptr};
std::shared_ptr<const RectangleBounds> m_yzBounds{nullptr};
Expand All @@ -159,34 +163,4 @@ class CuboidVolumeBounds : public VolumeBounds {
/// will throw a logic_exception if consistency is not given
void checkConsistency() noexcept(false);
};

inline bool CuboidVolumeBounds::inside(const Vector3& pos, double tol) const {
return (std::abs(pos.x()) <= get(eHalfLengthX) + tol &&
std::abs(pos.y()) <= get(eHalfLengthY) + tol &&
std::abs(pos.z()) <= get(eHalfLengthZ) + tol);
}

inline std::vector<double> CuboidVolumeBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}

inline void CuboidVolumeBounds::checkConsistency() noexcept(false) {
if (get(eHalfLengthX) <= 0 || get(eHalfLengthY) <= 0 ||
get(eHalfLengthZ) <= 0.) {
throw std::invalid_argument(
"CuboidVolumeBounds: invalid input, zero or negative.");
}
}

template <class stream_t>
stream_t& CuboidVolumeBounds::dumpT(stream_t& dt) const {
dt << std::setiosflags(std::ios::fixed);
dt << std::setprecision(5);
dt << "Acts::CuboidVolumeBounds: (halfLengthX, halfLengthY, halfLengthZ) = ";
dt << "(" << get(eHalfLengthX) << ", " << get(eHalfLengthY) << ", "
<< get(eHalfLengthZ) << ")";
return dt;
}
} // namespace Acts
8 changes: 8 additions & 0 deletions Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
const Vector3& envelope = {0, 0, 0},
const Volume* entity = nullptr) const final;

/// Get the canonical binning values, i.e. the binning values
/// for that fully describe the shape's extent
///
/// @return vector of canonical binning values
std::vector<Acts::BinningValue> canonicalBinning() const override {
return {Acts::binR, Acts::binPhi, Acts::binZ};
};

/// Write information about this instance to an outstream
///
/// @param sl The outstream
Expand Down
Loading

0 comments on commit 8104ee3

Please sign in to comment.