Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into releases
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Nov 8, 2024
2 parents b3e856d + 3aa6509 commit fc2a018
Show file tree
Hide file tree
Showing 42 changed files with 683 additions and 523 deletions.
13 changes: 11 additions & 2 deletions CI/physmon/workflows/physmon_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
)
)

s.addWriter(
acts.examples.RootParticleWriter(
level=acts.logging.INFO,
inputParticles="particles_input",
filePath=tp / "particles.root",
)
)

addFatras(
s,
setup.trackingGeometry,
Expand Down Expand Up @@ -100,6 +108,7 @@
s.run()

for file, name in [
(tp / "particles.root", "particles_gun.root"),
(tp / "fatras" / "particles_simulation.root", "particles_fatras.root"),
(tp / "geant4" / "particles_simulation.root", "particles_geant4.root"),
]:
Expand Down Expand Up @@ -135,8 +144,8 @@
s.run()

for file, name in [
(tp / "pythia8_particles.root", "particles_ttbar.root"),
(tp / "pythia8_vertices.root", "vertices_ttbar.root"),
(tp / "particles.root", "particles_ttbar.root"),
(tp / "vertices.root", "vertices_ttbar.root"),
]:
assert file.exists(), "file not found"
shutil.copy(file, setup.outdir / name)
3 changes: 2 additions & 1 deletion Core/include/Acts/EventData/ProxyAccessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ struct ProxyAccessorBase {

/// Create the accessor from a string key
/// @param _key the key
ProxyAccessorBase(const std::string& _key) : key{hashString(_key)} {}
constexpr ProxyAccessorBase(const std::string& _key)
: key{hashString(_key)} {}

/// Access the stored key on the proxy given as an argument. Mutable version
/// @tparam proxy_t the type of the proxy
Expand Down
20 changes: 17 additions & 3 deletions Core/include/Acts/EventData/detail/GenerateParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ struct GenerateQoverPOptions {
/// Indicate if the momentum referse to transverse momentum
bool pTransverse = true;

/// Indicate if the momentum should be uniformly distributed in log space.
bool pLogUniform = false;

/// Charge of the parameters.
double charge = 1;

Expand All @@ -157,6 +160,19 @@ inline double generateQoverP(generator_t& rng,
using UniformIndex = std::uniform_int_distribution<std::uint8_t>;
using UniformReal = std::uniform_real_distribution<double>;

auto drawP = [&options](generator_t& rng_, double theta_) -> double {
const double pTransverseScaling =
options.pTransverse ? 1. / std::sin(theta_) : 1.;

if (options.pLogUniform) {
UniformReal pLogDist(std::log(options.pMin), std::log(options.pMax));
return std::exp(pLogDist(rng_)) * pTransverseScaling;
}

UniformReal pDist(options.pMin, options.pMax);
return pDist(rng_) * pTransverseScaling;
};

// choose between particle/anti-particle if requested
// the upper limit of the distribution is inclusive
UniformIndex particleTypeChoice(0u, options.randomizeCharge ? 1u : 0u);
Expand All @@ -165,14 +181,12 @@ inline double generateQoverP(generator_t& rng,
options.charge,
-options.charge,
};
UniformReal pDist(options.pMin, options.pMax);

// draw parameters
const std::uint8_t type = particleTypeChoice(rng);
const double q = qChoices[type];

const double p =
pDist(rng) * (options.pTransverse ? 1. / std::sin(theta) : 1.);
const double p = drawP(rng, theta);
const double qOverP = (q != 0) ? q / p : 1 / p;

return qOverP;
Expand Down
12 changes: 5 additions & 7 deletions Core/include/Acts/Geometry/PortalShell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ class PortalShellBase {
/// Virtusl destructor
virtual ~PortalShellBase() = default;

/// Connect a volume to the outer side of all portal shells. Which "side" is
/// "outer" depends on the volume type.
/// This method essentially creates a @c TrivialPortalLink on the unconnected
/// side of each portal that is part of the chell
/// Fill the open slots of the shell with a @c TrivialPortalLink
/// to the given @p volume.
/// @param volume The volume to connect
virtual void connectOuter(TrackingVolume& volume) = 0;
virtual void fill(TrackingVolume& volume) = 0;

/// Get the number of portals in the shell. This number depends on the volume
/// type
Expand Down Expand Up @@ -88,8 +86,8 @@ class CylinderPortalShell : public PortalShellBase {
/// @param face The face to set the portal
virtual void setPortal(std::shared_ptr<Portal> portal, Face face) = 0;

/// @copydoc PortalShellBase::connectOuter
void connectOuter(TrackingVolume& volume) override;
/// @copydoc PortalShellBase::fill
void fill(TrackingVolume& volume) override;
};

/// Output stream operator for the CylinderPortalShell::Face enum
Expand Down
19 changes: 15 additions & 4 deletions Core/include/Acts/Seeding/GbtsTrackingFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// TODO: update to C++17 style
#include "Acts/Seeding/GbtsDataStorage.hpp" //includes geo which has trigindetsilayer, may move this to trigbase
#include "Acts/Utilities/Logger.hpp"

#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -112,8 +113,11 @@ template <typename external_spacepoint_t>
class GbtsTrackingFilter {
public:
GbtsTrackingFilter(const std::vector<Acts::TrigInDetSiLayer>& g,
std::vector<Acts::GbtsEdge<external_spacepoint_t>>& sb)
: m_geo(g), m_segStore(sb) {}
std::vector<Acts::GbtsEdge<external_spacepoint_t>>& sb,
std::unique_ptr<const Acts::Logger> logger =
Acts::getDefaultLogger("Filter",
Acts::Logging::Level::INFO))
: m_geo(g), m_segStore(sb), m_logger(std::move(logger)) {}

void followTrack(Acts::GbtsEdge<external_spacepoint_t>* pS,
GbtsEdgeState<external_spacepoint_t>& output) {
Expand Down Expand Up @@ -233,11 +237,15 @@ class GbtsTrackingFilter {
const float add_hit = 14.0;

if (ts.m_Cx[2][2] < 0.0 || ts.m_Cx[1][1] < 0.0 || ts.m_Cx[0][0] < 0.0) {
std::cout << "Negative cov_x" << std::endl;
ACTS_WARNING("Negative covariance detected in X components: "
<< "cov[2][2]=" << ts.m_Cx[2][2] << " cov[1][1]="
<< ts.m_Cx[1][1] << " cov[0][0]=" << ts.m_Cx[0][0]);
}

if (ts.m_Cy[1][1] < 0.0 || ts.m_Cy[0][0] < 0.0) {
std::cout << "Negative cov_y" << std::endl;
ACTS_WARNING("Negative covariance detected in Y components: "
<< "cov[1][1]=" << ts.m_Cy[1][1]
<< " cov[0][0]=" << ts.m_Cy[0][0]);
}

// add ms.
Expand Down Expand Up @@ -380,4 +388,7 @@ class GbtsTrackingFilter {
GbtsEdgeState<external_spacepoint_t> m_stateStore[MAX_EDGE_STATE];

int m_globalStateCounter{0};

const Acts::Logger& logger() const { return *m_logger; }
std::unique_ptr<const Acts::Logger> m_logger{nullptr};
};
2 changes: 1 addition & 1 deletion Core/include/Acts/Seeding/SeedFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class SeedFilter final {

const SeedFilterConfig m_cfg;
std::unique_ptr<const Acts::Logger> m_logger =
Acts::getDefaultLogger("SeedFilter", Logging::Level::INFO);
Acts::getDefaultLogger("Filter", Logging::Level::INFO);
const IExperimentCuts<external_spacepoint_t>* m_experimentCuts;
};
} // namespace Acts
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Seeding/SeedFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SeedFinder {
/// @param logger the ACTS logger
SeedFinder(const Acts::SeedFinderConfig<external_spacepoint_t>& config,
std::unique_ptr<const Acts::Logger> logger =
getDefaultLogger("SeedFinder", Logging::Level::INFO));
getDefaultLogger("Finder", Logging::Level::INFO));
SeedFinder(SeedFinder<external_spacepoint_t, grid_t, platform_t>&&) noexcept =
default;
SeedFinder& operator=(SeedFinder<external_spacepoint_t, grid_t,
Expand Down
17 changes: 11 additions & 6 deletions Core/include/Acts/Seeding/SeedFinderGbts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "Acts/Seeding/SeedFinderConfig.hpp"
#include "Acts/Seeding/SeedFinderGbtsConfig.hpp"
#include "Acts/TrackFinding/RoiDescriptor.hpp"
#include "Acts/Utilities/KDTree.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <array>
#include <iostream>
Expand Down Expand Up @@ -46,14 +46,15 @@ class SeedFinderGbts {
static constexpr std::size_t NDims = 3;

using seed_t = Seed<external_spacepoint_t>;
// using internal_sp_t = InternalSpacePoint<external_spacepoint_t>;
// using tree_t = KDTree<NDims, internal_sp_t *, ActsScalar, std::array, 4>;

// constructors
SeedFinderGbts(const SeedFinderGbtsConfig<external_spacepoint_t> &config,
const GbtsGeometry<external_spacepoint_t> &gbtsgeo);
const GbtsGeometry<external_spacepoint_t> &gbtsgeo,
std::unique_ptr<const Acts::Logger> logger =
Acts::getDefaultLogger("Finder",
Acts::Logging::Level::INFO));

~SeedFinderGbts(); //!!! is it dangerous not to use default? got def in ipp
~SeedFinderGbts() = default;
SeedFinderGbts() = default;
SeedFinderGbts(const SeedFinderGbts<external_spacepoint_t> &) = delete;
SeedFinderGbts<external_spacepoint_t> &operator=(
Expand Down Expand Up @@ -85,10 +86,14 @@ class SeedFinderGbts {
const Acts::GbtsGeometry<external_spacepoint_t> &gbtsgeo);

// needs to be member of class so can accessed by all member functions
GbtsDataStorage<external_spacepoint_t> *m_storage;
std::unique_ptr<GbtsDataStorage<external_spacepoint_t>> m_storage{nullptr};

// for create seeds:
std::vector<TrigInDetTriplet<external_spacepoint_t>> m_triplets;

const Acts::Logger &logger() const { return *m_logger; }
std::unique_ptr<const Acts::Logger> m_logger =
Acts::getDefaultLogger("Finder", Acts::Logging::Level::INFO);
};

} // namespace Acts
Expand Down
26 changes: 13 additions & 13 deletions Core/include/Acts/Seeding/SeedFinderGbts.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,18 @@ namespace Acts {
template <typename external_spacepoint_t>
SeedFinderGbts<external_spacepoint_t>::SeedFinderGbts(
const SeedFinderGbtsConfig<external_spacepoint_t>& config,
const GbtsGeometry<external_spacepoint_t>& gbtsGeo)
: m_config(config) {
m_storage = new GbtsDataStorage(gbtsGeo);
}

template <typename external_spacepoint_t>
SeedFinderGbts<external_spacepoint_t>::~SeedFinderGbts() {
delete m_storage;

m_storage = nullptr;
}
const GbtsGeometry<external_spacepoint_t>& gbtsGeo,
std::unique_ptr<const Acts::Logger> logger)
: m_config(config),
m_storage(
std::make_unique<GbtsDataStorage<external_spacepoint_t>>(gbtsGeo)),
m_logger(std::move(logger)) {}

// define loadspace points function
template <typename external_spacepoint_t>
void SeedFinderGbts<external_spacepoint_t>::loadSpacePoints(
const std::vector<GbtsSP<external_spacepoint_t>>& gbtsSPvect) {
ACTS_VERBOSE("Loading space points");
for (const auto& gbtssp : gbtsSPvect) {
bool is_Pixel = gbtssp.isPixel();
if (!is_Pixel) {
Expand All @@ -70,6 +66,7 @@ void SeedFinderGbts<external_spacepoint_t>::runGbts_TrackFinder(
std::vector<GbtsTrigTracklet<external_spacepoint_t>>& vTracks,
const Acts::RoiDescriptor& roi,
const Acts::GbtsGeometry<external_spacepoint_t>& gbtsGeo) {
ACTS_VERBOSE("Running GBTS Track Finder");
const float min_z0 = roi.zedMinus();
const float max_z0 = roi.zedPlus();
const float cut_zMinU = min_z0 + m_config.maxOuterRadius * roi.dzdrMinus();
Expand Down Expand Up @@ -328,6 +325,7 @@ void SeedFinderGbts<external_spacepoint_t>::runGbts_TrackFinder(
m_storage->getConnectingNodes(vNodes);

if (vNodes.empty()) {
ACTS_VERBOSE("No nodes");
return;
}

Expand Down Expand Up @@ -506,8 +504,9 @@ void SeedFinderGbts<external_spacepoint_t>::runGbts_TrackFinder(

// backtracking

GbtsTrackingFilter<external_spacepoint_t> tFilter(m_config.m_layerGeometry,
edgeStorage);
GbtsTrackingFilter<external_spacepoint_t> tFilter(
m_config.m_layerGeometry, edgeStorage,
logger().cloneWithSuffix("GbtsFilter"));

for (auto pS : vSeeds) {
if (pS->m_level == -1) {
Expand Down Expand Up @@ -651,6 +650,7 @@ void SeedFinderGbts<external_spacepoint_t>::createSeeds(
const Acts::RoiDescriptor& roi,
const Acts::GbtsGeometry<external_spacepoint_t>& gbtsGeo,
output_container_t& out_cont) {
ACTS_VERBOSE("Creating seeds");
std::vector<GbtsTrigTracklet<external_spacepoint_t>>
vTracks; // make empty vector

Expand Down
23 changes: 20 additions & 3 deletions Core/include/Acts/Seeding/SeedFinderOrthogonal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Acts/Seeding/SeedFinderConfig.hpp"
#include "Acts/Seeding/SeedFinderOrthogonalConfig.hpp"
#include "Acts/Utilities/KDTree.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <array>
#include <iostream>
Expand Down Expand Up @@ -53,10 +54,12 @@ class SeedFinderOrthogonal {
* @brief Construct a new orthogonal seed finder.
*
* @param config The configuration parameters for this seed finder.
* @param logger The ACTS logger.
*/
SeedFinderOrthogonal(
const Acts::SeedFinderOrthogonalConfig<external_spacepoint_t> &config);

const Acts::SeedFinderOrthogonalConfig<external_spacepoint_t> &config,
std::unique_ptr<const Acts::Logger> logger =
Acts::getDefaultLogger("Finder", Logging::Level::INFO));
/**
* @brief Destroy the orthogonal seed finder object.
*/
Expand All @@ -66,7 +69,11 @@ class SeedFinderOrthogonal {
SeedFinderOrthogonal(const SeedFinderOrthogonal<external_spacepoint_t> &) =
delete;
SeedFinderOrthogonal<external_spacepoint_t> &operator=(
const SeedFinderOrthogonal<external_spacepoint_t> &) = default;
const SeedFinderOrthogonal<external_spacepoint_t> &) = delete;
SeedFinderOrthogonal(
SeedFinderOrthogonal<external_spacepoint_t> &&) noexcept = default;
SeedFinderOrthogonal<external_spacepoint_t> &operator=(
SeedFinderOrthogonal<external_spacepoint_t> &&) noexcept = default;

/**
* @brief Perform seed finding, appending seeds to a container.
Expand Down Expand Up @@ -238,6 +245,16 @@ class SeedFinderOrthogonal {
* @brief The configuration for the seeding algorithm.
*/
Acts::SeedFinderOrthogonalConfig<external_spacepoint_t> m_config;

/**
* @brief Get the logger.
*/
const Logger &logger() const { return *m_logger; }

/**
* @brief The logger
*/
std::unique_ptr<const Acts::Logger> m_logger{getDummyLogger().clone()};
};
} // namespace Acts

Expand Down
Loading

0 comments on commit fc2a018

Please sign in to comment.