From 3c9137a6dca1d3eebb8092784b7a1d7fb6951515 Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Sat, 21 Dec 2024 18:38:43 +0100
Subject: [PATCH] Fix weekly tests

Correct file names in kfparticle test.
Add correct much initilization in kfparticle and mcbm hadron analysis
tests.
---
 macro/KF/kf_kfparticle.C          | 34 +++++++++++++++++++------------
 macro/mcbm/mcbm_hadron_analysis.C | 16 +++++++++++++++
 2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/macro/KF/kf_kfparticle.C b/macro/KF/kf_kfparticle.C
index 8f575c9b80..3c95f315f6 100644
--- a/macro/KF/kf_kfparticle.C
+++ b/macro/KF/kf_kfparticle.C
@@ -42,8 +42,8 @@ void kf_kfparticle(Int_t nEvents = 2, const TString setupName = "sis100_electron
   // -----   In- and output file names   ------------------------------------
   TString mcFile    = dataset + ".tra.root";
   TString parFile   = dataset + ".par.root";
-  TString rawFile   = dataset + ".raw.root";
-  TString recFile   = dataset + ".reco.root";
+  TString rawFile   = dataset + ".event.raw.root";
+  TString recFile   = dataset + ".rec.root";
   TString outFile   = dataset + ".phys.root";
   TString effFile   = dataset + ".Efficiency_KFParticleFinder.txt";
   TString histoFile = dataset + ".KFParticleFinder.root";
@@ -51,19 +51,10 @@ void kf_kfparticle(Int_t nEvents = 2, const TString setupName = "sis100_electron
 
   // -----   Load the geometry setup   -------------------------------------
   std::cout << std::endl;
-  TString setupFile  = srcDir + "/geometry/setup/setup_" + setupName + ".C";
-  TString setupFunct = "setup_";
-  setupFunct         = setupFunct + setupName + "()";
-  std::cout << "-I- " << macroName << ": Loading macro " << setupFile << std::endl;
-  gROOT->LoadMacro(setupFile);
-  gROOT->ProcessLine(setupFunct);
+  //  std::cout << "-I- " << myName << ": Loading setup " << setup << std::endl;
   CbmSetup* setup = CbmSetup::Instance();
+  setup->LoadSetup(setupName);
   TString geoTag;
-  // You can modify the pre-defined setup by using
-  // CbmSetup::Instance()->RemoveModule(ESystemId) or
-  // CbmSetup::Instance()->SetModule(ESystemId, const char*, Bool_t) or
-  // CbmSetup::Instance()->SetActive(ESystemId, Bool_t)
-  // See the class documentation of CbmSetup.
   // ------------------------------------------------------------------------
 
   // ----- Check if the simulation and reconstruction are complited ---------
@@ -149,6 +140,23 @@ void kf_kfparticle(Int_t nEvents = 2, const TString setupName = "sis100_electron
     l1->SetStsMaterialBudgetFileName(stsMatBudgetFileName.Data());
   }
   run->AddTask(l1);
+
+  // ----- MuCh digi parameters initialization --------------------------------------
+  if (setup->IsActive(ECbmModuleId::kMuch)) {
+    // Parameter file name
+    setup->GetGeoTag(ECbmModuleId::kMuch, geoTag);
+    Int_t muchFlag  = (geoTag.Contains("mcbm") ? 1 : 0);
+    TString parFile = gSystem->Getenv("VMCWORKDIR");
+    parFile += "/parameters/much/much_" + geoTag(0, 4) + "_digi_sector.root";
+
+    // Initialization of the geometry scheme
+    auto muchGeoScheme = CbmMuchGeoScheme::Instance();
+    if (!muchGeoScheme->IsInitialized()) {
+      muchGeoScheme->Init(parFile, muchFlag);
+    }
+  }
+  // --------------------------------------------------------------------------------
+
   // ------------------------------------------------------------------------
 
   // ----- PID for KF Particle Finder ---------------------------------------
diff --git a/macro/mcbm/mcbm_hadron_analysis.C b/macro/mcbm/mcbm_hadron_analysis.C
index f9642e6110..3dfdce7012 100644
--- a/macro/mcbm/mcbm_hadron_analysis.C
+++ b/macro/mcbm/mcbm_hadron_analysis.C
@@ -48,6 +48,22 @@ void mcbm_hadron_analysis(Int_t nEvents = 10, TString setupName = "mcbm_beam_202
   CbmSetup* setup = CbmSetup::Instance();
   //  setup->RemoveModule(ECbmModuleId::kTrd);
   // ------------------------------------------------------------------------
+  // ----- MuCh digi parameters initialization --------------------------------------
+
+  if (setup->IsActive(ECbmModuleId::kMuch)) {
+    // Parameter file name
+    TString geoTag;
+    setup->GetGeoTag(ECbmModuleId::kMuch, geoTag);
+    Int_t muchFlag  = (geoTag.Contains("mcbm") ? 1 : 0);
+    TString parFile = gSystem->Getenv("VMCWORKDIR");
+    parFile += "/parameters/much/much_" + geoTag(0, 4) + "_digi_sector.root";
+
+    // Initialization of the geometry scheme
+    auto muchGeoScheme = CbmMuchGeoScheme::Instance();
+    if (!muchGeoScheme->IsInitialized()) {
+      muchGeoScheme->Init(parFile, muchFlag);
+    }
+  }
 
   /*
   CbmMCDataManager* mcManager = new CbmMCDataManager("MCDataManager", 1);
-- 
GitLab