Skip to content

Commit 3c87416

Browse files
Use unique_ptr based SetSink Around (1/2)
Now that FairRun::SetSink supports unique_ptr, use it around to promote good style.
1 parent 8f05796 commit 3c87416

File tree

19 files changed

+115
-41
lines changed

19 files changed

+115
-41
lines changed

base/MQ/devices/FairMQSampler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class FairMQSampler : public fair::mq::Device
100100

101101
TString output = fInputFile;
102102
output.Append(".out.root");
103-
fFairRunAna->SetSink(new FairRootFileSink(output.Data()));
103+
fFairRunAna->SetSink(std::make_unique<FairRootFileSink>(output.Data()));
104104

105105
fFairRunAna->AddTask(fSamplerTask);
106106

base/sim/FairMCApplication.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ TVirtualMCApplication* FairMCApplication::CloneForWorker() const
502502
// and pass some data from master FairRunSim object
503503
FairRunSim* workerRun = new FairRunSim(kFALSE);
504504
workerRun->SetName(fRun->GetName()); // Transport engine
505-
workerRun->SetSink(fRun->GetSink()->CloneSink());
505+
workerRun->SetSink(std::unique_ptr<FairSink>{fRun->GetSink()->CloneSink()});
506506

507507
// Trajectories filter is created explicitly as we do not call
508508
// FairRunSim::Init on workers

base/steer/FairAnaSelector.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2022 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, *
@@ -116,7 +116,7 @@ void FairAnaSelector::Init(TTree* tree)
116116
fRunAna->SetSource(fProofSource);
117117
LOG(info) << "FairAnaSelector::Init(): SetInTree done";
118118

