This class provides file copy and merging services.
It can be used to copy files (not only ROOT files), using TFile or any of its remote file access plugins. It is therefore useful in a Grid environment where the files might be accessible only remotely. The merging interface allows files containing histograms and trees to be merged, like the standalone hadd program.
Definition at line 30 of file TFileMerger.h.
Public Types | |
enum | EPartialMergeType { kRegular = 0 , kIncremental = (1ULL << ( 1 )) , kResetable = (1ULL << ( 2 )) , kNonResetable = (1ULL << ( 3 )) , kDelayWrite = (1ULL << ( 4 )) , kAll = (1ULL << ( 2 ))|(1ULL << ( 3 )) , kAllIncremental = kIncremental | kAll , kOnlyListed = (1ULL << ( 5 )) , kSkipListed = (1ULL << ( 6 )) , kKeepCompression = (1ULL << ( 7 )) } |
Type of the partial merge. More... | |
Public Types inherited from TObject | |
enum | { kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 , kBitMask = 0x00ffffff } |
enum | { kSingleKey = (1ULL << ( 0 )) , kOverwrite = (1ULL << ( 1 )) , kWriteDelete = (1ULL << ( 2 )) } |
enum | EDeprecatedStatusBits { kObjInCanvas = (1ULL << ( 3 )) } |
enum | EStatusBits { kCanDelete = (1ULL << ( 0 )) , kMustCleanup = (1ULL << ( 3 )) , kIsReferenced = (1ULL << ( 4 )) , kHasUUID = (1ULL << ( 5 )) , kCannotPick = (1ULL << ( 6 )) , kNoContextMenu = (1ULL << ( 8 )) , kInvalidObject = (1ULL << ( 13 )) } |
Public Member Functions | |
TFileMerger (Bool_t isLocal=kTRUE, Bool_t histoOneGo=kTRUE) | |
Create file merger object. | |
~TFileMerger () override | |
Cleanup. | |
virtual Bool_t | AddAdoptFile (TFile *source, Bool_t cpProgress=kTRUE) |
Add the TFile to this file merger and give ownership of the TFile to this object (unless kFALSE is returned). | |
virtual Bool_t | AddFile (const char *url, Bool_t cpProgress=kTRUE) |
Add file to file merger. | |
virtual Bool_t | AddFile (TFile *source, Bool_t cpProgress=kTRUE) |
Add the TFile to this file merger and do not give ownership of the TFile to this object. | |
void | AddObjectNames (const char *name) |
void | ClearObjectNames () |
virtual const char * | GetCWD () |
Int_t | GetMaxOpenedFiles () const |
TList * | GetMergeList () |
const char * | GetMergeOptions () |
const char * | GetMsgPrefix () const |
Bool_t | GetNotrees () const |
const char * | GetObjectNames () const |
TFile * | GetOutputFile () const |
const char * | GetOutputFileName () const |
Int_t | GetPrintLevel () const |
Bool_t | HasCompressionChange () const |
TClass * | IsA () const override |
virtual Bool_t | Merge (Bool_t=kTRUE) |
Merge the files. | |
virtual Bool_t | OutputFile (const char *url, Bool_t force) |
Open merger output file. | |
virtual Bool_t | OutputFile (const char *url, Bool_t force, Int_t compressionLevel) |
Open merger output file. | |
virtual Bool_t | OutputFile (const char *url, const char *mode, Int_t compressionLevel) |
Open merger output file. | |
virtual Bool_t | OutputFile (const char *url, const char *mode="RECREATE") |
Open merger output file. | |
virtual Bool_t | OutputFile (std::unique_ptr< TFile > file) |
Set an output file opened externally by the users. | |
virtual Bool_t | PartialMerge (Int_t type=kAll|kIncremental) |
Merge the files. | |
virtual void | PrintFiles (Option_t *options) |
Print list of files being merged. | |
void | RecursiveRemove (TObject *obj) override |
Intercept the case where the output TFile is deleted! | |
virtual void | Reset () |
Reset merger file list. | |
virtual Bool_t | SetCWD (const char *) |
virtual void | SetFastMethod (Bool_t fast=kTRUE) |
void | SetIOFeatures (ROOT::TIOFeatures &features) |
void | SetMaxOpenedFiles (Int_t newmax) |
Set a limit to the number of files that TFileMerger will open simultaneously. | |
void | SetMergeOptions (const std::string_view &options) |
void | SetMergeOptions (const TString &options) |
void | SetMsgPrefix (const char *prefix) |
Set the prefix to be used when printing informational message. | |
virtual void | SetNotrees (Bool_t notrees=kFALSE) |
void | SetPrintLevel (Int_t level) |
void | Streamer (TBuffer &) override |
Stream an object of class TObject. | |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Public Member Functions inherited from TObject | |
TObject () | |
TObject constructor. | |
TObject (const TObject &object) | |
TObject copy ctor. | |
virtual | ~TObject () |
TObject destructor. | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. | |
ULong_t | CheckedHash () |
Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object. | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. | |
virtual void | Clear (Option_t *="") |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. | |
virtual Int_t | Compare (const TObject *obj) const |
Compare abstract method. | |
virtual void | Copy (TObject &object) const |
Copy this to obj. | |
virtual void | Delete (Option_t *option="") |
Delete this object. | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1) . | |
virtual void | Dump () const |
Dump contents of object on stdout. | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. | |
virtual void | Execute (const char *method, const char *params, Int_t *error=nullptr) |
Execute method on this object with the given parameter string, e.g. | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr) |
Execute method on this object with parameters stored in the TObjArray. | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. | |
virtual const char * | GetIconName () const |
Returns mime type name of object. | |
virtual const char * | GetName () const |
Returns name of object. | |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). | |
virtual Option_t * | GetOption () const |
virtual const char * | GetTitle () const |
Returns title of object. | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. | |
virtual ULong_t | Hash () const |
Return hash value for this object. | |
Bool_t | HasInconsistentHash () const |
Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e. | |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. | |
void | InvertBit (UInt_t f) |
Bool_t | IsDestructed () const |
IsDestructed. | |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). | |
R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
virtual Bool_t | IsSortable () const |
R__ALWAYS_INLINE Bool_t | IsZombie () const |
virtual void | ls (Option_t *option="") const |
The ls function lists the contents of a class on stdout. | |
void | MayNotUse (const char *method) const |
Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). | |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification (the base implementation is no-op). | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. | |
void | operator delete (void *ptr) |
Operator delete. | |
void | operator delete (void *ptr, void *vp) |
Only called by placement new when throwing an exception. | |
void | operator delete[] (void *ptr) |
Operator delete []. | |
void | operator delete[] (void *ptr, void *vp) |
Only called by placement new[] when throwing an exception. | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (const TObject &rhs) |
TObject assignment operator. | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. | |
virtual void | Print (Option_t *option="") const |
This method must be overridden when a class wants to print itself. | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. | |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". | |
void | SetBit (UInt_t f) |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. | |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. | |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. | |
R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
virtual void | UseCurrentStyle () |
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. | |
virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. | |
virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. | |
Static Public Member Functions | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
Static Public Member Functions inherited from TObject | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static Longptr_t | GetDtorOnly () |
Return destructor only flag. | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. | |
Protected Member Functions | |
virtual Bool_t | AddFile (TFile *source, Bool_t own, Bool_t cpProgress) |
Add the TFile to this file merger and give ownership of the TFile to this object (unless kFALSE is returned). | |
virtual Bool_t | MergeOne (TDirectory *target, TList *sourcelist, Int_t type, TFileMergeInfo &info, TString &oldkeyname, THashList &allNames, Bool_t &status, Bool_t &onlyListed, const TString &path, TDirectory *current_sourcedir, TFile *current_file, TKey *key, TObject *obj, TIter &nextkey) |
virtual Bool_t | MergeRecursive (TDirectory *target, TList *sourcelist, Int_t type=kRegular|kAll) |
Merge all objects in a directory. | |
Bool_t | OpenExcessFiles () |
Open up to fMaxOpenedFiles of the excess files. | |
Protected Member Functions inherited from TObject | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). | |
void | MakeZombie () |
Protected Attributes | |
Bool_t | fCompressionChange {kFALSE} |
True if the output and input have different compression level (default kFALSE) | |
TList | fExcessFiles |
! List of TObjString containing the name of the files not yet added to fFileList due to user or system limitation on the max number of files opened. | |
Bool_t | fExplicitCompLevel {kFALSE} |
True if the user explicitly requested a compression level change (default kFALSE) | |
Bool_t | fFastMethod {kTRUE} |
True if using Fast merging algorithm (default) | |
TList | fFileList |
A list the file (TFile*) which shall be merged. | |
Bool_t | fHistoOneGo |
Merger histos in one go (default is kTRUE) | |
TIOFeatures * | fIOFeatures {nullptr} |
IO features to use in the output file. | |
Bool_t | fLocal |
Makes local copies of merging files if True (default is kTRUE) | |
Int_t | fMaxOpenedFiles |
Maximum number of files opened at the same time by the TFileMerger. | |
TList | fMergeList |
list of TObjString containing the name of the files need to be merged | |
TString | fMergeOptions |
Options (in string format) to be passed down to the Merge functions. | |
TString | fMsgPrefix {"TFileMerger"} |
Prefix to be used when printing informational message (default TFileMerger) | |
Bool_t | fNoTrees {kFALSE} |
True if Trees should not be merged (default is kFALSE) | |
TString | fObjectNames |
List of object names to be either merged exclusively or skipped. | |
TFile * | fOutputFile {nullptr} |
The outputfile for merging. | |
TString | fOutputFilename |
The name of the outputfile for merging. | |
Int_t | fPrintLevel {0} |
How much information to print out at run time. | |
TStopwatch | fWatch |
Stop watch to measure file copy speed. | |
Private Types | |
using | TIOFeatures = ROOT::TIOFeatures |
Private Member Functions | |
TFileMerger (const TFileMerger &)=delete | |
TFileMerger & | operator= (const TFileMerger &)=delete |
Additional Inherited Members | |
Protected Types inherited from TObject | |
enum | { kOnlyPrepStep = (1ULL << ( 3 )) } |
#include <TFileMerger.h>
|
private |
Definition at line 32 of file TFileMerger.h.
Type of the partial merge.
Enumerator | |
---|---|
kRegular | Normal merge, overwriting the output file. |
kIncremental | Merge the input file with the content of the output file (if already existing). |
kResetable | Only the objects with a MergeAfterReset member function. |
kNonResetable | Only the objects without a MergeAfterReset member function. |
kDelayWrite | Delay the TFile write (to reduce the number of write when reusing the file) |
kAll | Merge all type of objects (default) |
kAllIncremental | Merge incrementally all type of objects. |
kOnlyListed | Only the objects specified in fObjectNames list. |
kSkipListed | Skip objects specified in fObjectNames list. |
kKeepCompression | Keep compression level unchanged for each input files. |
Definition at line 69 of file TFileMerger.h.
|
privatedelete |
Create file merger object.
Definition at line 91 of file TFileMerger.cxx.
|
override |
Cleanup.
Definition at line 105 of file TFileMerger.cxx.
Add the TFile to this file merger and give ownership of the TFile to this object (unless kFALSE is returned).
Return kTRUE if the addition was successful.
Definition at line 206 of file TFileMerger.cxx.
Add file to file merger.
Definition at line 128 of file TFileMerger.cxx.
Add the TFile to this file merger and do not give ownership of the TFile to this object.
Return kTRUE if the addition was successful.
Definition at line 195 of file TFileMerger.cxx.
Add the TFile to this file merger and give ownership of the TFile to this object (unless kFALSE is returned).
Return kTRUE if the addition was successful.
Definition at line 217 of file TFileMerger.cxx.
|
inline |
Definition at line 101 of file TFileMerger.h.
|
static |
|
inlinestaticconstexpr |
Definition at line 127 of file TFileMerger.h.
|
inline |
Definition at line 103 of file TFileMerger.h.
|
inlinestatic |
Definition at line 127 of file TFileMerger.h.
|
inlinevirtual |
Definition at line 107 of file TFileMerger.h.
|
inline |
Definition at line 93 of file TFileMerger.h.
|
inline |
Definition at line 91 of file TFileMerger.h.
|
inline |
Definition at line 97 of file TFileMerger.h.
|
inline |
Definition at line 95 of file TFileMerger.h.
|
inline |
Definition at line 123 of file TFileMerger.h.
|
inline |
Definition at line 102 of file TFileMerger.h.
|
inline |
Definition at line 92 of file TFileMerger.h.
|
inline |
Definition at line 90 of file TFileMerger.h.
|
inline |
Definition at line 87 of file TFileMerger.h.
|
inline |
Definition at line 89 of file TFileMerger.h.
|
inlineoverridevirtual |
Reimplemented from TObject.
Definition at line 127 of file TFileMerger.h.
Merge the files.
If no output file was specified it will write into the file "FileMerger.root" in the working directory. Returns true on success, false in case of error.
Definition at line 370 of file TFileMerger.cxx.
|
protectedvirtual |
Definition at line 450 of file TFileMerger.cxx.
|
protectedvirtual |
Merge all objects in a directory.
The type is defined by the bit values in TFileMerger::EPartialMergeType.
Definition at line 812 of file TFileMerger.cxx.
|
protected |
Open up to fMaxOpenedFiles of the excess files.
Definition at line 1031 of file TFileMerger.cxx.
|
privatedelete |
Open merger output file.
Definition at line 287 of file TFileMerger.cxx.
Open merger output file.
Definition at line 279 of file TFileMerger.cxx.
|
virtual |
Open merger output file.
The 'mode' parameter is passed to the TFile constructor as the option, it should be one of 'NEW','CREATE','RECREATE','UPDATE' 'UPDATE' is usually used in conjunction with IncrementalMerge.
Definition at line 301 of file TFileMerger.cxx.
|
virtual |
Open merger output file.
'mode' is passed to the TFile constructor as the option, it should be one of 'NEW','CREATE','RECREATE','UPDATE' 'UPDATE' is usually used in conjunction with IncrementalMerge.
Definition at line 347 of file TFileMerger.cxx.
Set an output file opened externally by the users.
Definition at line 315 of file TFileMerger.cxx.
|
virtual |
Merge the files.
If no output file was specified it will write into the file "FileMerger.root" in the working directory. Returns true on success, false in case of error. The type is defined by the bit values in EPartialMergeType: kRegular : normal merge, overwritting the output file kIncremental : merge the input file with the content of the output file (if already exising) (default) kAll : merge all type of objects (default) kResetable : merge only the objects with a MergeAfterReset member function. kNonResetable : merge only the objects without a MergeAfterReset member function.
If the type is set to kIncremental the output file is done deleted at the end of this operation. If the type is not set to kIncremental, the output file is closed.
Definition at line 917 of file TFileMerger.cxx.
|
virtual |
Print list of files being merged.
Definition at line 357 of file TFileMerger.cxx.
|
overridevirtual |
Intercept the case where the output TFile is deleted!
Reimplemented from TObject.
Definition at line 1078 of file TFileMerger.cxx.
|
virtual |
Reset merger file list.
Definition at line 117 of file TFileMerger.cxx.
|
inlinevirtual |
Definition at line 106 of file TFileMerger.h.
Definition at line 122 of file TFileMerger.h.
|
inline |
Definition at line 100 of file TFileMerger.h.
void TFileMerger::SetMaxOpenedFiles | ( | Int_t | newmax | ) |
Set a limit to the number of files that TFileMerger will open simultaneously.
If the request is higher than the system limit, we reset it to the system limit. If the request is less than two, we reset it to 2 (one for the output file and one for the input file).
Definition at line 1092 of file TFileMerger.cxx.
|
inline |
Definition at line 99 of file TFileMerger.h.
|
inline |
Definition at line 98 of file TFileMerger.h.
void TFileMerger::SetMsgPrefix | ( | const char * | prefix | ) |
Set the prefix to be used when printing informational message.
Definition at line 1108 of file TFileMerger.cxx.
Definition at line 124 of file TFileMerger.h.
|
inline |
Definition at line 88 of file TFileMerger.h.
|
overridevirtual |
|
inline |
Definition at line 127 of file TFileMerger.h.
True if the output and input have different compression level (default kFALSE)
Definition at line 45 of file TFileMerger.h.
|
protected |
! List of TObjString containing the name of the files not yet added to fFileList due to user or system limitation on the max number of files opened.
Definition at line 56 of file TFileMerger.h.
True if the user explicitly requested a compression level change (default kFALSE)
Definition at line 44 of file TFileMerger.h.
True if using Fast merging algorithm (default)
Definition at line 42 of file TFileMerger.h.
|
protected |
A list the file (TFile*) which shall be merged.
Definition at line 39 of file TFileMerger.h.
|
protected |
Merger histos in one go (default is kTRUE)
Definition at line 53 of file TFileMerger.h.
|
protected |
IO features to use in the output file.
Definition at line 48 of file TFileMerger.h.
|
protected |
Makes local copies of merging files if True (default is kTRUE)
Definition at line 52 of file TFileMerger.h.
|
protected |
Maximum number of files opened at the same time by the TFileMerger.
Definition at line 51 of file TFileMerger.h.
|
protected |
list of TObjString containing the name of the files need to be merged
Definition at line 55 of file TFileMerger.h.
|
protected |
Options (in string format) to be passed down to the Merge functions.
Definition at line 47 of file TFileMerger.h.
|
protected |
Prefix to be used when printing informational message (default TFileMerger)
Definition at line 49 of file TFileMerger.h.
True if Trees should not be merged (default is kFALSE)
Definition at line 43 of file TFileMerger.h.
|
protected |
List of object names to be either merged exclusively or skipped.
Definition at line 54 of file TFileMerger.h.
|
protected |
The outputfile for merging.
Definition at line 40 of file TFileMerger.h.
|
protected |
The name of the outputfile for merging.
Definition at line 41 of file TFileMerger.h.
|
protected |
How much information to print out at run time.
Definition at line 46 of file TFileMerger.h.
|
protected |
Stop watch to measure file copy speed.
Definition at line 38 of file TFileMerger.h.