From bb3a0a34cc84c248f7be609f3afb0237d90bc587 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz Date: Mon, 16 Jan 2023 17:28:03 +0100 Subject: [PATCH 1/4] Add release date to v18.8.0 in CHANGELOG (cherry picked from commit 320f42b902f5dcc57eaee491acf966d6e424c666) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e571b928aa..1cb397e02c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to FairRoot will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -## 18.8 (UNRELEASED) - 2022-11-XX +## 18.8.0 - 2022-12-16 ### Breaking Changes * Move online related code into the new Online library From 6f27daa977a828d2361e5e9c65c8e42ca91f2675 Mon Sep 17 00:00:00 2001 From: Christian Tacke <58549698+ChristianTackeGSI@users.noreply.github.com> Date: Thu, 12 Jan 2023 13:11:02 +0100 Subject: [PATCH 2/4] Cleanup FairEventHeader (cherry picked from commit 2489938e3ad886cd240493f00cfa18c6edaf991b) --- base/event/FairEventHeader.cxx | 11 +---------- base/event/FairEventHeader.h | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/base/event/FairEventHeader.cxx b/base/event/FairEventHeader.cxx index 8692197eac..8c794a83ae 100644 --- a/base/event/FairEventHeader.cxx +++ b/base/event/FairEventHeader.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,15 +14,6 @@ #include "FairRootManager.h" -FairEventHeader::FairEventHeader() - : fRunId(0) - , fEventTime(-1.) - , fInputFileId(0) - , fMCEntryNo(0) -{} - -FairEventHeader::~FairEventHeader() {} - void FairEventHeader::Register(Bool_t Persistence) { FairRootManager::Instance()->Register("EventHeader.", "EvtHeader", this, Persistence); diff --git a/base/event/FairEventHeader.h b/base/event/FairEventHeader.h index 31a08ec2f5..5681e319ce 100644 --- a/base/event/FairEventHeader.h +++ b/base/event/FairEventHeader.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,19 +25,24 @@ class FairEventHeader : public TNamed { public: /** Default constructor */ - FairEventHeader(); + FairEventHeader() = default; + + /** + * Destructor + */ + ~FairEventHeader() override = default; /** Get the run ID for this run*/ - UInt_t GetRunId() { return fRunId; } + UInt_t GetRunId() const { return fRunId; } /** Get the MC time for this event*/ - Double_t GetEventTime() { return fEventTime; } + Double_t GetEventTime() const { return fEventTime; } /** Get the MC input file Id for this event*/ - Int_t GetInputFileId() { return fInputFileId; } + Int_t GetInputFileId() const { return fInputFileId; } /**The entry number in the original MC chain */ - Int_t GetMCEntryNumber() { return fMCEntryNo; } + Int_t GetMCEntryNumber() const { return fMCEntryNo; } /** Set the run ID for this run * @param runid : unique run id @@ -55,23 +60,19 @@ class FairEventHeader : public TNamed /**The entry number in the original MC chain */ void SetMCEntryNumber(Int_t id) { fMCEntryNo = id; } - /** - * Destructor - */ - virtual ~FairEventHeader(); virtual void Register(Bool_t Persistance = kTRUE); protected: /** Run Id */ - UInt_t fRunId; + UInt_t fRunId{0}; /** Event Time **/ - Double_t fEventTime; + Double_t fEventTime{-1.}; /** Input file identifier, the file description is in the File header*/ - Int_t fInputFileId; + Int_t fInputFileId{0}; /**MC entry number from input chain*/ - Int_t fMCEntryNo; + Int_t fMCEntryNo{0}; - ClassDef(FairEventHeader, 3); + ClassDefOverride(FairEventHeader, 3); }; #endif From 3f4e589c46946b981d57c0e50cf546020e5a0aa6 Mon Sep 17 00:00:00 2001 From: Christian Tacke <58549698+ChristianTackeGSI@users.noreply.github.com> Date: Thu, 12 Jan 2023 13:12:46 +0100 Subject: [PATCH 3/4] Add FairRun::GetEvtHeaderRunId and use it Classes derived from FairRun often call GetRunId() on fEvtHeader. So let's have a shortcut. (cherry picked from commit f7091f7d86e8737f28913830713606da488a51cb) --- base/steer/FairRun.cxx | 3 +-- base/steer/FairRun.h | 8 +++++++- base/steer/FairRunAna.cxx | 13 +++++-------- base/steer/FairRunAnaProof.cxx | 9 ++++----- online/steer/FairRunOnline.cxx | 11 +++++------ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/base/steer/FairRun.cxx b/base/steer/FairRun.cxx index 37adcafcfd..3bace793a3 100644 --- a/base/steer/FairRun.cxx +++ b/base/steer/FairRun.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,7 +12,6 @@ #include "FairRun.h" -#include "FairEventHeader.h" // for FairEventHeader #include "FairFileHeader.h" // for FairFileHeader #include "FairLinkManager.h" // for FairLinkManager #include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN diff --git a/base/steer/FairRun.h b/base/steer/FairRun.h index 00305d1148..bc62514e00 100644 --- a/base/steer/FairRun.h +++ b/base/steer/FairRun.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,6 +9,7 @@ #define FAIRRUN_H #include "FairAlignmentHandler.h" +#include "FairEventHeader.h" #include "FairSink.h" #include "FairSource.h" @@ -252,6 +253,11 @@ class FairRun : public TNamed fSource->FillEventHeader(fEvtHeader); } + /** + * Get the RunId of the Event Header + */ + UInt_t GetEvtHeaderRunId() const { return fEvtHeader->GetRunId(); } + ClassDefOverride(FairRun, 5); }; #endif // FAIRRUN_H diff --git a/base/steer/FairRunAna.cxx b/base/steer/FairRunAna.cxx index 1291e94a30..ce4b8edf93 100644 --- a/base/steer/FairRunAna.cxx +++ b/base/steer/FairRunAna.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -210,7 +210,7 @@ void FairRunAna::Init() FillEventHeader(); - fRunId = fEvtHeader->GetRunId(); + fRunId = GetEvtHeaderRunId(); // Copy the Event Header Info to Output fEvtHeader->Register(fStoreEventHeader); @@ -281,7 +281,6 @@ void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end) if (fTimeStamps) { RunTSBuffers(); } else { - UInt_t tmpId = 0; // if (fInputFile==0) { if (!fInFileIsOpen) { DummyRun(Ev_start, Ev_end); @@ -344,7 +343,7 @@ void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end) FillEventHeader(); - tmpId = fEvtHeader->GetRunId(); + auto const tmpId = GetEvtHeaderRunId(); if (tmpId != fRunId) { fRunId = tmpId; if (!fStatic) { @@ -483,9 +482,8 @@ void FairRunAna::RunMQ(Long64_t entry) This methode is only needed and used with ZeroMQ it read a certain event and call the task exec, but no output is written */ - UInt_t tmpId = 0; fRootManager->ReadEvent(entry); - tmpId = fEvtHeader->GetRunId(); + auto const tmpId = GetEvtHeaderRunId(); if (tmpId != fRunId) { fRunId = tmpId; if (!fStatic) { @@ -502,9 +500,8 @@ void FairRunAna::RunMQ(Long64_t entry) //_____________________________________________________________________________ void FairRunAna::Run(Long64_t entry) { - UInt_t tmpId = 0; fRootManager->ReadEvent(entry); - tmpId = fEvtHeader->GetRunId(); + auto const tmpId = GetEvtHeaderRunId(); if (tmpId != fRunId) { fRunId = tmpId; if (!fStatic) { diff --git a/base/steer/FairRunAnaProof.cxx b/base/steer/FairRunAnaProof.cxx index b4026dab57..e19cbcc129 100644 --- a/base/steer/FairRunAnaProof.cxx +++ b/base/steer/FairRunAnaProof.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -176,7 +176,7 @@ void FairRunAnaProof::Init() FillEventHeader(); - fRunId = fEvtHeader->GetRunId(); + fRunId = GetEvtHeaderRunId(); // Copy the Event Header Info to Output fEvtHeader->Register(kTRUE); @@ -247,7 +247,7 @@ void FairRunAnaProof::InitContainers() FillEventHeader(); - fRunId = fEvtHeader->GetRunId(); + fRunId = GetEvtHeaderRunId(); // Copy the Event Header Info to Output fEvtHeader->Register(); @@ -284,12 +284,11 @@ void FairRunAnaProof::RunOneEvent(Long64_t entry) if (fTimeStamps) { RunTSBuffers(); } else { - UInt_t tmpId = 0; fRootManager->ReadEvent(entry); FillEventHeader(); - tmpId = fEvtHeader->GetRunId(); + auto const tmpId = GetEvtHeaderRunId(); if (tmpId != fRunId) { fRunId = tmpId; if (!fStatic) { diff --git a/online/steer/FairRunOnline.cxx b/online/steer/FairRunOnline.cxx index a6b1913ef2..41fcee90ff 100644 --- a/online/steer/FairRunOnline.cxx +++ b/online/steer/FairRunOnline.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -130,7 +130,7 @@ void FairRunOnline::Init() if (0 == fRunId) // Run ID was not set in run manager { - if (0 == fEvtHeader->GetRunId()) // Run ID was not set in source + if (0 == GetEvtHeaderRunId()) // Run ID was not set in source { // Generate unique Run ID FairRunIdGenerator genid; @@ -138,7 +138,7 @@ void FairRunOnline::Init() GetSource()->SetRunId(fRunId); } else { // Use Run ID from source - fRunId = fEvtHeader->GetRunId(); + fRunId = GetEvtHeaderRunId(); } } else { // Run ID was set in the run manager - propagate to source @@ -202,7 +202,6 @@ void FairRunOnline::Init() void FairRunOnline::InitContainers() { - fRtdb = GetRuntimeDb(); FairBaseParSet* par = static_cast(fRtdb->getContainer("FairBaseParSet")); LOG(info) << "FairRunOnline::InitContainers: par = " << par; @@ -212,7 +211,7 @@ void FairRunOnline::InitContainers() if (par) { fEvtHeader = static_cast(fRootManager->GetObject("EventHeader.")); - fRunId = fEvtHeader->GetRunId(); + fRunId = GetEvtHeaderRunId(); // Copy the Event Header Info to Output fEvtHeader->Register(); @@ -244,7 +243,7 @@ Int_t FairRunOnline::EventLoop() signal(SIGINT, handler_ctrlc); FillEventHeader(); - auto const tmpId = fEvtHeader->GetRunId(); + auto const tmpId = GetEvtHeaderRunId(); if (tmpId != fRunId) { LOG(info) << "FairRunOnline::EventLoop() Call Reinit due to changed RunID (from " << fRunId << " to " << tmpId; From c5d0d3dacb2cab27bacb93f24c648e439081aca4 Mon Sep 17 00:00:00 2001 From: Christian Tacke <58549698+ChristianTackeGSI@users.noreply.github.com> Date: Sat, 24 Dec 2022 18:53:14 +0100 Subject: [PATCH 4/4] fix(Ex1Processor): Handle nullptr, cleanup fix part of #1286: The result of ROOT's deserializer should be checked. (cherry picked from commit edb765742d48111c78282938c60c5c1f45ae0c22) --- .../MQ/serialization/1-simple/Ex1Processor.h | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/MQ/serialization/1-simple/Ex1Processor.h b/examples/MQ/serialization/1-simple/Ex1Processor.h index 74dab6910d..7495aa1688 100644 --- a/examples/MQ/serialization/1-simple/Ex1Processor.h +++ b/examples/MQ/serialization/1-simple/Ex1Processor.h @@ -21,7 +21,8 @@ class Ex1Processor : public fair::mq::Device { public: - Ex1Processor() {} + Ex1Processor() = default; + ~Ex1Processor() override = default; void Run() override { @@ -35,8 +36,11 @@ class Ex1Processor : public fair::mq::Device receivedMsgs++; // Deserialize - std::unique_ptr digis(nullptr); - RootSerializer().Deserialize(*msgIn, digis); + auto digis = RootSerializer().DeserializeTo(*msgIn); + if (!digis) { + LOG(warn) << "Deserialization FAILED, skipping"; + continue; + } // Compute TClonesArray hits = FindHits(*digis); @@ -54,22 +58,21 @@ class Ex1Processor : public fair::mq::Device LOG(info) << "Received " << receivedMsgs << " and sent " << sentMsgs << " messages!"; } + private: // do some random dummy task TClonesArray FindHits(const TClonesArray& digis) { TClonesArray hits("MyHit"); + const TVector3 dpos(1 / TMath::Sqrt(12), 1 / TMath::Sqrt(12), 1 / TMath::Sqrt(12)); + const Int_t fDetID = 0; + const Int_t fMCIndex = 0; for (int i = 0; i < digis.GetEntriesFast(); i++) { - TVector3 pos; - TVector3 dpos; // Double_t timestamp = 0; // Double_t timestampErr = 0; - Int_t fDetID = 0; - Int_t fMCIndex = 0; - MyDigi* digi = static_cast(digis.At(i)); - pos.SetXYZ(digi->GetX() + 0.5, digi->GetY() + 0.5, digi->GetZ() + 0.5); - dpos.SetXYZ(1 / TMath::Sqrt(12), 1 / TMath::Sqrt(12), 1 / TMath::Sqrt(12)); - MyHit* hit = new ((hits)[i]) MyHit(fDetID, fMCIndex, pos, dpos); + auto digi = static_cast(digis.At(i)); + const TVector3 pos(digi->GetX() + 0.5, digi->GetY() + 0.5, digi->GetZ() + 0.5); + auto hit = new ((hits)[i]) MyHit(fDetID, fMCIndex, pos, dpos); hit->SetTimeStamp(digi->GetTimeStamp()); hit->SetTimeStampError(digi->GetTimeStampError()); }