Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions include/AdePT/g4integration/ATLASSteppingActionConfig.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: 2026 CERN
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <AdePT/transport/config/ATLASSteppingActionParams.hh>

#include <string>
#include <vector>

/// @brief Configuration of the ATLAS stepping action (ADEPT_STEPPINGACTION=ATLAS), set by Athena.
/// @details Athena kills particles without an energy deposit in some regions with kill-only fast simulation models.
/// The ATLAS stepping action implements these models on the GPU, so that their regions can be transported on the GPU.
/// This configuration must mirror the Athena configuration of the models. The regions must exist in the geometry.
struct ATLASSteppingActionConfig {
ATLASSteppingActionParams params; ///< cuts copied to the GPU
std::vector<std::string> deadRegions; ///< all tracks are killed in these regions (SimpleFastKiller)
/// The DeadMaterialShower kill of ATLASSteppingActionParams applies in these regions
std::vector<std::string> deadMaterialShowerRegions;
};
8 changes: 8 additions & 0 deletions include/AdePT/g4integration/AdePTConfiguration.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <AdePT/g4integration/ATLASSteppingActionConfig.hh>
#include <AdePT/g4integration/CMSSteppingActionConfig.hh>

#include <algorithm>
Expand Down Expand Up @@ -71,6 +72,11 @@ public:
void AddDeadRegionName(std::string name) { fCMSSteppingActionConfig.deadRegions.push_back(name); }
/// @brief Replace the configuration of the CMS stepping action, including dead regions added with AddDeadRegionName.
void SetCMSSteppingActionConfig(CMSSteppingActionConfig config) { fCMSSteppingActionConfig = std::move(config); }
/// @brief Replace the configuration of the ATLAS stepping action.
void SetATLASSteppingActionConfig(ATLASSteppingActionConfig config)
{
fATLASSteppingActionConfig = std::move(config);
}
void SetVerbosity(int verbosity) { fVerbosity = verbosity; };
void SetMillionsOfTrackSlots(double millionSlots) { fMillionsOfTrackSlots = millionSlots; }
void SetMillionsOfHitSlots(double millionSlots) { fMillionsOfHitSlots = millionSlots; }
Expand Down Expand Up @@ -135,6 +141,7 @@ public:
const std::vector<std::string> *GetCPURegionNames() const { return &fCPURegionNames; }
const std::vector<std::string> &GetWDTRegionNames() const { return fWDTRegionNames; }
const CMSSteppingActionConfig &GetCMSSteppingActionConfig() const { return fCMSSteppingActionConfig; }
const ATLASSteppingActionConfig &GetATLASSteppingActionConfig() const { return fATLASSteppingActionConfig; }

// Temporary
std::string GetVecGeomGDML() const { return fVecGeomGDML; }
Expand Down Expand Up @@ -172,6 +179,7 @@ private:
std::vector<std::string> fCPURegionNames{};
std::vector<std::string> fWDTRegionNames{};
CMSSteppingActionConfig fCMSSteppingActionConfig{};
ATLASSteppingActionConfig fATLASSteppingActionConfig{};

std::string fVecGeomGDML{""};
std::string fCovfieBfieldFile{""};
Expand Down
5 changes: 4 additions & 1 deletion include/AdePT/g4integration/geometry/AdePTGeometryBridge.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <AdePT/g4integration/ATLASSteppingActionConfig.hh>
#include <AdePT/g4integration/CMSSteppingActionConfig.hh>
#include <AdePT/transport/geometry/GeometryAuxData.hh>
#include <AdePT/transport/woodcock/WoodcockData.hh>
Expand Down Expand Up @@ -49,9 +50,11 @@ public:
/// @brief Fills the auxiliary per-volume data needed by AdePT.
/// @param gpuRegions Regions handled by AdePT.
/// @param cmsConfig Configuration of the CMS stepping action, only used in CMS builds.
/// @param atlasConfig Configuration of the ATLAS stepping action, only used in ATLAS builds.
static void InitVolAuxData(adeptint::VolAuxData *volAuxData, G4HepEmData const *hepEmData,
G4HepEmTrackingManagerSpecialized *hepEmTM, std::set<G4Region const *> const &gpuRegions,
CMSSteppingActionConfig const &cmsConfig, adeptint::WDTHostRaw &wdtRaw);
CMSSteppingActionConfig const &cmsConfig, ATLASSteppingActionConfig const &atlasConfig,
adeptint::WDTHostRaw &wdtRaw);

