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, *
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