Changeset 2267 for trunk/MagicSoft/Mars/merpp.cc
- Timestamp:
- 07/06/03 23:38:12 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/merpp.cc
r2178 r2267 9 9 10 10 #include "MLog.h" 11 #include "MLogManip.h" 12 13 #include "MArgs.h" 11 14 #include "MTime.h" 12 15 #include "MArray.h" … … 15 18 #include "MRawEvtHeader.h" 16 19 #include "MRawCrateArray.h" 17 #include "MInputStreamID.h"18 20 19 21 using namespace std; … … 34 36 ////////////////////////////////////////////////////////////////////////////// 35 37 38 void 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 36 48 int main(const int argc, const char **argv) 37 49 { 50 MArgs arg(argc, argv); 51 arg.Print(); 52 38 53 gLog << "==================================================" << endl ; 39 54 gLog << " MERPP v0.1" << endl; … … 47 62 // check for the right usage of the program 48 63 // 49 if (arg c<3 || argc>4)64 if (arg.GetNumArguments()<2 || arg.GetNumArguments()>3) 50 65 { 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(); 56 67 return -1; 57 68 } … … 60 71 // Set verbosity to highest level. 61 72 // 62 gLog.SetDebugLevel( 2);73 gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetInt("-v") : 2); 63 74 64 75 // 65 76 // This is to make argv[i] more readable insidethe code 66 77 // 67 const char *kNamein = arg v[1];68 const char *kNameout = arg v[2];69 const int kComprlvl = arg c==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; 70 81 71 82 // 72 83 // initialize ROOT (this is obligatory here) 73 84 // 74 TROOT simple("merpp", "Mars - Merging and Preprocessing Program"); 85 TROOT merpp("merpp", "Mars - Merging and Preprocessing Program"); 86 merpp.SetBatch(); 75 87 76 88 // … … 79 91 if (gSystem->AccessPathName(kNamein, kFileExists)) 80 92 { 81 gLog << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;93 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl; 82 94 return -1; 83 95 } 84 96 85 97 if (!gSystem->AccessPathName(kNameout, kFileExists)) 86 gLog << "Warning: A file '" << kNameout << "' exists." << endl;98 gLog << warn << "Warning: A file '" << kNameout << "' exists." << endl; 87 99 else 88 100 if (!gSystem->AccessPathName(kNameout, kWritePermission)) 89 101 { 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; 91 103 return -1; 92 104 } … … 148 160 if (!magic.Eventloop()) 149 161 { 150 gLog << "ERROR: Merging and preprocessing failed!" << endl;162 gLog << err << "ERROR: Merging and preprocessing failed!" << endl; 151 163 return -1; 152 164 } 153 165 154 gLog << "Merpp finished successfull!" << endl;166 gLog << all << "Merpp finished successfull!" << endl; 155 167 return 0; 156 168 }
Note:
See TracChangeset
for help on using the changeset viewer.