119-
fRunAna->SetSink(new FairRootFileSink(fFile));
119+
fRunAna->SetSink(std::make_unique<FairRootFileSink>(fFile));
120120
if (containerS == "kTRUE") {
121121
fRunAna->SetContainerStatic(kTRUE);
122122
} else {

examples/simulation/Tutorial1/macros/run_tutorial1.C

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2022 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
********************************************************************************/
8+
9+
#include <TStopwatch.h>
10+
#include <TString.h>
11+
#include <TSystem.h>
12+
#include <memory>
13+
814
void run_tutorial1(Int_t nEvents = 10,
915
TString mcEngine = "TGeant3",
1016
Bool_t isMT = true,
1117
Bool_t loadPostInitConfig = false)
1218
{
13-
1419
TString dir = getenv("VMCWORKDIR");
1520
TString tutdir = dir + "/simulation/Tutorial1";
1621

@@ -70,7 +75,7 @@ void run_tutorial1(Int_t nEvents = 10,
7075
config->UsePostInitConfig();
7176
run->SetSimulationConfig(config);
7277
run->SetIsMT(isMT); // Multi-threading mode (Geant4 only)
73-
run->SetSink(new FairRootFileSink(outFile)); // Output file
78+
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
7479
FairRuntimeDb* rtdb = run->GetRuntimeDb();
7580
// ------------------------------------------------------------------------
7681

examples/simulation/Tutorial1/macros/run_tutorial1_binary.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2022 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, *
@@ -79,7 +79,7 @@ void run_tutorial1_main(const FairSimConfig& config)
7979
FairRunSim run;
8080
run.SetName(config.GetEngine()); // Transport engine
8181
run.SetIsMT(config.IsMultiThreaded()); // Multi-threading mode (Geant4 only)
82-
run.SetSink(new FairRootFileSink(outFile)); // Output file
82+
run.SetSink(std::make_unique<FairRootFileSink>(outFile));
8383
FairRuntimeDb* rtdb = run.GetRuntimeDb();
8484
// ------------------------------------------------------------------------
8585

examples/simulation/Tutorial1/macros/run_tutorial1_mesh.C

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2022 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
********************************************************************************/
8+
9+
#include <TStopwatch.h>
10+
#include <TString.h>
11+
#include <TSystem.h>
12+
#include <memory>
13+
814
void run_tutorial1_mesh(Int_t nEvents = 10, TString mcEngine = "TGeant3")
915
{
10-
1116
TString dir = getenv("VMCWORKDIR");
1217
TString tutdir = dir + "/simulation/Tutorial1";
1318

@@ -60,7 +65,7 @@ void run_tutorial1_mesh(Int_t nEvents = 10, TString mcEngine = "TGeant3")
6065
// ----- Create simulation run ----------------------------------------
6166
FairRunSim* run = new FairRunSim();
6267
run->SetName(mcEngine); // Transport engine
63-
run->SetSink(new FairRootFileSink(outFile)); // Output file
68+
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
6469
FairRuntimeDb* rtdb = run->GetRuntimeDb();
6570
// ------------------------------------------------------------------------
6671

examples/simulation/Tutorial1/macros/run_tutorial1_pythia6.C

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2022 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
********************************************************************************/
8+
9+
#include <TStopwatch.h>
10+
#include <TString.h>
11+
#include <TSystem.h>
12+
#include <memory>
13+
814
void run_tutorial1_pythia6(Int_t nEvents = 10, TString mcEngine = "TGeant3")
915
{
10-
1116
TString dir = getenv("VMCWORKDIR");
1217
TString tutdir = dir + "/simulation/Tutorial1";
1318

@@ -64,7 +69,7 @@ void run_tutorial1_pythia6(Int_t nEvents = 10, TString mcEngine = "TGeant3")
6469
// ----- Create simulation run ----------------------------------------
6570
FairRunSim* run = new FairRunSim();
6671
run->SetName(mcEngine); // Transport engine
67-
run->SetSink(new FairRootFileSink(outFile)); // Output file
72+
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
6873
run->SetPythiaDecayer(pythia6Config); // Define Pythia6 as decayer
6974

7075
FairRuntimeDb* rtdb = run->GetRuntimeDb();

examples/simulation/Tutorial1/macros/run_tutorial1_pythia8.C

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2022 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
********************************************************************************/
8+
9+
#include <TString.h>
10+
#include <TSystem.h>
11+
#include <memory>
12+
813
void run_tutorial1_pythia8(Int_t nEvents = 10, TString mcEngine = "TGeant3")
914
{
10-
1115
TString dir = getenv("VMCWORKDIR");
1216
TString tutdir = dir + "/simulation/Tutorial1";
1317

@@ -64,7 +68,7 @@ void run_tutorial1_pythia8(Int_t nEvents = 10, TString mcEngine = "TGeant3")
6468
// ----- Create simulation run ----------------------------------------
6569
FairRunSim* run = new FairRunSim();
6670
run->SetName(mcEngine); // Transport engine
67-
run->SetSink(new FairRootFileSink(outFile)); // Output file
71+
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
6872
run->SetPythiaDecayer(pythia8Config); // Define Pythia8 as decayer
6973

7074
FairRuntimeDb* rtdb = run->GetRuntimeDb();

examples/simulation/Tutorial1/macros/run_tutorial1_urqmd.C

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2022 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
********************************************************************************/
8+
9+
#include <TStopwatch.h>
10+
#include <TString.h>
11+
#include <TSystem.h>
12+
#include <memory>
13+
814
void run_tutorial1_urqmd(Int_t nEvents = 2, TString mcEngine = "TGeant3")
915
{
10-
1116
TString dir = getenv("VMCWORKDIR");
1217
TString tutdir = dir + "/simulation//Tutorial1";
1318

@@ -46,7 +51,7 @@ void run_tutorial1_urqmd(Int_t nEvents = 2, TString mcEngine = "TGeant3")
4651
// ----- Create simulation run ----------------------------------------
4752
FairRunSim* run = new FairRunSim();
4853
run->SetName(mcEngine); // Transport engine
49-
run->SetSink(new FairRootFileSink(outFile)); // Output file
54+
run->SetSink(std::make_unique<FairRootFileSink>(outFile));
5055
FairRuntimeDb* rtdb = run->GetRuntimeDb();
5156
// ------------------------------------------------------------------------
5257

examples/simulation/Tutorial2/macros/create_digis.C

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2022 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
********************************************************************************/
8+
9+
#include <TStopwatch.h>
10+
#include <TString.h>
11+
#include <iostream>
12+
#include <memory>
13+
14+
using std::cout;
15+
using std::endl;
16+
817
void create_digis()
918
{
10-
1119
TStopwatch timer;
1220
timer.Start();
1321

@@ -30,7 +38,7 @@ void create_digis()
3038
FairFileSource* fFileSource = new FairFileSource(inFile);
3139
fRun->SetSource(fFileSource);
3240

33-
fRun->SetSink(new FairRootFileSink(outFile));
41+
fRun->SetSink(std::make_unique<FairRootFileSink>(outFile));
3442

3543
// Init Simulation Parameters from Root File
3644
FairRuntimeDb* rtdb = fRun->GetRuntimeDb();

0 commit comments

Comments
 (0)