From 96f821105247a56a0c8b4eb33b7420a21d7ad915 Mon Sep 17 00:00:00 2001
From: Volker Friese <v.friese@gsi.de>
Date: Fri, 17 Dec 2021 17:35:31 +0100
Subject: [PATCH] Correct CbmDaq to provide the proper MC event list. Prevent
 tree access modes kRepeat and kRandom for the time being.

---
 core/base/CbmDaq.cxx                  | 2 +-
 macro/run/CMakeLists.txt              | 2 +-
 macro/run/config.json                 | 2 +-
 macro/run/run_digi.C                  | 2 +-
 sim/response/base/CbmDigitization.cxx | 2 ++
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/core/base/CbmDaq.cxx b/core/base/CbmDaq.cxx
index d6a3198bfa..be7cd8f21d 100644
--- a/core/base/CbmDaq.cxx
+++ b/core/base/CbmDaq.cxx
@@ -187,7 +187,7 @@ void CbmDaq::Exec(Option_t*)
 
   // Event info
   Int_t file         = FairRunAna::Instance()->GetEventHeader()->GetInputFileId();
-  Int_t event        = FairRootManager::Instance()->GetEntryNr();
+  Int_t event        = FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber();
   Double_t eventTime = FairRunAna::Instance()->GetEventHeader()->GetEventTime();
   fEventList.Insert(event, file, eventTime);
 
diff --git a/macro/run/CMakeLists.txt b/macro/run/CMakeLists.txt
index 0fcd03721a..bfacfd6ff2 100644
--- a/macro/run/CMakeLists.txt
+++ b/macro/run/CMakeLists.txt
@@ -154,7 +154,7 @@ foreach(setup IN LISTS cbm_setup)
   # --- Detector response simulation, time-based, using run_digi.C
   set(testname run_${sname}_digi_ts)
   set(eventrate 1.e7)
-  set(beamrate 1.e9)
+  set(beamrate 1.e7)
   set(tslength 1.e6)
   add_test(${testname} ${MACRO_DIR}/run_digi.sh
   	\"data/${sname}_coll\" -1 \"data/${sname}_ts\"\ ${eventrate} ${tslength}
diff --git a/macro/run/config.json b/macro/run/config.json
index 67b3383520..b81fc8d4bc 100644
--- a/macro/run/config.json
+++ b/macro/run/config.json
@@ -100,7 +100,7 @@
       {"id": -1,
        "path": "test_beam",
        "rate": "1.e9",
-       "treeAccessMode": "random"}
+       "treeAccessMode": "regular"}
     ],
     "output": {
       "path": "data/test_json",
diff --git a/macro/run/run_digi.C b/macro/run/run_digi.C
index 4e3f82f481..bede1dc98d 100644
--- a/macro/run/run_digi.C
+++ b/macro/run/run_digi.C
@@ -132,7 +132,7 @@ void run_digi(TString inputEvents = "", Int_t nEvents = -1, TString output = "",
   run.AddInput(0, evntFile, eventRate);
   if (!eventMode) {
     if (!inputSignal.IsNull()) run.EmbedInput(1, signFile, 0);
-    if (!inputBeam.IsNull()) run.AddInput(2, beamFile, beamRate, ECbmTreeAccess::kRandom);
+    if (!inputBeam.IsNull()) run.AddInput(2, beamFile, beamRate);
   }
   run.SetOutputFile(outFile, overwrite);
   run.SetMonitorFile(moniFile);
diff --git a/sim/response/base/CbmDigitization.cxx b/sim/response/base/CbmDigitization.cxx
index 0f89d0fad2..5ed24c626e 100644
--- a/sim/response/base/CbmDigitization.cxx
+++ b/sim/response/base/CbmDigitization.cxx
@@ -77,6 +77,8 @@ CbmDigitization::~CbmDigitization()
 void CbmDigitization::AddInput(UInt_t inputId, TString fileName, Double_t eventRate, ECbmTreeAccess mode)
 {
   if (gSystem->AccessPathName(fileName)) LOG(fatal) << fName << ": input file " << fileName << " does not exist!";
+  if (mode != ECbmTreeAccess::kRegular)
+    LOG(fatal) << fName << ": access modes other than kRegular are not yet supported!";
   TChain* chain = new TChain("cbmsim");
   chain->Add(fileName.Data());
   fSource->AddInput(inputId, chain, eventRate, mode);
-- 
GitLab