Skip to content

Commit d3ce573

Browse files
ChristianTackeGSIdennisklein
authored andcommitted
Switch ex_tutorial3_mq_* to Geant4
Also do not leak FairRun*.
1 parent b048223 commit d3ce573

5 files changed

Lines changed: 51 additions & 54 deletions

File tree

examples/advanced/Tutorial3/CMakeLists.txt

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
################################################################################
2-
# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
2+
# Copyright (C) 2014-2023 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, #
@@ -154,26 +154,23 @@ install(TARGETS tut3-sampler tut3-processor tut3-sink
154154

155155
# test script
156156
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/test.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test.sh)
157-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/test_data.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test_data.sh)
158157

159-
add_test(NAME ex_tutorial3_mq_data COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_data.sh)
160-
set_tests_properties(ex_tutorial3_mq_data PROPERTIES TIMEOUT "30")
158+
macro(add_ex_tutorial3_mq_test serializationformat)
159+
add_test(NAME ex_tutorial3_mq_${serializationformat} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh ${serializationformat})
160+
set_tests_properties(ex_tutorial3_mq_${serializationformat} PROPERTIES
161+
TIMEOUT "30"
162+
FIXTURES_REQUIRED fixture.ex_tutorial3_digi_TGeant4
163+
PASS_REGULAR_EXPRESSION "Received 100 messages!")
164+
endmacro()
161165

162-
add_test(NAME ex_tutorial3_mq_binary COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh binary)
163-
set_tests_properties(ex_tutorial3_mq_binary PROPERTIES TIMEOUT "30" DEPENDS "ex_tutorial3_mq_data" PASS_REGULAR_EXPRESSION "Received 100 messages!")
164-
165-
add_test(NAME ex_tutorial3_mq_boost COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh boost)
166-
set_tests_properties(ex_tutorial3_mq_boost PROPERTIES TIMEOUT "30" DEPENDS "ex_tutorial3_mq_data" PASS_REGULAR_EXPRESSION "Received 100 messages!")
166+
add_ex_tutorial3_mq_test("tmessage")
167+
add_ex_tutorial3_mq_test("binary")
168+
add_ex_tutorial3_mq_test("boost")
167169

168170
if(Flatbuffers_FOUND)
169-
add_test(NAME ex_tutorial3_mq_flatbuffers COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh flatbuffers)
170-
set_tests_properties(ex_tutorial3_mq_flatbuffers PROPERTIES TIMEOUT "30" DEPENDS "ex_tutorial3_mq_data" PASS_REGULAR_EXPRESSION "Received 100 messages!")
171+
add_ex_tutorial3_mq_test("flatbuffers")
171172
endif()
172173

173174
if(Protobuf_FOUND)
174-
add_test(NAME ex_tutorial3_mq_protobuf COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh protobuf)
175-
set_tests_properties(ex_tutorial3_mq_protobuf PROPERTIES TIMEOUT "30" DEPENDS "ex_tutorial3_mq_data" PASS_REGULAR_EXPRESSION "Received 100 messages!")
175+
add_ex_tutorial3_mq_test("protobuf")
176176
endif()
177-
178-
add_test(NAME ex_tutorial3_mq_tmessage COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh tmessage)
179-
set_tests_properties(ex_tutorial3_mq_tmessage PROPERTIES TIMEOUT "30" DEPENDS "ex_tutorial3_mq_data" PASS_REGULAR_EXPRESSION "Received 100 messages!")

examples/advanced/Tutorial3/MQ/test.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
mcEngine="TGeant3"
5+
mcEngine="TGeant4"
66

77
session="$(@FairMQ_BINDIR@/fairmq-uuid-gen -h)"
88

examples/advanced/Tutorial3/MQ/test_data.sh.in

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/advanced/Tutorial3/macro/run_digi.C

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 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, *
@@ -8,9 +8,13 @@
88

99
#include <TStopwatch.h>
1010
#include <TString.h>
11+
#include <iostream>
1112
#include <memory>
1213

