From cb5b47e2ec389fd0c2698af4427aeef8f950d9e8 Mon Sep 17 00:00:00 2001
From: "P.-A. Loizeau" <p.-a.loizeau@gsi.de>
Date: Wed, 6 Apr 2022 18:33:58 +0200
Subject: [PATCH] Add autoset of setup based on run ID for 03/22 beams in macro
 + MQ

---
 MQ/mcbm/startBuildRawEvents2022.sh.in | 13 ++++++++++++-
 macro/run/run_unpack_online.C         | 15 +++++++++++++++
 macro/run/run_unpack_online_bmon.C    | 15 +++++++++++++++
 macro/run/run_unpack_tsa.C            | 15 +++++++++++++++
 macro/run/run_unpack_tsa_bmon.C       | 15 +++++++++++++++
 5 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/MQ/mcbm/startBuildRawEvents2022.sh.in b/MQ/mcbm/startBuildRawEvents2022.sh.in
index d508da90f6..5903684368 100755
--- a/MQ/mcbm/startBuildRawEvents2022.sh.in
+++ b/MQ/mcbm/startBuildRawEvents2022.sh.in
@@ -82,7 +82,18 @@ _parfileBmon=@VMCWORKDIR@/macro/beamtime/mcbm2022/mBmonCriPar.par
 _parfileRich=@VMCWORKDIR@/macro/beamtime/mcbm2021/mRichPar_70.par
 _parfilePsd=@VMCWORKDIR@/macro/beamtime/mcbm2021/mPsdPar.par
 _setup_name=mcbm_beam_2022_03_22_iron
-_run_id=2158
+_run_id=2160
+
+if [ _run_id -ge 2060 ]; then
+  if [ _run_id -le 2065 ]; then
+    _setup_name=mcbm_beam_2022_03_09_carbon
+  elif [ _run_id -le 2160 ]; then # Potentially wrong setup between 2065 and 2150 but not official runs
+    _setup_name=mcbm_beam_2022_03_22_iron
+  elif [ _run_id -le 2310 ]; then # Potentially wrong setup between 2160 and 2176 but not official runs
+    _setup_name=mcbm_beam_2022_03_28_uranium
+  fi
+fi
+
 
 _ratelog=0 # hides ZMQ messages rates and bandwidth
 #_ratelog=1 # display ZMQ messages rates and bandwidth
diff --git a/macro/run/run_unpack_online.C b/macro/run/run_unpack_online.C
index 0449a64edb..986bb3b6bd 100644
--- a/macro/run/run_unpack_online.C
+++ b/macro/run/run_unpack_online.C
@@ -73,6 +73,21 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55
 
 
   // -----   CbmSetup   -----------------------------------------------------
+  if (2060 <= runid && defaultSetupName == setupName) {
+    /// Setup changed multiple times between the 2022 carbon and uranium runs
+    if (runid <= 2065) {
+      /// Carbon runs: 2060 - 2065 = 10/03/2022
+      setupName = "mcbm_beam_2022_03_09_carbon";
+    }
+    else if (2150 <= runid && runid <= 2160) {
+      /// Iron runs: 2150 - 2160 = 24-25/03/2022
+      setupName = "mcbm_beam_2022_03_22_iron";
+    }
+    else if (2176 <= runid && runid <= 2310) {
+      /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022
+      setupName = "mcbm_beam_2022_03_28_uranium";
+    }
+  }
   auto cbmsetup = CbmSetup::Instance();
   cbmsetup->LoadSetup(setupName);
   // ------------------------------------------------------------------------
diff --git a/macro/run/run_unpack_online_bmon.C b/macro/run/run_unpack_online_bmon.C
index e49ed60b6f..f5330c598f 100644
--- a/macro/run/run_unpack_online_bmon.C
+++ b/macro/run/run_unpack_online_bmon.C
@@ -65,6 +65,21 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho
 
 
   // -----   CbmSetup   -----------------------------------------------------
+  if (2060 <= runid && defaultSetupName == setupName) {
+    /// Setup changed multiple times between the 2022 carbon and uranium runs
+    if (runid <= 2065) {
+      /// Carbon runs: 2060 - 2065 = 10/03/2022
+      setupName = "mcbm_beam_2022_03_09_carbon";
+    }
+    else if (2150 <= runid && runid <= 2160) {
+      /// Iron runs: 2150 - 2160 = 24-25/03/2022
+      setupName = "mcbm_beam_2022_03_22_iron";
+    }
+    else if (2176 <= runid && runid <= 2310) {
+      /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022
+      setupName = "mcbm_beam_2022_03_28_uranium";
+    }
+  }
   auto cbmsetup = CbmSetup::Instance();
   cbmsetup->LoadSetup(setupName);
   // ------------------------------------------------------------------------
diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C
index c64aead16f..faed834f2d 100644
--- a/macro/run/run_unpack_tsa.C
+++ b/macro/run/run_unpack_tsa.C
@@ -85,6 +85,21 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid
 
 
   // -----   CbmSetup   -----------------------------------------------------
+  if (2060 <= runid && defaultSetupName == setupName) {
+    /// Setup changed multiple times between the 2022 carbon and uranium runs
+    if (runid <= 2065) {
+      /// Carbon runs: 2060 - 2065 = 10/03/2022
+      setupName = "mcbm_beam_2022_03_09_carbon";
+    }
+    else if (2150 <= runid && runid <= 2160) {
+      /// Iron runs: 2150 - 2160 = 24-25/03/2022
+      setupName = "mcbm_beam_2022_03_22_iron";
+    }
+    else if (2176 <= runid && runid <= 2310) {
+      /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022
+      setupName = "mcbm_beam_2022_03_28_uranium";
+    }
+  }
   auto cbmsetup = CbmSetup::Instance();
   cbmsetup->LoadSetup(setupName);
   // ------------------------------------------------------------------------
diff --git a/macro/run/run_unpack_tsa_bmon.C b/macro/run/run_unpack_tsa_bmon.C
index 57c4ecd3b7..20dca8be39 100644
--- a/macro/run/run_unpack_tsa_bmon.C
+++ b/macro/run/run_unpack_tsa_bmon.C
@@ -78,6 +78,21 @@ void run_unpack_tsa_bmon(std::vector<std::string> infile = {"test.tsa"}, UInt_t
 
 
   // -----   CbmSetup   -----------------------------------------------------
+  if (2060 <= runid && defaultSetupName == setupName) {
+    /// Setup changed multiple times between the 2022 carbon and uranium runs
+    if (runid <= 2065) {
+      /// Carbon runs: 2060 - 2065 = 10/03/2022
+      setupName = "mcbm_beam_2022_03_09_carbon";
+    }
+    else if (2150 <= runid && runid <= 2160) {
+      /// Iron runs: 2150 - 2160 = 24-25/03/2022
+      setupName = "mcbm_beam_2022_03_22_iron";
+    }
+    else if (2176 <= runid && runid <= 2310) {
+      /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022
+      setupName = "mcbm_beam_2022_03_28_uranium";
+    }
+  }
   auto cbmsetup = CbmSetup::Instance();
   cbmsetup->LoadSetup(setupName);
   // ------------------------------------------------------------------------
-- 
GitLab