From 8ab51f57f7b9d60b7ca67e4b8f3fd19ae277e05b Mon Sep 17 00:00:00 2001
From: "P.-A. Loizeau" <p.-a.loizeau@gsi.de>
Date: Thu, 17 Mar 2022 15:37:32 +0100
Subject: [PATCH] Update mTOF unpack par class + use 2022 par file to support
 new modules for runs from 2060 on

---
 core/detectors/tof/CbmMcbm2018TofPar.cxx | 16 ++++++++++++++++
 macro/beamtime/mcbm2022/mTofCriPar.par   | 16 ++++++++--------
 macro/run/.gitignore                     |  2 ++
 macro/run/run_unpack_online.C            |  4 ++++
 macro/run/run_unpack_tsa.C               |  4 ++++
 5 files changed, 34 insertions(+), 8 deletions(-)
 create mode 100644 macro/run/.gitignore

diff --git a/core/detectors/tof/CbmMcbm2018TofPar.cxx b/core/detectors/tof/CbmMcbm2018TofPar.cxx
index c2f8bfb1c3..be885c97e2 100644
--- a/core/detectors/tof/CbmMcbm2018TofPar.cxx
+++ b/core/detectors/tof/CbmMcbm2018TofPar.cxx
@@ -216,6 +216,7 @@ void CbmMcbm2018TofPar::BuildChannelsUidMap()
   UInt_t uCh = 0;
   for (UInt_t uGbtx = 0; uGbtx < uNrOfGbtx; ++uGbtx) {
     switch (fiRpcType[uGbtx]) {
+      case 2: // intended fall-through
       case 0: {
         // CBM modules
         BuildChannelsUidMapCbm(uCh, uGbtx);
@@ -419,6 +420,21 @@ void CbmMcbm2018TofPar::BuildChannelsUidMapStar2(UInt_t& uCh, UInt_t uGbtx)
             default:;
           }
           break;
+        case 3:  // direct beam 20210524
+          switch (iFeet) {
+            case 0:
+              iRpcMap  = 0;
+              iSideMap = 0;
+              iStrMap  = iStr;
+              break;
+            case 1:
+              iRpcMap  = 0;
+              iSideMap = 1;
+              iStrMap  = 31 - iStr;
+              break;
+            default: iSideMap = -1;
+          }
+          break;
       }
       if (iSideMap > -1)
         fviRpcChUId[uCh] =
diff --git a/macro/beamtime/mcbm2022/mTofCriPar.par b/macro/beamtime/mcbm2022/mTofCriPar.par
index 43e35e903e..0fe3bc583b 100644
--- a/macro/beamtime/mcbm2022/mTofCriPar.par
+++ b/macro/beamtime/mcbm2022/mTofCriPar.par
@@ -1,22 +1,22 @@
 ####################################################################################################
 [CbmMcbm2018TofPar]
 //----------------------------------------------------------------------------
-NrOfGdpbs: Int_t 7
+NrOfGdpbs: Int_t 8
 GdpbIdArray: Int_t \
-0xabc0 0xabc1 0xabc2 0xabc3 0xabc4 0xabc5 0xabc6
+0xabc0 0xabc1 0xabc2 0xabc3 0xabc4 0xabc5 0xabc6 0xabc7
 NrOfFeesPerGdpb: Int_t 10
 NrOfGet4PerFee:  Int_t 8
 NrOfChannelsPerGet4: Int_t 4
-NrOfGbtx: Int_t  13
-NrOfModule: Int_t 7
+NrOfGbtx: Int_t  16
+NrOfModule: Int_t 20
 NrOfRpc: Int_t \
-  5  5  5  5  5  5  5  5  5  5  5  5  2 
+  5  5  5  5  5  5  5  5  5  5  5  5  2  2  2  2
 RpcType: Int_t \
-  0  0  0  0  2  2  0  0  0  0  0  0  9
+  0  0  0  0  2  2  0  0  0  0  0  0  9  9  6  9
 RpcSide: Int_t \
-  1  0  1  0  1  0  1  0  0  1  0  1  0
+  0  1  0  1  0  1  0  1  0  1  0  1  2  2  2  0
 ModuleId: Int_t \
-  0  0  1  1  0  0  2  2  3  3  4  4  0
+  0  0  1  1  0  0  2  2  3  3  4  4  0 -1  0  1
 NbMsTot: Int_t 100
 NbMsOverlap: Int_t 1
 SizeMsInNs: Double_t 102400.0
diff --git a/macro/run/.gitignore b/macro/run/.gitignore
new file mode 100644
index 0000000000..97e44bd546
--- /dev/null
+++ b/macro/run/.gitignore
@@ -0,0 +1,2 @@
+all_*.par
+data/*.root
diff --git a/macro/run/run_unpack_online.C b/macro/run/run_unpack_online.C
index 6852a44bee..fd3c46a27a 100644
--- a/macro/run/run_unpack_online.C
+++ b/macro/run/run_unpack_online.C
@@ -236,6 +236,10 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55
     tofconfig->SetDoWriteOutput();
     // tofconfig->SetDoWriteOptOutA("CbmTofErrors");
     std::string parfilesbasepathTof = Form("%s/macro/beamtime/mcbm2021/", srcDir.Data());
+    if (2060 <= runid ) {
+      /// Additional modules added just before the 10/03/2022 Carbon run
+      parfilesbasepathTof = Form("%s/macro/beamtime/mcbm2022/", srcDir.Data());
+    }
     tofconfig->SetParFilesBasePath(parfilesbasepathTof);
     tofconfig->SetSystemTimeOffset(-1220);  // [ns] value to be updated
     if (runid <= 1659) {
diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C
index b77948d2fb..5fce45051b 100644
--- a/macro/run/run_unpack_tsa.C
+++ b/macro/run/run_unpack_tsa.C
@@ -248,6 +248,10 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid
     tofconfig->SetDoWriteOutput();
     // tofconfig->SetDoWriteOptOutA("CbmTofErrors");
     std::string parfilesbasepathTof = Form("%s/macro/beamtime/mcbm2021/", srcDir.Data());
+    if (2060 <= runid ) {
+      /// Additional modules added just before the 10/03/2022 Carbon run
+      parfilesbasepathTof = Form("%s/macro/beamtime/mcbm2022/", srcDir.Data());
+    }
     tofconfig->SetParFilesBasePath(parfilesbasepathTof);
     tofconfig->SetSystemTimeOffset(-1220);  // [ns] value to be updated
     if (runid <= 1659) {
-- 
GitLab