|
Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
|
Path-aware ROOT file helpers with optional thread-safe opening. More...
Classes | |
| class | ScopedRootLock |
| RAII guard engaging the same lock used by the open helpers. More... | |
Functions | |
| void | SetRootFilesBaseDir (const TString &dir) |
| Set the base directory that relative subpaths resolve against. | |
| TString | GetRootFilesBaseDir () |
| Current base directory for relative subpaths, without trailing slash. | |
| void | SetThreadSafe (Bool_t enabled=kTRUE) |
| Enable ROOT thread safety and serialise file opening. | |
| Bool_t | IsThreadSafe () |
| Whether thread-safe file opening is currently engaged. | |
| TFile * | OpenForReading (const TString &subpath) |
| Open a ROOT file for reading, resolved against the base directory. | |
| TFile * | OpenForWriting (const TString &subpath, const TString mode="RECREATE") |
| Open a ROOT file for writing, creating parent directories first. | |
Path-aware ROOT file helpers with optional thread-safe opening.
Every path passed to this namespace is interpreted relative to a single configurable base directory, so a project can pin its ROOT I/O to an absolute root once and have every downstream call land in the same tree regardless of the current working directory. Absolute paths bypass the base entirely.
All filesystem work goes through gSystem rather than std::filesystem.
| TString IO::GetRootFilesBaseDir | ( | ) |
Current base directory for relative subpaths, without trailing slash.
Definition at line 37 of file IOUtils.cpp.
Referenced by InitUtils::ConvertCoMPASSBinToROOT(), InitUtils::ConvertSOLBinToROOT(), InitUtils::ConvertWavedumpBinToROOT(), WaveformProcessingUtils::PrintAllStatistics(), WaveformProcessingUtils::ProcessFile(), and InitUtils::SetROOTPreferences().
| Bool_t IO::IsThreadSafe | ( | ) |
Whether thread-safe file opening is currently engaged.
Definition at line 46 of file IOUtils.cpp.
| TFile * IO::OpenForReading | ( | const TString & | subpath | ) |
Open a ROOT file for reading, resolved against the base directory.
| subpath | Path to the file. Joined onto the base directory unless it is absolute, in which case it is used as-is. |
Definition at line 58 of file IOUtils.cpp.
| TFile * IO::OpenForWriting | ( | const TString & | subpath, |
| const TString | mode = "RECREATE" ) |
Open a ROOT file for writing, creating parent directories first.
Parent directories of the resolved path are created recursively before the file is opened, so a caller need not pre-create the output tree.
| subpath | Path to the file. Joined onto the base directory unless it is absolute, in which case it is used as-is. |
| mode | ROOT open mode, passed through to TFile. "RECREATE" by default; "UPDATE" and "NEW" behave as ROOT documents them. |
Definition at line 68 of file IOUtils.cpp.
Referenced by InitUtils::ConvertCoMPASSBinToROOT(), InitUtils::ConvertSOLBinToROOT(), InitUtils::ConvertWavedumpBinToROOT(), and WaveformProcessingUtils::ProcessFile().
| void IO::SetRootFilesBaseDir | ( | const TString & | dir | ) |
Set the base directory that relative subpaths resolve against.
| dir | Base directory. May be relative or absolute; pass an absolute path so output is anchored to a project root regardless of the current working directory. Trailing slashes are stripped. |
Definition at line 30 of file IOUtils.cpp.
Referenced by InitUtils::SetROOTPreferences().
| void IO::SetThreadSafe | ( | Bool_t | enabled = kTRUE | ) |
Enable ROOT thread safety and serialise file opening.
When enabled this calls ROOT::EnableThreadSafety() and routes every OpenForReading() / OpenForWriting() call through a shared recursive mutex.
| enabled | kTRUE to enable, kFALSE to disable. Note that disabling only stops this namespace from taking the lock; ROOT's own thread-safety mode cannot be switched back off once enabled. |
Definition at line 39 of file IOUtils.cpp.
Referenced by WaveformProcessingUtils::ProcessFilesParallel(), and InitUtils::SetROOTPreferences().