/// @brief Pack the Woodcock tracking data from the sparse host-side map into arrays that can be copied to the GPU.
/// @param wdtRaw Raw WDT data collected during geometry traversal.
Expand Down
18 changes: 18 additions & 0 deletions include/AdePT/transport/config/ATLASSteppingActionParams.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2026 CERN
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <AdePT/transport/support/SystemOfUnits.h>

/// @brief Cuts of the ATLAS stepping action (ADEPT_STEPPINGACTION=ATLAS), copied to the GPU.
/// @details They mirror Athena's DeadMaterialShower fast simulation model (Athena property names in brackets) and are
/// set by Athena through AdePTConfiguration::SetATLASSteppingActionConfig. The defaults are the Athena defaults.
struct ATLASSteppingActionParams {
/// In the DeadMaterialShower regions, e+- and gammas up to deadMaterialShowerHighEnergy are killed at |z| >= this
/// [ZCutoff]
double deadMaterialShowerZCutoff{5698. * copcore::units::mm};
double deadMaterialShowerHighEnergy{1000. * copcore::units::GeV}; ///< [HighEnergy]
/// In the DeadMaterialShower regions, e+- below this energy are killed at |z| < deadMaterialShowerZCutoff [LowEnergy]
double deadMaterialShowerLowEnergy{0.};
};
5 changes: 4 additions & 1 deletion include/AdePT/transport/config/SteppingActionParams.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <AdePT/AdePTBuildFlags.hh>

#include <AdePT/transport/config/ATLASSteppingActionParams.hh>
#include <AdePT/transport/config/CMSSteppingActionParams.hh>
#include <AdePT/transport/config/LHCbSteppingActionParams.hh>

Expand All @@ -20,7 +21,9 @@ namespace adept {
using SteppingActionParamsT = CMSSteppingActionParams;
#elif ADEPT_STEPACTION_TYPE == 2
using SteppingActionParamsT = LHCbSteppingActionParams;
#elif ADEPT_STEPACTION_TYPE == 3
using SteppingActionParamsT = ATLASSteppingActionParams;
#else
using SteppingActionParamsT = EmptySteppingActionParams; // NONE, and ATLAS, which has no parameters
using SteppingActionParamsT = EmptySteppingActionParams; // NONE
#endif
} // namespace adept
3 changes: 3 additions & 0 deletions include/AdePT/transport/geometry/GeometryAuxData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ struct VolAuxData {
#endif
#if defined(ADEPT_STEPACTION_TYPE) && (ADEPT_STEPACTION_TYPE == 3)
bool fAtlasPhotonRussianRoulette{false}; ///< ATLAS-only flag: apply photon Russian Roulette to gammas born here
bool fAtlasDeadRegion{false}; ///< ATLAS-only flag: tracks entering this volume are killed by the stepping action
/// ATLAS-only flag: the stepping action applies the kill of Athena's DeadMaterialShower in this volume
bool fAtlasDeadMaterialShower{false};
#endif
};

