1 |
mocchiut |
1.1 |
// |
2 |
|
|
// FCaloQLOOK.cc -- standalone program to call the FCaloQLOOK macro. |
3 |
|
|
// by Emiliano Mocchiutti |
4 |
|
|
// |
5 |
|
|
// Version 1.00 (2005/02/28) |
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.6 |
#include <sstream> |
14 |
mocchiut |
1.2 |
#include <sys/types.h> |
15 |
|
|
#include <unistd.h> |
16 |
|
|
#include <stdio.h> |
17 |
mocchiut |
1.1 |
// |
18 |
mocchiut |
1.5 |
extern void FCaloQLOOK(TString, int, int, TString, TString, Bool_t, Bool_t); |
19 |
mocchiut |
1.1 |
extern void info(); |
20 |
mocchiut |
1.6 |
extern void stringcopy(TString& , const TString& , Int_t , Int_t ); |
21 |
mocchiut |
1.1 |
using namespace std; |
22 |
|
|
// |
23 |
mocchiut |
1.2 |
void usage(){ |
24 |
mocchiut |
1.3 |
printf("\nUsage:\n\n FCaloQLOOK [-name] file [OPTIONS] \n"); |
25 |
|
|
printf("\n file must be in the form: /path/to/filesfromyoda/ZZZ_XXX_YYYYY_cln2.root \n"); |
26 |
|
|
printf( " if in the first position \"-name\" can be omitted. \n"); |
27 |
|
|
printf("\n OPTIONS: \n"); |
28 |
|
|
printf("\n -v be verbose \n"); |
29 |
|
|
printf( " -fromev from_event first event to analyze [default = 0] \n"); |
30 |
|
|
printf( " -toev to_event last event to analyze [default = 0] \n"); |
31 |
|
|
printf( " -oudDir output_dir path of the output directory [default = ./] (with or without final '/') \n"); |
32 |
mocchiut |
1.4 |
printf( " -format format format for output file (without . )[default = png] \n"); |
33 |
mocchiut |
1.6 |
printf( " -interactive shows figures on the screen [default = non-interactive] \n"); |
34 |
|
|
printf( " -wait wait for canvas to be closed before going on [default = don't wait] \n"); |
35 |
mocchiut |
1.3 |
printf("\nExamples: "); |
36 |
|
|
printf("\n\nFCaloQLOOK /home/pamela/filesfromyoda/dw_050301_00100.root \n"); |
37 |
|
|
printf("\nFCaloQLOOK -v -name /home/pamela/filesfromyoda/dw_050301_00100.root \n"); |
38 |
|
|
printf("\nFCaloQLOOK /home/pamela/filesfromyoda/DW_050523_01600.root -v -fromev 0 -toev 0 -outDir /tmp/ -format gif \n\n"); |
39 |
mocchiut |
1.2 |
} |
40 |
|
|
|
41 |
mocchiut |
1.1 |
int main(int numinp, char *inps[]){ |
42 |
|
|
TString name; |
43 |
mocchiut |
1.6 |
TString outdir = "./"; |
44 |
mocchiut |
1.4 |
TString format = "png"; |
45 |
mocchiut |
1.2 |
int fromev = 0; |
46 |
|
|
int toev = 0; |
47 |
|
|
int nul = 0; |
48 |
|
|
bool beverbose = false; |
49 |
mocchiut |
1.5 |
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],"-fromev") ) { |
87 |
|
|
if ( numinp-1 < i+1 ){ |
88 |
|
|
usage(); |
89 |
|
|
exit(-3); |
90 |
mocchiut |
1.2 |
}; |
91 |
mocchiut |
1.3 |
fromev = atoi(inps[i+1]); |
92 |
mocchiut |
1.1 |
}; |
93 |
mocchiut |
1.3 |
if ( !strcmp(inps[i],"-toev") ) { |
94 |
|
|
if ( numinp-1 < i+1 ){ |
95 |
|
|
usage(); |
96 |
|
|
exit(-3); |
97 |
|
|
}; |
98 |
|
|
toev = atoi(inps[i+1]); |
99 |
|
|
}; |
100 |
mocchiut |
1.5 |
if ( !strcmp(inps[i],"-interactive") ) { |
101 |
|
|
iactive = true; |
102 |
|
|
}; |
103 |
|
|
if ( !strcmp(inps[i],"-wait") ) { |
104 |
|
|
w4i = true; |
105 |
|
|
}; |
106 |
mocchiut |
1.3 |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
107 |
mocchiut |
1.1 |
}; |
108 |
mocchiut |
1.3 |
} else { |
109 |
|
|
// |
110 |
|
|
// no input parameters exit with error, we need at least the run id. |
111 |
|
|
// |
112 |
|
|
usage(); |
113 |
|
|
return(0); |
114 |
mocchiut |
1.2 |
}; |
115 |
|
|
// |
116 |
mocchiut |
1.7 |
stringstream figsave; |
117 |
mocchiut |
1.2 |
if ( !beverbose ){ |
118 |
|
|
// |
119 |
mocchiut |
1.6 |
const string fil = gSystem->BaseName(name.Data()); |
120 |
|
|
Int_t posiz = fil.find(".root"); |
121 |
|
|
// |
122 |
|
|
TString file2; |
123 |
|
|
if ( posiz == -1 ){ |
124 |
|
|
file2 = gSystem->BaseName(name.Data()); |
125 |
|
|
} else { |
126 |
|
|
Int_t posiz2 = 0; |
127 |
|
|
stringcopy(file2,gSystem->BaseName(name.Data()),posiz2,posiz); |
128 |
|
|
}; |
129 |
|
|
const char *figrec = file2; |
130 |
|
|
// |
131 |
|
|
const char *outDir = outdir; |
132 |
|
|
figsave.str(""); |
133 |
|
|
figsave << outDir << "/" ; |
134 |
|
|
figsave << figrec << "_CaloQLOOK.txt"; |
135 |
|
|
// |
136 |
mocchiut |
1.2 |
// redirect to /dev/null the stdout and stderr |
137 |
mocchiut |
1.1 |
// |
138 |
mocchiut |
1.7 |
nul = open(figsave.str().c_str(), O_CREAT | O_RDWR,S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH); |
139 |
mocchiut |
1.2 |
dup2(nul,1); |
140 |
|
|
dup2(nul,2); |
141 |
mocchiut |
1.1 |
}; |
142 |
mocchiut |
1.11 |
printf("\n Welcome to FCaloQLOOK! v1r23 \n"); |
143 |
mocchiut |
1.1 |
// |
144 |
mocchiut |
1.5 |
FCaloQLOOK(name,fromev,toev,outdir,format,iactive,w4i); |
145 |
mocchiut |
1.2 |
// |
146 |
|
|
if ( !beverbose ) close(nul); |
147 |
mocchiut |
1.1 |
// |
148 |
|
|
return(0); |
149 |
|
|
} |