ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
EventLoop
util
eventloop_exec_worker.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 <
AsgMessaging/MessageCheck.h
>
6
#include <
EventLoop/Driver.h
>
7
#include <
RootCoreUtils/ShellExec.h
>
8
#include <
RootCoreUtils/ThrowMsg.h
>
9
#include <TSystem.h>
10
#include <
xAODRootAccess/Init.h
>
11
#include <fstream>
12
13
int
main
(
int
argc,
char
**argv)
14
{
15
using namespace
asg::msgUserCode;
16
ANA_CHECK_SET_TYPE
(
int
);
17
18
ANA_CHECK
(
xAOD::Init
());
19
20
if
(argc != 3)
21
{
22
ANA_MSG_ERROR
(
"invalid number of arguments"
);
23
return
-1;
24
}
25
26
std::string submitDir = argv[1];
27
std::size_t maxIndex = std::stoul (argv[2]);
28
29
std::ostringstream basedirName;
30
basedirName << submitDir <<
"/tmp"
;
31
32
if
(gSystem->MakeDirectory (basedirName.str().c_str()) != 0){
33
ANA_MSG_ERROR
(
"failed to create directory "
+ basedirName.str());
34
return
-1;
35
}
36
37
auto
submitSingle = [&] (std::size_t
index
)
noexcept
-> StatusCode
38
{
39
try
40
{
41
std::ostringstream dirName;
42
dirName << basedirName.str() <<
"/"
<<
index
;
43
if
(gSystem->MakeDirectory (dirName.str().c_str()) != 0)
44
{
45
ANA_MSG_ERROR
(
"failed to create directory "
+ dirName.str());
46
return
StatusCode::FAILURE;
47
}
48
49
std::ostringstream cmd;
50
cmd <<
"cd "
<< dirName.str() <<
" && "
;
51
cmd <<
RCU::Shell::quote
(submitDir) <<
"/submit/run "
<<
index
;
52
RCU::Shell::exec
(cmd.str());
53
}
catch
(std::exception& e)
54
{
55
ANA_MSG_ERROR
(
"exception in job "
<<
index
<<
": "
<< e.what());
56
return
StatusCode::FAILURE;
57
}
58
return
StatusCode::SUCCESS;
59
};
60
for
(std::size_t
index
= 0u;
index
!= maxIndex; ++
index
)
61
{
62
if
(submitSingle (
index
).isFailure())
63
return
EXIT_FAILURE;
64
}
65
// this particular file can be checked to see if a job has
66
// been submitted successfully.
67
std::ofstream ((submitDir +
"/submitted"
).c_str());
68
EL::Driver::retrieve
(submitDir);
69
return
0;
70
}
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
Driver.h
Init.h
ShellExec.h
ThrowMsg.h
EL::Driver::retrieve
static bool retrieve(const std::string &location)
retrieve all the output for the job in the given location
main
int main()
Definition
hello.cxx:18
RCU::Shell::exec
void exec(const std::string &cmd)
effects: execute the given command guarantee: strong failures: out of memory II failures: system fail...
Definition
ShellExec.cxx:26
RCU::Shell::quote
std::string quote(const std::string &name)
effects: quote the given name to protect it from the shell returns: the quoted name guarantee: strong...
Definition
ShellExec.cxx:72
index
Definition
index.py:1
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition
Init.cxx:31
Generated on
for ATLAS Offline Software by
1.17.0