Commit f963e506 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'p-max-track-length-fix' into 'master'

DepositionGeant4: limit maximum track length

Closes #238

See merge request allpix-squared/allpix-squared!834
parents 4d684773 6c265ffd
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <string>
#include <utility>

#include <G4Box.hh>
#include <G4EmParameters.hh>
#include <G4HadronicParameters.hh>
#include <G4HadronicProcessStore.hh>
@@ -220,8 +221,15 @@ void DepositionGeant4Module::initialize() {
    // Set user limits on world volume:
    auto world_log_volume = geo_manager_->getExternalObject<G4LogicalVolume>("", "world_log");
    if(world_log_volume != nullptr) {
        // Quickly estimate longest distance in world and limit max track length
        auto* world_box = static_cast<G4Box*>(world_log_volume->GetSolid());
        auto max_track_length =
            2e2 * (world_box->GetXHalfLength() + world_box->GetYHalfLength() + world_box->GetZHalfLength());
        user_limits_world_->SetUserMaxTrackLength(max_track_length);

        LOG(DEBUG) << "Setting world volume user limits to constrain event time to "
                   << Units::display(config_.get<double>("cutoff_time"), {"ns", "us", "ms", "s"});
                   << Units::display(config_.get<double>("cutoff_time"), {"ns", "us", "ms", "s"})
                   << " and maximum track length to " << Units::display(max_track_length, {"mm", "cm", "m"});
        world_log_volume->GetRegion()->SetUserLimits(user_limits_world_.get());
    }

+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ void DetectorConstructionG4::build(const std::shared_ptr<G4LogicalVolume>& world
        G4Transform3D transform_phys(*rotWrapper, posWrapper);

        G4LogicalVolumeStore* log_volume_store = G4LogicalVolumeStore::GetInstance();
        G4LogicalVolume* world_log_volume = log_volume_store->GetVolume("World_log");
        G4LogicalVolume* world_log_volume = log_volume_store->GetVolume("world_log");

        if(world_log_volume == nullptr) {
            throw ModuleError("Cannot find world volume");
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ G4VPhysicalVolume* GeometryConstructionG4::Construct() {
    auto world_box = std::make_shared<G4Box>("World", half_world_size.x(), half_world_size.y(), half_world_size.z());
    solids_.push_back(world_box);
    world_log_ =
        std::make_shared<G4LogicalVolume>(world_box.get(), g4material_world, "World_log", nullptr, nullptr, nullptr);
        std::make_shared<G4LogicalVolume>(world_box.get(), g4material_world, "world_log", nullptr, nullptr, nullptr);

    // Set the world to invisible in the viewer
    world_log_->SetVisAttributes(G4VisAttributes::GetInvisible());