--- eventviewer/flight/src/FEventViewer.cpp 2006/07/14 14:18:06 1.1 +++ eventviewer/flight/src/FEventViewer.cpp 2014/01/16 15:52:36 1.6 @@ -8,6 +8,7 @@ // // 0.00 - 1.00 : working. // +#include #include #include #include @@ -18,40 +19,95 @@ #include // using namespace std; +Bool_t NODB; +// + +void usage(){ + printf("\nUsage:\n\n EventViewer [-v] file selection_file output_dir \n"); + printf("\n -v be verbose and do not fork after launching the GUI\n"); + printf( " -file file must be in the form: /path/to/filesfromyoda/dw_000000_00000/ \n"); + printf( " -selfile selection_file selection file, empty if no selection is required \n"); + printf( " -outputDir outDir directory where to save figures\n"); + printf( " -noDB do not DB connection in PamLevel2 (RUNINFO WILL NOT WORK!)\n"); + printf("\nExamples: \n\nEventViewer /home/pamela/filesfromyoda/dw_050301_00100/ \"\" /home/pamela/\n"); + printf( "EventViewer -v /home/pamela/filesfromyoda/dw_050301_00100/ muselection.c \"\"\n\n"); + printf( "EventViewer \n\n"); + printf( "EventViewer -v \n\n"); +} + // int main(int numinp, char *inps[]){ TString name = ""; TString selfile = ""; TString outdir = ""; bool beverbose = false; - if ( numinp > 1 ){ - if ( !strcmp(inps[1],"--version") ){ - FEVInfo(true); + + + for (int i = 1; i < numinp; i++){ + // -----------------------------------------------------// + if (!strcmp(inps[i], "-file")){ + name = (TString)inps[++i]; + cout << "file "<7 ){ - printf("\nUsage:\n\n EventViewer [-v] file selection_file output_dir \n"); - printf("\n -v be verbose and do not fork after launching the GUI\n"); - printf( " file must be in the form: /path/to/filesfromyoda/dw_000000_00000/ \n"); - printf( " selection_file selection file, empty if no selection is required \n"); - printf( " outDir directory where to save figures\n"); - printf("\nExamples: \n\nEventViewer /home/pamela/filesfromyoda/dw_050301_00100/ \"\" /home/pamela/\n"); - printf( "EventViewer -v /home/pamela/filesfromyoda/dw_050301_00100/ muselection.c \"\"\n\n"); - printf( "EventViewer \n\n"); - printf( "EventViewer -v \n\n"); + } + else if (!strcmp(inps[i], "-noDB")){ + NODB = true; + continue; + } + else if (!strcmp(inps[i], "--version")){ + FEVInfo(true); return(0); - }; - if ( !strcmp(inps[1],"-v") || !strcmp(inps[1],"--verbose") ){ - beverbose = true; - if ( numinp >= 3 ) name = (TString)inps[2]; - if ( numinp >= 4 ) selfile = (TString)inps[3]; - if ( numinp == 5 ) outdir = (TString)inps[4]; - } else { - name = (TString)inps[1]; - if ( numinp >= 3 ) selfile = (TString)inps[2]; - if ( numinp >= 4 ) outdir = (TString)inps[3]; + } + }; + // + if ( !strcmp(name.Data(),"") ){ + if ( numinp > 1 ){ + if ( !strcmp(inps[1],"--version") ){ + FEVInfo(true); + return(0); + }; + if ( !strcmp(inps[1],"-h") || !strcmp(inps[1],"--help") || numinp>7 ){ + usage(); + return(0); + }; + if ( !strcmp(inps[1],"-v") || !strcmp(inps[1],"--verbose") ){ + beverbose = true; + if ( numinp >= 3 ) name = (TString)inps[2]; + if ( numinp >= 4 ) selfile = (TString)inps[3]; + if ( numinp == 5 ) outdir = (TString)inps[4]; + } else { + name = (TString)inps[1]; + if ( numinp >= 3 ) selfile = (TString)inps[2]; + if ( numinp >= 4 ) outdir = (TString)inps[3]; + }; }; }; + // + // + // if ( beverbose ){ ShowEvent(name,selfile,outdir); } else { @@ -59,7 +115,7 @@ // redirect to dev/null the stdout // int nul; - nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE); + nul = open("/dev/null", O_CREAT | O_RDWR,S_IRUSR | S_IWUSR); dup2(nul,1); dup2(nul,2); close(nul); @@ -71,7 +127,7 @@ pid_t pid; if( (pid=fork()) == -1 ){ fprintf(stderr," Fork error. Exiting.\n"); - exit(1); + return(1); }; if( !pid ) { ShowEvent(name,selfile,outdir);