Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.8] Backport #1311, #1305 #1325

Merged
merged 4 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions base/event/FairEventHeader.cxx
Original file line number Diff line number Diff line change
@@ -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, *
Expand All @@ -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);
Expand Down
31 changes: 16 additions & 15 deletions base/event/FairEventHeader.h
Original file line number Diff line number Diff line change
@@ -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, *
Expand All @@ -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
Expand All @@ -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
3 changes: 1 addition & 2 deletions base/steer/FairRun.cxx
Original file line number Diff line number Diff line change
@@ -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, *
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion base/steer/FairRun.h
Original file line number Diff line number Diff line change
@@ -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, *
Expand All @@ -9,6 +9,7 @@
#define FAIRRUN_H

#include "FairAlignmentHandler.h"
#include "FairEventHeader.h"
#include "FairSink.h"
#include "FairSource.h"

Expand Down Expand Up @@ -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
13 changes: 5 additions & 8 deletions base/steer/FairRunAna.cxx
Original file line number Diff line number Diff line change
@@ -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, *
Expand Down Expand Up @@ -210,7 +210,7 @@ void FairRunAna::Init()

FillEventHeader();

fRunId = fEvtHeader->GetRunId();
fRunId = GetEvtHeaderRunId();

// Copy the Event Header Info to Output
fEvtHeader->Register(fStoreEventHeader);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
9 changes: 4 additions & 5 deletions base/steer/FairRunAnaProof.cxx
Original file line number Diff line number Diff line change
@@ -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, *
Expand Down Expand Up @@ -176,7 +176,7 @@ void FairRunAnaProof::Init()

FillEventHeader();

fRunId = fEvtHeader->GetRunId();
fRunId = GetEvtHeaderRunId();

// Copy the Event Header Info to Output
fEvtHeader->Register(kTRUE);
Expand Down Expand Up @@ -247,7 +247,7 @@ void FairRunAnaProof::InitContainers()

FillEventHeader();

fRunId = fEvtHeader->GetRunId();
fRunId = GetEvtHeaderRunId();

// Copy the Event Header Info to Output
fEvtHeader->Register();
Expand Down Expand Up @@ -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) {
Expand Down
25 changes: 14 additions & 11 deletions examples/MQ/serialization/1-simple/Ex1Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
class Ex1Processor : public fair::mq::Device
{
public:
Ex1Processor() {}
Ex1Processor() = default;
~Ex1Processor() override = default;

void Run() override
{
Expand All @@ -35,8 +36,11 @@ class Ex1Processor : public fair::mq::Device
receivedMsgs++;

// Deserialize
std::unique_ptr<TClonesArray> digis(nullptr);
RootSerializer().Deserialize(*msgIn, digis);
auto digis = RootSerializer().DeserializeTo<TClonesArray>(*msgIn);
if (!digis) {
LOG(warn) << "Deserialization FAILED, skipping";
continue;
}

// Compute
TClonesArray hits = FindHits(*digis);
Expand All @@ -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<MyDigi*>(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<MyDigi const*>(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());
}
Expand Down
11 changes: 5 additions & 6 deletions online/steer/FairRunOnline.cxx
Original file line number Diff line number Diff line change
@@ -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, *
Expand Down Expand Up @@ -130,15 +130,15 @@ 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;
fRunId = genid.generateId();
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
Expand Down Expand Up @@ -202,7 +202,6 @@ void FairRunOnline::Init()

void FairRunOnline::InitContainers()
{

fRtdb = GetRuntimeDb();
FairBaseParSet* par = static_cast<FairBaseParSet*>(fRtdb->getContainer("FairBaseParSet"));
LOG(info) << "FairRunOnline::InitContainers: par = " << par;
Expand All @@ -212,7 +211,7 @@ void FairRunOnline::InitContainers()
if (par) {
fEvtHeader = static_cast<FairEventHeader*>(fRootManager->GetObject("EventHeader."));

fRunId = fEvtHeader->GetRunId();
fRunId = GetEvtHeaderRunId();

// Copy the Event Header Info to Output
fEvtHeader->Register();
Expand Down Expand Up @@ -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;
Expand Down