Ignore:
Timestamp:
07/06/03 23:38:12 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/merpp.cc

    r2178 r2267  
    99
    1010#include "MLog.h"
     11#include "MLogManip.h"
     12
     13#include "MArgs.h"
    1114#include "MTime.h"
    1215#include "MArray.h"
     
    1518#include "MRawEvtHeader.h"
    1619#include "MRawCrateArray.h"
    17 #include "MInputStreamID.h"
    1820
    1921using namespace std;
     
    3436//////////////////////////////////////////////////////////////////////////////
    3537
     38void Usage()
     39{
     40    gLog << "Sorry the usage is:" << endl;
     41    gLog << "   merpp [-vn] inputfile outputfile [compression level]" << endl << endl;
     42    gLog << "     input file:   Magic DAQ binary file." << endl;
     43    gLog << "     ouput file:   Merpped root file." << endl;
     44    gLog << "     compr. level: 1..9 [default=1]" << endl;
     45    gLog << "     -vn: Verbosity level n [default=2]" << endl << endl;
     46}
     47
    3648int main(const int argc, const char **argv)
    3749{
     50    MArgs arg(argc, argv);
     51    arg.Print();
     52
    3853    gLog << "==================================================" << endl ;
    3954    gLog << "                   MERPP v0.1" << endl;
     
    4762    // check for the right usage of the program
    4863    //
    49     if (argc<3 || argc>4)
     64    if (arg.GetNumArguments()<2 || arg.GetNumArguments()>3)
    5065    {
    51         gLog << "Sorry the usage is:" << endl;
    52         gLog << "   merpp inputfile outputfile [compression level]" << endl << endl;
    53         gLog << "     input file:   Magic DAQ binary file." << endl;
    54         gLog << "     ouput file:   Merpped root file." << endl;
    55         gLog << "     compr. level: 1..9 [default=1]" << endl << endl;
     66        Usage();
    5667        return -1;
    5768    }
     
    6071    // Set verbosity to highest level.
    6172    //
    62     gLog.SetDebugLevel(2);
     73    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetInt("-v") : 2);
    6374
    6475    //
    6576    // This is to make argv[i] more readable insidethe code
    6677    //
    67     const char *kNamein   = argv[1];
    68     const char *kNameout  = argv[2];
    69     const int   kComprlvl = argc==4 ? atoi(argv[3]) : 1;
     78    const char *kNamein   = arg.GetArgumentStr(0);
     79    const char *kNameout  = arg.GetArgumentStr(1);
     80    const int   kComprlvl = arg.GetNumArguments()==3 ? arg.GetArgumentInt(2) : 1;
    7081
    7182    //
    7283    //     initialize ROOT  (this is obligatory here)
    7384    //
    74     TROOT simple("merpp", "Mars - Merging and Preprocessing Program");
     85    TROOT merpp("merpp", "Mars - Merging and Preprocessing Program");
     86    merpp.SetBatch();
    7587
    7688    //
     
    7991    if (gSystem->AccessPathName(kNamein, kFileExists))
    8092    {
    81         gLog << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
     93        gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
    8294        return -1;
    8395    }
    8496
    8597    if (!gSystem->AccessPathName(kNameout, kFileExists))
    86         gLog << "Warning: A file '" << kNameout << "' exists." << endl;
     98        gLog << warn << "Warning: A file '" << kNameout << "' exists." << endl;
    8799    else
    88100        if (!gSystem->AccessPathName(kNameout, kWritePermission))
    89101        {
    90             gLog << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
     102            gLog << err << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
    91103            return -1;
    92104        }
     
    148160    if (!magic.Eventloop())
    149161    {
    150         gLog << "ERROR: Merging and preprocessing failed!" << endl;
     162        gLog << err << "ERROR: Merging and preprocessing failed!" << endl;
    151163        return -1;
    152164    }
    153165
    154     gLog << "Merpp finished successfull!" << endl;
     166    gLog << all << "Merpp finished successfull!" << endl;
    155167    return 0;
    156168}
Note: See TracChangeset for help on using the changeset viewer.