Skip to content

Commit ce472af

Browse files
Introduce FairExampleRunSim
1 parent 84175d0 commit ce472af

File tree

11 files changed

+136
-34
lines changed

11 files changed

+136
-34
lines changed

examples/MQ/pixelDetector/macros/run_sim.C

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
66
* copied verbatim in the file "LICENSE" *
77
********************************************************************************/
88

9+
#include "FairExampleRunSim.h"
10+
11+
#if !defined(__CLING__) || defined(__ROOTCLING__)
12+
#include "FairBoxGenerator.h"
13+
#include "FairCave.h"
14+
#include "FairParRootFileIo.h"
15+
#include "FairPrimaryGenerator.h"
16+
#include "FairRootFileSink.h"
17+
#include "FairSystemInfo.h"
18+
#include "Pixel.h"
19+
#endif
20+
921
#include <TFile.h>
1022
#include <TH1F.h>
1123
#include <TStopwatch.h>
@@ -59,8 +71,7 @@ void run_sim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Int_t fileId = 0,
5971
// ------------------------------------------------------------------------
6072

6173
// ----- Create simulation run ----------------------------------------
62-
auto run = std::make_unique<FairRunSim>();
63-
run->SetName(mcEngine); // Transport engine
74+
auto run = std::make_unique<FairExampleRunSim>(mcEngine.Data());
6475
run->SetIsMT(isMT); // Multi-threading mode (Geant4 only)
6576
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
6677
FairRuntimeDb* rtdb = run->GetRuntimeDb();

examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
@@ -14,6 +14,7 @@
1414

1515
#include "FairMQSimDevice.h"
1616

17+
#include "FairExampleRunSim.h"
1718
#include "FairModule.h"
1819
#include "FairParSet.h"
1920
#include "FairPrimaryGenerator.h"
@@ -44,7 +45,7 @@ FairMQSimDevice::FairMQSimDevice()
4445

