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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Fri Aug 11 10:24:10 2006 UTC (18 years, 4 months ago) by pam-fi
Branch: MAIN
CVS Tags: v1r08
Changes since 1.7: +1 -1 lines
release v1r08

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

  ViewVC Help
Powered by ViewVC 1.1.23