From a3d8b5c803e56a749f439f59d8f1020fa52fac32 Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Fri, 17 Jun 2022 18:57:55 +0200
Subject: [PATCH] macro/much/run_ana.C: added MuCh digi parameters
 initialization

---
 core/detectors/much/CbmMuchTrackingInterface.cxx | 10 ++++++----
 macro/much/run_ana.C                             | 13 +++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/core/detectors/much/CbmMuchTrackingInterface.cxx b/core/detectors/much/CbmMuchTrackingInterface.cxx
index 72fd41dda3..d86cb2e3c4 100644
--- a/core/detectors/much/CbmMuchTrackingInterface.cxx
+++ b/core/detectors/much/CbmMuchTrackingInterface.cxx
@@ -58,12 +58,13 @@ InitStatus CbmMuchTrackingInterface::Init()
   // Check initialization of the MuCh digi parameters file
   if (!fGeoScheme->IsInitialized()) {
     LOG(fatal) << "CbmMuchTrackingInterface::Init: MuCh digi parameters were not intialized\n"
-               << "\033[4;1;32mNOTE\033[0m: For the MuCh digi parameters initialization one can place the following "
-               << "code to the reconstruction macro:\n"
+               << "\033[4;1;32mNOTE\033[0m: For the MuCh digi parameters initialization please place the following "
+               << "code your macro:\n"
+               << "\n\t// ----- MuCh digi parameters initialization --------------------------------------"
                << "\n\tif (CbmSetup::Instance()->IsActive(ECbmModuleId::kMuch)) {"
                << "\n\t  // Parameter file name"
                << "\n\t  TString geoTag;"
-               << "\n\t  geo->GetGeoTag(ECbmModuleId::kMuch, geoTag);"
+               << "\n\t  CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kMuch, geoTag);"
                << "\n\t  Int_t muchFlag  = (geoTag.Contains(\"mcbm\") ? 1 : 0);"
                << "\n\t  TString parFile = gSystem->Getenv(\"VMCWORKDIR\");"
                << "\n\t  parFile += \"/parameters/much/much_\" + geoTag(0, 4) + \"_digi_sector.root\";"
@@ -71,7 +72,8 @@ InitStatus CbmMuchTrackingInterface::Init()
                << "\n\t  // Initialization of the geometry scheme"
                << "\n\t  auto muchGeoScheme = CbmMuchGeoScheme::Instance();"
                << "\n\t  if (!muchGeoScheme->IsInitialized()) { muchGeoScheme->Init(parFile, muchFlag); }"
-               << "\n\t}";
+               << "\n\t}"
+               << "\n\t// --------------------------------------------------------------------------------";
   }
 
   return kSUCCESS;
diff --git a/macro/much/run_ana.C b/macro/much/run_ana.C
index acf23e8193..c08e7310a4 100644
--- a/macro/much/run_ana.C
+++ b/macro/much/run_ana.C
@@ -49,6 +49,19 @@ void run_ana(Int_t nEvents = 1000, TString dataSet = "muons", TString setup = "s
 
 
   // ------------------------------------------------------------------------
+  if (CbmSetup::Instance()->IsActive(ECbmModuleId::kMuch)) {
+	  // Parameter file name
+	  TString geoTag;
+	  CbmSetup::Instance()->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); }
+	}
+
   run->AddTask(new CbmTrackingDetectorInterfaceInit());
   CbmKF* kf = new CbmKF();
   run->AddTask(kf);
-- 
GitLab