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

Annotation of /quicklook/tracker/flight/src/FTrkQLook_BASIC.cc

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.23