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