The Gaudi Framework
master (37c0b60a)
extractEvt.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#include "
extractEvt.C
"
12
#include <cstdlib>
13
#include <stdexcept>
14
15
static
int
usage
() {
16
::printf(
"Gaudi event extraction facility for ROOT tree based files.\n"
17
" Usage: \n"
18
"extract_event -o <output-file> -i <input-file> ...]\n\n"
19
"input- and output files may specify any legal (ROOT) file name.\n"
20
" -output Specify output file name.\n"
21
" -input Specify input file name.\n"
22
" -event Specify the event entry number.\n"
);
23
return
1;
24
}
25
26
int
main
(
int
argc
,
char
**
argv
) {
27
string
input;
28
string
output
;
29
int
evt_num = -1;
30
for
(
int
i = 1; i <
argc
; ++i ) {
31
if
( *
argv
[i] ==
'-'
) {
32
switch
( ::
toupper
( *(
argv
[i] + 1 ) ) ) {
33
case
'E'
:
34
if
( 1 != ::
sscanf
(
argv
[i + 1],
"%d"
, &evt_num ) ) {
35
::printf(
"\nERROR: No valid event identifier given.\n\n"
);
36
return
usage
();
37
}
38
++i;
39
break
;
40
case
'O'
:
41
if
( i + 1 <
argc
)
output
=
argv
[i + 1];
42
++i;
43
break
;
44
case
'I'
:
45
if
( i + 1 <
argc
) input =
argv
[i + 1];
46
++i;
47
break
;
48
default
:
49
return
usage
();
50
}
51
}
52
}
53
if
( input.
empty
() ) {
54
::printf(
"\nERROR: No input file(s) supplied\n\n"
);
55
return
usage
();
56
}
else
if
(
output
.empty() ) {
57
::printf(
"\nERROR: No output file supplied.\n\n"
);
58
return
usage
();
59
}
else
if
( evt_num < 0 ) {
60
::printf(
"\nERROR: No valid event identifier given.\n\n"
);
61
return
usage
();
62
}
63
gROOT->SetBatch( kTRUE );
64
try
{
65
if
(
extract_event
( input.
c_str
(),
output
.c_str(), evt_num ) != EXTRACT_SUCCESS ) {
66
::printf(
"\nERROR: Event extraction from file %s failed.\n"
, input.
c_str
() );
67
return
1;
68
}
69
return
0;
70
}
catch
(
const
std::exception
& e ) {
71
::printf(
"\nERROR: Event extraction from file %s failed [%s]\n"
, input.
c_str
(), e.
what
() );
72
}
catch
( ... ) { ::printf(
"\nERROR: Event extraction from file %s failed [unknown reason]\n"
, input.
c_str
() ); }
73
return
1;
74
}
toupper
void toupper(std::string &s)
Definition:
ExceptionSvc.cpp:36
std::exception
STL class.
plotBacklogPyRoot.argc
argc
Definition:
plotBacklogPyRoot.py:173
std::sscanf
T sscanf(T... args)
gaudirun.output
output
Definition:
gaudirun.py:521
extract_event
int extract_event(const char *input, const char *output, long num_evt)
Definition:
extractEvt.C:384
std::string::c_str
T c_str(T... args)
extractEvt.C
usage
void usage(const std::string &argv0)
Definition:
listcomponents.cpp:40
std::string::empty
T empty(T... args)
main
int main(int argc, char **argv)
Definition:
extractEvt.cpp:26
std::exception::what
T what(T... args)
gaudirun.argv
list argv
Definition:
gaudirun.py:327
RootCnv
merge
extractEvt.cpp
Generated on Thu Dec 19 2024 15:35:08 for The Gaudi Framework by
1.8.18