From ed65dd09e73c4e489dd27669f3186700dfe620d5 Mon Sep 17 00:00:00 2001
From: "P.-A. Loizeau" <p.-a.loizeau@gsi.de>
Date: Wed, 13 Jul 2022 17:00:11 +0200
Subject: [PATCH] Fix/adapt to the new 16ch diamond while keeping old data
 support in par and macro files

- Fix comp order in param file to avoid needing a channel remapping 16ch Diam
- Set spill thr for corresponding runs in BMon unp macros (monitors)
---
 macro/beamtime/.gitignore                        |  2 ++
 macro/beamtime/mcbm2022/mBmonCriPar.par          |  4 ++--
 .../mcbm2022/mTofCriParIron_withBmon.par         |  4 ++--
 macro/run/run_unpack_online_bmon.C               | 16 ++++++++++------
 macro/run/run_unpack_tsa_bmon.C                  |  4 ++++
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/macro/beamtime/.gitignore b/macro/beamtime/.gitignore
index ee321edab5..123fb5a525 100644
--- a/macro/beamtime/.gitignore
+++ b/macro/beamtime/.gitignore
@@ -1,3 +1,5 @@
 mcbm20??/all_*.par
 mcbm20??/core_dump*
 mcbm20??/*.pdf
+mcbm20??/*.png
+mcbm20??/*.log
diff --git a/macro/beamtime/mcbm2022/mBmonCriPar.par b/macro/beamtime/mcbm2022/mBmonCriPar.par
index ba7da7cc52..990e2448a8 100644
--- a/macro/beamtime/mcbm2022/mBmonCriPar.par
+++ b/macro/beamtime/mcbm2022/mBmonCriPar.par
@@ -3,7 +3,7 @@
 //----------------------------------------------------------------------------
 NrOfGdpbs: Int_t 4
 GdpbIdArray: Int_t \
-0xabf3 0xabf2 0xabf0 0xabf1
+0xabf3 0xabf2 0xabf1 0xabf0
 NrOfFeesPerGdpb: Int_t 10
 NrOfGet4PerFee:  Int_t 8
 NrOfChannelsPerGet4: Int_t 4
@@ -14,7 +14,7 @@ NrOfRpc: Int_t \
 RpcType: Int_t \
  99 -1 99 -1 99 -1 99 -1
 RpcSide: Int_t \
-  0  0  0  0  1  0  1  0
+  0  0  0  0  0  0  0  0
 ModuleId: Int_t \
   0 -1  0 -1  0 -1  0 -1
 NbMsTot: Int_t 100
diff --git a/macro/beamtime/mcbm2022/mTofCriParIron_withBmon.par b/macro/beamtime/mcbm2022/mTofCriParIron_withBmon.par
index 7a8f08b4d3..26af042e59 100644
--- a/macro/beamtime/mcbm2022/mTofCriParIron_withBmon.par
+++ b/macro/beamtime/mcbm2022/mTofCriParIron_withBmon.par
@@ -3,7 +3,7 @@
 //----------------------------------------------------------------------------
 NrOfGdpbs: Int_t 12
 GdpbIdArray: Int_t \
-0xabc0 0xabc1 0xabc2 0xabc3 0xabc4 0xabc5 0xabc6 0xabc7 0xabf3 0xabf2 0xabf0 0xabf1
+0xabc0 0xabc1 0xabc2 0xabc3 0xabc4 0xabc5 0xabc6 0xabc7 0xabf3 0xabf2 0xabf1 0xabf0
 NrOfFeesPerGdpb: Int_t 10
 NrOfGet4PerFee:  Int_t 8
 NrOfChannelsPerGet4: Int_t 4
@@ -14,7 +14,7 @@ NrOfRpc: Int_t \
 RpcType: Int_t \
   0  0  0  0  2  2  0  0  0  0  0  0  9  9  6  9 99 -1 99 -1 99 -1 99 -1
 RpcSide: Int_t \
-  0  1  0  1  0  1  0  1  0  1  0  1  2  2  2  0  0  0  0  0  1  0  1  0
+  0  1  0  1  0  1  0  1  0  1  0  1  2  2  2  0  0  0  0  0  0  0  0  0
 ModuleId: Int_t \
   0  0  1  1  0  0  2  2  3  3  4  4  0 -1  0  1  0 -1  0 -1  0 -1  0 -1
 NbMsTot: Int_t 100
diff --git a/macro/run/run_unpack_online_bmon.C b/macro/run/run_unpack_online_bmon.C
index f5330c598f..c272885aea 100644
--- a/macro/run/run_unpack_online_bmon.C
+++ b/macro/run/run_unpack_online_bmon.C
@@ -92,7 +92,7 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho
   bmonconfig = std::make_shared<CbmBmonUnpackConfig>("", runid);
   if (bmonconfig) {
     // bmonconfig->SetDebugState();
-    bmonconfig->SetDoWriteOutput();
+    // bmonconfig->SetDoWriteOutput();
     // bmonconfig->SetDoWriteOptOutA("CbmBmonErrors");
     std::string parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2022/", srcDir.Data());
     bmonconfig->SetParFilesBasePath(parfilesbasepathBmon);
@@ -100,6 +100,10 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho
     bmonconfig->SetSystemTimeOffset(-1220);  // [ns] value to be updated
     /// Enable Monitor plots
     bmonconfig->SetMonitor(GetTofMonitor(outfilename, true));
+    if (2337 <= runid) {
+      bmonconfig->GetMonitor()->SetSpillThreshold(250);
+      bmonconfig->GetMonitor()->SetSpillThresholdNonPulser(100);
+    }
   }
   // -------------
 
@@ -117,10 +121,10 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho
   // -----   CbmSourceTsArchive   -------------------------------------------
   auto source = new CbmSourceTsArchive(publisher);
   auto unpack = source->GetRecoUnpack();
-  unpack->SetDoPerfProfiling(doPerfProfiling);
-  unpack->SetOutputFilename(perfProfFileName);
+  //unpack->SetDoPerfProfiling(doPerfProfiling);
+  //unpack->SetOutputFilename(perfProfFileName);
   // Enable full time sorting instead sorting per FLIM link
-  unpack->SetTimeSorting(true);
+  //unpack->SetTimeSorting(true);
   unpack->SetMonitoringOnly(true);
 
   if (bmonconfig) unpack->SetUnpackConfig(bmonconfig);
@@ -217,8 +221,8 @@ std::shared_ptr<CbmTofUnpackMonitor> GetTofMonitor(std::string treefilename, boo
   return monitor;
 }
 
-void run_unpack_online_bmon(std::string publisher = "tcp://localhost:5556", Int_t serverHttpPort = 8080,
-                            Int_t serverRefreshRate = 100, std::int32_t nevents = -1, UInt_t runid = 1905,
+void run_unpack_online_bmon(std::string publisher = "tcp://localhost:5556", UInt_t runid = 1905,
+                            Int_t serverHttpPort = 8080, Int_t serverRefreshRate = 10, std::int32_t nevents = -1,
                             const char* setupName = defaultSetupName, std::string outpath = "data/")
 {
   std::vector<std::string> vPublisher = {publisher};
diff --git a/macro/run/run_unpack_tsa_bmon.C b/macro/run/run_unpack_tsa_bmon.C
index 20dca8be39..2abe001c88 100644
--- a/macro/run/run_unpack_tsa_bmon.C
+++ b/macro/run/run_unpack_tsa_bmon.C
@@ -113,6 +113,10 @@ void run_unpack_tsa_bmon(std::vector<std::string> infile = {"test.tsa"}, UInt_t
     bmonconfig->SetSystemTimeOffset(-1220);  // [ns] value to be updated
     /// Enable Monitor plots
     bmonconfig->SetMonitor(GetTofMonitor(outfilename, true));
+    if (2337 <= runid) {
+      bmonconfig->GetMonitor()->SetSpillThreshold(250);
+      bmonconfig->GetMonitor()->SetSpillThresholdNonPulser(100);
+    }
   }
   // -------------
 
-- 
GitLab