From f959e289e982c93f0ca277ca1eb6e5d385999fe8 Mon Sep 17 00:00:00 2001 From: Christian Tacke <58549698+ChristianTackeGSI@users.noreply.github.com> Date: Thu, 20 Jul 2023 23:20:43 +0200 Subject: [PATCH] Introduce FairExampleRunSim --- .../src/devices/FairMQSimDevice.cxx | 4 +-- .../src/devices/FairMQTransportDevice.cxx | 5 ++-- examples/common/mcstack/CMakeLists.txt | 1 + examples/common/mcstack/FairExampleRunSim.cxx | 15 ++++++++++ examples/common/mcstack/FairExampleRunSim.h | 28 +++++++++++++++++++ examples/common/mcstack/LinkDef.h | 8 +++--- 6 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 examples/common/mcstack/FairExampleRunSim.cxx create mode 100644 examples/common/mcstack/FairExampleRunSim.h diff --git a/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx b/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx index 0d7a54ec09..4882b2e9e6 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx +++ b/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx @@ -14,6 +14,7 @@ #include "FairMQSimDevice.h" +#include "FairExampleRunSim.h" #include "FairModule.h" #include "FairParSet.h" #include "FairPrimaryGenerator.h" @@ -44,7 +45,7 @@ FairMQSimDevice::FairMQSimDevice() void FairMQSimDevice::InitTask() { - fRunSim = std::make_unique(); + fRunSim = std::make_unique(fTransportName.c_str()); SetupRunSink(*fRunSim); @@ -56,7 +57,6 @@ void FairMQSimDevice::InitTask() rtdb->setSecondInput(fSecondParameter); } - fRunSim->SetName(fTransportName.c_str()); // fRunSim->SetSimulationConfig(new FairVMCConfig()); fRunSim->SetIsMT(kFALSE); diff --git a/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx b/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx index 50dad46f94..173324f79f 100644 --- a/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx +++ b/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx @@ -14,6 +14,7 @@ #include "FairMQTransportDevice.h" +#include "FairExampleRunSim.h" #include "FairGenericStack.h" #include "FairMCApplication.h" #include "FairMCSplitEventHeader.h" @@ -65,7 +66,7 @@ void FairMQTransportDevice::Init() void FairMQTransportDevice::InitTask() { - fRunSim = std::make_unique(); + fRunSim = std::make_unique(fTransportName.c_str()); fMCSplitEventHeader = new FairMCSplitEventHeader(fRunId, 0, 0, 0); fRunSim->SetMCEventHeader(fMCSplitEventHeader); @@ -81,8 +82,6 @@ void FairMQTransportDevice::InitTask() rtdb->setSecondInput(fSecondParameter); } - fRunSim->SetName(fTransportName.c_str()); - if (fUserConfig.Length() > 0) fRunSim->SetUserConfig(fUserConfig); if (fUserCuts.Length() > 0) diff --git a/examples/common/mcstack/CMakeLists.txt b/examples/common/mcstack/CMakeLists.txt index 9cebc30630..0fe55e593f 100644 --- a/examples/common/mcstack/CMakeLists.txt +++ b/examples/common/mcstack/CMakeLists.txt @@ -9,6 +9,7 @@ set(target ExMCStack) set(sources + FairExampleRunSim.cxx FairMCTrack.cxx FairStack.cxx ) diff --git a/examples/common/mcstack/FairExampleRunSim.cxx b/examples/common/mcstack/FairExampleRunSim.cxx new file mode 100644 index 0000000000..381b91a1ec --- /dev/null +++ b/examples/common/mcstack/FairExampleRunSim.cxx @@ -0,0 +1,15 @@ +/******************************************************************************** + * Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "FairExampleRunSim.h" + +FairExampleRunSim::FairExampleRunSim(const char* mcEngine) + : FairRunSim() +{ + SetName(mcEngine); +} diff --git a/examples/common/mcstack/FairExampleRunSim.h b/examples/common/mcstack/FairExampleRunSim.h new file mode 100644 index 0000000000..fd11b43357 --- /dev/null +++ b/examples/common/mcstack/FairExampleRunSim.h @@ -0,0 +1,28 @@ +/******************************************************************************** + * Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ +#ifndef FAIREXAMPLERUNSIM_H +#define FAIREXAMPLERUNSIM_H + +#include "FairRunSim.h" + +/** + * \brief RunSim with specific behaviour for an experiment + * + * One can derive from the FairRun classes. + * But please only call public APIs from inside any member + * functions. + */ +class FairExampleRunSim : public FairRunSim +{ + public: + explicit FairExampleRunSim(const char* mcEngine); + ~FairExampleRunSim() override = default; + ClassDefOverride(FairExampleRunSim, 0); +}; + +#endif diff --git a/examples/common/mcstack/LinkDef.h b/examples/common/mcstack/LinkDef.h index bece7e043d..dc9b2f13df 100644 --- a/examples/common/mcstack/LinkDef.h +++ b/examples/common/mcstack/LinkDef.h @@ -1,8 +1,8 @@ /******************************************************************************** - * 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, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ // $Id: ZdcLinkDef.h,v 1.1.1.1 @@ -14,8 +14,8 @@ #pragma link off all classes; #pragma link off all functions; +#pragma link C++ class FairExampleRunSim+; #pragma link C++ class FairStack+; #pragma link C++ class FairMCTrack+; #endif -