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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Tue May 11 09:13:50 2010 UTC (14 years, 6 months ago) by mocchiut
Branch: MAIN
Changes since 1.2: +73 -24 lines
New input option (still backward compatible) + noDB option

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 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 //
38 int main(int numinp, char *inps[]){
39 TString name = "";
40 TString selfile = "";
41 TString outdir = "";
42 bool beverbose = false;
43
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 else if (!strcmp(inps[i], "-v")){
60 beverbose = true;
61 continue;
62 }
63 // -----------------------------------------------------//
64 else if (!strcmp(inps[i], "-h")){
65 beverbose = true;
66 usage();
67 return(0);
68 }
69 else if (!strcmp(inps[i], "-noDB")){
70 NODB = true;
71 continue;
72 }
73 else if (!strcmp(inps[i], "--version")){
74 FEVInfo(true);
75 return(0);
76 }
77 };
78 //
79 if ( !strcmp(name.Data(),"") ){
80 if ( numinp > 1 ){
81 if ( !strcmp(inps[1],"--version") ){
82 FEVInfo(true);
83 return(0);
84 };
85 if ( !strcmp(inps[1],"-h") || !strcmp(inps[1],"--help") || numinp>7 ){
86 usage();
87 return(0);
88 };
89 if ( !strcmp(inps[1],"-v") || !strcmp(inps[1],"--verbose") ){
90 beverbose = true;
91 if ( numinp >= 3 ) name = (TString)inps[2];
92 if ( numinp >= 4 ) selfile = (TString)inps[3];
93 if ( numinp == 5 ) outdir = (TString)inps[4];
94 } else {
95 name = (TString)inps[1];
96 if ( numinp >= 3 ) selfile = (TString)inps[2];
97 if ( numinp >= 4 ) outdir = (TString)inps[3];
98 };
99 };
100 };
101 //
102 //
103 //
104 if ( beverbose ){
105 ShowEvent(name,selfile,outdir);
106 } else {
107 //
108 // redirect to dev/null the stdout
109 //
110 int nul;
111 nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
112 dup2(nul,1);
113 dup2(nul,2);
114 close(nul);
115 //
116 printf("\n Welcome to the PAMELA event viewer! \n\n");
117 //
118 // fork process
119 //
120 pid_t pid;
121 if( (pid=fork()) == -1 ){
122 fprintf(stderr," Fork error. Exiting.\n");
123 return(1);
124 };
125 if( !pid ) {
126 ShowEvent(name,selfile,outdir);
127 };
128 };
129 //
130 return(0);
131 }

  ViewVC Help
Powered by ViewVC 1.1.23