4546
void FairMQSimDevice::InitTask()
4647
{
47-
fRunSim = std::make_unique<FairRunSim>();
48+
fRunSim = std::make_unique<FairExampleRunSim>(fTransportName.c_str());
4849

4950
SetupRunSink(*fRunSim);
5051

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

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

examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "FairMQTransportDevice.h"
1616

17+
#include "FairExampleRunSim.h"
1718
#include "FairGenericStack.h"
1819
#include "FairMCApplication.h"
1920
#include "FairMCSplitEventHeader.h"
@@ -65,7 +66,7 @@ void FairMQTransportDevice::Init()
6566

6667
void FairMQTransportDevice::InitTask()
6768
{
68-
fRunSim = std::make_unique<FairRunSim>();
69+
fRunSim = std::make_unique<FairExampleRunSim>(fTransportName.c_str());
6970

7071
fMCSplitEventHeader = new FairMCSplitEventHeader(fRunId, 0, 0, 0);
7172
fRunSim->SetMCEventHeader(fMCSplitEventHeader);
@@ -81,8 +82,6 @@ void FairMQTransportDevice::InitTask()
8182
rtdb->setSecondInput(fSecondParameter);
8283
}
8384

84-
fRunSim->SetName(fTransportName.c_str());
85-
8685
if (fUserConfig.Length() > 0)
8786
fRunSim->SetUserConfig(fUserConfig);
8887
if (fUserCuts.Length() > 0)

examples/advanced/Tutorial3/macro/run_sim.C

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
66
* copied verbatim in the file "LICENSE" *
77
********************************************************************************/
88

9+
#include "FairExampleRunSim.h"
10+
911
#if !defined(__CLING__) || defined(__ROOTCLING__)
1012
#include "FairBoxGenerator.h"
1113
#include "FairCave.h"
@@ -14,7 +16,6 @@
1416
#include "FairParRootFileIo.h"
1517
#include "FairPrimaryGenerator.h"
1618
#include "FairRootFileSink.h"
17-
#include "FairRunSim.h"
1819
#include "FairSystemInfo.h"
1920
#include "FairTestDetector.h"
2021
#endif
@@ -45,13 +46,9 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant4")
4546
gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
4647

4748
// create Instance of Run Manager class
48-
FairRunSim run{};
49+
FairExampleRunSim run{mcEngine.Data()};
4950
run.SetUseFairLinks(kTRUE);
5051
// FairLinkManager::Instance()->AddIncludeType(0);
51-
// set the MC version used
52-
// ------------------------
53-
54-
run.SetName(mcEngine);
5552

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

examples/advanced/Tutorial3/macro/run_sim_sep.C

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
11
/********************************************************************************
2-
* Copyright (C) 2012-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2012-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
66
* copied verbatim in the file "LICENSE" *
77
********************************************************************************/
88

9+
#include "FairExampleRunSim.h"
10+
11+
#if !defined(__CLING__) || defined(__ROOTCLING__)
12+
#include "FairBoxGenerator.h"
13+
#include "FairCave.h"
14+
#include "FairConstField.h"
15+
#include "FairMagnet.h"
16+
#include "FairParRootFileIo.h"
17+
#include "FairPrimaryGenerator.h"
18+
#include "FairRootFileSink.h"
19+
#include "FairRuntimeDb.h"
20+
#include "FairSystemInfo.h"
21+
#include "FairTestDetector.h"
22+
#endif
23+
924
#include <TRandom.h>
1025
#include <TStopwatch.h>
1126
#include <TString.h>
1227
#include <TSystem.h>
28+
#include <iostream>
29+
30+
using std::cout;
31+
using std::endl;
1332

1433
void run_sim_sep(Int_t fileId, Int_t nEvents = 1000, TString mcEngine = "TGeant3")
1534
{
@@ -30,12 +49,7 @@ void run_sim_sep(Int_t fileId, Int_t nEvents = 1000, TString mcEngine = "TGeant3
3049
gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
3150

3251
// create Instance of Run Manager class
33-
FairRunSim run{};
34-
35-
// set the MC version used
36-
// ------------------------
37-
38-
run.SetName(mcEngine);
52+
FairExampleRunSim run{mcEngine};
3953

4054
TString outfile = Form("data/testrun_%s_f%d.root", mcEngine.Data(), fileId);
4155
TString outparam = Form("data/testpar_%s_f%d.root", mcEngine.Data(), fileId);

examples/advanced/propagator/macros/runMC.C

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
/********************************************************************************
2-
* Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2019-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
66
* copied verbatim in the file "LICENSE" *
77
********************************************************************************/
88

9+
#include "FairExampleRunSim.h"
10+
11+
#if !defined(__CLING__) || defined(__ROOTCLING__)
12+
#include "FairBoxGenerator.h"
13+
#include "FairCave.h"
14+
#include "FairConstField.h"
15+
#include "FairParRootFileIo.h"
16+
#include "FairPrimaryGenerator.h"
17+
#include "FairRootFileSink.h"
18+
#include "FairSystemInfo.h"
19+
#include "FairTrajFilter.h"
20+
#include "FairTutPropDet.h"
21+
#endif
22+
923
#include <TRandom.h>
1024
#include <TStopwatch.h>
1125
#include <TString.h>
1226
#include <TSystem.h>
27+
#include <iostream>
1328
#include <memory>
1429

30+
using std::cout;
31+
using std::endl;
32+
1533
int runMC(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = false)
1634
{
1735
UInt_t randomSeed = 123456;
@@ -55,8 +73,7 @@ int runMC(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals
5573
// ------------------------------------------------------------------------
5674

5775
// ----- Create simulation run ----------------------------------------
58-
FairRunSim run{};
59-
run.SetName(mcEngine); // Transport engine
76+
FairExampleRunSim run{mcEngine.Data()};
6077
// run.SetSimulationConfig(new FairVMCConfig());
6178
run.SetIsMT(isMT); // Multi-threading mode (Geant4 only)
6279
run.SetSink(std::make_unique<FairRootFileSink>(outFile));

examples/advanced/propagator/macros/runMM.C

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
/********************************************************************************
2-
* Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2019-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
66
* copied verbatim in the file "LICENSE" *
77
********************************************************************************/
88

9+
#include "FairExampleRunSim.h"
10+
11+
#if !defined(__CLING__) || defined(__ROOTCLING__)
12+
#include "FairBoxGenerator.h"
13+
#include "FairCave.h"
14+
#include "FairConstField.h"
15+
#include "FairParRootFileIo.h"
16+
#include "FairPrimaryGenerator.h"
17+
#include "FairRootFileSink.h"
18+
#include "FairSystemInfo.h"
19+
#include "FairTutPropDet.h"
20+
#endif
21+
922
#include <TRandom.h>
1023
#include <TStopwatch.h>
1124
#include <TString.h>
1225
#include <TSystem.h>
26+
#include <iostream>
27+
28+
using std::cout;
29+
using std::endl;
1330

1431
int runMM(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = false)
1532
{
@@ -47,8 +64,7 @@ int runMM(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals
4764
// ------------------------------------------------------------------------
4865

4966
// ----- Create simulation run ----------------------------------------
50-
FairRunSim run{};
51-
run.SetName(mcEngine); // Transport engine
67+
FairExampleRunSim run{mcEngine};
5268
// run.SetSimulationConfig(new FairVMCConfig());
5369
run.SetIsMT(isMT); // Multi-threading mode (Geant4 only)
5470
run.SetSink(new FairRootFileSink(outFile)); // Output file

examples/common/mcstack/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
################################################################################
2-
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
2+
# Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
33
# #
44
# This software is distributed under the terms of the #
55
# GNU Lesser General Public Licence (LGPL) version 3, #
@@ -9,6 +9,7 @@
99
set(target ExMCStack)
1010

1111
set(sources
12+
FairExampleRunSim.cxx
1213
FairMCTrack.cxx
1314
FairStack.cxx
1415
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/********************************************************************************
2+
* Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3+
* *
4+
* This software is distributed under the terms of the *
5+
* GNU Lesser General Public Licence (LGPL) version 3, *
6+
* copied verbatim in the file "LICENSE" *
7+
********************************************************************************/
8+
9+
#include "FairExampleRunSim.h"
10+
11+
FairExampleRunSim::FairExampleRunSim(const char* mcEngine)
12+
: FairRunSim()
13+
{
14+
SetName(mcEngine);
15+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/********************************************************************************
2+
* Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3+
* *
4+
* This software is distributed under the terms of the *
5+
* GNU Lesser General Public Licence (LGPL) version 3, *
6+
* copied verbatim in the file "LICENSE" *
7+
********************************************************************************/
8+
#ifndef FAIREXAMPLERUNSIM_H
9+
#define FAIREXAMPLERUNSIM_H
10+
11+
#include "FairRunSim.h"
12+
13+
/**
14+
* \brief RunSim with specific behaviour for an experiment
15+
*
16+
* \note This is an advanced use case and is likely only
17+
* interesting for bigger / more complex experiments
18+
* that need this kind of refactoring.
19+
*
20+
* One can derive from the FairRun classes.
21+
* But please only call public APIs from inside any member
22+
* functions.
23+
*/
24+
class FairExampleRunSim : public FairRunSim
25+
{
26+
public:
27+
explicit FairExampleRunSim(const char* mcEngine);
28+
~FairExampleRunSim() override = default;
29+
ClassDefOverride(FairExampleRunSim, 0);
30+
};
31+
32+
#endif

0 commit comments

Comments
 (0)