| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

# merge.cpp

Go to the documentation of this file.

    00001 #include "merge/merge.C"
    00002 #include <cstdlib>
    00003
    00004 static int usage() {
    00005   ::printf("Gaudi merge facility for ROOT tree based files.\n"
    00006            " Usage: \n"
    00007            "gaudi_merge -o <output-file> -i <input-file 1> [ -i <input-file 2> ...]\n\n"
    00008            "input- and output files may specify any legal (ROOT) file name.\n"
    00009            "   -output      Specify output file name.\n"
    00010            "   -input       Specify input file name.\n"
    00011            "   -debug       Switch debug flag on.\n"
    00012            );
    00013   return 1;
    00014 }
    00015
    00016 int main(int argc, char** argv) {
    00017   bool dbg = false, fixup=true;
    00018   vector<string> input;
    00019   string output;
    00020   for(int i=1; i < argc; ++i) {
    00021     if ( *argv[i] == '-' ) {
    00022       switch(::toupper(*(argv[i]+1))) {
    00023       case 'N':
    00024         fixup = false;
    00025         break;
    00026       case 'D':
    00027         dbg = true;
    00028         break;
    00029       case 'O':
    00030         if ( i+1 < argc ) output = argv[i+1];
    00031         ++i;
    00032         break;
    00033       case 'I':
    00034         if ( i+1 < argc ) input.push_back(argv[i+1]);
    00035         ++i;
    00036         break;
    00037       default:
    00038         return usage();
    00039       }
    00040     }
    00041   }
    00042   if ( input.empty() ) {
    00043     ::printf("\nERROR: No input file(s) supplied\n\n");
    00044     return usage();
    00045   }
    00046   else if ( output.empty() ) {
    00047     ::printf("\nERROR: No output file supplied.\n\n");
    00048     return usage();
    00049   }
    00050   gROOT->SetBatch(kTRUE);
    00051   for(size_t i=0; i<input.size();++i)  {
    00052     const string& in = input[i];
    00053     bool do_fixup = fixup && ((i+1)==input.size());
    00054     //::printf("+++ Target:%s\n+++ Source file:%s Fixup:%s Dbg:%s %d %d\n",
    00055     //         output.c_str(),in.c_str(),do_fixup ? "YES" : "NO",dbg ? "YES" : "NO",i,input.size());
    00056     int result = merge(output.c_str(),in.c_str(),do_fixup,dbg);
    00057     if ( result == MERGE_ERROR ) {
    00058       printf("\nERROR: File merge failed after %ld files.\n\n",long(i+1));
    00059       return 1;
    00060     }
    00061   }
    00062   return 0;
    00063 }

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines