Skip to content

Commit

Permalink
Introduce FairExampleRunSim
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianTackeGSI committed Jul 20, 2023
1 parent 98ce522 commit d0ffd96
Show file tree
Hide file tree
Showing 28 changed files with 87 additions and 65 deletions.
5 changes: 2 additions & 3 deletions examples/MQ/pixelDetector/macros/run_sim.C
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 @@ -59,8 +59,7 @@ void run_sim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Int_t fileId = 0,
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
auto run = std::make_unique<FairRunSim>();
run->SetName(mcEngine); // Transport engine
auto run = std::make_unique<FairExampleRunSim>(mcEngine);
run->SetIsMT(isMT); // Multi-threading mode (Geant4 only)
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
FairRuntimeDb* rtdb = run->GetRuntimeDb();
Expand Down
4 changes: 2 additions & 2 deletions examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "FairMQSimDevice.h"

#include "FairExampleRunSim.h"
#include "FairModule.h"
#include "FairParSet.h"
#include "FairPrimaryGenerator.h"
Expand Down Expand Up @@ -44,7 +45,7 @@ FairMQSimDevice::FairMQSimDevice()

void FairMQSimDevice::InitTask()
{
fRunSim = std::make_unique<FairRunSim>();
fRunSim = std::make_unique<FairExampleRunSim>(fTransportName.c_str());

SetupRunSink(*fRunSim);

Expand All @@ -56,7 +57,6 @@ void FairMQSimDevice::InitTask()
rtdb->setSecondInput(fSecondParameter);
}

