| The Gaudi Framework v27r1

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

- File List
- File Members

Functions
extractEvt.cpp File Reference
`#include "merge/extractEvt.C"`
`#include <stdexcept>`
`#include <cstdlib>`
Include dependency graph for extractEvt.cpp:

Go to the source code of this file.

## Functions
int | main (int argc, char **argv)

## Function Documentation

int main | ( | int | argc,
|  | char ** | argv
| ) |  |

Definition at line 17 of file extractEvt.cpp.

17 {
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 }
std::sscanf
T sscanf(T...args)
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
tuple argc
Definition: plotBacklogPyRoot.py:128
ana.i
list i
Definition: ana.py:128
toupper
void toupper(std::string &s)
Definition: StatusCodeSvc.cpp:10