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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.23