Merge only part of the content of a set of files.
This macro demonstrates how to merge only a part of the content of a set of input files, specified via the interface.
void AddObjectNames(const char *name)
The method can be called several times to add object names, or using a single string with names separated by a blank. Directory names contained in the files to be merged are accepted.
Two modes are supported:
- kOnlyListed: via
TFileMerger::PartialMerge(kOnlyListed)
This will merge only the objects in the files having the names in the specified list. If a folder is specified, its whole content will be merged
- kSkipListed: via
TFileMerger::PartialMerge(kSkipListed)
This will skip merging of specified objects. If a folder is specified, its whole content will be skipped.
Important note: the kOnlyListed and kSkipListed flags have to be bitwise OR-ed on top of the merging defaults: kAll | kIncremental (as in the example)
The files to be merged have the following structure:
The example first merges exclusively hprof and the content of "folder", producing the file exclusive.root, then merges all content but skipping hprof and the content of "folder". The result can be inspected in the browser.
{
fm->OutputFile(
"exclusive.root");
fm->AddObjectNames(
"hprof folder");
for (i=0; i<
nfiles; i++)
fm->AddFile(
Form(
"tomerge%03d.root",i));
fm->OutputFile(
"skipped.root");
fm->AddObjectNames(
"hprof folder");
for (i=0; i<
nfiles; i++)
fm->AddFile(
Form(
"tomerge%03d.root",i));
}
{
if (
sname.Contains(
"000")) {
}
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char mode
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
Using a TBrowser one can browse all ROOT objects.
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
virtual Bool_t cd()
Change current directory to "this" directory.
This class provides file copy and merging services.
@ kAll
Merge all type of objects (default)
@ kIncremental
Merge the input file with the content of the output file (if already existing).
@ kSkipListed
Skip objects specified in fObjectNames list.
@ kOnlyListed
Only the objects specified in fObjectNames list.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t buffersize=1000000)
Allows to copy this file to the dst URL.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void Close(Option_t *option="") override
Close a file.
1-D histogram with a float per channel (see TH1 documentation)
virtual int Unlink(const char *name)
Unlink, i.e.
- Author
- The Root Team
Definition in file mergeSelective.C.