1 |
mocchiut |
1.1 |
// |
2 |
|
|
// CaloCHKCALIB.cc -- standalone program to call the CaloCHKCALIB macro. |
3 |
|
|
// by Emiliano Mocchiutti |
4 |
|
|
// |
5 |
|
|
// Version 1.00 (2005/08/16) |
6 |
|
|
// |
7 |
|
|
// Changelog: |
8 |
|
|
// |
9 |
|
|
// 0.00 - 1.00 : working. |
10 |
|
|
// |
11 |
mocchiut |
1.2 |
#include <TSystem.h> |
12 |
mocchiut |
1.1 |
#include <iostream> |
13 |
mocchiut |
1.2 |
#include <sys/types.h> |
14 |
mocchiut |
1.6 |
#include <cstdlib> |
15 |
mocchiut |
1.2 |
#include <unistd.h> |
16 |
|
|
#include <stdio.h> |
17 |
mocchiut |
1.1 |
// |
18 |
mocchiut |
1.4 |
extern void FCaloCHKCALIB(TString, Long64_t, TString, int, TString, Bool_t, Bool_t); |
19 |
mocchiut |
1.1 |
extern void info(); |
20 |
|
|
using namespace std; |
21 |
|
|
// |
22 |
mocchiut |
1.2 |
void usage(){ |
23 |
mocchiut |
1.3 |
printf("\nUsage:\n\n FCaloCHKCALIB [-name] file [OPTIONS] \n"); |
24 |
|
|
printf("\n file must be in the form: /path/to/filesfromyoda/ZZZ_XXX_YYYYY_cln2.root \n"); |
25 |
|
|
printf( " if in the first position \"-name\" can be omitted. \n"); |
26 |
|
|
printf("\n OPTIONS: \n"); |
27 |
|
|
printf("\n -v be verbose \n"); |
28 |
|
|
printf( " -entry entry calibration entry to analyze [default = 0, all] \n"); |
29 |
mocchiut |
1.4 |
printf( " -interactive shows figures on the screen [default = non-interactive] \n"); |
30 |
|
|
printf( " -wait wait for canvas to be closed before going on [default = don't wait] \n"); |
31 |
mocchiut |
1.3 |
printf( " -matra draw the strip rms in a box plot [default: do not draw] \n"); |
32 |
|
|
printf( " -oudDir output_dir path of the output directory [default = ./] (with or without final '/') \n"); |
33 |
mocchiut |
1.4 |
printf( " -format format format for output file (without . )[default = png] \n"); |
34 |
mocchiut |
1.3 |
printf("\nExamples: "); |
35 |
|
|
printf("\n\nFCaloCHKCALIB /home/pamela/filesfromyoda/dw_050301_00100.root \n"); |
36 |
|
|
printf("\nFCaloCHKCALIB -v -name /home/pamela/filesfromyoda/dw_050301_00100.root \n"); |
37 |
|
|
printf("\nFCaloCHKCALIB /home/pamela/filesfromyoda/DW_050523_01600.root -v -entry 2 -matra -outDir /tmp/ -format gif \n\n"); |
38 |
mocchiut |
1.2 |
} |
39 |
|
|
// |
40 |
mocchiut |
1.1 |
int main(int numinp, char *inps[]){ |
41 |
|
|
TString name; |
42 |
mocchiut |
1.5 |
TString outdir = "./"; |
43 |
mocchiut |
1.4 |
TString format = "png"; |
44 |
mocchiut |
1.2 |
int matra = 0; |
45 |
|
|
Long64_t calibno = 0; |
46 |
|
|
char *pEnd; |
47 |
|
|
int nul = 0; |
48 |
|
|
bool beverbose = false; |
49 |
mocchiut |
1.4 |
Bool_t iactive = false; |
50 |
|
|
Bool_t w4i = false; |
51 |
mocchiut |
1.3 |
|
52 |
mocchiut |
1.2 |
if ( numinp > 1 ){ |
53 |
mocchiut |
1.3 |
name = (TString)inps[1]; |
54 |
|
|
for ( int i = 0; i < numinp; i++ ){ |
55 |
|
|
|
56 |
|
|
if ( !strcmp(inps[i],"--version") ){ |
57 |
|
|
info(); |
58 |
|
|
return(0); |
59 |
|
|
}; |
60 |
|
|
if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){ |
61 |
|
|
usage(); |
62 |
|
|
return(0); |
63 |
|
|
}; |
64 |
|
|
if ( !strcmp(inps[i],"-name") ) { |
65 |
|
|
if ( numinp-1 < i+1 ){ |
66 |
|
|
usage(); |
67 |
|
|
exit(-3); |
68 |
|
|
}; |
69 |
|
|
name = (TString)inps[i+1]; |
70 |
|
|
}; |
71 |
|
|
if ( !strcmp(inps[i],"-outDir") ) { |
72 |
|
|
if ( numinp-1 < i+1 ){ |
73 |
|
|
usage(); |
74 |
|
|
exit(-3); |
75 |
|
|
}; |
76 |
|
|
outdir = (TString)inps[i+1]; |
77 |
|
|
}; |
78 |
|
|
if ( !strcmp(inps[i],"-format") ) { |
79 |
|
|
if ( numinp-1 < i+1 ){ |
80 |
|
|
usage(); |
81 |
|
|
exit(-3); |
82 |
|
|
}; |
83 |
|
|
format = (TString)inps[i+1]; |
84 |
|
|
}; |
85 |
|
|
|
86 |
|
|
if ( !strcmp(inps[i],"-entry") ) { |
87 |
|
|
if ( numinp-1 < i+1 ){ |
88 |
|
|
usage(); |
89 |
|
|
exit(-3); |
90 |
mocchiut |
1.2 |
}; |
91 |
mocchiut |
1.3 |
calibno = strtoull(inps[i+1],&pEnd,0); |
92 |
mocchiut |
1.1 |
}; |
93 |
mocchiut |
1.3 |
if ( !strcmp(inps[i],"-matra") ) { |
94 |
|
|
matra = 1; |
95 |
|
|
}; |
96 |
mocchiut |
1.4 |
if ( !strcmp(inps[i],"-interactive") ) { |
97 |
|
|
iactive = true; |
98 |
|
|
}; |
99 |
|
|
if ( !strcmp(inps[i],"-wait") ) { |
100 |
|
|
w4i = true; |
101 |
|
|
}; |
102 |
mocchiut |
1.3 |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
103 |
mocchiut |
1.1 |
}; |
104 |
mocchiut |
1.3 |
} else { |
105 |
|
|
// |
106 |
|
|
// no input parameters exit with error, we need at least the run id. |
107 |
|
|
// |
108 |
|
|
usage(); |
109 |
|
|
return(0); |
110 |
mocchiut |
1.2 |
}; |
111 |
|
|
// |
112 |
|
|
if ( !beverbose ){ |
113 |
|
|
// |
114 |
|
|
// redirect to /dev/null the stdout and stderr |
115 |
mocchiut |
1.1 |
// |
116 |
mocchiut |
1.2 |
nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE); |
117 |
|
|
dup2(nul,1); |
118 |
|
|
dup2(nul,2); |
119 |
mocchiut |
1.1 |
}; |
120 |
mocchiut |
1.2 |
printf("\n Welcome to FCaloCHKCALIB! \n"); |
121 |
mocchiut |
1.1 |
// |
122 |
mocchiut |
1.4 |
FCaloCHKCALIB(name,calibno,outdir,matra,format,iactive,w4i); |
123 |
mocchiut |
1.1 |
// |
124 |
mocchiut |
1.2 |
if ( !beverbose ) close(nul); |
125 |
mocchiut |
1.1 |
return(0); |
126 |
|
|
} |