9#include <framework/utilities/RootFileCreationManager.h>
10#include <framework/logging/Logger.h>
11#include <framework/core/MetadataService.h>
16 void TFile_Deleter(TFile* file)
19 B2DEBUG(30,
"Closing ROOT file");
35 std::shared_ptr<TFile> ptr =
m_files[fileName].lock();
40 TDirectory::TContext gDirectoryGuard;
42 ptr = std::shared_ptr<TFile>(TFile::Open(fileName.c_str(),
"RECREATE"), TFile_Deleter);
44 if (!ptr || !ptr->IsOpen()) {
45 if (!ignoreErrors) B2ERROR(
"Could not create file " << std::quoted(fileName));
This single instance class takes track of all open ROOT files open in "create" mode,...
std::map< std::string, std::weak_ptr< TFile > > m_files
store for the open files
std::shared_ptr< TFile > getFile(std::string, bool ignoreErrors=false)
Get a file with a specific name, if is does not exist it will be created.
static RootFileCreationManager & getInstance()
Interface for the FileManager.
Abstract base class for different kinds of events.