# TFileMerger* ``` 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 via Castor, rfio, dcap, etc. The merging interface allows files containing histograms and trees to be merged, like the standalone hadd program. ``` ```cpp class TFileMerger : public TObject ``` ## class ```cpp private: using TIOFeatures = ROOT::TIOFeatures; TFileMerger(const TFileMerger&) = delete; TFileMerger& operator=(const TFileMerger&) = delete; protected: TStopwatch fWatch; ///< Stop watch to measure file copy speed TList fFileList; ///< A list the file (TFile*) which shall be merged TFile *fOutputFile{nullptr}; ///< The outputfile for merging TString fOutputFilename; ///< The name of the outputfile for merging Bool_t fFastMethod{kTRUE}; ///< True if using Fast merging algorithm (default) Bool_t fNoTrees{kFALSE}; ///< True if Trees should not be merged (default is kFALSE) Bool_t fExplicitCompLevel{kFALSE}; ///< True if the user explicitly requested a compressio level change (default kFALSE) Bool_t fCompressionChange{kFALSE}; ///< True if the output and input have different compression level (default kFALSE) Int_t fPrintLevel{0}; ///< How much information to print out at run time TString fMergeOptions; ///< Options (in string format) to be passed down to the Merge functions TIOFeatures *fIOFeatures{nullptr}; ///< IO features to use in the output file. TString fMsgPrefix{"TFileMerger"}; ///< Prefix to be used when printing informational message (default TFileMerger) Int_t fMaxOpenedFiles; ///< Maximum number of files opened at the same time by the TFileMerger Bool_t fLocal; ///< Makes local copies of merging files if True (default is kTRUE) Bool_t fHistoOneGo; ///< Merger histos in one go (default is kTRUE) TString fObjectNames; ///< List of object names to be either merged exclusively or skipped TList fMergeList; ///< list of TObjString containing the name of the files need to be merged TList fExcessFiles; /// file);/// Set an output file opened externally by the users virtual void PrintFiles(Option_t *options);/// Print list of files being merged. virtual Bool_t Merge(Bool_t = kTRUE); /// 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. virtual Bool_t PartialMerge(Int_t type = kAll | kIncremental); /// 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. virtual void SetFastMethod(Bool_t fast=kTRUE) {fFastMethod = fast;} virtual void SetNotrees(Bool_t notrees=kFALSE) {fNoTrees = notrees;} virtual void RecursiveRemove(TObject *obj);/// Intercept the case where the output TFile is deleted! ```