]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/FMDBaseda.cxx
MUON + CheckCompiler
[u/mrichter/AliRoot.git] / FMD / FMDBaseda.cxx
index ba6e17575eaee3981d19743386ba199d23af0039..c472c85497d342372d31e1a35e8060c3f0b8cd70 100644 (file)
   Output Files:            conditions.csv
   Trigger types used:      PHYSICS_EVENT
 */
+#include <cstdlib>
+#include <Riostream.h>
 #include "monitor.h"
 #include "event.h"
+#include <AliLog.h>
 #include <TSystem.h>
 #include <TString.h>
 #include <AliFMDParameters.h>
 #include "TROOT.h"
 #include "TPluginManager.h"
 
-
+void
+usage(std::ostream& o, const char* progname)
+{
+  o << "Usage: " << progname << " FILE [OPTIONS]\n\n"
+    << "Options:\n"
+    << "\t-h,--help         Show this help\n"
+    << "\t-d,--diagnostics  Create diagnostics\n"
+    << "\t-D,--debug LEVEL  Set the debug level\n"
+    << std::endl;
+}
 
 int main(int argc, char **argv) 
 {
@@ -49,13 +61,50 @@ int main(int argc, char **argv)
   AliFMDParameters::Instance()->UseCompleteHeader(old);
   struct eventHeaderStruct *event;
   int status;
-  /* define data source : this is argument 1 */  
-  status=monitorSetDataSource( argv[1] );
+
+  Int_t  debugLevel = 0;
+  Bool_t badOption  = false;
+  char*  source     = 0;
+  for (int i = 1; i < argc; i++) { 
+    if (argv[i][0] == '-') { // Options 
+      if (argv[i][1] == '-') { // Long option 
+       TString arg(&(argv[i][2])); 
+       if      (arg.EqualTo("help")) { usage(std::cout, argv[0]); return 0; }
+       if      (arg.EqualTo("diagnostics")) { }
+       else if (arg.EqualTo("debug")) debugLevel = atoi(argv[++i]); 
+       else                             badOption = true;
+      }
+      else { // Short option 
+       switch (argv[i][1]) { 
+       case 'h': usage(std::cout, argv[0]); return 0; 
+       case 'd': break; 
+       case 'D': debugLevel = atoi(argv[++i]); break;
+       default:  badOption = true;
+       }
+      }
+      if (badOption) { 
+       std::cerr << argv[0] << ": Unknown option " << argv[i] 
+                 << std::endl;
+       return 1;
+      }
+    }
+    else { 
+      if (!source) source     = argv[i];
+      else         debugLevel = atoi(argv[i]);
+    }
+  }
+  if (!source) { 
+    printf("%s: No data source specified\n", argv[0]);
+    return -1;
+  }
+  status=monitorSetDataSource(source);
   if (status!=0) {
-    printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
+    printf("monitorSetDataSource() failed for %s: %s\n",
+          source, monitorDecodeError(status));
     return -1;
   }
   
+  AliLog::SetModuleDebugLevel("FMD", debugLevel);
   /* declare monitoring program */
   status=monitorDeclareMp( __FILE__ );
   if (status!=0) {
@@ -84,7 +133,8 @@ int main(int argc, char **argv)
     }
     
     if (status!=0) {
-      printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
+      printf("monitorGetEventDynamic() failed : %s\n",
+            monitorDecodeError(status));
       break;
     }
     
@@ -101,7 +151,9 @@ int main(int argc, char **argv)
       reader = new AliRawReaderDate((void*)event);
       baseDA.Run(reader);
       SODread = kTRUE;
-      retval = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
+      retval = 
+       daqDA_FES_storeFile("conditions.csv", 
+                           AliFMDParameters::Instance()->GetConditionsShuttleID());
       if (retval != 0) std::cerr << "Base DA failed" << std::endl;
       
       break;