From e1f657584def672b4e2f905483feea1a89ac8f1d Mon Sep 17 00:00:00 2001 From: Pascal Raisig <praisig@ikf.uni-frankfurt.de> Date: Wed, 21 Jul 2021 15:38:21 +0200 Subject: [PATCH] Use event header in a more FairRootish way Remove by hand added CbmTsEventHeader from CbmRecoUnpack. Instead, use the getter from the FairRun::Instance() to access the event header. Remark a fatal will be created if the wrong event header is set in the steering macro --- macro/run/run_unpack_tsa.C | 3 +++ reco/steer/CbmRecoUnpack.cxx | 11 +++++++---- reco/steer/CbmRecoUnpack.h | 4 +--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C index c5cfacdc4a..444693d290 100644 --- a/macro/run/run_unpack_tsa.C +++ b/macro/run/run_unpack_tsa.C @@ -190,6 +190,9 @@ void run_unpack_tsa(std::string infile = "test.tsa", UInt_t runid = 0, const cha auto run = new FairRunOnline(source); auto sink = new FairRootFileSink(outfilename.data()); run->SetSink(sink); + auto eventheader = new CbmTsEventHeader(); + run->SetRunId(runid); + run->SetEventHeader(eventheader); // ------------------------------------------------------------------------ diff --git a/reco/steer/CbmRecoUnpack.cxx b/reco/steer/CbmRecoUnpack.cxx index eec6bd5745..191dcff0cf 100644 --- a/reco/steer/CbmRecoUnpack.cxx +++ b/reco/steer/CbmRecoUnpack.cxx @@ -54,10 +54,13 @@ Bool_t CbmRecoUnpack::Init() FairRootManager* ioman = FairRootManager::Instance(); assert(ioman); - // --- Register the branch for the Timeslice start time - fCbmTsEventHeader = new CbmTsEventHeader(); - ioman->RegisterAny("TsEventHeader", fCbmTsEventHeader, kTRUE); - LOG(info) << "CbmRecoUnpack::Init() registered CbmTsEventHeader to output tree!\n"; + + auto eh = FairRun::Instance()->GetEventHeader(); + if (eh->IsA() == CbmTsEventHeader::Class()) fCbmTsEventHeader = static_cast<CbmTsEventHeader*>(eh); + else + LOG(fatal) + << "CbmRecoUnpack::Init() no CbmTsEventHeader was added to the run. Without it, we can not store the UTC of the " + "Timeslices correctly. Hence, this causes a fatal. Please add it in the steering macro to the Run."; // --- Psd diff --git a/reco/steer/CbmRecoUnpack.h b/reco/steer/CbmRecoUnpack.h index 7f9441ac31..c1d9cd2c01 100644 --- a/reco/steer/CbmRecoUnpack.h +++ b/reco/steer/CbmRecoUnpack.h @@ -39,9 +39,7 @@ class CbmRecoUnpack : public TObject { public: /** @brief Constructor - ** @param fileName Name of (single) input file. - ** - ** More input files can be added by the method AddInputFile. + ** */ CbmRecoUnpack(); -- GitLab