ATLAS Offline Software
Loading...
Searching...
No Matches
TFileMerger.h
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// $Id: TFileMerger.h 784654 2016-11-16 17:17:32Z krasznaa $
8#ifndef XAODROOTACCESS_TOOLS_TFILEMERGER_H
9#define XAODROOTACCESS_TOOLS_TFILEMERGER_H
10
11// System include(s):
12#include <string>
13#include <vector>
14#include <map>
15#include <set>
16#include <memory>
17
18// ROOT include(s):
19#include <TObject.h>
20
21// Local include(s):
25
26// Forward declaration(s):
27class TFile;
28class TDirectory;
29class TTree;
30class TBranch;
31
32namespace xAOD {
33
47 class TFileMerger : public ::TObject {
48
49 public:
54
56 StatusCode setOutputFileName( const std::string& name,
57 const std::string& mode = "RECREATE" );
58
60 StatusCode addFile( const std::string& name,
61 bool copyLocally = false );
62
64 StatusCode addMetaDataTool( const std::string& typeName );
65
74 };
75
77 static const ::Long64_t kBigNumber = 1234567890;
78
80 StatusCode merge( EMergeMode mode = kFastMerge,
81 ::Long64_t entries = kBigNumber );
82
87
89 int verbosity() const;
91 void setVerbosity( int value );
92
94 const std::set< std::string >& treesSkipped() const;
96 void addTreeToSkip( const std::string& name );
97
98 private:
100 StatusCode closeFiles();
102 StatusCode mergeDirectory( ::TDirectory& input, ::TDirectory& output,
103 EMergeMode mode, bool topLevelDir );
105 StatusCode mergeObject( ::TObject& input, ::TObject& output );
109 std::vector< ::TBranch* > getMissingBranches( ::TTree* first,
110 ::TTree* second ) const;
112 std::vector< ::TBranch* > getSkippedBranches( ::TTree* tree ) const;
114 StatusCode addAuxBranch( ::TTree* otree, ::TBranch* ibranch ) const;
115
117 std::vector< ::TFile* > m_input;
119 std::vector< bool > m_copiedInput;
121 ::TFile* m_output;
122
124 std::set< std::string > m_treesToSkip;
125
127 std::map< std::string, std::unique_ptr< TEvent > > m_events;
129 std::vector< ::TFile* > m_helperFiles;
130
132 std::set< std::string > m_metaDataToolNames;
134 std::map< std::string, THolder > m_metaDataTools;
135
138
141
144
146 ClassDef( xAOD::TFileMerger, 0 )
147
148 }; // class TFileMerger
149
150} // namespace xAOD
151
152#endif // XAODROOTACCESS_TOOLS_TFILEMERGER_H
Helper class for merging xAOD files.
Definition TFileMerger.h:47
std::vector< ::TFile * > m_input
The list of input files to be merged.
StatusCode merge(EMergeMode mode=kFastMerge, ::Long64_t entries=kBigNumber)
Execute the file merge itself.
StatusCode closeFiles()
Close all the open files.
int verbosity() const
The current verbosity level.
::TFile * m_output
The output file to write to.
const std::set< std::string > & treesSkipped() const
Get the names of the trees that will be skipped from the merge.
std::set< std::string > m_treesToSkip
Names of the TTrees to skip from the merge.
void setAccessMode(TEvent::EAuxMode mode)
Set the access mode used for slow and metadata merging.
StatusCode setOutputFileName(const std::string &name, const std::string &mode="RECREATE")
Set the name of the output file that should be created.
StatusCode mergeDirectory(::TDirectory &input, ::TDirectory &output, EMergeMode mode, bool topLevelDir)
Merge the contents of one directory from the input files.
TFileMerger()
Default constructor.
StatusCode addMetaDataTool(const std::string &typeName)
Add a metadata tool to be used during the merging.
std::vector< ::TBranch * > getMissingBranches(::TTree *first, ::TTree *second) const
Get the auxiliary branches missing in one of the trees.
static const ::Long64_t kBigNumber
Number of entries that are assumed to be never exceeded in a file.
Definition TFileMerger.h:77
TEvent::EAuxMode accessMode() const
The access mode used for slow and metadata merging.
int m_verbosity
Verbosity level.
std::vector< bool > m_copiedInput
Whether the files were copied locally before being merged.
void setVerbosity(int value)
Set verbosity level (meant for debugging mainly)
std::vector< ::TBranch * > getSkippedBranches(::TTree *tree) const
Get the branches that should be skipped from merging.
EMergeMode
Types of merging that can be done.
Definition TFileMerger.h:71
@ kSlowMerge
Merging is done using TEvent.
Definition TFileMerger.h:72
@ kFastMerge
Merging is done using fast TTree merge.
Definition TFileMerger.h:73
StatusCode addFile(const std::string &name, bool copyLocally=false)
Add a file to the list to be merged, by name.
~TFileMerger()
Destructor.
void addTreeToSkip(const std::string &name)
Add a tree name that should be skipped during the merging.
TEvent::EAuxMode m_mode
Access mode for the created TEvent objects.
StatusCode createMetaDataTools()
Instantiate the metadata handling tools.
std::map< std::string, std::unique_ptr< TEvent > > m_events
Helper objects for merging the xAOD Tree(s) from the input file(s)
::Long64_t m_entriesToMerge
Events to merge into the output.
std::set< std::string > m_metaDataToolNames
Names of the metadata handling tools.
std::map< std::string, THolder > m_metaDataTools
Metadata tools instantiated for the file merging.
StatusCode mergeObject(::TObject &input, ::TObject &output)
Merge two top level objects that were found in the inputs.
std::vector< ::TFile * > m_helperFiles
Helper in-memory files used during fast merging.
StatusCode addAuxBranch(::TTree *otree, ::TBranch *ibranch) const
Duplicate an auxiliary branch from the input into the output.
double entries
Definition listroot.cxx:49
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
TChain * tree