| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

extractEvt.cpp
Go to the documentation of this file.
1 #include "merge/extractEvt.C"
2 #include <stdexcept>
3 #include <cstdlib>
4
5 static int usage() {
6 ::printf("Gaudi event extraction facility for ROOT tree based files.\n"
7 " Usage: \n"
8 "extract_event -o <output-file> -i <input-file> ...]\n\n"
9 "input- and output files may specify any legal (ROOT) file name.\n"
10 " -output Specify output file name.\n"
11 " -input Specify input file name.\n"
12 " -event Specify the event entry number.\n"
13 );
14 return 1;
15 }
16
17 int main(int argc, char** argv) {
18 string input;
19 string output;
20 int evt_num = -1;
21 for(int i=1; i < argc; ++i) {
22 if ( *argv[i] == '-' ) {
23 switch(::toupper(*(argv[i]+1))) {
24 case 'E':
25 if ( 1 != ::sscanf(argv[i+1],"%d",&evt_num) ) {
26 ::printf("\nERROR: No valid event identifier given.\n\n");
27 return usage();
28 }
29 ++i;
30 break;
31 case 'O':
32 if ( i+1 < argc ) output = argv[i+1];
33 ++i;
34 break;
35 case 'I':
36 if ( i+1 < argc ) input = argv[i+1];
37 ++i;
38 break;
39 default:
40 return usage();
41 }
42 }
43 }
44 if ( input.empty() ) {
45 ::printf("\nERROR: No input file(s) supplied\n\n");
46 return usage();
47 }
48 else if ( output.empty() ) {
49 ::printf("\nERROR: No output file supplied.\n\n");
50 return usage();
51 }
52 else if ( evt_num < 0 ) {
53 ::printf("\nERROR: No valid event identifier given.\n\n");
54 return usage();
55 }
56 gROOT->SetBatch(kTRUE);
57 try {
58 if ( extract_event(input.c_str(),output.c_str(),evt_num) != EXTRACT_SUCCESS ) {
59 ::printf("\nERROR: Event extraction from file %s failed.\n",input.c_str());
60 return 1;
61 }
62 return 0;
63 }
64 catch (const std::exception& e) {
65 ::printf("\nERROR: Event extraction from file %s failed [%s]\n",input.c_str(),e.what());
66 }
67 catch( ... ) {
68 ::printf("\nERROR: Event extraction from file %s failed [unknown reason]\n",input.c_str());
69 }
70 return 1;
71 }
gaudirun.output
output
Definition: gaudirun.py:388
gaudirun.argv
list argv
Definition: gaudirun.py:227
usage
void usage(std::string argv0)
Definition: listcomponents.cpp:38
std::exception::what
T what(T...args)
std::exception
STL class.
plotBacklogPyRoot.argc
argc
Definition: plotBacklogPyRoot.py:128
main
int main(int argc, char **argv)
Definition: extractEvt.cpp:17
toupper
void toupper(std::string &s)
Definition: StatusCodeSvc.cpp:10