Expand Down
45 changes: 38 additions & 7 deletions include/AdePT/transport/kernels/AdePTSteppingAction.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ struct LHCbAction {
// the GPU. The current threshold and weight are intentionally hardcoded here to
// match the Athena defaults until AdePT has an experiment-facing configuration
// hook for these values.
// The ATLAS stepping action is also the GPU implementation of Athena's kill-only
// fast simulation models (SimpleFastKiller, DeadMaterialShower), configured by
// Athena through ATLASSteppingActionConfig.
struct ATLASAction {
using Params = EmptySteppingActionParams;
using Params = ATLASSteppingActionParams;

static constexpr double kPhotonRussianRouletteThreshold = 0.5 * copcore::units::MeV;
static constexpr float kPhotonRussianRouletteWeight = 10.0f;
Expand All @@ -268,16 +271,44 @@ struct ATLASAction {
return p2 * dirT2 >= kTruthMinPt * kTruthMinPt;
}

__device__ __forceinline__ static void ElectronAction(bool &, double &, double &, vecgeom::Vector3D<double> const &,
double const &, adeptint::VolAuxData const &,
G4HepEmData const *, Params const &)
/// @brief GPU implementation of Athena's kill-only fast simulation models.
/// @details As Athena checks the trigger of a fast simulation model, the kill is evaluated at the start of every step
/// inside the region of the model, so a track is killed at the same point.
/// - Dead regions (SimpleFastKiller): every track is killed.
/// - DeadMaterialShower regions: behind the z cut, e+-, gamma (and hadrons, which never reach AdePT) up to
/// HighEnergy are killed; in front of it, only e+- below LowEnergy.
///
/// As in Athena, the killed energy is not deposited, and a killed positron does not annihilate.
__device__ __forceinline__ static void FastSimulationKill(bool &alive, double &eKin, bool charged,
vecgeom::Vector3D<double> const &pos,
adeptint::VolAuxData const &auxData, Params const &params)
{
if (!alive) return;
bool kill = auxData.fAtlasDeadRegion;
if (auxData.fAtlasDeadMaterialShower) {
kill = fabs(pos.z()) >= params.deadMaterialShowerZCutoff ? eKin <= params.deadMaterialShowerHighEnergy
: charged && eKin < params.deadMaterialShowerLowEnergy;
Comment thread
SeverinDiederichs marked this conversation as resolved.
Resolved
}
if (kill) {
alive = false;
eKin = 0.;
}
}

__device__ __forceinline__ static void GammaAction(bool &, double &, double &, vecgeom::Vector3D<double> const &,
double const &, adeptint::VolAuxData const &, G4HepEmData const *,
Params const &)
__device__ __forceinline__ static void ElectronAction(bool &alive, double &eKin, double &,
vecgeom::Vector3D<double> const &pos, double const &,
adeptint::VolAuxData const &auxData, G4HepEmData const *,
Params const &params)
{
FastSimulationKill(alive, eKin, /*charged=*/true, pos, auxData, params);
}

__device__ __forceinline__ static void GammaAction(bool &alive, double &eKin, double &,
vecgeom::Vector3D<double> const &pos, double const &,
adeptint::VolAuxData const &auxData, G4HepEmData const *,
Params const &params)
{
FastSimulationKill(alive, eKin, /*charged=*/false, pos, auxData, params);
}

__device__ __forceinline__ static SecondaryDecision ClassifySecondary(TrackBase &parentTrack, ParticleType type,
Expand Down
38 changes: 37 additions & 1 deletion src/g4integration/geometry/AdePTGeometryBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ void AdePTGeometryBridge::CheckGeometry(G4HepEmData const *hepEmData)
void AdePTGeometryBridge::InitVolAuxData(adeptint::VolAuxData *volAuxData, G4HepEmData const *hepEmData,
G4HepEmTrackingManagerSpecialized *hepEmTM,
std::set<G4Region const *> const &gpuRegions,
CMSSteppingActionConfig const &cmsConfig, adeptint::WDTHostRaw &wdtRaw)
CMSSteppingActionConfig const &cmsConfig,
ATLASSteppingActionConfig const &atlasConfig, adeptint::WDTHostRaw &wdtRaw)
{
// Note: the hepEmTM must be passed explicitly here, since this is now a stateless
// global bridge helper and therefore cannot reach any per-thread integration members.
Expand Down Expand Up @@ -474,6 +475,27 @@ void AdePTGeometryBridge::InitVolAuxData(adeptint::VolAuxData *volAuxData, G4Hep

#if defined(ADEPT_STEPACTION_TYPE) && (ADEPT_STEPACTION_TYPE == 3)
std::vector<bool> atlasPhotonRRInitialized(vecgeom::GeoManager::Instance().GetRegisteredVolumesCount(), false);

// ATLAS stepping action: resolve the region names of the configuration once on the host.
auto findATLASRegions = [](std::vector<std::string> const &regionNames) {
std::vector<G4Region const *> regions;
for (const std::string &regionName : regionNames) {
G4Region const *region = G4RegionStore::GetInstance()->GetRegion(regionName, false);
if (!region) {
G4Exception("AdePTGeometryBridge", "Invalid parameter", FatalErrorInArgument,
("Region of the ATLAS stepping action configuration: " + regionName + " not found\n").c_str());
}
regions.push_back(region);
}
return regions;
};
const auto atlasDeadRegions = findATLASRegions(atlasConfig.deadRegions);
const auto atlasDeadMaterialShowerRegions = findATLASRegions(atlasConfig.deadMaterialShowerRegions);
auto atlasContains = [](std::vector<G4Region const *> const &regions, G4Region const *region) {
return std::find(regions.begin(), regions.end(), region) != regions.end();
};
#else
(void)atlasConfig;
#endif

// Collect the GPU regions and first CPU region found inside each WDT envelope.
Expand Down Expand Up @@ -566,6 +588,20 @@ void AdePTGeometryBridge::InitVolAuxData(adeptint::VolAuxData *volAuxData, G4Hep
G4cerr << "ATLAS photon Russian Roulette flag is inconsistent for logical volume '" << g4_lvol->GetName()
<< "': saw both LAr and non-LAr placed-volume names while building VolAuxData." << G4endl;
}

// ATLAS stepping action: per-volume part of the configuration.
auto &atlasAuxData = volAuxData[vg_lvol->id()];
atlasAuxData.fAtlasDeadRegion = atlasContains(atlasDeadRegions, region);
atlasAuxData.fAtlasDeadMaterialShower = atlasContains(atlasDeadMaterialShowerRegions, region);
// WDT skips internal boundaries, so the ATLAS kill must stay the same throughout the envelope.
if (activeWDTRoot >= 0 && isGPURegion) {
G4Region const *rootRegion = wdtRootCandidates[activeWDTRoot].logicalVolume->GetRegion();
if (atlasAuxData.fAtlasDeadRegion != atlasContains(atlasDeadRegions, rootRegion) ||
atlasAuxData.fAtlasDeadMaterialShower != atlasContains(atlasDeadMaterialShowerRegions, rootRegion)) {
Comment thread
SeverinDiederichs marked this conversation as resolved.
Resolved
G4Exception("AdePTGeometryBridge::InitVolAuxData", "WDTEnvelopeContainsATLASKillRegion", FatalException,
"Woodcock tracking cannot mix regions with different ATLAS kills in the same envelope.");
}
}
#endif

// Now do the daughters.
Expand Down
6 changes: 5 additions & 1 deletion src/g4integration/tracking_managers/AdePTTrackingManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ AdePTTransportConfig MakeAdePTTransportConfig(const AdePTConfiguration &configur
#if defined(ADEPT_STEPACTION_TYPE) && (ADEPT_STEPACTION_TYPE == 1)
// In CMS builds the selected parameter type is CMSSteppingActionParams, see SteppingActionParams.hh.
transportConfig.steppingActionParams = configuration.GetCMSSteppingActionConfig().params;
#elif defined(ADEPT_STEPACTION_TYPE) && (ADEPT_STEPACTION_TYPE == 3)
// In ATLAS builds the selected parameter type is ATLASSteppingActionParams, see SteppingActionParams.hh.
transportConfig.steppingActionParams = configuration.GetATLASSteppingActionConfig().params;
#endif
return transportConfig;
}
Expand Down Expand Up @@ -193,7 +196,8 @@ void AdePTTrackingManager::InitializeSharedAdePTTransport()
auto auxData = std::make_unique<adeptint::VolAuxData[]>(vecgeom::GeoManager::Instance().GetRegisteredVolumesCount());
adeptint::WDTHostRaw wdtRaw;
AdePTGeometryBridge::InitVolAuxData(auxData.get(), adeptG4HepEmState->GetData(), fHepEmTrackingManager.get(),
fGPURegions, fAdePTConfiguration->GetCMSSteppingActionConfig(), wdtRaw);
fGPURegions, fAdePTConfiguration->GetCMSSteppingActionConfig(),
fAdePTConfiguration->GetATLASSteppingActionConfig(), wdtRaw);
adeptint::WDTHostPacked wdtPacked = AdePTGeometryBridge::PackWDT(wdtRaw);
auto transportConfig = MakeAdePTTransportConfig(*fAdePTConfiguration);

Expand Down
5 changes: 4 additions & 1 deletion test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ set(ADEPT_TRANSPORT_GTESTS
)

if(ADEPT_STEPPINGACTION STREQUAL "ATLAS")
list(APPEND ADEPT_TRANSPORT_GTESTS test_atlas_truth_selection.cu)
list(APPEND ADEPT_TRANSPORT_GTESTS
test_atlas_truth_selection.cu
test_atlas_kill_regions.cu # Kills of Athena's kill-only fast simulation models
)
endif()

set(ADEPT_TRANSPORT_UTILITIES
Expand Down
Loading
Loading