| The Gaudi Framework v32r1 (f65d50dc)

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