10 |
// |
// |
11 |
#include <TSystem.h> |
#include <TSystem.h> |
12 |
#include <iostream> |
#include <iostream> |
13 |
|
#include <sstream> |
14 |
#include <sys/types.h> |
#include <sys/types.h> |
15 |
#include <unistd.h> |
#include <unistd.h> |
16 |
#include <stdio.h> |
#include <stdio.h> |
17 |
// |
// |
18 |
extern void FCaloQLOOK(TString, int, int, TString, TString); |
extern void FCaloQLOOK(TString, int, int, TString, TString, Bool_t, Bool_t); |
19 |
extern void info(); |
extern void info(); |
20 |
|
extern void stringcopy(TString& , const TString& , Int_t , Int_t ); |
21 |
using namespace std; |
using namespace std; |
22 |
// |
// |
23 |
void usage(){ |
void usage(){ |
29 |
printf( " -fromev from_event first event to analyze [default = 0] \n"); |
printf( " -fromev from_event first event to analyze [default = 0] \n"); |
30 |
printf( " -toev to_event last event to analyze [default = 0] \n"); |
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"); |
printf( " -oudDir output_dir path of the output directory [default = ./] (with or without final '/') \n"); |
32 |
printf( " -format format format for output file (without . )[default = ps] \n"); |
printf( " -format format format for output file (without . )[default = png] \n"); |
33 |
|
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 |
printf("\nExamples: "); |
printf("\nExamples: "); |
36 |
printf("\n\nFCaloQLOOK /home/pamela/filesfromyoda/dw_050301_00100.root \n"); |
printf("\n\nFCaloQLOOK /home/pamela/filesfromyoda/dw_050301_00100.root \n"); |
37 |
printf("\nFCaloQLOOK -v -name /home/pamela/filesfromyoda/dw_050301_00100.root \n"); |
printf("\nFCaloQLOOK -v -name /home/pamela/filesfromyoda/dw_050301_00100.root \n"); |
40 |
|
|
41 |
int main(int numinp, char *inps[]){ |
int main(int numinp, char *inps[]){ |
42 |
TString name; |
TString name; |
43 |
TString outdir = ""; |
TString outdir = "./"; |
44 |
TString format = "ps"; |
TString format = "png"; |
45 |
int fromev = 0; |
int fromev = 0; |
46 |
int toev = 0; |
int toev = 0; |
47 |
int nul = 0; |
int nul = 0; |
48 |
bool beverbose = false; |
bool beverbose = false; |
49 |
|
Bool_t iactive = false; |
50 |
|
Bool_t w4i = false; |
51 |
// |
// |
52 |
if ( numinp > 1 ){ |
if ( numinp > 1 ){ |
53 |
name = (TString)inps[1]; |
name = (TString)inps[1]; |
97 |
}; |
}; |
98 |
toev = atoi(inps[i+1]); |
toev = atoi(inps[i+1]); |
99 |
}; |
}; |
100 |
|
if ( !strcmp(inps[i],"-interactive") ) { |
101 |
|
iactive = true; |
102 |
|
}; |
103 |
|
if ( !strcmp(inps[i],"-wait") ) { |
104 |
|
w4i = true; |
105 |
|
}; |
106 |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
107 |
}; |
}; |
108 |
} else { |
} else { |
113 |
return(0); |
return(0); |
114 |
}; |
}; |
115 |
// |
// |
116 |
|
stringstream figsave; |
117 |
if ( !beverbose ){ |
if ( !beverbose ){ |
118 |
// |
// |
119 |
|
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 |
// redirect to /dev/null the stdout and stderr |
// redirect to /dev/null the stdout and stderr |
137 |
// |
// |
138 |
nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE); |
nul = open(figsave.str().c_str(), O_CREAT | O_RDWR,S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH); |
139 |
dup2(nul,1); |
dup2(nul,1); |
140 |
dup2(nul,2); |
dup2(nul,2); |
141 |
}; |
}; |
142 |
printf("\n Welcome to FCaloQLOOK! \n"); |
printf("\n Welcome to FCaloQLOOK! v1r21 \n"); |
143 |
// |
// |
144 |
FCaloQLOOK(name,fromev,toev,outdir,format); |
FCaloQLOOK(name,fromev,toev,outdir,format,iactive,w4i); |
145 |
// |
// |
146 |
if ( !beverbose ) close(nul); |
if ( !beverbose ) close(nul); |
147 |
// |
// |