/[PAMELA software]/eventviewer/ground/src/EventViewer.cc
ViewVC logotype

Diff of /eventviewer/ground/src/EventViewer.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mocchiut, Tue Dec 6 10:12:56 2005 UTC revision 1.2 by mocchiut, Thu Mar 9 15:50:54 2006 UTC
# Line 11  Line 11 
11  #include <TSystem.h>  #include <TSystem.h>
12  #include <caloclasses.h>  #include <caloclasses.h>
13  #include <iostream>  #include <iostream>
14    #include <sys/types.h>
15    #include <unistd.h>
16    #include <stdio.h>
17  //  //
18  extern void ShowEvent(TString, TString, Int_t, Int_t, Int_t, Int_t, TString);  extern void ShowEvent(TString, TString, Int_t, Int_t, Int_t, Int_t, TString);
19  extern void info();  extern void info();
20  using namespace std;  using namespace std;
21  //  //
22  int main(int numinp, char *inps[]){  int main(int numinp, char *inps[]){
23    TString name;    TString name = "";
24    TString selfile;    TString selfile = "";
25    TString outdir;    TString outdir = "";
26    int dl;    int dl = -1;
27    int figlay;      int figlay = 509;  
28    if ( numinp < 6 ){    bool beverbose = false;
29      if ( numinp > 1 ){    if ( numinp > 1 ){
30        if ( !strcmp(inps[1],"--version") ){      if ( !strcmp(inps[1],"--version") ){
31          info();        info();
32          return(0);        return(0);
       };  
       if ( !strcmp(inps[1],"-h") || !strcmp(inps[1],"--help") ){  
         printf("\nUsage:\n\n EventViewer file selection_file figure_layout data_level output_dir \n");  
         printf("\n - 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(  " - figure_layout    10 bit integer to control the figure layout. Each bit \n");  
         printf(  "                    set to 1 activate the visualization of a detector or  \n");  
         printf(  "                    a part of the figure. This is the association scheme: \n");  
         printf(  "                  10    9    8    7     6    5     4    3      2     1  \n");  
         printf(  "               special TOF  AC   TRK   CALO S4    ND   infos  names legenda \n");  
         printf(  "                    The default value is 509 = 0111111101 that is all detectors\n");  
         printf(  "                    and infos are shown, names are hidden. \n");  
         printf(  "                    When the \"special\" bit is set NO SIGNAL will be shown in \n");  
         printf(  "                    the detectors. It can be used to draw a draft of the PAMELA\n");  
         printf(  "                    apparatus without any event.\n");  
         printf(  "                    Other examples: \n");  
         printf(  "                    505 = 0111111001 : don't print infos on figure \n");  
         printf(  "                    507 = 0111111011 : show detector names+legenda (no infos) \n");  
         printf(  "                    8   = 0000001000 : show only ND. \n");  
         printf(  " - data_level       by default the program will try to display the highest level\n");  
         printf(  "                    data available. This flag force the level0 visualization\n");  
         printf(  "                    when it is set to 0. Default value is -1. \n");  
         printf(  " - outDir           directory where to save figures\n");  
         printf("\nExamples: \n\nEventViewer /home/pamela/filesfromyoda/dw_050301_00100/ \"\" 509 -1 /home/pamela/\n");  
         printf(                "EventViewer /home/pamela/filesfromyoda/dw_050301_00100/ muselection.c 509 -1 \"\"\n\n");  
         return(0);  
       };  
33      };      };
34      printf("\n Welcome to the PAMELA event viewer! \n\n");      if ( !strcmp(inps[1],"-h") || !strcmp(inps[1],"--help") || numinp>7 ){
35      //        printf("\nUsage:\n\n EventViewer [-v] file selection_file figure_layout data_level output_dir \n");
36      printf("\n You must provide the following input parameters: \n\n");        printf("\n -v                be verbose and do not fork after launching the GUI\n");
37      //        printf(  "  file             must be in the form: /path/to/filesfromyoda/dw_000000_00000/  \n");
38      char input[256];        printf(  "  selection_file   selection file, empty if no selection is required \n");
39      //        printf(  "  figure_layout    10 bit integer to control the figure layout. Each bit \n");
40      printf(" Path to YODA unpacked directory: \n ");        printf(  "                   set to 1 activate the visualization of a detector or  \n");
41      cin.getline(input,256);        printf(  "                   a part of the figure. This is the association scheme: \n");
42      name = (TString)input;        printf(  "                  10    9    8    7     6    5     4    3      2     1  \n");
43      printf(" Selection file to use?: \n ");        printf(  "               special TOF  AC   TRK   CALO S4    ND   infos  names legenda \n");
44      cin.getline(input,256);        printf(  "                   The default value is 509 = 0111111101 that is all detectors\n");
45      if ( !strcmp(input,"") ){        printf(  "                   and infos are shown, names are hidden. \n");
46        selfile = "";        printf(  "                   When the \"special\" bit is set NO SIGNAL will be shown in \n");
47      } else {        printf(  "                   the detectors. It can be used to draw a draft of the PAMELA\n");
48        selfile = (TString)input;        printf(  "                   apparatus without any event.\n");
49          printf(  "                   Other examples: \n");
50          printf(  "                   505 = 0111111001 : don't print infos on figure \n");
51          printf(  "                   507 = 0111111011 : show detector names+legenda (no infos) \n");
52          printf(  "                   8   = 0000001000 : show only ND. \n");
53          printf(  "  data_level       by default the program will try to display the highest level\n");
54          printf(  "                   data available. This flag force the level0 visualization\n");
55          printf(  "                   when it is set to 0. Default value is -1. \n");
56          printf(  "  outDir           directory where to save figures\n");
57          printf("\nExamples: \n\nEventViewer /home/pamela/filesfromyoda/dw_050301_00100/ \"\" 509 -1 /home/pamela/\n");
58          printf(                "EventViewer -v /home/pamela/filesfromyoda/dw_050301_00100/ muselection.c 509 -1 \"\"\n\n");
59          printf(                "EventViewer \n\n");
60          printf(                "EventViewer -v \n\n");
61          return(0);
62      };      };
63      printf(" Figure layout (default 509)?: \n ");      if ( !strcmp(inps[1],"-v") || !strcmp(inps[1],"--verbose") ){
64      cin.getline(input,256);        beverbose = true;
65      if ( !strcmp(input,"") ){        if ( numinp >= 3 ) name = (TString)inps[2];
66        figlay = 509;        if ( numinp >= 4 ) selfile = (TString)inps[3];
67          if ( numinp >= 5 ) figlay = atoi(inps[4]);
68          if ( numinp >= 6 ) dl = atoi(inps[5]);
69          if ( numinp == 7 ) outdir = (TString)inps[6];
70      } else {      } else {
71        figlay = atoi(input);        name = (TString)inps[1];
72          if ( numinp >= 3 ) selfile = (TString)inps[2];
73          if ( numinp >= 4 ) figlay = atoi(inps[3]);
74          if ( numinp >= 5 ) dl = atoi(inps[4]);
75          if ( numinp >= 6 ) outdir = (TString)inps[5];
76      };      };
77      printf(" Data level (default -1 = as high as possible)?: \n ");    };
78      cin.getline(input,256);    if ( beverbose ){
79      if ( !strcmp(input,"0") ){      ShowEvent(name,selfile,figlay,dl,0,0,outdir);
       dl = 0;  
     } else {  
       dl = -1;  
     };  
     printf(" Output directory: \n ");  
     cin.getline(input,256);  
     outdir = (TString)input;  
     //  
80    } else {    } else {
81        //
82        // redirect to dev/null the stdout
83        //
84        int nul;
85        nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
86        dup2(nul,1);
87        dup2(nul,2);
88        close(nul);
89        //
90      printf("\n Welcome to  the PAMELA event viewer! \n\n");      printf("\n Welcome to  the PAMELA event viewer! \n\n");
91      name = (TString)inps[1];      //
92      selfile = (TString)inps[2];      // fork process
93      figlay = atoi(inps[3]);      //
94      dl = atoi(inps[4]);      pid_t pid;
95      outdir = (TString)inps[5];      if( (pid=fork()) == -1 ){
96          fprintf(stderr," Fork error. Exiting.\n");
97          exit(1);        
98        };
99        if( !pid ) {
100          ShowEvent(name,selfile,figlay,dl,0,0,outdir);
101        };
102    };    };
103    //    //
   ShowEvent(name,selfile,figlay,dl,0,0,outdir);  
   //  
104    return(0);    return(0);
105  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23