/[PAMELA software]/eventviewer/flight/src/FEventViewer.cpp
ViewVC logotype

Annotation of /eventviewer/flight/src/FEventViewer.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Fri May 21 13:16:11 2010 UTC (14 years, 6 months ago) by mocchiut
Branch: MAIN
Changes since 1.3: +6 -0 lines
Small bug in input parameters handling fixed

1 mocchiut 1.1 //
2     // EventViewer.cc -- standalone program to call the EventViewer macro.
3     // by Emiliano Mocchiutti
4     //
5     // Version 1.00 (2005/11/07)
6     //
7     // Changelog:
8     //
9     // 0.00 - 1.00 : working.
10     //
11     #include <TSystem.h>
12     #include <iostream>
13     #include <sys/types.h>
14     #include <unistd.h>
15     #include <stdio.h>
16     //
17     #include <FEventViewerCore.h>
18     #include <FEVVerl2.h>
19     //
20     using namespace std;
21 mocchiut 1.3 Bool_t NODB;
22     //
23    
24     void usage(){
25     printf("\nUsage:\n\n EventViewer [-v] file selection_file output_dir \n");
26     printf("\n -v be verbose and do not fork after launching the GUI\n");
27     printf( " -file file must be in the form: /path/to/filesfromyoda/dw_000000_00000/ \n");
28     printf( " -selfile selection_file selection file, empty if no selection is required \n");
29     printf( " -outputDir outDir directory where to save figures\n");
30     printf( " -noDB do not DB connection in PamLevel2 (RUNINFO WILL NOT WORK!)\n");
31     printf("\nExamples: \n\nEventViewer /home/pamela/filesfromyoda/dw_050301_00100/ \"\" /home/pamela/\n");
32     printf( "EventViewer -v /home/pamela/filesfromyoda/dw_050301_00100/ muselection.c \"\"\n\n");
33     printf( "EventViewer \n\n");
34     printf( "EventViewer -v \n\n");
35     }
36    
37 mocchiut 1.1 //
38     int main(int numinp, char *inps[]){
39     TString name = "";
40     TString selfile = "";
41     TString outdir = "";
42     bool beverbose = false;
43 mocchiut 1.3
44    
45     for (int i = 1; i < numinp; i++){
46     // -----------------------------------------------------//
47     if (!strcmp(inps[i], "-file")){
48     name = (TString)inps[++i];
49     cout << "file "<<name.Data()<<endl;
50     continue;
51     }
52     // -----------------------------------------------------//
53     else if (!strcmp(inps[i], "-outputDir")){
54     outdir = (TString)inps[++i];
55     cout << "outputDir "<<outdir.Data()<<endl;
56     continue;
57     }
58     // -----------------------------------------------------//
59 mocchiut 1.4 else if (!strcmp(inps[i], "-selfile")){
60     selfile = (TString)inps[++i];
61     cout << "selfile "<<selfile.Data()<<endl;
62     continue;
63     }
64     // -----------------------------------------------------//
65 mocchiut 1.3 else if (!strcmp(inps[i], "-v")){
66     beverbose = true;
67     continue;
68     }
69     // -----------------------------------------------------//
70     else if (!strcmp(inps[i], "-h")){
71     beverbose = true;
72     usage();
73     return(0);
74     }
75     else if (!strcmp(inps[i], "-noDB")){
76     NODB = true;
77     continue;
78     }
79     else if (!strcmp(inps[i], "--version")){
80 mocchiut 1.1 FEVInfo(true);
81     return(0);
82 mocchiut 1.3 }
83     };
84     //
85     if ( !strcmp(name.Data(),"") ){
86     if ( numinp > 1 ){
87     if ( !strcmp(inps[1],"--version") ){
88     FEVInfo(true);
89     return(0);
90     };
91     if ( !strcmp(inps[1],"-h") || !strcmp(inps[1],"--help") || numinp>7 ){
92     usage();
93     return(0);
94     };
95     if ( !strcmp(inps[1],"-v") || !strcmp(inps[1],"--verbose") ){
96     beverbose = true;
97     if ( numinp >= 3 ) name = (TString)inps[2];
98     if ( numinp >= 4 ) selfile = (TString)inps[3];
99     if ( numinp == 5 ) outdir = (TString)inps[4];
100     } else {
101     name = (TString)inps[1];
102     if ( numinp >= 3 ) selfile = (TString)inps[2];
103     if ( numinp >= 4 ) outdir = (TString)inps[3];
104     };
105 mocchiut 1.1 };
106     };
107 mocchiut 1.3 //
108     //
109     //
110 mocchiut 1.1 if ( beverbose ){
111     ShowEvent(name,selfile,outdir);
112     } else {
113     //
114     // redirect to dev/null the stdout
115     //
116     int nul;
117     nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
118     dup2(nul,1);
119     dup2(nul,2);
120     close(nul);
121     //
122     printf("\n Welcome to the PAMELA event viewer! \n\n");
123     //
124     // fork process
125     //
126     pid_t pid;
127     if( (pid=fork()) == -1 ){
128     fprintf(stderr," Fork error. Exiting.\n");
129 mocchiut 1.2 return(1);
130 mocchiut 1.1 };
131     if( !pid ) {
132     ShowEvent(name,selfile,outdir);
133     };
134     };
135     //
136     return(0);
137     }

  ViewVC Help
Powered by ViewVC 1.1.23