From 49bbacb431e6f023b30183e853cd49687e91f785 Mon Sep 17 00:00:00 2001 From: Florian Uhlig <f.uhlig@gsi.de> Date: Wed, 13 Mar 2024 14:21:16 +0100 Subject: [PATCH] Fix geant4 settings in gconfig scripts The scripts are the old way to define settings fro geant3 and geant4 and are still used in some of the test macros. With this commit the changes already implemented in the new class CbmGeant4Settings some time ago with commits cb453d4b and 982c4b7 are added to fix errors during Geant4 initilisation. --- sim/transport/gconfig/g4Config.C | 14 ++++++++++---- sim/transport/gconfig/g4config.in | 11 ++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sim/transport/gconfig/g4Config.C b/sim/transport/gconfig/g4Config.C index 96692f783d..aad1a727f0 100644 --- a/sim/transport/gconfig/g4Config.C +++ b/sim/transport/gconfig/g4Config.C @@ -61,11 +61,17 @@ void Config() if (cut == 0) gInterpreter->ProcessLine("SetCuts()"); - //set geant4 specific stuff + // --- Random seed and maximum number of steps + size_t buf_size = 100; + Text_t buffer[buf_size]; // Get the infomation about the seed value defined by SetSeed from the base class. - // Since ROOT 6.24 the derived classes return a differnt value. - Text_t buffer[50]; - sprintf(buffer, "/random/setSeeds %i %i ", gRandom->TRandom::GetSeed(), gRandom->TRandom::GetSeed()); + // Since ROOT 6.24 the derrived classes return a differnt value. + Int_t randomSeed = gRandom->TRandom::GetSeed(); + LOG(info) << "Set Geant4 random seed to " << randomSeed; + int result_length = snprintf(buffer, buf_size - 1, "/random/setSeeds %i %i ", randomSeed, randomSeed); + if (!(result_length > 0 && result_length < static_cast<int>(buf_size))) { + LOG(fatal) << "Buffer overrun. Random seed for Geant4 would be improper."; + } geant4->ProcessGeantCommand(buffer); geant4->SetMaxNStep(10000); // default is 30000 diff --git a/sim/transport/gconfig/g4config.in b/sim/transport/gconfig/g4config.in index 30cefff1d3..088b462e65 100644 --- a/sim/transport/gconfig/g4config.in +++ b/sim/transport/gconfig/g4config.in @@ -40,8 +40,9 @@ # (Needed as Cerenkov process does not limit step itself) # /process/optical/verbose 0 -/process/optical/defaults/cerenkov/setMaxPhotons 20 -/process/optical/defaults/cerenkov/setMaxBetaChange 0.1 -/process/optical/setTrackSecondariesFirst Cerenkov false - - +/process/optical/cerenkov/setMaxPhotons 20 +/process/optical/cerenkov/setMaxBetaChange 0.1 +/process/optical/cerenkov/setTrackSecondariesFirst true +/process/optical/processActivation Cerenkov true +/process/optical/processActivation OpAbsorption true +/process/optical/processActivation OpBoundary true -- GitLab