Skip to content

Commit 986ceb9

Browse files
ChristianTackeGSIkarabowi
authored andcommitted
refactor(Base): Introduce FairRootManager::CreateOutputFolder
1 parent f5fc5c4 commit 986ceb9

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

fairroot/base/sink/FairRootFileSink.cxx

Lines changed: 2 additions & 2 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, *
@@ -87,7 +87,7 @@ Bool_t FairRootFileSink::InitSink()
8787

8888
// FairRun* fRun = FairRun::Instance();
8989
/**Check if a simulation run!*/
90-
fOutFolder = gROOT->GetRootFolder()->AddFolder(FairRootManager::GetFolderName(), "Main Folder");
90+
fOutFolder = FairRootManager::Instance()->CreateOutputFolder();
9191
gROOT->GetListOfBrowsables()->Add(fOutFolder);
9292

9393
LOG(info) << "FairRootFileSink initialized.";

fairroot/base/source/FairFileSource.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Bool_t FairFileSource::Init()
167167
if (!fCbmroot) {
168168
fCbmroot = fRootFile->Get<TFolder>("cbmout");
169169
if (!fCbmroot) {
170-
fCbmroot = gROOT->GetRootFolder()->AddFolder(FairRootManager::GetFolderName(), "Main Folder");
170+
fCbmroot = FairRootManager::Instance()->CreateOutputFolder();
171171
} else {
172172
fCbmroot->SetName(FairRootManager::GetFolderName());
173173
}

fairroot/base/source/FairMixedSource.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ Bool_t FairMixedSource::Init()
212212
if (!fCbmroot) {
213213
fCbmroot = fRootFile->Get<TFolder>("cbmout");
214214
if (!fCbmroot) {
215-
fCbmroot = gROOT->GetRootFolder()->AddFolder(FairRootManager::GetFolderName(), "Main Folder");
215+
fCbmroot = fRootManager->CreateOutputFolder();
216216
} else {
217217
fCbmroot->SetName(FairRootManager::GetFolderName());
218218
}
@@ -475,7 +475,7 @@ Bool_t FairMixedSource::OpenBackgroundChain()
475475
if (!fCbmroot) {
476476
fCbmroot = fRootFile->Get<TFolder>("cbmout");
477477
if (!fCbmroot) {
478-
fCbmroot = gROOT->GetRootFolder()->AddFolder(FairRootManager::GetFolderName(), "Main Folder");
478+
fCbmroot = fRootManager->CreateOutputFolder();
479479
} else {
480480
fCbmroot->SetName(FairRootManager::GetFolderName());
481481
}

fairroot/base/steer/FairRootManager.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ void FairRootManager::CreateGeometryFile(const char* geofile)
375375
file->Close();
376376
}
377377

378+
TFolder* FairRootManager::CreateOutputFolder()
379+
{
380+
return gROOT->GetRootFolder()->AddFolder(GetFolderName(), "Main Folder");
381+
}
382+
378383
void FairRootManager::WriteFolder()
379384
{
380385
if (fSink) {
@@ -386,7 +391,7 @@ void FairRootManager::WriteFolder()
386391

387392
void FairRootManager::RemoveOutputFolderForMtMode()
388393
{
389-
auto rootFolder = static_cast<TFolder*>(gROOT->GetRootFolder());
394+
auto rootFolder = gROOT->GetRootFolder();
390395
rootFolder->Remove(rootFolder->FindObject(GetFolderName()));
391396
}
392397

fairroot/base/steer/FairRootManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ class FairRootManager : public TObject
216216
void WriteGeometry();
217217
/**Write the file header object to the output file*/
218218
void WriteFileHeader(FairFileHeader* f);
219+
220+
/**
221+
* \brief Internal: Create the folder describing the output tree structure from gROOT
222+
*/
223+
TFolder* CreateOutputFolder();
224+
219225
/**Write the folder structure used to create the tree to the output file */
220226
void WriteFolder();
221227
/**

0 commit comments

Comments
 (0)