/[PAMELA software]/quicklook/tracker/flight/src/FTrkQLook_EXPERT.cc
ViewVC logotype

Contents of /quicklook/tracker/flight/src/FTrkQLook_EXPERT.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations) (download)
Fri Jan 17 15:10:45 2014 UTC (10 years, 10 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +2 -1 lines
Compilation warnings using GCC4.7 fixed

1 /**
2 * FTrkQLook_EXPERT.cc
3 *
4 * autor: D.Fedele
5 * version v1r..
6 * Parameters:
7 * file - path of the root file to analyze (give at least this parameter)
8 * fromevent - first event to analyze
9 * toevent - last event to analyze
10 * outDir - total path of output file
11 * format - extension of output file (pdf,ps,gif,jpg)
12 *
13 */
14 #include <TString.h>
15 #include <fcntl.h>
16 #include <unistd.h>
17 #include <cstdlib>
18 #include <sys/stat.h>
19 extern void FTrkQLook_EXPERT(TString file, Int_t fromevent, Int_t toevent, TString outdir, TString format);
20 extern void info();
21
22 void usage(){
23 printf("\nUsage:\n FTrkQLook_EXPERT file [OPTIONS] \n\n");
24 printf("\t --help: print this help and exit \n");
25 printf("\t file: path of the root file to analyze (give at least this parameter) \n");
26 printf("\nOPTIONS:\n");
27 printf("\t -v: be verbose \n");
28 printf("\t -fromev: first event to analyze [default = 0] \n");
29 printf("\t -toev: last event to analyze [default = 0] \n");
30 printf("\t -outDir: path of the output directory [default = ./] (with or without final '/')\n");
31 printf("\t -format: format for output file (without . )[default = pdf] (accepted formats: pdf, ps, png, jpg, gif)\n");
32 printf("\nExamples:\n\tFTrkQLook_EXPERT /home/pamela/filesfromyoda/DW_050523_01600.root -v \n\n");
33 printf("\tFTrkQLook_EXPERT /home/pamela/filesfromyoda/DW_050523_01600.root -v -format jpg\n\n");
34 printf("\tFTrkQLook_EXPERT /home/pamela/filesfromyoda/DW_050523_01600.root -v -format jpg -outDir ~/tmp/ \n\n");
35 }
36
37 int main(int argc, char* argv[]){
38
39 TString FILE,OUTDIR="./",FORMAT="pdf";
40 Int_t FROMEVENT=0,TOEVENT=0;
41 bool beverbose = false;
42 int nul = 0;
43
44
45 if(argc>1){
46 if ( !strcmp(argv[1],"--version") ){
47 info();
48 return(0);
49 };
50 if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") || argc>11){
51 usage();
52 return(0);
53 }
54 if ( (!strcmp(argv[1],"-v") || !strcmp(argv[1],"--verbose"))&& argc == 2 ){
55 info();
56 return(0);
57 }
58 else {
59
60 FILE = argv[1];
61 for(int i=2; i<argc;i++){
62
63 if ( !strcmp(argv[i],"-v") || !strcmp(argv[i],"--verbose") )
64 beverbose = true;
65
66 if (!strcmp(argv[i], "-outDir")){
67 if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-format") || !strcmp(argv[i], "-fromev") || !strcmp(argv[i], "-toev")){
68 printf( "\n-outDir needs arguments. \n");
69 usage();
70 return(0);
71 }
72 else{
73 OUTDIR = argv[i];
74 continue;
75 }
76 }
77
78 if (!strcmp(argv[i], "-fromev")){
79 if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-format") || !strcmp(argv[i], "-toev") || !strcmp(argv[i], "-outDir")){
80 printf( "\n-fromev needs arguments. \n");
81 usage();
82 return(0);
83 }
84 else{
85 FROMEVENT = atoi(argv[i]);
86 continue;
87 }
88 }
89
90 if (!strcmp(argv[i], "-toev")){
91 if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-format") || !strcmp(argv[i], "-fromev") || !strcmp(argv[i], "-outDir")){
92 printf( "\n-toev needs arguments. \n");
93 usage();
94 return(0);
95 }
96 else{
97 TOEVENT = atoi(argv[i]);
98 continue;
99 }
100 }
101
102 if (!strcmp(argv[i], "-format")){
103 if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-fromev") || !strcmp(argv[i], "-toev") || !strcmp(argv[i], "-outDir")){
104 printf( "\n-format needs arguments. \n");
105 usage();
106 return(0);
107 }
108 else{
109 FORMAT = argv[i];
110 continue;
111 }
112 }
113
114 if(strcmp(argv[i], "-format") && strcmp(argv[i], "-outDir") && strcmp(argv[i],"-v") && strcmp(argv[i],"--verbose") && strcmp(argv[i], "-fromev") && strcmp(argv[i], "-toev")){
115 printf( "\n------>Warning: WRONG OPTIONS!\n");
116 usage();
117 return(0);
118 }
119 }
120 }
121 }
122
123 else if(argc==1){
124 printf("\n\tYou have to insert at least the file to analyze \n");
125 usage();
126 return(0);
127 }
128
129 if ( !beverbose ){
130 //
131 // redirect to /dev/null the stdout and stderr
132 //
133 nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
134 dup2(nul,1);
135 dup2(nul,2);
136 };
137 printf("\n Welcome to FTrkQLook_EXPERT! \n\n");
138 //
139 FTrkQLook_EXPERT(FILE,FROMEVENT,TOEVENT,OUTDIR,FORMAT);
140 //
141 if ( !beverbose ) close(nul);
142 return(0);
143 }

  ViewVC Help
Powered by ViewVC 1.1.23