diff --git a/Examples/Io/Root/src/RootTrajectoryStatesWriter.cpp b/Examples/Io/Root/src/RootTrajectoryStatesWriter.cpp index 51c579a1e43..d42366b9567 100644 --- a/Examples/Io/Root/src/RootTrajectoryStatesWriter.cpp +++ b/Examples/Io/Root/src/RootTrajectoryStatesWriter.cpp @@ -218,7 +218,11 @@ ActsExamples::RootTrajectoryStatesWriter::RootTrajectoryStatesWriter( } } -ActsExamples::RootTrajectoryStatesWriter::~RootTrajectoryStatesWriter() {} +ActsExamples::RootTrajectoryStatesWriter::~RootTrajectoryStatesWriter() { + if (m_outputFile) { + m_outputFile->Close(); + } +} ActsExamples::ProcessCode ActsExamples::RootTrajectoryStatesWriter::endRun() { if (m_outputFile) { @@ -226,7 +230,6 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectoryStatesWriter::endRun() { m_outputTree->Write(); ACTS_INFO("Write states of trajectories to tree '" << m_cfg.treeName << "' in '" << m_cfg.treeName << "'"); - m_outputFile->Close(); } return ProcessCode::SUCCESS; } diff --git a/Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp b/Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp index 028499d5588..f299e7e89e2 100644 --- a/Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp +++ b/Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp @@ -128,7 +128,11 @@ ActsExamples::RootTrajectorySummaryWriter::RootTrajectorySummaryWriter( } } -ActsExamples::RootTrajectorySummaryWriter::~RootTrajectorySummaryWriter() {} +ActsExamples::RootTrajectorySummaryWriter::~RootTrajectorySummaryWriter() { + if (m_outputFile) { + m_outputFile->Close(); + } +} ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::endRun() { if (m_outputFile) { @@ -136,7 +140,6 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::endRun() { m_outputTree->Write(); ACTS_INFO("Write parameters of trajectories to tree '" << m_cfg.treeName << "' in '" << m_cfg.filePath << "'"); - m_outputFile->Close(); } return ProcessCode::SUCCESS; }