From d38b06f36670c9b366df2f4db84b7397e6dc7b15 Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Tue, 11 Mar 2025 13:16:07 +0100
Subject: [PATCH 1/4] Fix Geant4 configuration

With the additional parameter specialCuts the energy based Geant3 cuts are
automatically converted to the range based Geant4 cuts by VMC. Without the
parameter the default Geant4 cuts are used. The change reduced the number of
secondaries by a factor of 5 or more for a normal CbmRoot UrQMD simulation and
speed up the runtime by factors. The runtime compared to Geant3 went from being
slower by a factor of 4 to being slower by 30 %.
The change of the maximum number of steps from 1e7 to the correct number of
10000 has no effect. There are no tracks exceeding 10000 steps such that there
is no additional speedup.
---
 sim/transport/steer/CbmGeant4Settings.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sim/transport/steer/CbmGeant4Settings.h b/sim/transport/steer/CbmGeant4Settings.h
index 6b58e44dee..9c1082df41 100644
--- a/sim/transport/steer/CbmGeant4Settings.h
+++ b/sim/transport/steer/CbmGeant4Settings.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2020-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Florian Uhlig [committer] */
 
@@ -95,7 +95,7 @@ public:
   Int_t GetMaximumNumberOfSteps() { return fMaxNumSteps; }
 
 private:
-  std::array<std::string, 3> fG4RunConfig {{"geomRoot", "QGSP_BERT_EMV+optical", "stepLimiter"}};
+  std::array<std::string, 3> fG4RunConfig {{"geomRoot", "QGSP_BERT_EMV+optical", "stepLimiter+specialCuts"}};
 
   /*
   See https://redmine.cbm.gsi.de/issues/2913
@@ -110,7 +110,7 @@ private:
                                         "/process/optical/processActivation OpAbsorption true",
                                         "/process/optical/processActivation OpBoundary true"};
 
-  Int_t fMaxNumSteps {10000000};
+  Int_t fMaxNumSteps {10000};
 
   Int_t fRandomSeed {0};
 
-- 
GitLab


From ee2219baac82a3e30b6fcbf5df1708b406217252 Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Tue, 11 Mar 2025 13:13:10 +0100
Subject: [PATCH 2/4] Apply clang-format

---
 sim/transport/steer/CbmGeant4Settings.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/sim/transport/steer/CbmGeant4Settings.h b/sim/transport/steer/CbmGeant4Settings.h
index 9c1082df41..98b2e11c7d 100644
--- a/sim/transport/steer/CbmGeant4Settings.h
+++ b/sim/transport/steer/CbmGeant4Settings.h
@@ -25,7 +25,7 @@
 class TVirtualMC;
 
 class CbmGeant4Settings : public CbmVMCSettings {
-public:
+ public:
   CbmGeant4Settings()                         = default;
   ~CbmGeant4Settings()                        = default;
   CbmGeant4Settings(const CbmGeant4Settings&) = delete;
@@ -94,25 +94,25 @@ public:
    **/
   Int_t GetMaximumNumberOfSteps() { return fMaxNumSteps; }
 
-private:
-  std::array<std::string, 3> fG4RunConfig {{"geomRoot", "QGSP_BERT_EMV+optical", "stepLimiter+specialCuts"}};
+ private:
+  std::array<std::string, 3> fG4RunConfig{{"geomRoot", "QGSP_BERT_EMV+optical", "stepLimiter+specialCuts"}};
 
   /*
   See https://redmine.cbm.gsi.de/issues/2913
   As of Geant4-10.5 these commands were changed.
   Tested for Geant4-11
   */
-  std::vector<std::string> fG4Commands {"/process/optical/verbose 0",
-                                        "/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"};
+  std::vector<std::string> fG4Commands{"/process/optical/verbose 0",
+                                       "/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"};
 
-  Int_t fMaxNumSteps {10000};
+  Int_t fMaxNumSteps{10000};
 
-  Int_t fRandomSeed {0};
+  Int_t fRandomSeed{0};
 
   ClassDef(CbmGeant4Settings, 4);
 };
-- 
GitLab


From 7f1b63bf3b7fd7469ab410d9fe2f1e5b6b83bb47 Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Fri, 14 Mar 2025 13:26:31 +0100
Subject: [PATCH 3/4] Fix geant4 config script

Depending on an environment variable it can happen that a path contains a //.
In such a case the excution of the specified macro fails which is now fixed.
---
 sim/transport/gconfig/g4Config.C | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sim/transport/gconfig/g4Config.C b/sim/transport/gconfig/g4Config.C
index aad1a727f0..0ba3c7eb3c 100644
--- a/sim/transport/gconfig/g4Config.C
+++ b/sim/transport/gconfig/g4Config.C
@@ -52,10 +52,12 @@ void Config()
 
   TString configm(gSystem->Getenv("CONFIG_DIR"));
   TString configm1 = configm + "/g4config.in";
+  configm1.ReplaceAll("//", "/");
   cout << " -I g4Config() using g4conf  macro: " << configm1 << endl;
 
   // set the common cuts
   TString cuts = configm + "/SetCuts.C";
+  cuts.ReplaceAll("//", "/");
   cout << "Physics cuts with script \n " << cuts.Data() << endl;
   Int_t cut = gROOT->LoadMacro(cuts.Data());
   if (cut == 0) gInterpreter->ProcessLine("SetCuts()");
-- 
GitLab


From 29e955c017e6c4b808acd11e47923331b7987055 Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Thu, 10 Apr 2025 09:25:44 +0200
Subject: [PATCH 4/4] Workaround for failing qa test on macosx

Fix the problem by excluding the distribution from the qa checks. The problem
why the test fails is a low statistic in the distribution such that the mean
and the errors fluctuate strongly.
---
 .../qa/configs/qa_tasks_config_mcbm_beam_2021_07_surveyed.yaml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/macro/qa/configs/qa_tasks_config_mcbm_beam_2021_07_surveyed.yaml b/macro/qa/configs/qa_tasks_config_mcbm_beam_2021_07_surveyed.yaml
index e12dd8c0e4..4ffb5ab665 100644
--- a/macro/qa/configs/qa_tasks_config_mcbm_beam_2021_07_surveyed.yaml
+++ b/macro/qa/configs/qa_tasks_config_mcbm_beam_2021_07_surveyed.yaml
@@ -45,5 +45,6 @@ qa:
       pull_x_station_%d: true
       pull_y_station_%d: true
       pull_t_station_%d: true
-
+      pull_t_station_4: false
+      
 ...
-- 
GitLab