fRunSim->SetName(fTransportName.c_str());
// fRunSim->SetSimulationConfig(new FairVMCConfig());
fRunSim->SetIsMT(kFALSE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "FairMQTransportDevice.h"

#include "FairExampleRunSim.h"
#include "FairGenericStack.h"
#include "FairMCApplication.h"
#include "FairMCSplitEventHeader.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ void FairMQTransportDevice::Init()

void FairMQTransportDevice::InitTask()
{
fRunSim = std::make_unique<FairRunSim>();
fRunSim = std::make_unique<FairExampleRunSim>(fTransportName.c_str());

fMCSplitEventHeader = new FairMCSplitEventHeader(fRunId, 0, 0, 0);
fRunSim->SetMCEventHeader(fMCSplitEventHeader);
Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions examples/advanced/Tutorial3/macro/run_sim.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant4")
gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());

// create Instance of Run Manager class
FairRunSim run{};
FairExampleRunSim run{mcEngine};
run.SetUseFairLinks(kTRUE);
// FairLinkManager::Instance()->AddIncludeType(0);
// set the MC version used
// ------------------------

run.SetName(mcEngine);

TString outFile = "data/testrun_";
outFile = outFile + mcEngine + ".root";

Expand Down
7 changes: 1 addition & 6 deletions examples/advanced/Tutorial3/macro/run_sim_sep.C
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ void run_sim_sep(Int_t fileId, Int_t nEvents = 1000, TString mcEngine = "TGeant3
gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());

// create Instance of Run Manager class
FairRunSim run{};

// set the MC version used
// ------------------------

run.SetName(mcEngine);
FairExampleRunSim run{mcEngine};

TString outfile = Form("data/testrun_%s_f%d.root", mcEngine.Data(), fileId);
TString outparam = Form("data/testpar_%s_f%d.root", mcEngine.Data(), fileId);
Expand Down
3 changes: 1 addition & 2 deletions examples/advanced/propagator/macros/runMC.C
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ int runMC(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
FairRunSim run{};
run.SetName(mcEngine); // Transport engine
FairExampleRunSim run{mcEngine};
// run.SetSimulationConfig(new FairVMCConfig());
run.SetIsMT(isMT); // Multi-threading mode (Geant4 only)
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
Expand Down
3 changes: 1 addition & 2 deletions examples/advanced/propagator/macros/runMM.C
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ int runMM(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
FairRunSim run{};
run.SetName(mcEngine); // Transport engine
FairExampleRunSim run{mcEngine};
// run.SetSimulationConfig(new FairVMCConfig());
run.SetIsMT(isMT); // Multi-threading mode (Geant4 only)
run.SetSink(new FairRootFileSink(outFile)); // Output file
Expand Down
3 changes: 2 additions & 1 deletion examples/common/mcstack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
set(target ExMCStack)

set(sources
FairExampleRunSim.cxx
FairMCTrack.cxx
FairStack.cxx
)
Expand Down Expand Up @@ -45,7 +46,7 @@ target_link_libraries(${target}

fairroot_target_root_dictionary(${target}
HEADERS ${headers}
LINKDEF MCStackLinkDef.h
LINKDEF LinkDef.h
EXTRA_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR}
)

Expand Down
15 changes: 15 additions & 0 deletions examples/common/mcstack/FairExampleRunSim.cxx
Original file line number Diff line number Diff line change
@@ -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);
}
28 changes: 28 additions & 0 deletions examples/common/mcstack/FairExampleRunSim.h
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

3 changes: 1 addition & 2 deletions examples/simulation/Tutorial1/macros/run_tutorial1.C
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ int run_tutorial1(int nEvents = 10, string mcEngine = "TGeant3", bool isMT = tru
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
auto run = std::make_unique<FairRunSim>();
run->SetName(mcEngine.c_str()); // Transport engine
auto run = std::make_unique<FairExampleRunSim>(mcEngine.c_str());
auto config = std::make_unique<FairGenericVMCConfig>();
if (loadPostInitConfig)
config->UsePostInitConfig();
Expand Down
7 changes: 3 additions & 4 deletions examples/simulation/Tutorial1/macros/run_tutorial1_binary.C
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 @@ -10,10 +10,10 @@
#include <iostream>
#include "FairBoxGenerator.h"
#include "FairCave.h"
#include "FairExampleRunSim.h"
#include "FairParRootFileIo.h"
#include "FairPrimaryGenerator.h"
#include "FairRootFileSink.h"
#include "FairRunSim.h"
#include "FairSimConfig.h"
#include "FairSystemInfo.h"
#include "FairTutorialDet1.h"
Expand Down Expand Up @@ -76,8 +76,7 @@ void run_tutorial1_main(const FairSimConfig& config)
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
FairRunSim run;
run.SetName(config.GetEngine()); // Transport engine
FairExampleRunSim run(config.GetEngine());
run.SetIsMT(config.IsMultiThreaded()); // Multi-threading mode (Geant4 only)
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
FairRuntimeDb* rtdb = run.GetRuntimeDb();
Expand Down
3 changes: 1 addition & 2 deletions examples/simulation/Tutorial1/macros/run_tutorial1_fastsim.C
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ void run_tutorial1_fastsim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Boo
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
FairRunSim run{};
run.SetName(mcEngine); // Transport engine
FairExampleRunSim run{mcEngine};
run.SetIsMT(isMT); // Multi-threading mode (Geant4 only)
run.SetSink(new FairRootFileSink(outFile)); // Output file
FairRuntimeDb* rtdb = run.GetRuntimeDb();
Expand Down
3 changes: 1 addition & 2 deletions examples/simulation/Tutorial1/macros/run_tutorial1_mesh.C
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ void run_tutorial1_mesh(Int_t nEvents = 10, TString mcEngine = "TGeant3")
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
FairRunSim run{};
run.SetName(mcEngine); // Transport engine
FairExampleRunSim run{mcEngine};
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
FairRuntimeDb* rtdb = run.GetRuntimeDb();
// ------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions examples/simulation/Tutorial1/macros/run_tutorial1_pythia6.C
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ void run_tutorial1_pythia6(Int_t nEvents = 10, TString mcEngine = "TGeant3")
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
FairRunSim run{};
run.SetName(mcEngine); // Transport engine
FairExampleRunSim run{mcEngine};
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
run.SetPythiaDecayer(pythia6Config); // Define Pythia6 as decayer

Expand Down
3 changes: 1 addition & 2 deletions examples/simulation/Tutorial1/macros/run_tutorial1_pythia8.C
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ void run_tutorial1_pythia8(Int_t nEvents = 10, TString mcEngine = "TGeant3")
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
FairRunSim run{};
run.SetName(mcEngine); // Transport engine
FairExampleRunSim run{mcEngine};
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
run.SetPythiaDecayer(pythia8Config); // Define Pythia8 as decayer

Expand Down
3 changes: 1 addition & 2 deletions examples/simulation/Tutorial1/macros/run_tutorial1_urqmd.C
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void run_tutorial1_urqmd(Int_t nEvents = 2, TString mcEngine = "TGeant3")
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
FairRunSim run{};
run.SetName(mcEngine); // Transport engine
FairExampleRunSim run{mcEngine};
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
FairRuntimeDb* rtdb = run.GetRuntimeDb();
// ------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion examples/simulation/Tutorial1/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ install(TARGETS ${target} LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR})
install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

add_executable(tut1 runTutorial1.cxx)
target_link_libraries(tut1 PRIVATE ExSimulation1)
target_link_libraries(tut1
PRIVATE
ExSimulation1
FairRoot::ExMCStack)

install(TARGETS tut1
RUNTIME DESTINATION ${PROJECT_INSTALL_DATADIR}/examples/simulation/Tutorial1/bin
Expand Down
1 change: 1 addition & 0 deletions examples/simulation/Tutorial2/macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ endforeach()
add_library(${prefix}_check_compile OBJECT ${macrofiles})
target_link_libraries(${prefix}_check_compile PRIVATE
FairRoot::ExSimulation2
FairRoot::ExMCStack
FairRoot::ExPassive
FairRoot::Generators)

Expand Down
5 changes: 2 additions & 3 deletions examples/simulation/Tutorial2/macros/run_background.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "FairBoxGenerator.h"
#include "FairCave.h"
#include "FairDetector.h"
#include "FairExampleRunSim.h"
#include "FairModule.h"
#include "FairParRootFileIo.h"
#include "FairPrimaryGenerator.h"
#include "FairRootFileSink.h"
#include "FairRunSim.h"
#include "FairRuntimeDb.h"
#include "FairSystemInfo.h"
#include "FairTutorialDet2.h"
Expand Down Expand Up @@ -79,8 +79,7 @@ void run_background(Int_t nEvents = 130)
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
auto run = std::make_unique<FairRunSim>();
run->SetName("TGeant4"); // Transport engine
auto run = std::make_unique<FairExampleRunSim>("TGeant4"); // Transport engine
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
FairRuntimeDb* rtdb = run->GetRuntimeDb();
// ------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions examples/simulation/Tutorial2/macros/run_signal.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "FairBoxGenerator.h"
#include "FairCave.h"
#include "FairDetector.h"
#include "FairExampleRunSim.h"
#include "FairModule.h"
#include "FairParRootFileIo.h"
#include "FairPrimaryGenerator.h"
#include "FairRootFileSink.h"
#include "FairRunSim.h"
#include "FairRuntimeDb.h"
#include "FairSystemInfo.h"
#include "FairTutorialDet2.h"
Expand Down Expand Up @@ -80,8 +80,7 @@ void run_signal(Int_t fileNr, Int_t nEvents = 10)
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
auto run = std::make_unique<FairRunSim>();
run->SetName("TGeant4"); // Transport engine
auto run = std::make_unique<FairExampleRunSim>("TGeant4"); // Transport engine
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
FairRuntimeDb* rtdb = run->GetRuntimeDb();
// ------------------------------------------------------------------------
Expand Down
7 changes: 3 additions & 4 deletions examples/simulation/Tutorial2/macros/run_tutorial2.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "FairBoxGenerator.h"
#include "FairCave.h"
#include "FairDetector.h"
#include "FairExampleRunSim.h"
#include "FairModule.h"
#include "FairParRootFileIo.h"
#include "FairPrimaryGenerator.h"
#include "FairRootFileSink.h"
#include "FairRunSim.h"
#include "FairRuntimeDb.h"
#include "FairSystemInfo.h"
#include "FairTutorialDet2.h"
Expand Down Expand Up @@ -79,9 +79,8 @@ void run_tutorial2(Int_t nEvents = 10, TString mcEngine = "TGeant4", Bool_t isMT
// ------------------------------------------------------------------------

// ----- Create simulation run ----------------------------------------
auto run = std::make_unique<FairRunSim>();
run->SetName(mcEngine); // Transport engine
run->SetIsMT(isMT); // Multi-threading mode (Geant4 only)
auto run = std::make_unique<FairExampleRunSim>(mcEngine);
run->SetIsMT(isMT); // Multi-threading mode (Geant4 only)
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
FairRuntimeDb* rtdb = run->GetRuntimeDb();
// ------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions examples/simulation/Tutorial4/macros/run_tutorial4.C
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ void run_tutorial4(Int_t nEvents = 10, TString mcEngine = "TGeant3", Bool_t doAl
// gLogger->SetLogScreenLevel("INFO");

// ----- Create simulation run ----------------------------------------
FairRunSim run{};
run.SetName(mcEngine); // Transport engine
run.SetIsMT(isMT); // Multi-threading mode (Geant4 only)
FairExampleRunSim run{mcEngine};
run.SetIsMT(isMT); // Multi-threading mode (Geant4 only)
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
FairRuntimeDb* rtdb = run.GetRuntimeDb();
// ------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit d0ffd96

Please sign in to comment.