From 03ab7ae16e57e1635ef930aef2d35c68cac1d542 Mon Sep 17 00:00:00 2001
From: P-A Loizeau <p.-a.loizeau@gsi.de>
Date: Thu, 3 Nov 2022 10:27:59 +0100
Subject: [PATCH] Add support for DigiEvent out in mCBM macro + CI test

---
 macro/beamtime/mcbm2022/mcbm_event.C | 10 ++++++++--
 macro/run/CMakeLists.txt             | 16 ++++++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/macro/beamtime/mcbm2022/mcbm_event.C b/macro/beamtime/mcbm2022/mcbm_event.C
index 1d2b281e15..7ef8e207c8 100644
--- a/macro/beamtime/mcbm2022/mcbm_event.C
+++ b/macro/beamtime/mcbm2022/mcbm_event.C
@@ -32,6 +32,7 @@ Bool_t mcbm_event(std::string infile,
                   UInt_t uRunId,
                   uint32_t uTriggerSet = 3,
                   std::int32_t nTimeslices = -1,
+                  bool bDigiEvtsOutput = false,
                   std::string sOutDir = "data/")
 {
   /// FIXME: Re-enable clang formatting after parameters initial values setting
@@ -341,11 +342,13 @@ Bool_t mcbm_event(std::string infile,
 
 
   // -----   Output filename   ----------------------------------------------
-  std::string filename    = Form("%d%s.event.root", uRunId, (bTrigSet ? Form("_%u", uTriggerSet) : ""));
+  std::string suffix = ".event.root";
+  if (bDigiEvtsOutput) suffix = ".digievents.root";
+  std::string filename    = Form("%d%s", uRunId, (bTrigSet ? Form("_%u", uTriggerSet) : "")) + suffix;
   std::string outfilename = sOutDir + "/" + filename;
   std::cout << "-I- " << myName << ": Output file will be " << outfilename << std::endl;
   std::string histosfilename = sOutDir + "/" + filename;
-  histosfilename.replace(histosfilename.find(".event.root"), 11, ".hist.root");
+  histosfilename.replace(histosfilename.find(suffix), suffix.size(), ".hist.root");
   std::cout << "-I- " << myName << ": Histos file will be " << histosfilename << std::endl;
   // ------------------------------------------------------------------------
 
@@ -441,6 +444,9 @@ Bool_t mcbm_event(std::string infile,
   // Use standard MUCH digis
   evBuildRaw->ChangeMuchBeamtimeDigiFlag();
 
+  // Enable DigiEvent output if requested
+  if (bDigiEvtsOutput) evBuildRaw->SetDigiEventOutput();
+
   evBuildRaw->SetOutFilename(histosfilename);
   // evBuildRaw->SetOutputBranchPersistent("CbmEvent", kFALSE);
   evBuildRaw->SetWriteHistosToFairSink(kFALSE);
diff --git a/macro/run/CMakeLists.txt b/macro/run/CMakeLists.txt
index 6b4d6b13d2..a953513017 100644
--- a/macro/run/CMakeLists.txt
+++ b/macro/run/CMakeLists.txt
@@ -402,7 +402,7 @@ If(DEFINED ENV{RAW_DATA_PATH} )
       ### Raw data analysis tests: event building and reconstruction => need calibration files!!
       Set(testname mcbm_event_2022_${RUN})
       Set(fixture_event_${RUN} fixture_done_${testname})
-      Add_Test(${testname} ${CBMROOT_BINARY_DIR}/macro/beamtime/mcbm2022/mcbm_event.sh \"${CBMROOT_BINARY_DIR}/macro/run/data/${RUN}_first20Ts.digi.root\" ${RUN})
+      Add_Test(${testname} ${CBMROOT_BINARY_DIR}/macro/beamtime/mcbm2022/mcbm_event.sh \"${CBMROOT_BINARY_DIR}/macro/run/data/${RUN}_first20Ts.digi.root\" ${RUN} 4 -1 false \"${CBMROOT_BINARY_DIR}/macro/run/data/\")
       Set_Tests_Properties(${testname} PROPERTIES
             TIMEOUT ${RAW_DATA_CHECK_TO}
             FAIL_REGULAR_EXPRESSION "segmentation violation"
@@ -411,6 +411,18 @@ If(DEFINED ENV{RAW_DATA_PATH} )
             FIXTURES_SETUP ${fixture_event_${RUN}}
             )
 
+      ### Raw data analysis tests: event building and reconstruction => need calibration files!!
+      Set(testname mcbm_digievent_2022_${RUN})
+      Set(fixture_digievent_${RUN} fixture_done_${testname})
+      Add_Test(${testname} ${CBMROOT_BINARY_DIR}/macro/beamtime/mcbm2022/mcbm_event.sh \"${CBMROOT_BINARY_DIR}/macro/run/data/${RUN}_first20Ts.digi.root\" ${RUN} 4 -1 true \"${CBMROOT_BINARY_DIR}/macro/run/data/\")
+      Set_Tests_Properties(${testname} PROPERTIES
+            TIMEOUT ${RAW_DATA_CHECK_TO}
+            FAIL_REGULAR_EXPRESSION "segmentation violation"
+            PASS_REGULAR_EXPRESSION "Macro finished successfully"
+            FIXTURES_REQUIRED ${fixture_event_${RUN}}
+            FIXTURES_SETUP ${fixture_digievent_${RUN}}
+            )
+
       ### Raw analysis tests: (event building and) reconstruction => need calibration files!!
       Set(testname mcbm_reco_2022_${RUN})
       Set(fixture_reco_${RUN} fixture_done_${testname})
@@ -423,7 +435,7 @@ If(DEFINED ENV{RAW_DATA_PATH} )
             TIMEOUT ${RAW_DATA_RECO_TO}
             FAIL_REGULAR_EXPRESSION "segmentation violation"
             PASS_REGULAR_EXPRESSION "Macro finished successfully"
-            FIXTURES_REQUIRED "${fixture_geo_${RUN}};${fixture_event_${RUN}}"
+            FIXTURES_REQUIRED "${fixture_geo_${RUN}};${fixture_digievent_${RUN}}"
             FIXTURES_SETUP ${fixture_reco_${RUN}}
             RESOURCE_LOCK mcbmRecoAllCoresBug
             )
-- 
GitLab