Commit e1f65758 authored by Pascal Raisig's avatar Pascal Raisig Committed by Pierre-Alain Loizeau
Browse files

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
parent a77bbe77
...@@ -190,6 +190,9 @@ void run_unpack_tsa(std::string infile = "test.tsa", UInt_t runid = 0, const cha ...@@ -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 run = new FairRunOnline(source);
auto sink = new FairRootFileSink(outfilename.data()); auto sink = new FairRootFileSink(outfilename.data());
run->SetSink(sink); run->SetSink(sink);
auto eventheader = new CbmTsEventHeader();
run->SetRunId(runid);
run->SetEventHeader(eventheader);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
......
...@@ -54,10 +54,13 @@ Bool_t CbmRecoUnpack::Init() ...@@ -54,10 +54,13 @@ Bool_t CbmRecoUnpack::Init()
FairRootManager* ioman = FairRootManager::Instance(); FairRootManager* ioman = FairRootManager::Instance();
assert(ioman); assert(ioman);
// --- Register the branch for the Timeslice start time
fCbmTsEventHeader = new CbmTsEventHeader(); auto eh = FairRun::Instance()->GetEventHeader();
ioman->RegisterAny("TsEventHeader", fCbmTsEventHeader, kTRUE); if (eh->IsA() == CbmTsEventHeader::Class()) fCbmTsEventHeader = static_cast<CbmTsEventHeader*>(eh);
LOG(info) << "CbmRecoUnpack::Init() registered CbmTsEventHeader to output tree!\n"; 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 // --- Psd
......
...@@ -39,9 +39,7 @@ class CbmRecoUnpack : public TObject { ...@@ -39,9 +39,7 @@ class CbmRecoUnpack : public TObject {
public: public:
/** @brief Constructor /** @brief Constructor
** @param fileName Name of (single) input file. **
**
** More input files can be added by the method AddInputFile.
*/ */
CbmRecoUnpack(); CbmRecoUnpack();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment