| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

merge.cpp
Go to the documentation of this file.
1 #include "merge/merge.C"
2 #include "TError.h"
3 #include <cstdlib>
4
5 static int usage()
6 {
7 ::printf( "Gaudi merge facility for ROOT tree based files.\n"
8 " Usage: \n"
9 "gaudi_merge -o <output-file> -i <input-file 1> [ -i <input-file 2> ...]\n\n"
10 "input- and output files may specify any legal (ROOT) file name.\n"
11 " -output Specify output file name.\n"
12 " -input Specify input file name.\n"
13 " -debug Switch debug flag on.\n" );
14 return 1;
15 }
16
17 static ErrorHandlerFunc_t s_err = nullptr;
18 static void err_handler( Int_t level, Bool_t abort_bool, const char* location, const char* msg )
19 {
20 if ( msg && strstr( msg, "no dictionary for class" ) ) return;
21 s_err( level, abort_bool, location, msg );
22 }
23
24 int main( int argc, char** argv )
25 {
26 bool dbg = false, fixup = true;
27 vector<string> input;
28 string output;
29 for ( int i = 1; i < argc; ++i ) {
30 if ( *argv[i] == '-' ) {
31 switch (::toupper( *( argv[i] + 1 ) ) ) {
32 case 'N':
33 fixup = false;
34 break;
35 case 'D':
36 dbg = true;
37 break;
38 case 'O':
39 if ( i + 1 < argc ) output = argv[i + 1];
40 ++i;
41 break;
42 case 'I':
43 if ( i + 1 < argc ) input.push_back( argv[i + 1] );
44 ++i;
45 break;
46 default:
47 return usage();
48 }
49 }
50 }
51 if ( input.empty() ) {
52 ::printf( "\nERROR: No input file(s) supplied\n\n" );
53 return usage();
54 } else if ( output.empty() ) {
55 ::printf( "\nERROR: No output file supplied.\n\n" );
56 return usage();
57 }
58 gROOT->SetBatch( kTRUE );
59 s_err = SetErrorHandler( err_handler );
60 for ( size_t i = 0; i < input.size(); ++i ) {
61 const string& in = input[i];
62 bool do_fixup = fixup && ( ( i + 1 ) == input.size() );
63 //::printf("+++ Target:%s\n+++ Source file:%s Fixup:%s Dbg:%s %d %d\n",
64 // output.c_str(),in.c_str(),do_fixup ? "YES" : "NO",dbg ? "YES" : "NO",i,input.size());
65 int result = merge( output.c_str(), in.c_str(), do_fixup, dbg );
66 if ( result == MERGE_ERROR ) {
67 printf( "\nERROR: File merge failed after %ld files.\n\n", long( i + 1 ) );
68 return 1;
69 }
70 }
71 return 0;
72 }
gaudirun.output
output
Definition: gaudirun.py:404
gaudirun.argv
list argv
Definition: gaudirun.py:235
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:899
usage
void usage(std::string argv0)
Definition: listcomponents.cpp:39
plotBacklogPyRoot.argc
argc
Definition: plotBacklogPyRoot.py:138
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
std::strstr
T strstr(T...args)
gaudirun.level
level
Definition: gaudirun.py:271
main
int main(int argc, char **argv)
Definition: merge.cpp:24
toupper
void toupper(std::string &s)
Definition: StatusCodeSvc.cpp:10