/[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.11 - (hide annotations) (download)
Fri Jan 17 15:10:44 2014 UTC (10 years, 10 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +4 -1 lines
Compilation warnings using GCC4.7 fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23