1 |
pam-fi |
1.1 |
/** |
2 |
|
|
* FTrkCalibQLook_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 <cstdlib> |
20 |
|
|
#include <sys/stat.h> |
21 |
pam-fi |
1.1 |
extern void FTrkCalibQLook_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 FTrkCalibQLook_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\tFTrkCalibQLook_BASIC /home/pamela/filesfromyoda/DW_050523_01600.root -v \n\n"); |
35 |
|
|
printf("\tFTrkCalibQLook_BASIC /home/pamela/filesfromyoda/DW_050523_01600.root -v -format jpg\n\n"); |
36 |
pam-fi |
1.4 |
printf("\tFTrkCalibQLook_BASIC /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; |
44 |
|
|
bool beverbose = false; |
45 |
|
|
int nul = 0; |
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>11){ |
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 |
pam-fi |
1.4 |
if (!strcmp(argv[i], "-outDir")){ |
69 |
pam-fi |
1.1 |
if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-format") || !strcmp(argv[i], "-fromev") || !strcmp(argv[i], "-toev")){ |
70 |
pam-fi |
1.4 |
printf( "\n-outDir needs arguments. \n"); |
71 |
pam-fi |
1.1 |
usage(); |
72 |
|
|
return(0); |
73 |
|
|
} |
74 |
|
|
else{ |
75 |
|
|
OUTDIR = argv[i]; |
76 |
|
|
continue; |
77 |
|
|
} |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
if (!strcmp(argv[i], "-fromev")){ |
81 |
pam-fi |
1.4 |
if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-format") || !strcmp(argv[i], "-toev") || !strcmp(argv[i], "-outDir")){ |
82 |
pam-fi |
1.1 |
printf( "\n-fromev needs arguments. \n"); |
83 |
|
|
usage(); |
84 |
|
|
return(0); |
85 |
|
|
} |
86 |
|
|
else{ |
87 |
|
|
FROMEVENT = atoi(argv[i]); |
88 |
|
|
continue; |
89 |
|
|
} |
90 |
|
|
} |
91 |
|
|
|
92 |
|
|
if (!strcmp(argv[i], "-toev")){ |
93 |
pam-fi |
1.4 |
if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-format") || !strcmp(argv[i], "-fromev") || !strcmp(argv[i], "-outDir")){ |
94 |
pam-fi |
1.1 |
printf( "\n-toev needs arguments. \n"); |
95 |
|
|
usage(); |
96 |
|
|
return(0); |
97 |
|
|
} |
98 |
|
|
else{ |
99 |
|
|
TOEVENT = atoi(argv[i]); |
100 |
|
|
continue; |
101 |
|
|
} |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
if (!strcmp(argv[i], "-format")){ |
105 |
pam-fi |
1.4 |
if (++i >= argc || !strcmp(argv[i],"-v") || !strcmp(argv[i], "-fromev") || !strcmp(argv[i], "-toev") || !strcmp(argv[i], "-outDir")){ |
106 |
pam-fi |
1.1 |
printf( "\n-format needs arguments. \n"); |
107 |
|
|
usage(); |
108 |
|
|
return(0); |
109 |
|
|
} |
110 |
|
|
else{ |
111 |
|
|
FORMAT = argv[i]; |
112 |
|
|
continue; |
113 |
|
|
} |
114 |
|
|
} |
115 |
pam-fi |
1.4 |
|
116 |
|
|
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") ){ |
117 |
|
|
printf( "\n------>Warning: WRONG OPTIONS!\n"); |
118 |
|
|
usage(); |
119 |
|
|
return(0); |
120 |
|
|
} |
121 |
pam-fi |
1.1 |
} |
122 |
|
|
} |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
else if(argc==1){ |
126 |
|
|
printf("\n\tYou have to insert at least the file to analyze \n"); |
127 |
|
|
usage(); |
128 |
|
|
return(0); |
129 |
|
|
} |
130 |
|
|
if ( !beverbose ){ |
131 |
|
|
// |
132 |
|
|
// redirect to /dev/null the stdout and stderr |
133 |
|
|
// |
134 |
|
|
nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE); |
135 |
|
|
dup2(nul,1); |
136 |
|
|
dup2(nul,2); |
137 |
|
|
}; |
138 |
|
|
printf("\n Welcome to FTrkCalibQLook_BASIC! \n\n"); |
139 |
|
|
// |
140 |
|
|
FTrkCalibQLook_BASIC(FILE,FROMEVENT,TOEVENT,OUTDIR,FORMAT); |
141 |
|
|
// |
142 |
|
|
if ( !beverbose ) close(nul); |
143 |
|
|
return(0); |
144 |
|
|
} |
145 |
|
|
|