Project

General

Profile

Output file renaming for ROOT files

The RootOutput module now offers the ability to rename output files upon close to reflect information gleaned during the job. By using format specifiers in the fileName, one can include dynamic information in the final output filename:

Output File Format Specifiers.

Specifier Meaning
%# Sequence number1 (i.e. the third file written to this output stream will have sequence number 3).
%ifb Base name of input file without extension.
%ifd Fully-resolved path of input file without file name.
%ife Extension of input file.
%ifn Base name of input file with extension.
%ifp Fully-resolved path with file name of input file.
%ifs%<match>%<format>%[ig]% Regex-based substitutions of input file (ECMAScript with % delimiter). For ease of processing, literal % characters in match or format clauses are forbidden.
%l Label of output module.
%p art's process name from FHiCL or command-line.
%r Lowest run # of run records written to this file1.
%R Highest run # of run records written to this file1.
%s Lowest subrun # of subrun records written to this file1.
%S Highest subrun # of subrun records written to this file1.
%to Time2 of file-open.
%tc Time2 of file-close.
%ts Start time2 of SubRun corresponding to the %s specifier3.
%tS Start time2 of SubRun corresponding to the %S specifier3.
%tr Start time2 of Run corresponding to the %r specifier3.
%tR Start time2 of Run corresponding to the %R specifier3.

1 Also accepts printf-style fill modifiers (e.g. %05s for a substitution that is zero-filled to 5 digits).

2 The format is "YYYYMMDDTHHMMSS", where "T" separates the date and time.

3 Supported as of art 3.01.00.

The ROOT file is written, initially as a temporary file with unique file name in the same directory as that specified by the fileName parameter. Upon close, it is renamed as specified by fileName.

Non-destructive post-close callback.

In addition, interested services may register callback functions with signature:

void func(art::OutputFileInfo const &)
where an art::OutputFileInfo is described in source:art/Framework/Core/OutputFileInfo.h and callbacks are registered with sPostCloseOutputFile.watch(...). These functions are called after the file has been moved to its final name and position and are intended (obviously) for non-destructive purposes.

Note that in the case of a catastrophic exit (eg segmentation fault), the file will retain its temporary name; it will also likely be unreadable.