00001
00002
00003 #ifndef XAODROOTACCESS_TOOLS_TFILEMERGER_H
00004 #define XAODROOTACCESS_TOOLS_TFILEMERGER_H
00005
00006
00007 #include <string>
00008 #include <vector>
00009 #include <map>
00010 #include <set>
00011
00012
00013 #include <TObject.h>
00014
00015
00016 #include "xAODRootAccess/TEvent.h"
00017 #include "xAODRootAccess/tools/TReturnCode.h"
00018 #include "xAODRootAccess/tools/THolder.h"
00019
00020
00021 class TFile;
00022 class TDirectory;
00023 class TTree;
00024 class TBranch;
00025
00026 namespace xAOD {
00027
00041 class TFileMerger : public ::TObject {
00042
00043 public:
00045 TFileMerger();
00047 ~TFileMerger();
00048
00050 TReturnCode setOutputFileName( const std::string& name,
00051 const std::string& mode = "RECREATE" );
00052
00054 TReturnCode addFile( const std::string& name,
00055 bool copyLocally = false );
00056
00058 TReturnCode addMetaDataTool( const std::string& typeName );
00059
00065 enum EMergeMode {
00066 kSlowMerge = 0,
00067 kFastMerge = 1
00068 };
00069
00071 static const ::Long64_t kBigNumber = 1234567890;
00072
00074 TReturnCode merge( EMergeMode mode = kFastMerge,
00075 ::Long64_t entries = kBigNumber );
00076
00078 TEvent::EAuxMode accessMode() const;
00080 void setAccessMode( TEvent::EAuxMode mode );
00081
00083 int verbosity() const;
00085 void setVerbosity( int value );
00086
00088 const std::set< std::string >& treesSkipped() const;
00090 void addTreeToSkip( const std::string& name );
00091
00092 private:
00094 TReturnCode closeFiles();
00096 TReturnCode mergeDirectory( ::TDirectory& input, ::TDirectory& output,
00097 EMergeMode mode, bool topLevelDir );
00099 TReturnCode mergeObject( ::TObject& input, ::TObject& output );
00101 TReturnCode createMetaDataTools();
00103 std::vector< ::TBranch* > getMissingBranches( ::TTree* first,
00104 ::TTree* second ) const;
00106 std::vector< ::TBranch* > getSkippedBranches( ::TTree* tree ) const;
00108 TReturnCode addAuxBranch( ::TTree* otree, ::TBranch* ibranch ) const;
00109
00111 std::vector< ::TFile* > m_input;
00113 std::vector< bool > m_copiedInput;
00115 ::TFile* m_output;
00116
00118 std::set< std::string > m_treesToSkip;
00119
00121 std::map< std::string, TEvent > m_events;
00123 std::vector< ::TFile* > m_helperFiles;
00124
00126 std::set< std::string > m_metaDataToolNames;
00128 std::map< std::string, THolder > m_metaDataTools;
00129
00131 TEvent::EAuxMode m_mode;
00132
00134 ::Long64_t m_entriesToMerge;
00135
00137 int m_verbosity;
00138
00140 ClassDef( xAOD::TFileMerger, 0 )
00141
00142 };
00143
00144 }
00145
00146 #endif // XAODROOTACCESS_TOOLS_TFILEMERGER_H