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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide 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.16: +2 -1 lines
Compilation warnings using GCC4.7 fixed

1 pam-fi 1.1 /**
2     * FTrkScanQLook_EXPERT.cc
3     *
4     * autor: D.Fedele
5 pam-fi 1.11 * version v1r..
6 pam-fi 1.1 * Parameters:
7     * file - the path to the root file to analyze
8 pam-fi 1.5 * outDir - total path of output file
9 pam-fi 1.1 * event - the number of the single event to analyze
10 pam-fi 1.14 * va1 - the number of the single va1 to analyze
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 mocchiut 1.17 #include <cstdlib>
18     #include <sys/stat.h>
19 pam-fi 1.15 extern void FTrkScanQLook_EXPERT(TString file, TString outdir, Int_t event, Int_t va1, Int_t value, TString format);
20 pam-fi 1.1 extern void info();
21    
22     void usage(){
23     printf("\nUsage:\n\n FTrkScanQLook_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 pam-fi 1.14 printf("\t -event: which event to analyze [default = 0] (if negative analyze |event| events after a calibration)\n");
29 pam-fi 1.15 printf("\t -va1: which va1 to analyze [default = 0] (the standard is: DSP*100+VA1)\n");
30 pam-fi 1.16 printf("\t -value: number of events to store in the .dat file with va1 values*10 + # of calibration (if #of cal = 0, select all calibrations)\n");
31 pam-fi 1.5 printf("\t -outDir: path of the output directory [default = ./] (with or without final '/')\n");
32     printf("\t -format: format of the output file (without .) [default = pdf] (accepted formats: pdf, ps, png, jpg, gif)\n");
33 pam-fi 1.1 printf("\nExamples:\n\tFTrkScanQLook_EXPERT /home/pamela/filesfromyoda/DW_xxxxxx_yyyy.root \n\n");
34 pam-fi 1.14 printf("\tFTrkScanQLook_EXPERT /home/pamela/filesfromyoda/DW_xxxxxx_yyyy.root -v -va1 1123 -outDir ~/tmp/\n\n");
35 pam-fi 1.1 }
36    
37     int main(int argc, char* argv[]){
38    
39     TString FILE,OUTDIR="./",FORMAT="pdf";
40 pam-fi 1.15 Int_t EVENT=0,VA1=0,VALUE=0;
41 pam-fi 1.1 bool beverbose = false;
42     int nul = 0;
43    
44     if(argc>1){
45     if ( !strcmp(argv[1],"--version") ){
46     info();
47     return(0);
48     };
49 pam-fi 1.15 if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") || argc>13){
50 pam-fi 1.1 usage();
51     return(0);
52     }
53     if ( (!strcmp(argv[1],"-v") || !strcmp(argv[1],"--verbose"))&& argc == 2 ){
54     info();
55     return(0);
56     }
57     else {
58    
59     FILE = argv[1];
60     for(int i=2; i<argc;i++){
61    
62     if ( !strcmp(argv[i],"-v") || !strcmp(argv[i],"--verbose") )
63     beverbose = true;
64    
65 pam-fi 1.5 if (!strcmp(argv[i], "-outDir")){
66 pam-fi 1.15 if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-format")||!strcmp(argv[i], "-event") || !strcmp(argv[i], "-value") || !strcmp(argv[i], "-va1")){
67 pam-fi 1.5 printf( "\n-outDir needs arguments. \n");
68 pam-fi 1.1 usage();
69     return(0);
70     }
71     else{
72     OUTDIR = argv[i];
73     continue;
74     }
75     }
76     if (!strcmp(argv[i], "-format")){
77 pam-fi 1.15 if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-outDir")||!strcmp(argv[i], "-event") || !strcmp(argv[i], "-value") || !strcmp(argv[i], "-va1")){
78 pam-fi 1.1 printf( "\n-format needs arguments. \n");
79     usage();
80     return(0);
81     }
82     else{
83     FORMAT = argv[i];
84     continue;
85     }
86     }
87 pam-fi 1.13
88     if (!strcmp(argv[i], "-event")){
89 pam-fi 1.15 if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-outDir")|| !strcmp(argv[i], "-format") || !strcmp(argv[i], "-va1") || !strcmp(argv[i], "-value")){
90 pam-fi 1.13 printf( "\n-event needs arguments. \n");
91     usage();
92     return(0);
93     }
94     else{
95     EVENT = atoi(argv[i]);
96     continue;
97     }
98     }
99 pam-fi 1.14
100     if (!strcmp(argv[i], "-va1")){
101 pam-fi 1.15 if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-outDir")|| !strcmp(argv[i], "-format") || !strcmp(argv[i], "-event") || !strcmp(argv[i], "-value")){
102 pam-fi 1.14 printf( "\n-va1 needs arguments. \n");
103     usage();
104     return(0);
105     }
106     else{
107     VA1 = atoi(argv[i]);
108     continue;
109     }
110 pam-fi 1.15 }
111    
112     if (!strcmp(argv[i], "-value")){
113     if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-outDir")|| !strcmp(argv[i], "-format") || !strcmp(argv[i], "-event") || !strcmp(argv[i], "-va1")){
114     printf( "\n-value needs arguments. \n");
115     usage();
116     return(0);
117     }
118     else{
119     VALUE = atoi(argv[i]);
120     continue;
121     }
122 pam-fi 1.14 }
123 pam-fi 1.5
124 pam-fi 1.15 if( strcmp(argv[i], "-format") && strcmp(argv[i], "-outDir") && strcmp(argv[i],"-v") && strcmp(argv[i],"--verbose") && strcmp(argv[i], "-event") && strcmp(argv[i], "-va1") && strcmp(argv[i], "-value")){
125 pam-fi 1.5 printf( "\n------>Warning: WRONG OPTIONS!\n");
126     usage();
127     return(0);
128     }
129 pam-fi 1.1 }
130     }
131     }
132 pam-fi 1.12
133     else if(argc==1){
134     printf("\n\tYou have to insert at least the file to analyze \n");
135     usage();
136     return(0);
137     }
138 pam-fi 1.1
139    
140     if ( !beverbose ){
141     //
142     // redirect to /dev/null the stdout and stderr
143     //
144     nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
145     dup2(nul,1);
146     dup2(nul,2);
147     };
148     printf("\n Welcome to FTrkScanQLook! \n\n");
149     //
150 pam-fi 1.15 FTrkScanQLook_EXPERT(FILE,OUTDIR,EVENT,VA1,VALUE,FORMAT);
151 pam-fi 1.1 //
152     if ( !beverbose ) close(nul);
153     return(0);
154     }

  ViewVC Help
Powered by ViewVC 1.1.23