ATLAS Offline Software
Loading...
Searching...
No Matches
eventloop_exec_worker.cxx File Reference
#include <AsgMessaging/MessageCheck.h>
#include <EventLoop/Driver.h>
#include <RootCoreUtils/ShellExec.h>
#include <RootCoreUtils/ThrowMsg.h>
#include <TSystem.h>
#include <xAODRootAccess/Init.h>
#include <fstream>
Include dependency graph for eventloop_exec_worker.cxx:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 13 of file eventloop_exec_worker.cxx.

14{
15 using namespace asg::msgUserCode;
17
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 RCU_THROW_MSG ("failed to create directory " + basedirName.str());
34 }
35 auto submitSingle = [&] (std::size_t index) noexcept -> StatusCode
36 {
37 try
38 {
39 std::ostringstream dirName;
40 dirName << basedirName.str() << "/" << index;
41 if (gSystem->MakeDirectory (dirName.str().c_str()) != 0)
42 {
43 ANA_MSG_ERROR ("failed to create directory " + dirName.str());
44 return StatusCode::FAILURE;
45 }
46
47 std::ostringstream cmd;
48 cmd << "cd " << dirName.str() << " && ";
49 cmd << RCU::Shell::quote (submitDir) << "/submit/run " << index;
50 RCU::Shell::exec (cmd.str());
51 } catch (std::exception& e)
52 {
53 ANA_MSG_ERROR ("exception in job " << index << ": " << e.what());
54 return StatusCode::FAILURE;
55 }
56 return StatusCode::SUCCESS;
57 };
58 for (std::size_t index = 0u; index != maxIndex; ++ index)
59 {
60 if (submitSingle (index).isFailure())
61 return EXIT_FAILURE;
62 }
63 // this particular file can be checked to see if a job has
64 // been submitted successfully.
65 std::ofstream ((submitDir + "/submitted").c_str());
66 EL::Driver::retrieve (submitDir);
67 return 0;
68}
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:58
static bool retrieve(const std::string &location)
retrieve all the output for the job in the given location
void exec(const std::string &cmd)
effects: execute the given command guarantee: strong failures: out of memory II failures: system fail...
Definition ShellExec.cxx:29
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:75
Definition index.py:1
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31