ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
EventLoopGrid
util
eventloop_grid_merge.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <
EventLoop/OutputStream.h
>
6
#include <
xAODRootAccess/Init.h
>
7
#include <
AsgMessaging/MessageCheck.h
>
8
#include <TList.h>
9
#include <TSystem.h>
10
#include <TFile.h>
11
#include <regex>
12
13
bool
try_exec
(
const
std::string& cmd)
14
{
15
using namespace
asg::msgUserCode;
16
if
(gSystem->Exec(cmd.c_str()) != 0) {
17
ANA_MSG_ERROR
(
"command failed: "
+ cmd);
18
return
false
;
19
}
20
return
true
;
21
}
22
23
int
main
(
int
argc,
char
**argv)
24
{
25
using namespace
asg::msgUserCode;
26
ANA_CHECK_SET_TYPE
(
int
);
27
28
ANA_CHECK
(
xAOD::Init
());
29
30
if
(argc != 4)
31
{
32
ANA_MSG_ERROR
(
"invalid number of arguments"
);
33
return
-1;
34
}
35
36
std::string jobDefFile = argv[1];
37
std::string output = argv[2];
38
std::string input = argv[3];
39
40
std::string
type
=
"DEFAULT"
;
41
std::string mergeCmd =
""
;
42
43
TFile jd(jobDefFile.c_str());
44
45
std::unique_ptr<TList> outs{
dynamic_cast<
TList*
>
(jd.Get(
"outputs"
))};
46
if
(outs.get() ==
nullptr
) {
47
ANA_MSG_ERROR
(
"Unable to get list of output streams"
);
48
return
-1;
49
}
50
TIter itr(outs.get());
51
TObject* obj;
52
while
((obj = itr())) {
53
EL::OutputStream
* os =
dynamic_cast<
EL::OutputStream
*
>
(obj);
54
if
(std::regex_match(output, std::regex(os->label() +
"\\.root.*"
)) ||
55
std::regex_match(output, std::regex(
".*\\."
+ os->label() +
"\\.root.*"
)))
56
{
57
type
= os->options()->castString(
EL::OutputStream::optType
,
""
,
SH::MetaObject::CAST_NOCAST_DEFAULT
);
58
mergeCmd = os->options()->castString(
EL::OutputStream::optMergeCmd
,
""
,
SH::MetaObject::CAST_NOCAST_DEFAULT
);
59
break
;
60
}
61
}
62
63
if
(mergeCmd.empty()) {
64
if
(
type
==
"xAOD"
) {
65
mergeCmd =
"xAODMerge -s"
;
66
}
else
if
(
type
==
"xAODNoMeta"
) {
67
mergeCmd =
"xAODMerge"
;
68
}
else
{
69
mergeCmd =
"hadd -f"
;
70
}
71
}
72
mergeCmd +=
" "
+ output +
" "
+ input;
73
if
(not
try_exec
(mergeCmd))
return
-1;
74
}
MessageCheck.h
macros for messaging and checking status codes
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
Init.h
OutputStream.h
EL::OutputStream
Definition
OutputStream.h:25
EL::OutputStream::optType
static const std::string optType
Definition
OutputStream.h:111
EL::OutputStream::optMergeCmd
static const std::string optMergeCmd
Definition
OutputStream.h:112
SH::MetaObject::CAST_NOCAST_DEFAULT
@ CAST_NOCAST_DEFAULT
cast and return the default value if the input has the wrong type
Definition
MetaObject.h:70
try_exec
bool try_exec(const std::string &cmd)
Definition
eventloop_grid_merge.cxx:13
main
int main()
Definition
hello.cxx:18
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition
Init.cxx:31
type
Generated on
for ATLAS Offline Software by
1.17.0