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 <caloclasses.h> |
13 |
|
|
#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); |
19 |
|
|
extern void info(); |
20 |
|
|
using namespace std; |
21 |
|
|
// |
22 |
|
|
int main(int numinp, char *inps[]){ |
23 |
|
|
TString name = ""; |
24 |
|
|
TString selfile = ""; |
25 |
|
|
TString outdir = ""; |
26 |
|
|
int dl = -1; |
27 |
|
|
int figlay = 509; |
28 |
|
|
bool beverbose = false; |
29 |
|
|
if ( numinp > 1 ){ |
30 |
|
|
if ( !strcmp(inps[1],"--version") ){ |
31 |
|
|
info(); |
32 |
|
|
return(0); |
33 |
|
|
}; |
34 |
|
|
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 -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 |
|
|
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( " set to 1 activate the visualization of a detector or \n"); |
41 |
|
|
printf( " a part of the figure. This is the association scheme: \n"); |
42 |
|
|
printf( " 10 9 8 7 6 5 4 3 2 1 \n"); |
43 |
|
|
printf( " special TOF AC TRK CALO S4 ND infos names legenda \n"); |
44 |
|
|
printf( " The default value is 509 = 0111111101 that is all detectors\n"); |
45 |
|
|
printf( " and infos are shown, names are hidden. \n"); |
46 |
|
|
printf( " When the \"special\" bit is set NO SIGNAL will be shown in \n"); |
47 |
|
|
printf( " the detectors. It can be used to draw a draft of the PAMELA\n"); |
48 |
|
|
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 |
|
|
if ( !strcmp(inps[1],"-v") || !strcmp(inps[1],"--verbose") ){ |
64 |
|
|
beverbose = true; |
65 |
|
|
if ( numinp >= 3 ) name = (TString)inps[2]; |
66 |
|
|
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 { |
71 |
|
|
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 |
|
|
}; |
78 |
|
|
if ( beverbose ){ |
79 |
|
|
ShowEvent(name,selfile,figlay,dl,0,0,outdir); |
80 |
|
|
} 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"); |
91 |
|
|
// |
92 |
|
|
// fork process |
93 |
|
|
// |
94 |
|
|
pid_t pid; |
95 |
|
|
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 |
|
|
// |
104 |
|
|
return(0); |
105 |
|
|
} |