13-
void run_digi(TString mcEngine = "TGeant3")
14+
using std::cout;
15+
using std::endl;
16+
17+
void run_digi(TString mcEngine = "TGeant4")
1418
{
1519
FairLogger* logger = FairLogger::GetLogger();
1620
// logger->SetLogFileName("MyLog.log");
@@ -39,28 +43,28 @@ void run_digi(TString mcEngine = "TGeant3")
3943
TStopwatch timer;
4044

4145
// ----- Reconstruction run -------------------------------------------
42-
FairRunAna* fRun = new FairRunAna();
46+
FairRunAna run{};
4347
FairFileSource* fFileSource = new FairFileSource(inFile);
44-
fRun->SetSource(fFileSource);
45-
fRun->SetSink(std::make_unique<FairRootFileSink>(outFile));
46-
fRun->SetUseFairLinks(kTRUE);
48+
run.SetSource(fFileSource);
49+
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
50+
run.SetUseFairLinks(kTRUE);
4751
FairLinkManager::Instance()->AddIncludeType(0);
4852
// FairLinkManager::Instance()->AddIncludeType(1);
49-
fRun->SetGenerateRunInfo(kTRUE); // Create FairRunInfo file
53+
run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file
5054

51-
FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
55+
FairRuntimeDb* rtdb = run.GetRuntimeDb();
5256
FairParRootFileIo* parInput1 = new FairParRootFileIo();
5357
parInput1->open(parFile.Data());
5458
rtdb->setFirstInput(parInput1);
5559

5660
// ----- TorinoDetector hit producers ---------------------------------
5761
FairTestDetectorDigiTask* digiTask = new FairTestDetectorDigiTask();
58-
fRun->AddTask(digiTask);
62+
run.AddTask(digiTask);
5963

60-
fRun->Init();
64+
run.Init();
6165

6266
timer.Start();
63-
fRun->Run();
67+
run.Run();
6468

6569
// ----- Finish -------------------------------------------------------
6670

examples/advanced/Tutorial3/macro/run_sim.C

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 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,9 +9,13 @@
99
#include <TStopwatch.h>
1010
#include <TString.h>
1111
#include <TSystem.h>
12+
#include <iostream>
1213
#include <memory>
1314

14-
void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3")
15+
using std::cout;
16+
using std::endl;
17+
18+
void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant4")
1519
{
1620
TStopwatch timer;
1721
timer.Start();
@@ -28,13 +32,13 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3")
2832
gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
2933

3034
// create Instance of Run Manager class
31-
FairRunSim *fRun = new FairRunSim();
32-
fRun->SetUseFairLinks(kTRUE);
35+
FairRunSim run{};
36+
run.SetUseFairLinks(kTRUE);
3337
// FairLinkManager::Instance()->AddIncludeType(0);
3438
// set the MC version used
3539
// ------------------------
3640

37-
fRun->SetName(mcEngine);
41+
run.SetName(mcEngine);
3842

3943
TString outFile = "data/testrun_";
4044
outFile = outFile + mcEngine + ".root";
@@ -45,40 +49,40 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3")
4549
TString parFile = "data/testparams_";
4650
parFile = parFile + mcEngine + ".root";
4751

48-
fRun->SetSink(std::make_unique<FairRootFileSink>(outFile));
49-
fRun->SetGenerateRunInfo(kTRUE); // Create FairRunInfo file
52+
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
53+
run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file
5054

5155
// ----- Magnetic field -------------------------------------------
5256
// Constant Field
5357
FairConstField *fMagField = new FairConstField();
5458
fMagField->SetField(0., 10., 0.); // values are in kG
5559
fMagField->SetFieldRegion(-50, 50, -50, 50, 350, 450); // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
56-
fRun->SetField(fMagField);
60+
run.SetField(fMagField);
5761
// --------------------------------------------------------------------
5862

5963
// Set Material file Name
6064
//-----------------------
61-
fRun->SetMaterials("media.geo");
65+
run.SetMaterials("media.geo");
6266

6367
// Create and add detectors
6468
//-------------------------
6569
FairModule *Cave = new FairCave("CAVE");
6670
Cave->SetGeometryFileName("cave.geo");
67-
fRun->AddModule(Cave);
71+
run.AddModule(Cave);
6872

6973
FairModule *Magnet = new FairMagnet("MAGNET");
7074
Magnet->SetGeometryFileName("magnet.geo");
71-
fRun->AddModule(Magnet);
75+
run.AddModule(Magnet);
7276

7377
FairDetector *Torino = new FairTestDetector("TORINO", kTRUE);
7478
Torino->SetGeometryFileName("torino.geo");
75-
fRun->AddModule(Torino);
79+
run.AddModule(Torino);
7680

7781
// Create and Set Event Generator
7882
//-------------------------------
7983

8084
FairPrimaryGenerator *primGen = new FairPrimaryGenerator();
81-
fRun->SetGenerator(primGen);
85+
run.SetGenerator(primGen);
8286

8387
// Box Generator
8488
FairBoxGenerator *boxGen = new FairBoxGenerator(2212, 10); // 13 = muon; 1 = multipl.
@@ -90,9 +94,9 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3")
9094
// boxGen->SetXYZ(0., 0.37, 0.);
9195
primGen->AddGenerator(boxGen);
9296

93-
fRun->SetStoreTraj(kTRUE);
97+
run.SetStoreTraj(kTRUE);
9498

95-
fRun->Init();
99+
run.Init();
96100

97101
// -Trajectories Visualization (TGeoManager Only )
98102
// -----------------------------------------------
@@ -110,7 +114,7 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3")
110114
// Fill the Parameter containers for this run
111115
//-------------------------------------------
112116

113-
FairRuntimeDb *rtdb = fRun->GetRuntimeDb();
117+
FairRuntimeDb* rtdb = run.GetRuntimeDb();
114118
Bool_t kParameterMerged = kTRUE;
115119
FairParRootFileIo *output = new FairParRootFileIo(kParameterMerged);
116120
output->open(parFile);
@@ -123,9 +127,9 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3")
123127
// -----------------
124128

125129
// Int_t nEvents = 1;
126-
fRun->Run(nEvents);
130+
run.Run(nEvents);
127131

128-
fRun->CreateGeometryFile(geoFile);
132+
run.CreateGeometryFile(geoFile);
129133

130134
// ----- Finish -------------------------------------------------------
131135

0 commit comments

Comments
 (0)